@splinetool/runtime 0.9.458 → 0.9.459
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/runtime.cjs +8 -8
- package/build/runtime.js +8 -8
- package/package.json +1 -1
package/build/runtime.cjs
CHANGED
|
@@ -3135,10 +3135,10 @@ 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 Wk(i,t,e){let n=new tf,r=new B,s=new B,o=new Xe,a=new nf({depthPacking:gb}),l=new Wx,u={},c=e.maxTextureSize,h={[fi]:kn,[kn]:fi,[Ur]:Ur},d=new ot({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new B},radius:{value:4}},vertexShader:Hk,fragmentShader:jk}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let p=new Ae;p.setAttribute("position",new Ge(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new Fn(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ng,this.render=function(b,w,E){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let _=i.getRenderTarget(),S=i.getActiveCubeFace(),T=i.getActiveMipmapLevel(),M=i.state;M.setBlending(Nt),M.buffers.color.setClear(1,1,1,1),M.buffers.depth.setTest(!0),M.setScissorTest(!1);for(let C=0,D=b.length;C<D;C++){let P=b[C],I=P.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;r.copy(I.mapSize);let L=I.getFrameExtents();if(r.multiply(L),s.copy(I.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/L.x),r.x=s.x*L.x,I.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/L.y),r.y=s.y*L.y,I.mapSize.y=s.y)),I.map===null){let U=this.type!==Wd?{minFilter:Lt,magFilter:Lt}:{};I.map=new ut(r.x,r.y,U),I.map.texture.name=P.name+".shadowMap",I.camera.updateProjectionMatrix()}i.setRenderTarget(I.map),i.clear();let H=I.getViewportCount();for(let U=0;U<H;U++){let G=I.getViewport(U);o.set(s.x*G.x,s.y*G.y,s.x*G.z,s.y*G.w),M.viewport(o),I.updateMatrices(P,U),n=I.getFrustum(),x(w,E,I.camera,P,this.type)}I.isPointLightShadow!==!0&&this.type===Wd&&y(I,E),I.needsUpdate=!1}g.needsUpdate=!1,i.setRenderTarget(_,S,T)};function y(b,w){let E=t.update(m);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new ut(r.x,r.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(w,null,E,d,m,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,i.setRenderTarget(b.map),i.clear(),i.renderBufferDirect(w,null,E,f,m,null)}function v(b,w,E,_,S,T){let M=null,C=E.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)M=C;else if(M=E.isPointLight===!0?l:a,i.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){let D=M.uuid,P=w.uuid,I=u[D];I===void 0&&(I={},u[D]=I);let L=I[P];L===void 0&&(L=M.clone(),I[P]=L),M=L}return M.visible=w.visible,M.wireframe=w.wireframe,T===Wd?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:h[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,E.isPointLight===!0&&M.isMeshDistanceMaterial===!0&&(M.referencePosition.setFromMatrixPosition(E.matrixWorld),M.nearDistance=_,M.farDistance=S),M}function x(b,w,E,_,S){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&S===Wd)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,b.matrixWorld);let C=t.update(b),D=b.material;if(Array.isArray(D)){let P=C.groups;for(let I=0,L=P.length;I<L;I++){let H=P[I],U=D[H.materialIndex];if(U&&U.visible){let G=v(b,U,_,E.near,E.far,S);i.renderBufferDirect(E,null,C,G,b,H)}}}else if(D.visible){let P=v(b,D,_,E.near,E.far,S);i.renderBufferDirect(E,null,C,P,b,null)}}let M=b.children;for(let C=0,D=M.length;C<D;C++)x(M[C],w,E,_,S)}}function qk(i,t,e){let n=e.isWebGL2;function r(){let Y=!1,ce=new Xe,ve=null,Ue=new Xe(0,0,0,0);return{setMask:function(Be){ve!==Be&&!Y&&(i.colorMask(Be,Be,Be,Be),ve=Be)},setLocked:function(Be){Y=Be},setClear:function(Be,wt,Rn,Sn,sl){sl===!0&&(Be*=Sn,wt*=Sn,Rn*=Sn),ce.set(Be,wt,Rn,Sn),Ue.equals(ce)===!1&&(i.clearColor(Be,wt,Rn,Sn),Ue.copy(ce))},reset:function(){Y=!1,ve=null,Ue.set(-1,0,0,0)}}}function s(){let Y=!1,ce=null,ve=null,Ue=null;return{setTest:function(Be){Be?Z(2929):Q(2929)},setMask:function(Be){ce!==Be&&!Y&&(i.depthMask(Be),ce=Be)},setFunc:function(Be){if(ve!==Be){switch(Be){case wL:i.depthFunc(512);break;case AL:i.depthFunc(519);break;case EL:i.depthFunc(513);break;case Dx:i.depthFunc(515);break;case _L:i.depthFunc(514);break;case TL:i.depthFunc(518);break;case ML:i.depthFunc(516);break;case CL:i.depthFunc(517);break;default:i.depthFunc(515)}ve=Be}},setLocked:function(Be){Y=Be},setClear:function(Be){Ue!==Be&&(i.clearDepth(Be),Ue=Be)},reset:function(){Y=!1,ce=null,ve=null,Ue=null}}}function o(){let Y=!1,ce=null,ve=null,Ue=null,Be=null,wt=null,Rn=null,Sn=null,sl=null;return{setTest:function(on){Y||(on?Z(2960):Q(2960))},setMask:function(on){ce!==on&&!Y&&(i.stencilMask(on),ce=on)},setFunc:function(on,uo,_i){(ve!==on||Ue!==uo||Be!==_i)&&(i.stencilFunc(on,uo,_i),ve=on,Ue=uo,Be=_i)},setOp:function(on,uo,_i){(wt!==on||Rn!==uo||Sn!==_i)&&(i.stencilOp(on,uo,_i),wt=on,Rn=uo,Sn=_i)},setLocked:function(on){Y=on},setClear:function(on){sl!==on&&(i.clearStencil(on),sl=on)},reset:function(){Y=!1,ce=null,ve=null,Ue=null,Be=null,wt=null,Rn=null,Sn=null,sl=null}}}let a=new r,l=new s,u=new o,c=new WeakMap,h=new WeakMap,d={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,b=null,w=null,E=null,_=null,S=null,T=!1,M=null,C=null,D=null,P=null,I=null,L=i.getParameter(35661),H=!1,U=0,G=i.getParameter(7938);G.indexOf("WebGL")!==-1?(U=parseFloat(/^WebGL (\d)/.exec(G)[1]),H=U>=1):G.indexOf("OpenGL ES")!==-1&&(U=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),H=U>=2);let z=null,V={},$=i.getParameter(3088),F=i.getParameter(2978),j=new Xe().fromArray($),X=new Xe().fromArray(F);function q(Y,ce,ve){let Ue=new Uint8Array(4),Be=i.createTexture();i.bindTexture(Y,Be),i.texParameteri(Y,10241,9728),i.texParameteri(Y,10240,9728);for(let wt=0;wt<ve;wt++)i.texImage2D(ce+wt,0,6408,1,1,0,6408,5121,Ue);return Be}let k={};k[3553]=q(3553,3553,1),k[34067]=q(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),Z(2929),l.setFunc(Dx),Oe(!1),Ie(L1),Z(2884),we(Nt);function Z(Y){d[Y]!==!0&&(i.enable(Y),d[Y]=!0)}function Q(Y){d[Y]!==!1&&(i.disable(Y),d[Y]=!1)}function K(Y,ce){return f[Y]!==ce?(i.bindFramebuffer(Y,ce),f[Y]=ce,n&&(Y===36009&&(f[36160]=ce),Y===36160&&(f[36009]=ce)),!0):!1}function W(Y,ce){let ve=m,Ue=!1;if(Y)if(ve=p.get(ce),ve===void 0&&(ve=[],p.set(ce,ve)),Y.isWebGLMultipleRenderTargets){let Be=Y.texture;if(ve.length!==Be.length||ve[0]!==36064){for(let wt=0,Rn=Be.length;wt<Rn;wt++)ve[wt]=36064+wt;ve.length=Be.length,Ue=!0}}else ve[0]!==36064&&(ve[0]=36064,Ue=!0);else ve[0]!==1029&&(ve[0]=1029,Ue=!0);Ue&&(e.isWebGL2?i.drawBuffers(ve):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ve))}function ye(Y){return g!==Y?(i.useProgram(Y),g=Y,!0):!1}let fe={[Tc]:32774,[hL]:32778,[dL]:32779};if(n)fe[k1]=32775,fe[U1]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(fe[k1]=Y.MIN_EXT,fe[U1]=Y.MAX_EXT)}let ie={[fL]:0,[pL]:1,[mL]:768,[h_]:770,[SL]:776,[xL]:774,[yL]:772,[gL]:769,[d_]:771,[bL]:775,[vL]:773};function we(Y,ce,ve,Ue,Be,wt,Rn,Sn){if(Y===Nt){y===!0&&(Q(3042),y=!1);return}if(y===!1&&(Z(3042),y=!0),Y!==uL){if(Y!==v||Sn!==T){if((x!==Tc||E!==Tc)&&(i.blendEquation(32774),x=Tc,E=Tc),Sn)switch(Y){case Ic:i.blendFuncSeparate(1,771,1,771);break;case N1:i.blendFunc(1,1);break;case B1:i.blendFuncSeparate(0,769,0,1);break;case F1:i.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case Ic:i.blendFuncSeparate(770,771,1,771);break;case N1:i.blendFunc(770,1);break;case B1:i.blendFuncSeparate(0,769,0,1);break;case F1:i.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}b=null,w=null,_=null,S=null,v=Y,T=Sn}return}Be=Be||ce,wt=wt||ve,Rn=Rn||Ue,(ce!==x||Be!==E)&&(i.blendEquationSeparate(fe[ce],fe[Be]),x=ce,E=Be),(ve!==b||Ue!==w||wt!==_||Rn!==S)&&(i.blendFuncSeparate(ie[ve],ie[Ue],ie[wt],ie[Rn]),b=ve,w=Ue,_=wt,S=Rn),v=Y,T=!1}function xe(Y,ce){Y.side===Ur?Q(2884):Z(2884);let ve=Y.side===kn;ce&&(ve=!ve),Oe(ve),Y.blending===Ic&&Y.transparent===!1?we(Nt):we(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.premultipliedAlpha),l.setFunc(Y.depthFunc),l.setTest(Y.depthTest),l.setMask(Y.depthWrite),a.setMask(Y.colorWrite);let Ue=Y.stencilWrite;u.setTest(Ue),Ue&&(u.setMask(Y.stencilWriteMask),u.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),u.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),_e(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?Z(32926):Q(32926)}function Oe(Y){M!==Y&&(Y?i.frontFace(2304):i.frontFace(2305),M=Y)}function Ie(Y){Y!==aL?(Z(2884),Y!==C&&(Y===L1?i.cullFace(1029):Y===lL?i.cullFace(1028):i.cullFace(1032))):Q(2884),C=Y}function Pe(Y){Y!==D&&(H&&i.lineWidth(Y),D=Y)}function _e(Y,ce,ve){Y?(Z(32823),(P!==ce||I!==ve)&&(i.polygonOffset(ce,ve),P=ce,I=ve)):Q(32823)}function Ve(Y){Y?Z(3089):Q(3089)}function ze(Y){Y===void 0&&(Y=33984+L-1),z!==Y&&(i.activeTexture(Y),z=Y)}function R(Y,ce,ve){ve===void 0&&(z===null?ve=33984+L-1:ve=z);let Ue=V[ve];Ue===void 0&&(Ue={type:void 0,texture:void 0},V[ve]=Ue),(Ue.type!==Y||Ue.texture!==ce)&&(z!==ve&&(i.activeTexture(ve),z=ve),i.bindTexture(Y,ce||k[Y]),Ue.type=Y,Ue.texture=ce)}function O(){let Y=V[z];Y!==void 0&&Y.type!==void 0&&(i.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function ne(){try{i.compressedTexImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ue(){try{i.compressedTexImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function me(){try{i.texSubImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function De(){try{i.texSubImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Me(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ee(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function le(){try{i.texStorage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ke(){try{i.texStorage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ke(){try{i.texImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Le(){try{i.texImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function je(Y){j.equals(Y)===!1&&(i.scissor(Y.x,Y.y,Y.z,Y.w),j.copy(Y))}function Je(Y){X.equals(Y)===!1&&(i.viewport(Y.x,Y.y,Y.z,Y.w),X.copy(Y))}function St(Y,ce){let ve=h.get(ce);ve===void 0&&(ve=new WeakMap,h.set(ce,ve));let Ue=ve.get(Y);Ue===void 0&&(Ue=i.getUniformBlockIndex(ce,Y.name),ve.set(Y,Ue))}function Zt(Y,ce){let Ue=h.get(ce).get(Y);c.get(ce)!==Ue&&(i.uniformBlockBinding(ce,Ue,Y.__bindingPointIndex),c.set(ce,Ue))}function On(){i.disable(3042),i.disable(2884),i.disable(2929),i.disable(32823),i.disable(3089),i.disable(2960),i.disable(32926),i.blendEquation(32774),i.blendFunc(1,0),i.blendFuncSeparate(1,0,1,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(513),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(519,0,4294967295),i.stencilOp(7680,7680,7680),i.clearStencil(0),i.cullFace(1029),i.frontFace(2305),i.polygonOffset(0,0),i.activeTexture(33984),i.bindFramebuffer(36160,null),n===!0&&(i.bindFramebuffer(36009,null),i.bindFramebuffer(36008,null)),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),d={},z=null,V={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,b=null,w=null,E=null,_=null,S=null,T=!1,M=null,C=null,D=null,P=null,I=null,j.set(0,0,i.canvas.width,i.canvas.height),X.set(0,0,i.canvas.width,i.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:Z,disable:Q,bindFramebuffer:K,drawBuffers:W,useProgram:ye,setBlending:we,setMaterial:xe,setFlipSided:Oe,setCullFace:Ie,setLineWidth:Pe,setPolygonOffset:_e,setScissorTest:Ve,activeTexture:ze,bindTexture:R,unbindTexture:O,compressedTexImage2D:ne,compressedTexImage3D:ue,texImage2D:ke,texImage3D:Le,updateUBOMapping:St,uniformBlockBinding:Zt,texStorage2D:le,texStorage3D:Ke,texSubImage2D:me,texSubImage3D:De,compressedTexSubImage2D:Me,compressedTexSubImage3D:Ee,scissor:je,viewport:Je,reset:On}}function Yk(i,t,e,n,r,s,o){let a=r.isWebGL2,l=r.maxTextures,u=r.maxCubemapSize,c=r.maxTextureSize,h=r.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap,m,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(R,O){return y?new OffscreenCanvas(R,O):Om("canvas")}function x(R,O,ne,ue){let me=1;if((R.width>ue||R.height>ue)&&(me=ue/Math.max(R.width,R.height)),me<1||O===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let De=O?Im:Math.floor,Me=De(me*R.width),Ee=De(me*R.height);m===void 0&&(m=v(Me,Ee));let le=ne?v(Me,Ee):m;return le.width=Me,le.height=Ee,le.getContext("2d").drawImage(R,0,0,Me,Ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Me+"x"+Ee+")."),le}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function b(R){return Bx(R.width)&&Bx(R.height)}function w(R){return a?!1:R.wrapS!==Jt||R.wrapT!==Jt||R.minFilter!==Lt&&R.minFilter!==Ze}function E(R,O){return R.generateMipmaps&&O&&R.minFilter!==Lt&&R.minFilter!==Ze}function _(R){i.generateMipmap(R)}function S(R,O,ne,ue,me=!1){if(a===!1)return O;if(R!==null){if(i[R]!==void 0)return i[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let De=O;return O===6403&&(ne===5126&&(De=33326),ne===5131&&(De=33325),ne===5121&&(De=33321)),O===33319&&(ne===5126&&(De=33328),ne===5131&&(De=33327),ne===5121&&(De=33323)),O===6408&&(ne===5126&&(De=34836),ne===5131&&(De=34842),ne===5121&&(De=ue===$e&&me===!1?35907:32856),ne===32819&&(De=32854),ne===32820&&(De=32855)),(De===33325||De===33326||De===33327||De===33328||De===34842||De===34836)&&t.get("EXT_color_buffer_float"),De}function T(R,O,ne){return E(R,ne)===!0||R.isFramebufferTexture&&R.minFilter!==Lt&&R.minFilter!==Ze?Math.log2(Math.max(O.width,O.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?O.mipmaps.length:1}function M(R){return R===Lt||R===V1||R===Y0?9728:9729}function C(R){let O=R.target;O.removeEventListener("dispose",C),P(O),O.isVideoTexture&&p.delete(O)}function D(R){let O=R.target;O.removeEventListener("dispose",D),L(O)}function P(R){let O=n.get(R);if(O.__webglInit===void 0)return;let ne=R.source,ue=g.get(ne);if(ue){let me=ue[O.__cacheKey];me.usedTimes--,me.usedTimes===0&&I(R),Object.keys(ue).length===0&&g.delete(ne)}n.remove(R)}function I(R){let O=n.get(R);i.deleteTexture(O.__webglTexture);let ne=R.source,ue=g.get(ne);delete ue[O.__cacheKey],o.memory.textures--}function L(R){let O=R.texture,ne=n.get(R),ue=n.get(O);if(ue.__webglTexture!==void 0&&(i.deleteTexture(ue.__webglTexture),o.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)i.deleteFramebuffer(ne.__webglFramebuffer[me]),ne.__webglDepthbuffer&&i.deleteRenderbuffer(ne.__webglDepthbuffer[me]);else{if(i.deleteFramebuffer(ne.__webglFramebuffer),ne.__webglDepthbuffer&&i.deleteRenderbuffer(ne.__webglDepthbuffer),ne.__webglMultisampledFramebuffer&&i.deleteFramebuffer(ne.__webglMultisampledFramebuffer),ne.__webglColorRenderbuffer)for(let me=0;me<ne.__webglColorRenderbuffer.length;me++)ne.__webglColorRenderbuffer[me]&&i.deleteRenderbuffer(ne.__webglColorRenderbuffer[me]);ne.__webglDepthRenderbuffer&&i.deleteRenderbuffer(ne.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let me=0,De=O.length;me<De;me++){let Me=n.get(O[me]);Me.__webglTexture&&(i.deleteTexture(Me.__webglTexture),o.memory.textures--),n.remove(O[me])}n.remove(O),n.remove(R)}let H=0;function U(){H=0}function G(){let R=H;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),H+=1,R}function z(R){let O=[];return O.push(R.wrapS),O.push(R.wrapT),O.push(R.wrapR||0),O.push(R.magFilter),O.push(R.minFilter),O.push(R.anisotropy),O.push(R.internalFormat),O.push(R.format),O.push(R.type),O.push(R.generateMipmaps),O.push(R.premultiplyAlpha),O.push(R.flipY),O.push(R.unpackAlignment),O.push(R.encoding),O.join()}function V(R,O){let ne=n.get(R);if(R.isVideoTexture&&Ve(R),R.isRenderTargetTexture===!1&&R.version>0&&ne.__version!==R.version){let ue=R.image;if(ue===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ue.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q(ne,R,O);return}}e.bindTexture(3553,ne.__webglTexture,33984+O)}function $(R,O){let ne=n.get(R);if(R.version>0&&ne.__version!==R.version){Q(ne,R,O);return}e.bindTexture(35866,ne.__webglTexture,33984+O)}function F(R,O){let ne=n.get(R);if(R.version>0&&ne.__version!==R.version){Q(ne,R,O);return}e.bindTexture(32879,ne.__webglTexture,33984+O)}function j(R,O){let ne=n.get(R);if(R.version>0&&ne.__version!==R.version){K(ne,R,O);return}e.bindTexture(34067,ne.__webglTexture,33984+O)}let X={[Zi]:10497,[Jt]:33071,[Rx]:33648},q={[Lt]:9728,[V1]:9984,[Y0]:9986,[Ze]:9729,[BL]:9985,[gl]:9987};function k(R,O,ne){if(ne?(i.texParameteri(R,10242,X[O.wrapS]),i.texParameteri(R,10243,X[O.wrapT]),(R===32879||R===35866)&&i.texParameteri(R,32882,X[O.wrapR]),i.texParameteri(R,10240,q[O.magFilter]),i.texParameteri(R,10241,q[O.minFilter])):(i.texParameteri(R,10242,33071),i.texParameteri(R,10243,33071),(R===32879||R===35866)&&i.texParameteri(R,32882,33071),(O.wrapS!==Jt||O.wrapT!==Jt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(R,10240,M(O.magFilter)),i.texParameteri(R,10241,M(O.minFilter)),O.minFilter!==Lt&&O.minFilter!==Ze&&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 ue=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===Lt||O.minFilter!==Y0&&O.minFilter!==gl||O.type===Sr&&t.has("OES_texture_float_linear")===!1||a===!1&&O.type===yl&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||n.get(O).__currentAnisotropy)&&(i.texParameterf(R,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,r.getMaxAnisotropy())),n.get(O).__currentAnisotropy=O.anisotropy)}}function Z(R,O){let ne=!1;R.__webglInit===void 0&&(R.__webglInit=!0,O.addEventListener("dispose",C));let ue=O.source,me=g.get(ue);me===void 0&&(me={},g.set(ue,me));let De=z(O);if(De!==R.__cacheKey){me[De]===void 0&&(me[De]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,ne=!0),me[De].usedTimes++;let Me=me[R.__cacheKey];Me!==void 0&&(me[R.__cacheKey].usedTimes--,Me.usedTimes===0&&I(O)),R.__cacheKey=De,R.__webglTexture=me[De].texture}return ne}function Q(R,O,ne){let ue=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(ue=35866),O.isData3DTexture&&(ue=32879);let me=Z(R,O),De=O.source;e.bindTexture(ue,R.__webglTexture,33984+ne);let Me=n.get(De);if(De.version!==Me.__version||me===!0){e.activeTexture(33984+ne),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let Ee=w(O)&&b(O.image)===!1,le=x(O.image,Ee,!1,c);le=ze(O,le);let Ke=b(le)||a,ke=s.convert(O.format,O.encoding),Le=s.convert(O.type),je=S(O.internalFormat,ke,Le,O.encoding,O.isVideoTexture);k(ue,O,Ke);let Je,St=O.mipmaps,Zt=a&&O.isVideoTexture!==!0,On=Me.__version===void 0||me===!0,Y=T(O,le,Ke);if(O.isDepthTexture)je=6402,a?O.type===Sr?je=36012:O.type===xo?je=33190:O.type===sa?je=35056:je=33189:O.type===Sr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===pl&&je===6402&&O.type!==m_&&O.type!==xo&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=xo,Le=s.convert(O.type)),O.format===la&&je===6402&&(je=34041,O.type!==sa&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=sa,Le=s.convert(O.type))),On&&(Zt?e.texStorage2D(3553,1,je,le.width,le.height):e.texImage2D(3553,0,je,le.width,le.height,0,ke,Le,null));else if(O.isDataTexture)if(St.length>0&&Ke){Zt&&On&&e.texStorage2D(3553,Y,je,St[0].width,St[0].height);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],Zt?e.texSubImage2D(3553,ce,0,0,Je.width,Je.height,ke,Le,Je.data):e.texImage2D(3553,ce,je,Je.width,Je.height,0,ke,Le,Je.data);O.generateMipmaps=!1}else Zt?(On&&e.texStorage2D(3553,Y,je,le.width,le.height),e.texSubImage2D(3553,0,0,0,le.width,le.height,ke,Le,le.data)):e.texImage2D(3553,0,je,le.width,le.height,0,ke,Le,le.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Zt&&On&&e.texStorage3D(35866,Y,je,St[0].width,St[0].height,le.depth);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],O.format!==di?ke!==null?Zt?e.compressedTexSubImage3D(35866,ce,0,0,0,Je.width,Je.height,le.depth,ke,Je.data,0,0):e.compressedTexImage3D(35866,ce,je,Je.width,Je.height,le.depth,0,Je.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Zt?e.texSubImage3D(35866,ce,0,0,0,Je.width,Je.height,le.depth,ke,Le,Je.data):e.texImage3D(35866,ce,je,Je.width,Je.height,le.depth,0,ke,Le,Je.data)}else{Zt&&On&&e.texStorage2D(3553,Y,je,St[0].width,St[0].height);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],O.format!==di?ke!==null?Zt?e.compressedTexSubImage2D(3553,ce,0,0,Je.width,Je.height,ke,Je.data):e.compressedTexImage2D(3553,ce,je,Je.width,Je.height,0,Je.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Zt?e.texSubImage2D(3553,ce,0,0,Je.width,Je.height,ke,Le,Je.data):e.texImage2D(3553,ce,je,Je.width,Je.height,0,ke,Le,Je.data)}else if(O.isDataArrayTexture)Zt?(On&&e.texStorage3D(35866,Y,je,le.width,le.height,le.depth),e.texSubImage3D(35866,0,0,0,0,le.width,le.height,le.depth,ke,Le,le.data)):e.texImage3D(35866,0,je,le.width,le.height,le.depth,0,ke,Le,le.data);else if(O.isData3DTexture)Zt?(On&&e.texStorage3D(32879,Y,je,le.width,le.height,le.depth),e.texSubImage3D(32879,0,0,0,0,le.width,le.height,le.depth,ke,Le,le.data)):e.texImage3D(32879,0,je,le.width,le.height,le.depth,0,ke,Le,le.data);else if(O.isFramebufferTexture){if(On)if(Zt)e.texStorage2D(3553,Y,je,le.width,le.height);else{let ce=le.width,ve=le.height;for(let Ue=0;Ue<Y;Ue++)e.texImage2D(3553,Ue,je,ce,ve,0,ke,Le,null),ce>>=1,ve>>=1}}else if(St.length>0&&Ke){Zt&&On&&e.texStorage2D(3553,Y,je,St[0].width,St[0].height);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],Zt?e.texSubImage2D(3553,ce,0,0,ke,Le,Je):e.texImage2D(3553,ce,je,ke,Le,Je);O.generateMipmaps=!1}else Zt?(On&&e.texStorage2D(3553,Y,je,le.width,le.height),e.texSubImage2D(3553,0,0,0,ke,Le,le)):e.texImage2D(3553,0,je,ke,Le,le);E(O,Ke)&&_(ue),Me.__version=De.version,O.onUpdate&&O.onUpdate(O)}R.__version=O.version}function K(R,O,ne){if(O.image.length!==6)return;let ue=Z(R,O),me=O.source;e.bindTexture(34067,R.__webglTexture,33984+ne);let De=n.get(me);if(me.version!==De.__version||ue===!0){e.activeTexture(33984+ne),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let Me=O.isCompressedTexture||O.image[0].isCompressedTexture,Ee=O.image[0]&&O.image[0].isDataTexture,le=[];for(let ce=0;ce<6;ce++)!Me&&!Ee?le[ce]=x(O.image[ce],!1,!0,u):le[ce]=Ee?O.image[ce].image:O.image[ce],le[ce]=ze(O,le[ce]);let Ke=le[0],ke=b(Ke)||a,Le=s.convert(O.format,O.encoding),je=s.convert(O.type),Je=S(O.internalFormat,Le,je,O.encoding),St=a&&O.isVideoTexture!==!0,Zt=De.__version===void 0||ue===!0,On=T(O,Ke,ke);k(34067,O,ke);let Y;if(Me){St&&Zt&&e.texStorage2D(34067,On,Je,Ke.width,Ke.height);for(let ce=0;ce<6;ce++){Y=le[ce].mipmaps;for(let ve=0;ve<Y.length;ve++){let Ue=Y[ve];O.format!==di?Le!==null?St?e.compressedTexSubImage2D(34069+ce,ve,0,0,Ue.width,Ue.height,Le,Ue.data):e.compressedTexImage2D(34069+ce,ve,Je,Ue.width,Ue.height,0,Ue.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):St?e.texSubImage2D(34069+ce,ve,0,0,Ue.width,Ue.height,Le,je,Ue.data):e.texImage2D(34069+ce,ve,Je,Ue.width,Ue.height,0,Le,je,Ue.data)}}}else{Y=O.mipmaps,St&&Zt&&(Y.length>0&&On++,e.texStorage2D(34067,On,Je,le[0].width,le[0].height));for(let ce=0;ce<6;ce++)if(Ee){St?e.texSubImage2D(34069+ce,0,0,0,le[ce].width,le[ce].height,Le,je,le[ce].data):e.texImage2D(34069+ce,0,Je,le[ce].width,le[ce].height,0,Le,je,le[ce].data);for(let ve=0;ve<Y.length;ve++){let Be=Y[ve].image[ce].image;St?e.texSubImage2D(34069+ce,ve+1,0,0,Be.width,Be.height,Le,je,Be.data):e.texImage2D(34069+ce,ve+1,Je,Be.width,Be.height,0,Le,je,Be.data)}}else{St?e.texSubImage2D(34069+ce,0,0,0,Le,je,le[ce]):e.texImage2D(34069+ce,0,Je,Le,je,le[ce]);for(let ve=0;ve<Y.length;ve++){let Ue=Y[ve];St?e.texSubImage2D(34069+ce,ve+1,0,0,Le,je,Ue.image[ce]):e.texImage2D(34069+ce,ve+1,Je,Le,je,Ue.image[ce])}}}E(O,ke)&&_(34067),De.__version=me.version,O.onUpdate&&O.onUpdate(O)}R.__version=O.version}function W(R,O,ne,ue,me){let De=s.convert(ne.format,ne.encoding),Me=s.convert(ne.type),Ee=S(ne.internalFormat,De,Me,ne.encoding);n.get(O).__hasExternalTextures||(me===32879||me===35866?e.texImage3D(me,0,Ee,O.width,O.height,O.depth,0,De,Me,null):e.texImage2D(me,0,Ee,O.width,O.height,0,De,Me,null)),e.bindFramebuffer(36160,R),_e(O)?d.framebufferTexture2DMultisampleEXT(36160,ue,me,n.get(ne).__webglTexture,0,Pe(O)):(me===3553||me>=34069&&me<=34074)&&i.framebufferTexture2D(36160,ue,me,n.get(ne).__webglTexture,0),e.bindFramebuffer(36160,null)}function ye(R,O,ne){if(i.bindRenderbuffer(36161,R),O.depthBuffer&&!O.stencilBuffer){let ue=33189;if(ne||_e(O)){let me=O.depthTexture;me&&me.isDepthTexture&&(me.type===Sr?ue=36012:me.type===xo&&(ue=33190));let De=Pe(O);_e(O)?d.renderbufferStorageMultisampleEXT(36161,De,ue,O.width,O.height):i.renderbufferStorageMultisample(36161,De,ue,O.width,O.height)}else i.renderbufferStorage(36161,ue,O.width,O.height);i.framebufferRenderbuffer(36160,36096,36161,R)}else if(O.depthBuffer&&O.stencilBuffer){let ue=Pe(O);ne&&_e(O)===!1?i.renderbufferStorageMultisample(36161,ue,35056,O.width,O.height):_e(O)?d.renderbufferStorageMultisampleEXT(36161,ue,35056,O.width,O.height):i.renderbufferStorage(36161,34041,O.width,O.height),i.framebufferRenderbuffer(36160,33306,36161,R)}else{let ue=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let me=0;me<ue.length;me++){let De=ue[me],Me=s.convert(De.format,De.encoding),Ee=s.convert(De.type),le=S(De.internalFormat,Me,Ee,De.encoding),Ke=Pe(O);ne&&_e(O)===!1?i.renderbufferStorageMultisample(36161,Ke,le,O.width,O.height):_e(O)?d.renderbufferStorageMultisampleEXT(36161,Ke,le,O.width,O.height):i.renderbufferStorage(36161,le,O.width,O.height)}}i.bindRenderbuffer(36161,null)}function fe(R,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,R),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),V(O.depthTexture,0);let ue=n.get(O.depthTexture).__webglTexture,me=Pe(O);if(O.depthTexture.format===pl)_e(O)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ue,0,me):i.framebufferTexture2D(36160,36096,3553,ue,0);else if(O.depthTexture.format===la)_e(O)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ue,0,me):i.framebufferTexture2D(36160,33306,3553,ue,0);else throw new Error("Unknown depthTexture format")}function ie(R){let O=n.get(R),ne=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!O.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");fe(O.__webglFramebuffer,R)}else if(ne){O.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)e.bindFramebuffer(36160,O.__webglFramebuffer[ue]),O.__webglDepthbuffer[ue]=i.createRenderbuffer(),ye(O.__webglDepthbuffer[ue],R,!1)}else e.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=i.createRenderbuffer(),ye(O.__webglDepthbuffer,R,!1);e.bindFramebuffer(36160,null)}function we(R,O,ne){let ue=n.get(R);O!==void 0&&W(ue.__webglFramebuffer,R,R.texture,36064,3553),ne!==void 0&&ie(R)}function xe(R){let O=R.texture,ne=n.get(R),ue=n.get(O);R.addEventListener("dispose",D),R.isWebGLMultipleRenderTargets!==!0&&(ue.__webglTexture===void 0&&(ue.__webglTexture=i.createTexture()),ue.__version=O.version,o.memory.textures++);let me=R.isWebGLCubeRenderTarget===!0,De=R.isWebGLMultipleRenderTargets===!0,Me=b(R)||a;if(me){ne.__webglFramebuffer=[];for(let Ee=0;Ee<6;Ee++)ne.__webglFramebuffer[Ee]=i.createFramebuffer()}else{if(ne.__webglFramebuffer=i.createFramebuffer(),De)if(r.drawBuffers){let Ee=R.texture;for(let le=0,Ke=Ee.length;le<Ke;le++){let ke=n.get(Ee[le]);ke.__webglTexture===void 0&&(ke.__webglTexture=i.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&R.samples>0&&_e(R)===!1){let Ee=De?O:[O];ne.__webglMultisampledFramebuffer=i.createFramebuffer(),ne.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ne.__webglMultisampledFramebuffer);for(let le=0;le<Ee.length;le++){let Ke=Ee[le];ne.__webglColorRenderbuffer[le]=i.createRenderbuffer(),i.bindRenderbuffer(36161,ne.__webglColorRenderbuffer[le]);let ke=s.convert(Ke.format,Ke.encoding),Le=s.convert(Ke.type),je=S(Ke.internalFormat,ke,Le,Ke.encoding,R.isXRRenderTarget===!0),Je=Pe(R);i.renderbufferStorageMultisample(36161,Je,je,R.width,R.height),i.framebufferRenderbuffer(36160,36064+le,36161,ne.__webglColorRenderbuffer[le])}i.bindRenderbuffer(36161,null),R.depthBuffer&&(ne.__webglDepthRenderbuffer=i.createRenderbuffer(),ye(ne.__webglDepthRenderbuffer,R,!0)),e.bindFramebuffer(36160,null)}}if(me){e.bindTexture(34067,ue.__webglTexture),k(34067,O,Me);for(let Ee=0;Ee<6;Ee++)W(ne.__webglFramebuffer[Ee],R,O,36064,34069+Ee);E(O,Me)&&_(34067),e.unbindTexture()}else if(De){let Ee=R.texture;for(let le=0,Ke=Ee.length;le<Ke;le++){let ke=Ee[le],Le=n.get(ke);e.bindTexture(3553,Le.__webglTexture),k(3553,ke,Me),W(ne.__webglFramebuffer,R,ke,36064+le,3553),E(ke,Me)&&_(3553)}e.unbindTexture()}else{let Ee=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(a?Ee=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Ee,ue.__webglTexture),k(Ee,O,Me),W(ne.__webglFramebuffer,R,O,36064,Ee),E(O,Me)&&_(Ee),e.unbindTexture()}R.depthBuffer&&ie(R)}function Oe(R){let O=b(R)||a,ne=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let ue=0,me=ne.length;ue<me;ue++){let De=ne[ue];if(E(De,O)){let Me=R.isWebGLCubeRenderTarget?34067:3553,Ee=n.get(De).__webglTexture;e.bindTexture(Me,Ee),_(Me),e.unbindTexture()}}}function Ie(R){if(a&&R.samples>0&&_e(R)===!1){let O=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],ne=R.width,ue=R.height,me=16384,De=[],Me=R.stencilBuffer?33306:36096,Ee=n.get(R),le=R.isWebGLMultipleRenderTargets===!0;if(le)for(let Ke=0;Ke<O.length;Ke++)e.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,null),e.bindFramebuffer(36160,Ee.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,null,0);e.bindFramebuffer(36008,Ee.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Ee.__webglFramebuffer);for(let Ke=0;Ke<O.length;Ke++){De.push(36064+Ke),R.depthBuffer&&De.push(Me);let ke=Ee.__ignoreDepthValues!==void 0?Ee.__ignoreDepthValues:!1;if(ke===!1&&(R.depthBuffer&&(me|=256),R.stencilBuffer&&(me|=1024)),le&&i.framebufferRenderbuffer(36008,36064,36161,Ee.__webglColorRenderbuffer[Ke]),ke===!0&&(i.invalidateFramebuffer(36008,[Me]),i.invalidateFramebuffer(36009,[Me])),le){let Le=n.get(O[Ke]).__webglTexture;i.framebufferTexture2D(36009,36064,3553,Le,0)}i.blitFramebuffer(0,0,ne,ue,0,0,ne,ue,me,9728),f&&i.invalidateFramebuffer(36008,De)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),le)for(let Ke=0;Ke<O.length;Ke++){e.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,Ee.__webglColorRenderbuffer[Ke]);let ke=n.get(O[Ke]).__webglTexture;e.bindFramebuffer(36160,Ee.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,ke,0)}e.bindFramebuffer(36009,Ee.__webglMultisampledFramebuffer)}}function Pe(R){return Math.min(h,R.samples)}function _e(R){let O=n.get(R);return a&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Ve(R){let O=o.render.frame;p.get(R)!==O&&(p.set(R,O),R.update())}function ze(R,O){let ne=R.encoding,ue=R.format,me=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===Nx||ne!==pi&&(ne===$e?a===!1?t.has("EXT_sRGB")===!0&&ue===di?(R.format=Nx,R.minFilter=Ze,R.generateMipmaps=!1):O=Rm.sRGBToLinear(O):(ue!==di||me!==nn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ne)),O}this.allocateTextureUnit=G,this.resetTextureUnits=U,this.setTexture2D=V,this.setTexture2DArray=$,this.setTexture3D=F,this.setTextureCube=j,this.rebindTextures=we,this.setupRenderTarget=xe,this.updateRenderTargetMipmap=Oe,this.updateMultisampleRenderTarget=Ie,this.setupDepthRenderbuffer=ie,this.setupFrameBufferTexture=W,this.useMultisampledRTT=_e}function Xk(i,t,e){let n=e.isWebGL2;function r(s,o=null){let a;if(s===nn)return 5121;if(s===VL)return 32819;if(s===zL)return 32820;if(s===FL)return 5120;if(s===kL)return 5122;if(s===m_)return 5123;if(s===UL)return 5124;if(s===xo)return 5125;if(s===Sr)return 5126;if(s===yl)return n?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===GL)return 6406;if(s===di)return 6408;if(s===HL)return 6409;if(s===jL)return 6410;if(s===pl)return 6402;if(s===la)return 34041;if(s===Nx)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===WL)return 6403;if(s===qL)return 36244;if(s===db)return 33319;if(s===YL)return 33320;if(s===XL)return 36249;if(s===X0||s===K0||s===Q0||s===Z0)if(o===$e)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===X0)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===K0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Q0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Z0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===X0)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===K0)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Q0)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Z0)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===z1||s===G1||s===H1||s===j1)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===z1)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===G1)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===H1)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===j1)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===KL)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===W1||s===q1)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===W1)return o===$e?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===q1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Y1||s===X1||s===K1||s===Q1||s===Z1||s===J1||s===$1||s===eE||s===tE||s===nE||s===rE||s===iE||s===sE||s===oE)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Y1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===X1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===K1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Q1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Z1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===J1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===$1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===eE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===tE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===nE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===rE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===iE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===sE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===oE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===J0)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===J0)return o===$e?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===QL||s===aE||s===lE||s===cE)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===J0)return a.COMPRESSED_RED_RGTC1_EXT;if(s===aE)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===lE)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===cE)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===sa?n?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):i[s]!==void 0?i[s]:null}return{convert:r}}var qx=class extends An{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},Ts=class extends mt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Kk={type:"move"},Kd=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ts,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 Ts,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ts,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let r=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(u&&t.hand){o=!0;for(let m of t.hand.values()){let g=e.getJointPose(m,n),y=this._getHandJoint(u,m);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=g.radius),y.visible=g!==null}let c=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],d=c.position.distanceTo(h.position),f=.02,p=.005;u.inputState.pinching&&d>f+p?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&d<=f-p&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(r=e.getPose(t.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Kk)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new Ts;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},Ci=class extends en{constructor(t,e,n,r,s,o,a,l,u,c){if(c=c!==void 0?c:pl,c!==pl&&c!==la)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===pl&&(n=xo),n===void 0&&c===la&&(n=sa),super(null,r,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Lt,this.minFilter=l!==void 0?l:Lt,this.flipY=!1,this.generateMipmaps=!1}},Yx=class extends Ht{constructor(t,e){super();let n=this,r=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,h=null,d=null,f=null,p=null,m=e.getContextAttributes(),g=null,y=null,v=[],x=[],b=new Set,w=new Map,E=new An;E.layers.enable(1),E.viewport=new Xe;let _=new An;_.layers.enable(2),_.viewport=new Xe;let S=[E,_],T=new qx;T.layers.enable(1),T.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(F){let j=v[F];return j===void 0&&(j=new Kd,v[F]=j),j.getTargetRaySpace()},this.getControllerGrip=function(F){let j=v[F];return j===void 0&&(j=new Kd,v[F]=j),j.getGripSpace()},this.getHand=function(F){let j=v[F];return j===void 0&&(j=new Kd,v[F]=j),j.getHandSpace()};function D(F){let j=x.indexOf(F.inputSource);if(j===-1)return;let X=v[j];X!==void 0&&X.dispatchEvent({type:F.type,data:F.inputSource})}function P(){r.removeEventListener("select",D),r.removeEventListener("selectstart",D),r.removeEventListener("selectend",D),r.removeEventListener("squeeze",D),r.removeEventListener("squeezestart",D),r.removeEventListener("squeezeend",D),r.removeEventListener("end",P),r.removeEventListener("inputsourceschange",I);for(let F=0;F<v.length;F++){let j=x[F];j!==null&&(x[F]=null,v[F].disconnect(j))}M=null,C=null,t.setRenderTarget(g),f=null,d=null,h=null,r=null,y=null,$.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(F){s=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(F){a=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(F){u=F},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(F){if(r=F,r!==null){if(g=t.getRenderTarget(),r.addEventListener("select",D),r.addEventListener("selectstart",D),r.addEventListener("selectend",D),r.addEventListener("squeeze",D),r.addEventListener("squeezestart",D),r.addEventListener("squeezeend",D),r.addEventListener("end",P),r.addEventListener("inputsourceschange",I),m.xrCompatible!==!0&&await e.makeXRCompatible(),r.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let j={antialias:r.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,e,j),r.updateRenderState({baseLayer:f}),y=new ut(f.framebufferWidth,f.framebufferHeight,{format:di,type:nn,encoding:t.outputEncoding,stencilBuffer:m.stencil})}else{let j=null,X=null,q=null;m.depth&&(q=m.stencil?35056:33190,j=m.stencil?la:pl,X=m.stencil?sa:xo);let k={colorFormat:32856,depthFormat:q,scaleFactor:s};h=new XRWebGLBinding(r,e),d=h.createProjectionLayer(k),r.updateRenderState({layers:[d]}),y=new ut(d.textureWidth,d.textureHeight,{format:di,type:nn,depthTexture:new Ci(d.textureWidth,d.textureHeight,X,void 0,void 0,void 0,void 0,void 0,void 0,j),stencilBuffer:m.stencil,encoding:t.outputEncoding,samples:m.antialias?4:0});let Z=t.properties.get(y);Z.__ignoreDepthValues=d.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await r.requestReferenceSpace(a),$.setContext(r),$.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function I(F){for(let j=0;j<F.removed.length;j++){let X=F.removed[j],q=x.indexOf(X);q>=0&&(x[q]=null,v[q].disconnect(X))}for(let j=0;j<F.added.length;j++){let X=F.added[j],q=x.indexOf(X);if(q===-1){for(let Z=0;Z<v.length;Z++)if(Z>=x.length){x.push(X),q=Z;break}else if(x[Z]===null){x[Z]=X,q=Z;break}if(q===-1)break}let k=v[q];k&&k.connect(X)}}let L=new A,H=new A;function U(F,j,X){L.setFromMatrixPosition(j.matrixWorld),H.setFromMatrixPosition(X.matrixWorld);let q=L.distanceTo(H),k=j.projectionMatrix.elements,Z=X.projectionMatrix.elements,Q=k[14]/(k[10]-1),K=k[14]/(k[10]+1),W=(k[9]+1)/k[5],ye=(k[9]-1)/k[5],fe=(k[8]-1)/k[0],ie=(Z[8]+1)/Z[0],we=Q*fe,xe=Q*ie,Oe=q/(-fe+ie),Ie=Oe*-fe;j.matrixWorld.decompose(F.position,F.quaternion,F.scale),F.translateX(Ie),F.translateZ(Oe),F.matrixWorld.compose(F.position,F.quaternion,F.scale),F.matrixWorldInverse.copy(F.matrixWorld).invert();let Pe=Q+Oe,_e=K+Oe,Ve=we-Ie,ze=xe+(q-Ie),R=W*K/_e*Pe,O=ye*K/_e*Pe;F.projectionMatrix.makePerspective(Ve,ze,R,O,Pe,_e)}function G(F,j){j===null?F.matrixWorld.copy(F.matrix):F.matrixWorld.multiplyMatrices(j.matrixWorld,F.matrix),F.matrixWorldInverse.copy(F.matrixWorld).invert()}this.updateCamera=function(F){if(r===null)return;T.near=_.near=E.near=F.near,T.far=_.far=E.far=F.far,(M!==T.near||C!==T.far)&&(r.updateRenderState({depthNear:T.near,depthFar:T.far}),M=T.near,C=T.far);let j=F.parent,X=T.cameras;G(T,j);for(let k=0;k<X.length;k++)G(X[k],j);T.matrixWorld.decompose(T.position,T.quaternion,T.scale),F.matrix.copy(T.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale);let q=F.children;for(let k=0,Z=q.length;k<Z;k++)q[k].updateMatrixWorld(!0);X.length===2?U(T,E,_):T.projectionMatrix.copy(E.projectionMatrix)},this.getCamera=function(){return T},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(F){l=F,d!==null&&(d.fixedFoveation=F),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=F)},this.getPlanes=function(){return b};let z=null;function V(F,j){if(c=j.getViewerPose(u||o),p=j,c!==null){let X=c.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let q=!1;X.length!==T.cameras.length&&(T.cameras.length=0,q=!0);for(let k=0;k<X.length;k++){let Z=X[k],Q=null;if(f!==null)Q=f.getViewport(Z);else{let W=h.getViewSubImage(d,Z);Q=W.viewport,k===0&&(t.setRenderTargetTextures(y,W.colorTexture,d.ignoreDepthValues?void 0:W.depthStencilTexture),t.setRenderTarget(y))}let K=S[k];K===void 0&&(K=new An,K.layers.enable(k),K.viewport=new Xe,S[k]=K),K.matrix.fromArray(Z.transform.matrix),K.projectionMatrix.fromArray(Z.projectionMatrix),K.viewport.set(Q.x,Q.y,Q.width,Q.height),k===0&&T.matrix.copy(K.matrix),q===!0&&T.cameras.push(K)}}for(let X=0;X<v.length;X++){let q=x[X],k=v[X];q!==null&&k!==void 0&&k.update(q,j,u||o)}if(z&&z(F,j),j.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:j.detectedPlanes});let X=null;for(let q of b)j.detectedPlanes.has(q)||(X===null&&(X=[]),X.push(q));if(X!==null)for(let q of X)b.delete(q),w.delete(q),n.dispatchEvent({type:"planeremoved",data:q});for(let q of j.detectedPlanes)if(!b.has(q))b.add(q),w.set(q,j.lastChangedTime),n.dispatchEvent({type:"planeadded",data:q});else{let k=w.get(q);q.lastChangedTime>k&&(w.set(q,q.lastChangedTime),n.dispatchEvent({type:"planechanged",data:q}))}}p=null}let $=new b_;$.setAnimationLoop(V),this.setAnimationLoop=function(F){z=F},this.dispose=function(){}}};function Qk(i,t){function e(m,g){g.color.getRGB(m.fogColor.value,x_(i)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?r(m,g):g.isMeshToonMaterial?(r(m,g),c(m,g)):g.isMeshPhongMaterial?(r(m,g),u(m,g)):g.isMeshStandardMaterial?(r(m,g),h(m,g),g.isMeshPhysicalMaterial&&d(m,g,x)):g.isMeshMatcapMaterial?(r(m,g),f(m,g)):g.isMeshDepthMaterial?r(m,g):g.isMeshDistanceMaterial?(r(m,g),p(m,g)):g.isMeshNormalMaterial?r(m,g):g.isLineBasicMaterial?(s(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?a(m,g,y,v):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.bumpMap&&(m.bumpMap.value=g.bumpMap,m.bumpScale.value=g.bumpScale,g.side===kn&&(m.bumpScale.value*=-1)),g.displacementMap&&(m.displacementMap.value=g.displacementMap,m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap),g.normalMap&&(m.normalMap.value=g.normalMap,m.normalScale.value.copy(g.normalScale),g.side===kn&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(m.envMap.value=y,m.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;let b=i.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*b}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uv2Transform.value.copy(x.matrix))}function s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function a(m,g,y,v){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=v*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix))}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function c(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function d(m,g,y){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===kn&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function f(m,g){g.matcap&&(m.matcap.value=g.matcap)}function p(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:n}}function Zk(i,t,e,n){let r={},s={},o=[],a=e.isWebGL2?i.getParameter(35375):0;function l(v,x){let b=x.program;n.uniformBlockBinding(v,b)}function u(v,x){let b=r[v.id];b===void 0&&(p(v),b=c(v),r[v.id]=b,v.addEventListener("dispose",g));let w=x.program;n.updateUBOMapping(v,w);let E=t.render.frame;s[v.id]!==E&&(d(v),s[v.id]=E)}function c(v){let x=h();v.__bindingPointIndex=x;let b=i.createBuffer(),w=v.__size,E=v.usage;return i.bindBuffer(35345,b),i.bufferData(35345,w,E),i.bindBuffer(35345,null),i.bindBufferBase(35345,x,b),b}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let x=r[v.id],b=v.uniforms,w=v.__cache;i.bindBuffer(35345,x);for(let E=0,_=b.length;E<_;E++){let S=b[E];if(f(S,E,w)===!0){let T=S.__offset,M=Array.isArray(S.value)?S.value:[S.value],C=0;for(let D=0;D<M.length;D++){let P=M[D],I=m(P);typeof P=="number"?(S.__data[0]=P,i.bufferSubData(35345,T+C,S.__data)):P.isMatrix3?(S.__data[0]=P.elements[0],S.__data[1]=P.elements[1],S.__data[2]=P.elements[2],S.__data[3]=P.elements[0],S.__data[4]=P.elements[3],S.__data[5]=P.elements[4],S.__data[6]=P.elements[5],S.__data[7]=P.elements[0],S.__data[8]=P.elements[6],S.__data[9]=P.elements[7],S.__data[10]=P.elements[8],S.__data[11]=P.elements[0]):(P.toArray(S.__data,C),C+=I.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(35345,T,S.__data)}}i.bindBuffer(35345,null)}function f(v,x,b){let w=v.value;if(b[x]===void 0){if(typeof w=="number")b[x]=w;else{let E=Array.isArray(w)?w:[w],_=[];for(let S=0;S<E.length;S++)_.push(E[S].clone());b[x]=_}return!0}else if(typeof w=="number"){if(b[x]!==w)return b[x]=w,!0}else{let E=Array.isArray(b[x])?b[x]:[b[x]],_=Array.isArray(w)?w:[w];for(let S=0;S<E.length;S++){let T=E[S];if(T.equals(_[S])===!1)return T.copy(_[S]),!0}}return!1}function p(v){let x=v.uniforms,b=0,w=16,E=0;for(let _=0,S=x.length;_<S;_++){let T=x[_],M={boundary:0,storage:0},C=Array.isArray(T.value)?T.value:[T.value];for(let D=0,P=C.length;D<P;D++){let I=C[D],L=m(I);M.boundary+=L.boundary,M.storage+=L.storage}if(T.__data=new Float32Array(M.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=b,_>0){E=b%w;let D=w-E;E!==0&&D-M.boundary<0&&(b+=w-E,T.__offset=b)}b+=M.storage}return E=b%w,E>0&&(b+=w-E),v.__size=b,v.__cache={},this}function m(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let b=o.indexOf(x.__bindingPointIndex);o.splice(b,1),i.deleteBuffer(r[x.id]),delete r[x.id],delete s[x.id]}function y(){for(let v in r)i.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:l,update:u,dispose:y}}function Jk(){let i=Om("canvas");return i.style.display="block",i}function xb(i={}){this.isWebGLRenderer=!0;let t=i.canvas!==void 0?i.canvas:Jk(),e=i.context!==void 0?i.context:null,n=i.depth!==void 0?i.depth:!0,r=i.stencil!==void 0?i.stencil:!0,s=i.antialias!==void 0?i.antialias:!1,o=i.premultipliedAlpha!==void 0?i.premultipliedAlpha:!0,a=i.preserveDrawingBuffer!==void 0?i.preserveDrawingBuffer:!1,l=i.powerPreference!==void 0?i.powerPreference:"default",u=i.failIfMajorPerformanceCaveat!==void 0?i.failIfMajorPerformanceCaveat:!1,c;e!==null?c=e.getContextAttributes().alpha:c=i.alpha!==void 0?i.alpha:!1;let h=null,d=null,f=[],p=[];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=pi,this.physicallyCorrectLights=!1,this.toneMapping=So,this.toneMappingExposure=1;let m=this,g=!1,y=0,v=0,x=null,b=-1,w=null,E=new Xe,_=new Xe,S=null,T=t.width,M=t.height,C=1,D=null,P=null,I=new Xe(0,0,T,M),L=new Xe(0,0,T,M),H=!1,U=new tf,G=!1,z=!1,V=null,$=new se,F=new B,j=new A,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return x===null?C:1}let k=e;function Z(N,te){for(let he=0;he<N.length;he++){let ee=N[he],pe=t.getContext(ee,te);if(pe!==null)return pe}return null}try{let N={alpha:!0,depth:n,stencil:r,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${To}`),t.addEventListener("webglcontextlost",je,!1),t.addEventListener("webglcontextrestored",Je,!1),t.addEventListener("webglcontextcreationerror",St,!1),k===null){let te=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&te.shift(),k=Z(te,N),k===null)throw Z(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}k.getShaderPrecisionFormat===void 0&&(k.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let Q,K,W,ye,fe,ie,we,xe,Oe,Ie,Pe,_e,Ve,ze,R,O,ne,ue,me,De,Me,Ee,le,Ke;function ke(){Q=new xF(k),K=new fF(k,Q,i),Q.init(K),Ee=new Xk(k,Q,K),W=new qk(k,Q,K),ye=new wF,fe=new Lk,ie=new Yk(k,Q,W,fe,K,Ee,ye),we=new mF(m),xe=new vF(m),Oe=new I3(k,K),le=new hF(k,Q,Oe,K),Ie=new bF(k,Oe,ye,le),Pe=new TF(k,Ie,Oe,ye),me=new _F(k,K,ie),O=new pF(fe),_e=new Rk(m,we,xe,Q,K,le,O),Ve=new Qk(m,fe),ze=new Bk,R=new Gk(Q,K),ue=new uF(m,we,xe,W,Pe,c,o),ne=new Wk(m,Pe,K),Ke=new Zk(k,ye,K,W),De=new dF(k,Q,ye,K),Me=new SF(k,Q,ye,K),ye.programs=_e.programs,m.capabilities=K,m.extensions=Q,m.properties=fe,m.renderLists=ze,m.shadowMap=ne,m.state=W,m.info=ye}ke();let Le=new Yx(m,k);this.xr=Le,this.getContext=function(){return k},this.getContextAttributes=function(){return k.getContextAttributes()},this.forceContextLoss=function(){let N=Q.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){let N=Q.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(N){N!==void 0&&(C=N,this.setSize(T,M,!1))},this.getSize=function(N){return N.set(T,M)},this.setSize=function(N,te,he){if(Le.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=N,M=te,t.width=Math.floor(N*C),t.height=Math.floor(te*C),he!==!1&&(t.style.width=N+"px",t.style.height=te+"px"),this.setViewport(0,0,N,te)},this.getDrawingBufferSize=function(N){return N.set(T*C,M*C).floor()},this.setDrawingBufferSize=function(N,te,he){T=N,M=te,C=he,t.width=Math.floor(N*he),t.height=Math.floor(te*he),this.setViewport(0,0,N,te)},this.getCurrentViewport=function(N){return N.copy(E)},this.getViewport=function(N){return N.copy(I)},this.setViewport=function(N,te,he,ee){N.isVector4?I.set(N.x,N.y,N.z,N.w):I.set(N,te,he,ee),W.viewport(E.copy(I).multiplyScalar(C).floor())},this.getScissor=function(N){return N.copy(L)},this.setScissor=function(N,te,he,ee){N.isVector4?L.set(N.x,N.y,N.z,N.w):L.set(N,te,he,ee),W.scissor(_.copy(L).multiplyScalar(C).floor())},this.getScissorTest=function(){return H},this.setScissorTest=function(N){W.setScissorTest(H=N)},this.setOpaqueSort=function(N){D=N},this.setTransparentSort=function(N){P=N},this.getClearColor=function(N){return N.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(N=!0,te=!0,he=!0){let ee=0;N&&(ee|=16384),te&&(ee|=256),he&&(ee|=1024),k.clear(ee)},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",je,!1),t.removeEventListener("webglcontextrestored",Je,!1),t.removeEventListener("webglcontextcreationerror",St,!1),ze.dispose(),R.dispose(),fe.dispose(),we.dispose(),xe.dispose(),Pe.dispose(),le.dispose(),Ke.dispose(),_e.dispose(),Le.dispose(),Le.removeEventListener("sessionstart",Ue),Le.removeEventListener("sessionend",Be),V&&(V.dispose(),V=null),wt.stop()};function je(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function Je(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let N=ye.autoReset,te=ne.enabled,he=ne.autoUpdate,ee=ne.needsUpdate,pe=ne.type;ke(),ye.autoReset=N,ne.enabled=te,ne.autoUpdate=he,ne.needsUpdate=ee,ne.type=pe}function St(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function Zt(N){let te=N.target;te.removeEventListener("dispose",Zt),On(te)}function On(N){Y(N),fe.remove(N)}function Y(N){let te=fe.get(N).programs;te!==void 0&&(te.forEach(function(he){_e.releaseProgram(he)}),N.isShaderMaterial&&_e.releaseShaderCache(N))}this.renderBufferDirect=function(N,te,he,ee,pe,it){te===null&&(te=X);let ht=pe.isMesh&&pe.matrixWorld.determinant()<0,pt=ZR(N,te,he,ee,pe);W.setMaterial(ee,ht);let vt=he.index,It=1;ee.wireframe===!0&&(vt=Ie.getWireframeAttribute(he),It=2);let At=he.drawRange,Et=he.attributes.position,Ln=At.start*It,li=(At.start+At.count)*It;it!==null&&(Ln=Math.max(Ln,it.start*It),li=Math.min(li,(it.start+it.count)*It)),vt!==null?(Ln=Math.max(Ln,0),li=Math.min(li,vt.count)):Et!=null&&(Ln=Math.max(Ln,0),li=Math.min(li,Et.count));let ho=li-Ln;if(ho<0||ho===1/0)return;le.setup(pe,ee,pt,he,vt);let ol,Nn=De;if(vt!==null&&(ol=Oe.get(vt),Nn=Me,Nn.setIndex(ol)),pe.isMesh)ee.wireframe===!0?(W.setLineWidth(ee.wireframeLinewidth*q()),Nn.setMode(1)):Nn.setMode(4);else if(pe.isLine){let _t=ee.linewidth;_t===void 0&&(_t=1),W.setLineWidth(_t*q()),pe.isLineSegments?Nn.setMode(1):pe.isLineLoop?Nn.setMode(2):Nn.setMode(3)}else pe.isPoints?Nn.setMode(0):pe.isSprite&&Nn.setMode(4);if(pe.isInstancedMesh)Nn.renderInstances(Ln,ho,pe.count);else if(he.isInstancedBufferGeometry){let _t=he._maxInstanceCount!==void 0?he._maxInstanceCount:1/0,H0=Math.min(he.instanceCount,_t);Nn.renderInstances(Ln,ho,H0)}else Nn.render(Ln,ho)},this.compile=function(N,te){function he(ee,pe,it){ee.transparent===!0&&ee.side===Ur&&ee.forceSinglePass===!1?(ee.side=kn,ee.needsUpdate=!0,_i(ee,pe,it),ee.side=fi,ee.needsUpdate=!0,_i(ee,pe,it),ee.side=Ur):_i(ee,pe,it)}d=R.get(N),d.init(),p.push(d),N.traverseVisible(function(ee){ee.isLight&&ee.layers.test(te.layers)&&(d.pushLight(ee),ee.castShadow&&d.pushShadow(ee))}),d.setupLights(m.physicallyCorrectLights),N.traverse(function(ee){let pe=ee.material;if(pe)if(Array.isArray(pe))for(let it=0;it<pe.length;it++){let ht=pe[it];he(ht,N,ee)}else he(pe,N,ee)}),p.pop(),d=null};let ce=null;function ve(N){ce&&ce(N)}function Ue(){wt.stop()}function Be(){wt.start()}let wt=new b_;wt.setAnimationLoop(ve),typeof self<"u"&&wt.setContext(self),this.setAnimationLoop=function(N){ce=N,Le.setAnimationLoop(N),N===null?wt.stop():wt.start()},Le.addEventListener("sessionstart",Ue),Le.addEventListener("sessionend",Be),this.render=function(N,te){if(te!==void 0&&te.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),Le.enabled===!0&&Le.isPresenting===!0&&(Le.cameraAutoUpdate===!0&&Le.updateCamera(te),te=Le.getCamera()),N.isScene===!0&&N.onBeforeRender(m,N,te,x),d=R.get(N,p.length),d.init(),p.push(d),$.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),U.setFromProjectionMatrix($),z=this.localClippingEnabled,G=O.init(this.clippingPlanes,z),h=ze.get(N,f.length),h.init(),f.push(h),Rn(N,te,0,m.sortObjects),h.finish(),m.sortObjects===!0&&h.sort(D,P),G===!0&&O.beginShadows();let he=d.state.shadowsArray;if(ne.render(he,N,te),G===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(h,N),d.setupLights(m.physicallyCorrectLights),te.isArrayCamera){let ee=te.cameras;for(let pe=0,it=ee.length;pe<it;pe++){let ht=ee[pe];Sn(h,N,ht,ht.viewport)}}else Sn(h,N,te);x!==null&&(ie.updateMultisampleRenderTarget(x),ie.updateRenderTargetMipmap(x)),N.isScene===!0&&N.onAfterRender(m,N,te),le.resetDefaultState(),b=-1,w=null,p.pop(),p.length>0?d=p[p.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function Rn(N,te,he,ee){if(N.visible===!1)return;if(N.layers.test(te.layers)){if(N.isGroup)he=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(te);else if(N.isLight)d.pushLight(N),N.castShadow&&d.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||U.intersectsSprite(N)){ee&&j.setFromMatrixPosition(N.matrixWorld).applyMatrix4($);let ht=Pe.update(N),pt=N.material;pt.visible&&h.push(N,ht,pt,he,j.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==ye.render.frame&&(N.skeleton.update(),N.skeleton.frame=ye.render.frame),!N.frustumCulled||U.intersectsObject(N))){ee&&j.setFromMatrixPosition(N.matrixWorld).applyMatrix4($);let ht=Pe.update(N),pt=N.material;if(Array.isArray(pt)){let vt=ht.groups;for(let It=0,At=vt.length;It<At;It++){let Et=vt[It],Ln=pt[Et.materialIndex];Ln&&Ln.visible&&h.push(N,ht,Ln,he,j.z,Et)}}else pt.visible&&h.push(N,ht,pt,he,j.z,null)}}let it=N.children;for(let ht=0,pt=it.length;ht<pt;ht++)Rn(it[ht],te,he,ee)}function Sn(N,te,he,ee){let pe=N.opaque,it=N.transmissive,ht=N.transparent;d.setupLightsView(he),G===!0&&O.setGlobalState(m.clippingPlanes,he),it.length>0&&sl(pe,te,he),ee&&W.viewport(E.copy(ee)),pe.length>0&&on(pe,te,he),it.length>0&&on(it,te,he),ht.length>0&&on(ht,te,he),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function sl(N,te,he){let ee=K.isWebGL2;V===null&&(V=new ut(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?yl:nn,minFilter:gl,samples:ee&&s===!0?4:0})),m.getDrawingBufferSize(F),ee?V.setSize(F.x,F.y):V.setSize(Im(F.x),Im(F.y));let pe=m.getRenderTarget();m.setRenderTarget(V),m.clear();let it=m.toneMapping;m.toneMapping=So,on(N,te,he),m.toneMapping=it,ie.updateMultisampleRenderTarget(V),ie.updateRenderTargetMipmap(V),m.setRenderTarget(pe)}function on(N,te,he){let ee=te.isScene===!0?te.overrideMaterial:null;for(let pe=0,it=N.length;pe<it;pe++){let ht=N[pe],pt=ht.object,vt=ht.geometry,It=ee===null?ht.material:ee,At=ht.group;pt.layers.test(he.layers)&&uo(pt,te,he,vt,It,At)}}function uo(N,te,he,ee,pe,it){N.onBeforeRender(m,te,he,ee,pe,it),N.modelViewMatrix.multiplyMatrices(he.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),pe.onBeforeRender(m,te,he,ee,N,it),pe.transparent===!0&&pe.side===Ur&&pe.forceSinglePass===!1?(pe.side=kn,pe.needsUpdate=!0,m.renderBufferDirect(he,te,ee,pe,N,it),pe.side=fi,pe.needsUpdate=!0,m.renderBufferDirect(he,te,ee,pe,N,it),pe.side=Ur):m.renderBufferDirect(he,te,ee,pe,N,it),N.onAfterRender(m,te,he,ee,pe,it)}function _i(N,te,he){te.isScene!==!0&&(te=X);let ee=fe.get(N),pe=d.state.lights,it=d.state.shadowsArray,ht=pe.state.version,pt=_e.getParameters(N,pe.state,it,te,he),vt=_e.getProgramCacheKey(pt),It=ee.programs;ee.environment=N.isMeshStandardMaterial?te.environment:null,ee.fog=te.fog,ee.envMap=(N.isMeshStandardMaterial?xe:we).get(N.envMap||ee.environment),It===void 0&&(N.addEventListener("dispose",Zt),It=new Map,ee.programs=It);let At=It.get(vt);if(At!==void 0){if(ee.currentProgram===At&&ee.lightsStateVersion===ht)return P1(N,pt),At}else pt.uniforms=_e.getUniforms(N),N.onBuild(he,pt,m),N.onBeforeCompile(pt,m),At=_e.acquireProgram(pt,vt),It.set(vt,At),ee.uniforms=pt.uniforms;let Et=ee.uniforms;(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(Et.clippingPlanes=O.uniform),P1(N,pt),ee.needsLights=$R(N),ee.lightsStateVersion=ht,ee.needsLights&&(Et.ambientLightColor.value=pe.state.ambient,Et.lightProbe.value=pe.state.probe,Et.directionalLights.value=pe.state.directional,Et.directionalLightShadows.value=pe.state.directionalShadow,Et.spotLights.value=pe.state.spot,Et.spotLightShadows.value=pe.state.spotShadow,Et.rectAreaLights.value=pe.state.rectArea,Et.ltc_1.value=pe.state.rectAreaLTC1,Et.ltc_2.value=pe.state.rectAreaLTC2,Et.pointLights.value=pe.state.point,Et.pointLightShadows.value=pe.state.pointShadow,Et.hemisphereLights.value=pe.state.hemi,Et.directionalShadowMap.value=pe.state.directionalShadowMap,Et.directionalShadowMatrix.value=pe.state.directionalShadowMatrix,Et.spotShadowMap.value=pe.state.spotShadowMap,Et.spotLightMatrix.value=pe.state.spotLightMatrix,Et.spotLightMap.value=pe.state.spotLightMap,Et.pointShadowMap.value=pe.state.pointShadowMap,Et.pointShadowMatrix.value=pe.state.pointShadowMatrix);let Ln=At.getUniforms(),li=Oc.seqWithValue(Ln.seq,Et);return ee.currentProgram=At,ee.uniformsList=li,At}function P1(N,te){let he=fe.get(N);he.outputEncoding=te.outputEncoding,he.instancing=te.instancing,he.skinning=te.skinning,he.morphTargets=te.morphTargets,he.morphNormals=te.morphNormals,he.morphColors=te.morphColors,he.morphTargetsCount=te.morphTargetsCount,he.numClippingPlanes=te.numClippingPlanes,he.numIntersection=te.numClipIntersection,he.vertexAlphas=te.vertexAlphas,he.vertexTangents=te.vertexTangents,he.toneMapping=te.toneMapping}function ZR(N,te,he,ee,pe){te.isScene!==!0&&(te=X),ie.resetTextureUnits();let it=te.fog,ht=ee.isMeshStandardMaterial?te.environment:null,pt=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:pi,vt=(ee.isMeshStandardMaterial?xe:we).get(ee.envMap||ht),It=ee.vertexColors===!0&&!!he.attributes.color&&he.attributes.color.itemSize===4,At=!!ee.normalMap&&!!he.attributes.tangent,Et=!!he.morphAttributes.position,Ln=!!he.morphAttributes.normal,li=!!he.morphAttributes.color,ho=ee.toneMapped?m.toneMapping:So,ol=he.morphAttributes.position||he.morphAttributes.normal||he.morphAttributes.color,Nn=ol!==void 0?ol.length:0,_t=fe.get(ee),H0=d.state.lights;if(G===!0&&(z===!0||N!==w)){let ci=N===w&&ee.id===b;O.setState(ee,N,ci)}let rr=!1;ee.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==H0.state.version||_t.outputEncoding!==pt||pe.isInstancedMesh&&_t.instancing===!1||!pe.isInstancedMesh&&_t.instancing===!0||pe.isSkinnedMesh&&_t.skinning===!1||!pe.isSkinnedMesh&&_t.skinning===!0||_t.envMap!==vt||ee.fog===!0&&_t.fog!==it||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==O.numPlanes||_t.numIntersection!==O.numIntersection)||_t.vertexAlphas!==It||_t.vertexTangents!==At||_t.morphTargets!==Et||_t.morphNormals!==Ln||_t.morphColors!==li||_t.toneMapping!==ho||K.isWebGL2===!0&&_t.morphTargetsCount!==Nn)&&(rr=!0):(rr=!0,_t.__version=ee.version);let al=_t.currentProgram;rr===!0&&(al=_i(ee,te,pe));let D1=!1,Bd=!1,j0=!1,br=al.getUniforms(),ll=_t.uniforms;if(W.useProgram(al.program)&&(D1=!0,Bd=!0,j0=!0),ee.id!==b&&(b=ee.id,Bd=!0),D1||w!==N){if(br.setValue(k,"projectionMatrix",N.projectionMatrix),K.logarithmicDepthBuffer&&br.setValue(k,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),w!==N&&(w=N,Bd=!0,j0=!0),ee.isShaderMaterial||ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshStandardMaterial||ee.envMap){let ci=br.map.cameraPosition;ci!==void 0&&ci.setValue(k,j.setFromMatrixPosition(N.matrixWorld))}(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial)&&br.setValue(k,"isOrthographic",N.isOrthographicCamera===!0),(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial||ee.isShadowMaterial||pe.isSkinnedMesh)&&br.setValue(k,"viewMatrix",N.matrixWorldInverse)}if(pe.isSkinnedMesh){br.setOptional(k,pe,"bindMatrix"),br.setOptional(k,pe,"bindMatrixInverse");let ci=pe.skeleton;ci&&(K.floatVertexTextures?(ci.boneTexture===null&&ci.computeBoneTexture(),br.setValue(k,"boneTexture",ci.boneTexture,ie),br.setValue(k,"boneTextureSize",ci.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 W0=he.morphAttributes;if((W0.position!==void 0||W0.normal!==void 0||W0.color!==void 0&&K.isWebGL2===!0)&&me.update(pe,he,ee,al),(Bd||_t.receiveShadow!==pe.receiveShadow)&&(_t.receiveShadow=pe.receiveShadow,br.setValue(k,"receiveShadow",pe.receiveShadow)),ee.isMeshGouraudMaterial&&ee.envMap!==null&&(ll.envMap.value=vt,ll.flipEnvMap.value=vt.isCubeTexture&&vt.isRenderTargetTexture===!1?-1:1),Bd&&(br.setValue(k,"toneMappingExposure",m.toneMappingExposure),_t.needsLights&&JR(ll,j0),it&&ee.fog===!0&&Ve.refreshFogUniforms(ll,it),Ve.refreshMaterialUniforms(ll,ee,C,M,V),Oc.upload(k,_t.uniformsList,ll,ie)),ee.isShaderMaterial&&ee.uniformsNeedUpdate===!0&&(Oc.upload(k,_t.uniformsList,ll,ie),ee.uniformsNeedUpdate=!1),ee.isSpriteMaterial&&br.setValue(k,"center",pe.center),br.setValue(k,"modelViewMatrix",pe.modelViewMatrix),br.setValue(k,"normalMatrix",pe.normalMatrix),br.setValue(k,"modelMatrix",pe.matrixWorld),pe.previousModelViewMatrix&&br.setValue(k,"previousModelViewMatrix",pe.previousModelViewMatrix),N.previousProjectionMatrix&&br.setValue(k,"previousProjectionMatrix",N.previousProjectionMatrix),ee.isShaderMaterial||ee.isRawShaderMaterial){let ci=ee.uniformsGroups;for(let q0=0,eL=ci.length;q0<eL;q0++)if(K.isWebGL2){let I1=ci[q0];Ke.update(I1,al),Ke.bind(I1,al)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return al}function JR(N,te){N.ambientLightColor.needsUpdate=te,N.lightProbe.needsUpdate=te,N.directionalLights.needsUpdate=te,N.directionalLightShadows.needsUpdate=te,N.pointLights.needsUpdate=te,N.pointLightShadows.needsUpdate=te,N.spotLights.needsUpdate=te,N.spotLightShadows.needsUpdate=te,N.rectAreaLights.needsUpdate=te,N.hemisphereLights.needsUpdate=te}function $R(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(N,te,he){fe.get(N.texture).__webglTexture=te,fe.get(N.depthTexture).__webglTexture=he;let ee=fe.get(N);ee.__hasExternalTextures=!0,ee.__hasExternalTextures&&(ee.__autoAllocateDepthBuffer=he===void 0,ee.__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"),ee.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(N,te){let he=fe.get(N);he.__webglFramebuffer=te,he.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(N,te=0,he=0){x=N,y=te,v=he;let ee=!0,pe=null,it=!1,ht=!1;if(N){let vt=fe.get(N);vt.__useDefaultFramebuffer!==void 0?(W.bindFramebuffer(36160,null),ee=!1):vt.__webglFramebuffer===void 0?ie.setupRenderTarget(N):vt.__hasExternalTextures&&ie.rebindTextures(N,fe.get(N.texture).__webglTexture,fe.get(N.depthTexture).__webglTexture);let It=N.texture;(It.isData3DTexture||It.isDataArrayTexture||It.isCompressedArrayTexture)&&(ht=!0);let At=fe.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(pe=At[te],it=!0):K.isWebGL2&&N.samples>0&&ie.useMultisampledRTT(N)===!1?pe=fe.get(N).__webglMultisampledFramebuffer:pe=At,E.copy(N.viewport),_.copy(N.scissor),S=N.scissorTest}else E.copy(I).multiplyScalar(C).floor(),_.copy(L).multiplyScalar(C).floor(),S=H;if(W.bindFramebuffer(36160,pe)&&K.drawBuffers&&ee&&W.drawBuffers(N,pe),W.viewport(E),W.scissor(_),W.setScissorTest(S),it){let vt=fe.get(N.texture);k.framebufferTexture2D(36160,36064,34069+te,vt.__webglTexture,he)}else if(ht){let vt=fe.get(N.texture),It=te||0;k.framebufferTextureLayer(36160,36064,vt.__webglTexture,he||0,It)}b=-1},this.readRenderTargetPixels=function(N,te,he,ee,pe,it,ht){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let pt=fe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&ht!==void 0&&(pt=pt[ht]),pt){W.bindFramebuffer(36160,pt);try{let vt=N.texture,It=vt.format,At=vt.type;if(It!==di&&Ee.convert(It)!==k.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Et=At===yl&&(Q.has("EXT_color_buffer_half_float")||K.isWebGL2&&Q.has("EXT_color_buffer_float"));if(At!==nn&&Ee.convert(At)!==k.getParameter(35738)&&!(At===Sr&&(K.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!Et){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=N.width-ee&&he>=0&&he<=N.height-pe&&k.readPixels(te,he,ee,pe,Ee.convert(It),Ee.convert(At),it)}finally{let vt=x!==null?fe.get(x).__webglFramebuffer:null;W.bindFramebuffer(36160,vt)}}},this.copyFramebufferToTexture=function(N,te,he=0){let ee=Math.pow(2,-he),pe=Math.floor(te.image.width*ee),it=Math.floor(te.image.height*ee);ie.setTexture2D(te,0),k.copyTexSubImage2D(3553,he,0,0,N.x,N.y,pe,it),W.unbindTexture()},this.copyTextureToTexture=function(N,te,he,ee=0){let pe=te.image.width,it=te.image.height,ht=Ee.convert(he.format),pt=Ee.convert(he.type);ie.setTexture2D(he,0),k.pixelStorei(37440,he.flipY),k.pixelStorei(37441,he.premultiplyAlpha),k.pixelStorei(3317,he.unpackAlignment),te.isDataTexture?k.texSubImage2D(3553,ee,N.x,N.y,pe,it,ht,pt,te.image.data):te.isCompressedTexture?k.compressedTexSubImage2D(3553,ee,N.x,N.y,te.mipmaps[0].width,te.mipmaps[0].height,ht,te.mipmaps[0].data):k.texSubImage2D(3553,ee,N.x,N.y,ht,pt,te.image),ee===0&&he.generateMipmaps&&k.generateMipmap(3553),W.unbindTexture()},this.copyTextureToTexture3D=function(N,te,he,ee,pe=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let it=N.max.x-N.min.x+1,ht=N.max.y-N.min.y+1,pt=N.max.z-N.min.z+1,vt=Ee.convert(ee.format),It=Ee.convert(ee.type),At;if(ee.isData3DTexture)ie.setTexture3D(ee,0),At=32879;else if(ee.isDataArrayTexture)ie.setTexture2DArray(ee,0),At=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}k.pixelStorei(37440,ee.flipY),k.pixelStorei(37441,ee.premultiplyAlpha),k.pixelStorei(3317,ee.unpackAlignment);let Et=k.getParameter(3314),Ln=k.getParameter(32878),li=k.getParameter(3316),ho=k.getParameter(3315),ol=k.getParameter(32877),Nn=he.isCompressedTexture?he.mipmaps[0]:he.image;k.pixelStorei(3314,Nn.width),k.pixelStorei(32878,Nn.height),k.pixelStorei(3316,N.min.x),k.pixelStorei(3315,N.min.y),k.pixelStorei(32877,N.min.z),he.isDataTexture||he.isData3DTexture?k.texSubImage3D(At,pe,te.x,te.y,te.z,it,ht,pt,vt,It,Nn.data):he.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),k.compressedTexSubImage3D(At,pe,te.x,te.y,te.z,it,ht,pt,vt,Nn.data)):k.texSubImage3D(At,pe,te.x,te.y,te.z,it,ht,pt,vt,It,Nn),k.pixelStorei(3314,Et),k.pixelStorei(32878,Ln),k.pixelStorei(3316,li),k.pixelStorei(3315,ho),k.pixelStorei(32877,ol),pe===0&&ee.generateMipmaps&&k.generateMipmap(At),W.unbindTexture()},this.initTexture=function(N){N.isCubeTexture?ie.setTextureCube(N,0):N.isData3DTexture?ie.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?ie.setTexture2DArray(N,0):ie.setTexture2D(N,0),W.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,W.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var Xx=class extends xb{};Xx.prototype.isWebGL1Renderer=!0;var Bc=class{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Fe(t),this.near=e,this.far=n}clone(){return new Bc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},wr=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(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},Vm=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Lx,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Mi()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let r=0,s=this.stride;r<s;r++)this.array[t+r]=e.array[n+r];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mi()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mi()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Fr=new A,xl=class{constructor(t,e,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Fr.fromBufferAttribute(this,e),Fr.applyMatrix4(t),this.setXYZ(e,Fr.x,Fr.y,Fr.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Fr.fromBufferAttribute(this,e),Fr.applyNormalMatrix(t),this.setXYZ(e,Fr.x,Fr.y,Fr.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Fr.fromBufferAttribute(this,e),Fr.transformDirection(t),this.setXYZ(e,Fr.x,Fr.y,Fr.z);return this}setX(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=bo(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=bo(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=bo(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=bo(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array),r=Wt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array),r=Wt(r,this.array),s=Wt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}return new Ge(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new xl(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var rf=class extends mt{constructor(){super(),this.isBone=!0,this.type="Bone"}},Eo=class extends en{constructor(t=null,e=1,n=1,r,s,o,a,l,u=Lt,c=Lt,h,d){super(null,o,a,l,u,c,r,s,h,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},HE=new se,$k=new se,ca=class{constructor(t=[],e=[]){this.uuid=Mi(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new se)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let n=new se;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let t=this.bones,e=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:$k;HE.multiplyMatrices(a,e[s]),HE.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new ca(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=g_(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let n=new Eo(e,t,t,di,Sr);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){let r=this.bones[e];if(r.name===t)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,r=t.bones.length;n<r;n++){let s=t.bones[n],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new rf),this.bones.push(o),this.boneInverses.push(new se().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){let t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,n=this.boneInverses;for(let r=0,s=e.length;r<s;r++){let o=e[r];t.bones.push(o.uuid);let a=n[r];t.boneInverses.push(a.toArray())}return t}},zm=class extends Ge{constructor(t,e,n,r=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};var Pi=class extends vl{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Fe(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},jE=new A,WE=new A,qE=new se,Ex=new Ji,xm=new ln,bl=class extends mt{constructor(t=new Ae,e=new Pi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let r=1,s=e.count;r<s;r++)jE.fromBufferAttribute(e,r-1),WE.fromBufferAttribute(e,r),n[r]=n[r-1],n[r]+=jE.distanceTo(WE);t.setAttribute("lineDistance",new be(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,r=this.matrixWorld,s=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),xm.copy(n.boundingSphere),xm.applyMatrix4(r),xm.radius+=s,t.ray.intersectsSphere(xm)===!1)return;qE.copy(r).invert(),Ex.copy(t.ray).applyMatrix4(qE);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new A,c=new A,h=new A,d=new A,f=this.isLineSegments?2:1,p=n.index,g=n.attributes.position;if(p!==null){let y=Math.max(0,o.start),v=Math.min(p.count,o.start+o.count);for(let x=y,b=v-1;x<b;x+=f){let w=p.getX(x),E=p.getX(x+1);if(u.fromBufferAttribute(g,w),c.fromBufferAttribute(g,E),Ex.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let S=t.ray.origin.distanceTo(d);S<t.near||S>t.far||e.push({distance:S,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,b=v-1;x<b;x+=f){if(u.fromBufferAttribute(g,x),c.fromBufferAttribute(g,x+1),Ex.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let E=t.ray.origin.distanceTo(d);E<t.near||E>t.far||e.push({distance:E,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},YE=new A,XE=new A,ua=class extends bl{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let r=0,s=e.count;r<s;r+=2)YE.fromBufferAttribute(e,r),XE.fromBufferAttribute(e,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+YE.distanceTo(XE);t.setAttribute("lineDistance",new be(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Gm=class extends en{constructor(t,e,n,r,s,o,a,l,u){super(t,e,n,r,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Ze,this.magFilter=s!==void 0?s:Ze,this.generateMipmaps=!1;let c=this;function h(){c.needsUpdate=!0,t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var Di=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,r=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(r),e.push(s),r=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),r=0,s=n.length,o;e?o=e:o=t*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(r=Math.floor(a+(l-a)/2),u=n[r]-o,u<0)a=r+1;else if(u>0)l=r-1;else{l=r;break}if(r=l,n[r]===o)return r/(s-1);let c=n[r],d=n[r+1]-c,f=(o-c)/d;return(r+f)/(s-1)}getTangent(t,e){let r=t-1e-4,s=t+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),l=e||(o.isVector2?new B:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new A,r=[],s=[],o=[],a=new A,l=new se;for(let f=0;f<=t;f++){let p=f/t;r[f]=this.getTangentAt(p,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(r[0].x),h=Math.abs(r[0].y),d=Math.abs(r[0].z);c<=u&&(u=c,n.set(1,0,0)),h<=u&&(u=h,n.set(0,1,0)),d<=u&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(r[f-1],r[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(Wn(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(r[f],s[f])}if(e===!0){let f=Math.acos(Wn(s[0].dot(s[t]),-1,1));f/=t,r[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(r[p],f*p)),o[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},Sl=class extends Di{constructor(t=0,e=0,n=1,r=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let n=e||new B,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),u=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let c=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=u-this.aY;l=d*c-f*h+this.aX,u=d*h+f*c+this.aY}return n.set(l,u)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},Kx=class extends Sl{constructor(t,e,n,r,s,o){super(t,e,n,n,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function bb(){let i=0,t=0,e=0,n=0;function r(s,o,a,l){i=s,t=a,e=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){r(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,h){let d=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+h)+(l-a)/h;d*=c,f*=c,r(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return i+t*s+e*o+n*a}}}var bm=new A,_x=new bb,Tx=new bb,Mx=new bb,Qx=class extends Di{constructor(t=[],e=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=r}getPoint(t,e=new A){let n=e,r=this.points,s=r.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=r[(a-1)%s]:(bm.subVectors(r[0],r[1]).add(r[0]),u=bm);let h=r[a%s],d=r[(a+1)%s];if(this.closed||a+2<s?c=r[(a+2)%s]:(bm.subVectors(r[s-1],r[s-2]).add(r[s-1]),c=bm),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(u.distanceToSquared(h),f),m=Math.pow(h.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(c),f);m<1e-4&&(m=1),p<1e-4&&(p=m),g<1e-4&&(g=m),_x.initNonuniformCatmullRom(u.x,h.x,d.x,c.x,p,m,g),Tx.initNonuniformCatmullRom(u.y,h.y,d.y,c.y,p,m,g),Mx.initNonuniformCatmullRom(u.z,h.z,d.z,c.z,p,m,g)}else this.curveType==="catmullrom"&&(_x.initCatmullRom(u.x,h.x,d.x,c.x,this.tension),Tx.initCatmullRom(u.y,h.y,d.y,c.y,this.tension),Mx.initCatmullRom(u.z,h.z,d.z,c.z,this.tension));return n.set(_x.calc(l),Tx.calc(l),Mx.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new A().fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function KE(i,t,e,n,r){let s=(n-t)*.5,o=(r-e)*.5,a=i*i,l=i*a;return(2*e-2*n+s+o)*l+(-3*e+3*n-2*s-o)*a+s*i+e}function eU(i,t){let e=1-i;return e*e*t}function tU(i,t){return 2*(1-i)*i*t}function nU(i,t){return i*i*t}function Qd(i,t,e,n){return eU(i,t)+tU(i,e)+nU(i,n)}function rU(i,t){let e=1-i;return e*e*e*t}function iU(i,t){let e=1-i;return 3*e*e*i*t}function sU(i,t){return 3*(1-i)*i*i*t}function oU(i,t){return i*i*i*t}function Zd(i,t,e,n,r){return rU(i,t)+iU(i,e)+sU(i,n)+oU(i,r)}var Dr=class extends Di{constructor(t=new B,e=new B,n=new B,r=new B){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new B){let n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Zd(t,r.x,s.x,o.x,a.x),Zd(t,r.y,s.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},wl=class extends Di{constructor(t=new A,e=new A,n=new A,r=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new A){let n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Zd(t,r.x,s.x,o.x,a.x),Zd(t,r.y,s.y,o.y,a.y),Zd(t,r.z,s.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Ir=class extends Di{constructor(t=new B,e=new B){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new B){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let n=e||new B;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},sf=class extends Di{constructor(t=new A,e=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new A){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},mi=class extends Di{constructor(t=new B,e=new B,n=new B){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new B){let n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(Qd(t,r.x,s.x,o.x),Qd(t,r.y,s.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Zx=class extends Di{constructor(t=new A,e=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new A){let n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(Qd(t,r.x,s.x,o.x),Qd(t,r.y,s.y,o.y),Qd(t,r.z,s.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Fc=class extends Di{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new B){let n=e,r=this.points,s=(r.length-1)*t,o=Math.floor(s),a=s-o,l=r[o===0?o:o-1],u=r[o],c=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return n.set(KE(a,l.x,u.x,c.x,h.x),KE(a,l.y,u.y,c.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new B().fromArray(r))}return this}},aU=Object.freeze({__proto__:null,ArcCurve:Kx,CatmullRomCurve3:Qx,CubicBezierCurve:Dr,CubicBezierCurve3:wl,EllipseCurve:Sl,LineCurve:Ir,LineCurve3:sf,QuadraticBezierCurve:mi,QuadraticBezierCurve3:Zx,SplineCurve:Fc}),of=class extends Di{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Ir(e,t))}getPoint(t,e){let n=t*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=n){let o=r[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,r=this.curves.length;n<r;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];n&&n.equals(c)||(e.push(c),n=c)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(r.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let r=this.curves[e];t.curves.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(new aU[r.type]().fromJSON(r))}return this}},Al=class extends of{constructor(t){super(),this.type="Path",this.currentPoint=new B,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let n=new Ir(this.currentPoint.clone(),new B(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,r){let s=new mi(this.currentPoint.clone(),new B(t,e),new B(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(t,e,n,r,s,o){let a=new Dr(this.currentPoint.clone(),new B(t,e),new B(n,r),new B(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new Fc(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,r,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,n,r,s,o),this}absarc(t,e,n,r,s,o){return this.absellipse(t,e,n,n,r,s,o),this}ellipse(t,e,n,r,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,n,r,s,o,a,l),this}absellipse(t,e,n,r,s,o,a,l){let u=new Sl(t,e,n,r,s,o,a,l);if(this.curves.length>0){let h=u.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},kc=class extends Ae{constructor(t=[new B(0,-.5),new B(.5,0),new B(0,.5)],e=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:r},e=Math.floor(e),r=Wn(r,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,h=new A,d=new B,f=new A,p=new A,m=new A,g=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(m.x,m.y,m.z);break;default:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),l.push(f.x,f.y,f.z),m.copy(p)}for(let v=0;v<=e;v++){let x=n+v*c*r,b=Math.sin(x),w=Math.cos(x);for(let E=0;E<=t.length-1;E++){h.x=t[E].x*b,h.y=t[E].y,h.z=t[E].x*w,o.push(h.x,h.y,h.z),d.x=v/e,d.y=E/(t.length-1),a.push(d.x,d.y);let _=l[3*E+0]*b,S=l[3*E+1],T=l[3*E+0]*w;u.push(_,S,T)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let b=x+v*t.length,w=b,E=b+t.length,_=b+t.length+1,S=b+1;s.push(w,E,S),s.push(_,S,E)}this.setIndex(s),this.setAttribute("position",new be(o,3)),this.setAttribute("uv",new be(a,2)),this.setAttribute("normal",new be(u,3))}static fromJSON(t){return new kc(t.points,t.segments,t.phiStart,t.phiLength)}};var El=class extends Ae{constructor(t=1,e=1,n=1,r=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;r=Math.floor(r),s=Math.floor(s);let c=[],h=[],d=[],f=[],p=0,m=[],g=n/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new be(h,3)),this.setAttribute("normal",new be(d,3)),this.setAttribute("uv",new be(f,2));function v(){let b=new A,w=new A,E=0,_=(e-t)/n;for(let S=0;S<=s;S++){let T=[],M=S/s,C=M*(e-t)+t;for(let D=0;D<=r;D++){let P=D/r,I=P*l+a,L=Math.sin(I),H=Math.cos(I);w.x=C*L,w.y=-M*n+g,w.z=C*H,h.push(w.x,w.y,w.z),b.set(L,_,H).normalize(),d.push(b.x,b.y,b.z),f.push(P,1-M),T.push(p++)}m.push(T)}for(let S=0;S<r;S++)for(let T=0;T<s;T++){let M=m[T][S],C=m[T+1][S],D=m[T+1][S+1],P=m[T][S+1];c.push(M,C,P),c.push(C,D,P),E+=6}u.addGroup(y,E,0),y+=E}function x(b){let w=p,E=new B,_=new A,S=0,T=b===!0?t:e,M=b===!0?1:-1;for(let D=1;D<=r;D++)h.push(0,g*M,0),d.push(0,M,0),f.push(.5,.5),p++;let C=p;for(let D=0;D<=r;D++){let I=D/r*l+a,L=Math.cos(I),H=Math.sin(I);_.x=T*H,_.y=g*M,_.z=T*L,h.push(_.x,_.y,_.z),d.push(0,M,0),E.x=L*.5+.5,E.y=H*.5*M+.5,f.push(E.x,E.y),p++}for(let D=0;D<r;D++){let P=w+D,I=C+D;b===!0?c.push(I,I+1,P):c.push(I+1,I,P),S+=3}u.addGroup(y,S,b===!0?1:2),y+=S}}static fromJSON(t){return new El(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Uc=class extends El{constructor(t=1,e=1,n=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,n,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new Uc(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Vc=class extends Ae{constructor(t=[],e=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:r};let s=[],o=[];a(r),u(n),c(),this.setAttribute("position",new be(s,3)),this.setAttribute("normal",new be(s.slice(),3)),this.setAttribute("uv",new be(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new A,b=new A,w=new A;for(let E=0;E<e.length;E+=3)f(e[E+0],x),f(e[E+1],b),f(e[E+2],w),l(x,b,w,v)}function l(v,x,b,w){let E=w+1,_=[];for(let S=0;S<=E;S++){_[S]=[];let T=v.clone().lerp(b,S/E),M=x.clone().lerp(b,S/E),C=E-S;for(let D=0;D<=C;D++)D===0&&S===E?_[S][D]=T:_[S][D]=T.clone().lerp(M,D/C)}for(let S=0;S<E;S++)for(let T=0;T<2*(E-S)-1;T++){let M=Math.floor(T/2);T%2===0?(d(_[S][M+1]),d(_[S+1][M]),d(_[S][M])):(d(_[S][M+1]),d(_[S+1][M+1]),d(_[S+1][M]))}}function u(v){let x=new A;for(let b=0;b<s.length;b+=3)x.x=s[b+0],x.y=s[b+1],x.z=s[b+2],x.normalize().multiplyScalar(v),s[b+0]=x.x,s[b+1]=x.y,s[b+2]=x.z}function c(){let v=new A;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let b=g(v)/2/Math.PI+.5,w=y(v)/Math.PI+.5;o.push(b,1-w)}p(),h()}function h(){for(let v=0;v<o.length;v+=6){let x=o[v+0],b=o[v+2],w=o[v+4],E=Math.max(x,b,w),_=Math.min(x,b,w);E>.9&&_<.1&&(x<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),w<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){let b=v*3;x.x=t[b+0],x.y=t[b+1],x.z=t[b+2]}function p(){let v=new A,x=new A,b=new A,w=new A,E=new B,_=new B,S=new B;for(let T=0,M=0;T<s.length;T+=9,M+=6){v.set(s[T+0],s[T+1],s[T+2]),x.set(s[T+3],s[T+4],s[T+5]),b.set(s[T+6],s[T+7],s[T+8]),E.set(o[M+0],o[M+1]),_.set(o[M+2],o[M+3]),S.set(o[M+4],o[M+5]),w.copy(v).add(x).add(b).divideScalar(3);let C=g(w);m(E,M+0,v,C),m(_,M+2,x,C),m(S,M+4,b,C)}}function m(v,x,b,w){w<0&&v.x===1&&(o[x]=v.x-1),b.x===0&&b.z===0&&(o[x]=w/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function y(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(t){return new Vc(t.vertices,t.indices,t.radius,t.details)}},zc=class extends Vc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,r=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new zc(t.radius,t.detail)}};var _o=class extends Al{constructor(t){super(t),this.uuid=Mi(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,r=this.holes.length;n<r;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(r.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let r=this.holes[e];t.holes.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(new Al().fromJSON(r))}return this}},lU={triangulate:function(i,t,e=2){let n=t&&t.length,r=n?t[0]*e:i.length,s=__(i,0,r,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,h,d,f;if(n&&(s=fU(i,t,s,e)),i.length>80*e){a=u=i[0],l=c=i[1];for(let p=e;p<r;p+=e)h=i[p],d=i[p+1],h<a&&(a=h),d<l&&(l=d),h>u&&(u=h),d>c&&(c=d);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return af(s,o,e,a,l,f,0),o}};function __(i,t,e,n,r){let s,o;if(r===EU(i,t,e,n)>0)for(s=t;s<e;s+=n)o=QE(s,i[s],i[s+1],o);else for(s=e-n;s>=t;s-=n)o=QE(s,i[s],i[s+1],o);return o&&ig(o,o.next)&&(cf(o),o=o.next),o}function _l(i,t){if(!i)return i;t||(t=i);let e=i,n;do if(n=!1,!e.steiner&&(ig(e,e.next)||fn(e.prev,e,e.next)===0)){if(cf(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function af(i,t,e,n,r,s,o){if(!i)return;!o&&s&&vU(i,n,r,s);let a=i,l,u;for(;i.prev!==i.next;){if(l=i.prev,u=i.next,s?uU(i,n,r,s):cU(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(u.i/e|0),cf(i),i=u.next,a=u.next;continue}if(i=u,i===a){o?o===1?(i=hU(_l(i),t,e),af(i,t,e,n,r,s,2)):o===2&&dU(i,t,e,n,r,s):af(_l(i),t,e,n,r,s,1);break}}}function cU(i){let t=i.prev,e=i,n=i.next;if(fn(t,e,n)>=0)return!1;let r=t.x,s=e.x,o=n.x,a=t.y,l=e.y,u=n.y,c=r<s?r<o?r:o:s<o?s:o,h=a<l?a<u?a:u:l<u?l:u,d=r>s?r>o?r:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,p=n.next;for(;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=h&&p.y<=f&&Dc(r,a,s,l,o,u,p.x,p.y)&&fn(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function uU(i,t,e,n){let r=i.prev,s=i,o=i.next;if(fn(r,s,o)>=0)return!1;let a=r.x,l=s.x,u=o.x,c=r.y,h=s.y,d=o.y,f=a<l?a<u?a:u:l<u?l:u,p=c<h?c<d?c:d:h<d?h:d,m=a>l?a>u?a:u:l>u?l:u,g=c>h?c>d?c:d:h>d?h:d,y=Jx(f,p,t,e,n),v=Jx(m,g,t,e,n),x=i.prevZ,b=i.nextZ;for(;x&&x.z>=y&&b&&b.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Dc(a,c,l,h,u,d,x.x,x.y)&&fn(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Dc(a,c,l,h,u,d,b.x,b.y)&&fn(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Dc(a,c,l,h,u,d,x.x,x.y)&&fn(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Dc(a,c,l,h,u,d,b.x,b.y)&&fn(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function hU(i,t,e){let n=i;do{let r=n.prev,s=n.next.next;!ig(r,s)&&T_(r,n,n.next,s)&&lf(r,s)&&lf(s,r)&&(t.push(r.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),cf(n),cf(n.next),n=i=s),n=n.next}while(n!==i);return _l(n)}function dU(i,t,e,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&SU(o,a)){let l=M_(o,a);o=_l(o,o.next),l=_l(l,l.next),af(o,t,e,n,r,s,0),af(l,t,e,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function fU(i,t,e,n){let r=[],s,o,a,l,u;for(s=0,o=t.length;s<o;s++)a=t[s]*n,l=s<o-1?t[s+1]*n:i.length,u=__(i,a,l,n,!1),u===u.next&&(u.steiner=!0),r.push(bU(u));for(r.sort(pU),s=0;s<r.length;s++)e=mU(r[s],e);return e}function pU(i,t){return i.x-t.x}function mU(i,t){let e=gU(i,t);if(!e)return t;let n=M_(e,i);return _l(n,n.next),_l(e,e.next)}function gU(i,t){let e=t,n=-1/0,r,s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>n&&(n=d,r=e.x<e.next.x?e:e.next,d===s))return r}e=e.next}while(e!==t);if(!r)return null;let a=r,l=r.x,u=r.y,c=1/0,h;e=r;do s>=e.x&&e.x>=l&&s!==e.x&&Dc(o<u?s:n,o,l,u,o<u?n:s,o,e.x,e.y)&&(h=Math.abs(o-e.y)/(s-e.x),lf(e,i)&&(h<c||h===c&&(e.x>r.x||e.x===r.x&&yU(r,e)))&&(r=e,c=h)),e=e.next;while(e!==a);return r}function yU(i,t){return fn(i.prev,i,t.prev)<0&&fn(t.next,i,i.next)<0}function vU(i,t,e,n){let r=i;do r.z===0&&(r.z=Jx(r.x,r.y,t,e,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,xU(r)}function xU(i){let t,e,n,r,s,o,a,l,u=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,n=e,a=0,t=0;t<u&&(a++,n=n.nextZ,!!n);t++);for(l=u;a>0||l>0&&n;)a!==0&&(l===0||!n||e.z<=n.z)?(r=e,e=e.nextZ,a--):(r=n,n=n.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;e=n}s.nextZ=null,u*=2}while(o>1);return i}function Jx(i,t,e,n,r){return i=(i-e)*r|0,t=(t-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function bU(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function Dc(i,t,e,n,r,s,o,a){return(r-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(r-o)*(n-a)}function SU(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!wU(i,t)&&(lf(i,t)&&lf(t,i)&&AU(i,t)&&(fn(i.prev,i,t.prev)||fn(i,t.prev,t))||ig(i,t)&&fn(i.prev,i,i.next)>0&&fn(t.prev,t,t.next)>0)}function fn(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function ig(i,t){return i.x===t.x&&i.y===t.y}function T_(i,t,e,n){let r=wm(fn(i,t,e)),s=wm(fn(i,t,n)),o=wm(fn(e,n,i)),a=wm(fn(e,n,t));return!!(r!==s&&o!==a||r===0&&Sm(i,e,t)||s===0&&Sm(i,n,t)||o===0&&Sm(e,i,n)||a===0&&Sm(e,t,n))}function Sm(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function wm(i){return i>0?1:i<0?-1:0}function wU(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&T_(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function lf(i,t){return fn(i.prev,i,i.next)<0?fn(i,t,i.next)>=0&&fn(i,i.prev,t)>=0:fn(i,t,i.prev)<0||fn(i,i.next,t)<0}function AU(i,t){let e=i,n=!1,r=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&r<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==i);return n}function M_(i,t){let e=new $x(i.i,i.x,i.y),n=new $x(t.i,t.x,t.y),r=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function QE(i,t,e,n){let r=new $x(i,t,e);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function cf(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function $x(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function EU(i,t,e,n){let r=0;for(let s=t,o=e-n;s<e;s+=n)r+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return r}var Gc=class{static area(t){let e=t.length,n=0;for(let r=e-1,s=0;s<e;r=s++)n+=t[r].x*t[s].y-t[s].x*t[r].y;return n*.5}static isClockWise(t){return Gc.area(t)<0}static triangulateShape(t,e){let n=[],r=[],s=[];ZE(t),JE(n,t);let o=t.length;e.forEach(ZE);for(let l=0;l<e.length;l++)r.push(o),o+=e[l].length,JE(n,e[l]);let a=lU.triangulate(n,r);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function ZE(i){let t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function JE(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}var Hc=class extends Vc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Hc(t.radius,t.detail)}};var Tl=class extends Ae{constructor(t=1,e=32,n=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),u=0,c=[],h=new A,d=new A,f=[],p=[],m=[],g=[];for(let y=0;y<=n;y++){let v=[],x=y/n,b=0;y==0&&o==0?b=.5/e:y==n&&l==Math.PI&&(b=-.5/e);for(let w=0;w<=e;w++){let E=w/e;h.x=-t*Math.cos(r+E*s)*Math.sin(o+x*a),h.y=t*Math.cos(o+x*a),h.z=t*Math.sin(r+E*s)*Math.sin(o+x*a),p.push(h.x,h.y,h.z),d.copy(h).normalize(),m.push(d.x,d.y,d.z),g.push(E+b,1-x),v.push(u++)}c.push(v)}for(let y=0;y<n;y++)for(let v=0;v<e;v++){let x=c[y][v+1],b=c[y][v],w=c[y+1][v],E=c[y+1][v+1];(y!==0||o>0)&&f.push(x,b,E),(y!==n-1||l<Math.PI)&&f.push(b,w,E)}this.setIndex(f),this.setAttribute("position",new be(p,3)),this.setAttribute("normal",new be(m,3)),this.setAttribute("uv",new be(g,2))}static fromJSON(t){return new Tl(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var jc=class extends Ae{constructor(t=1,e=.4,n=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:r,p:s,q:o},n=Math.floor(n),r=Math.floor(r);let a=[],l=[],u=[],c=[],h=new A,d=new A,f=new A,p=new A,m=new A,g=new A,y=new A;for(let x=0;x<=n;++x){let b=x/n*s*Math.PI*2;v(b,s,o,t,f),v(b+.01,s,o,t,p),g.subVectors(p,f),y.addVectors(p,f),m.crossVectors(g,y),y.crossVectors(m,g),m.normalize(),y.normalize();for(let w=0;w<=r;++w){let E=w/r*Math.PI*2,_=-e*Math.cos(E),S=e*Math.sin(E);h.x=f.x+(_*y.x+S*m.x),h.y=f.y+(_*y.y+S*m.y),h.z=f.z+(_*y.z+S*m.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),u.push(d.x,d.y,d.z),c.push(x/n),c.push(w/r)}}for(let x=1;x<=n;x++)for(let b=1;b<=r;b++){let w=(r+1)*(x-1)+(b-1),E=(r+1)*x+(b-1),_=(r+1)*x+b,S=(r+1)*(x-1)+b;a.push(w,E,S),a.push(E,_,S)}this.setIndex(a),this.setAttribute("position",new be(l,3)),this.setAttribute("normal",new be(u,3)),this.setAttribute("uv",new be(c,2));function v(x,b,w,E,_){let S=Math.cos(x),T=Math.sin(x),M=w/b*x,C=Math.cos(M);_.x=E*(2+C)*.5*S,_.y=E*(2+C)*T*.5,_.z=E*Math.sin(M)*.5}}static fromJSON(t){return new jc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function ia(i,t,e){return C_(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function Am(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function C_(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function _U(i){function t(r,s){return i[r]-i[s]}let e=i.length,n=new Array(e);for(let r=0;r!==e;++r)n[r]=r;return n.sort(t),n}function $E(i,t,e){let n=i.length,r=new i.constructor(n);for(let s=0,o=0;o!==n;++s){let a=e[s]*t;for(let l=0;l!==t;++l)r[o++]=i[a+l]}return r}function P_(i,t,e,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=i[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=i[r++];while(s!==void 0);else do o=s[n],o!==void 0&&(t.push(s.time),e.push(o)),s=i[r++];while(s!==void 0)}var Wc=class{constructor(t,e,n,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,r=e[n],s=e[n-1];e:{t:{let o;n:{r:if(!(t<r)){for(let a=n+2;;){if(r===void 0){if(t<s)break r;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=r,r=e[++n],t<r)break t}o=e.length;break n}if(!(t>=s)){let a=e[1];t<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(r=s,s=e[--n-1],t>=s)break t}o=n,n=0;break n}break e}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(r=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,t,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=t*r;for(let o=0;o!==r;++o)e[o]=n[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},eb=class extends Wc{constructor(t,e,n,r){super(t,e,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Mc,endingEnd:Mc}}intervalChanged_(t,e,n){let r=this.parameterPositions,s=t-2,o=t+1,a=r[s],l=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case Cc:s=t,a=2*e-n;break;case Dm:s=r.length-2,a=e+r[s]-r[s+1];break;default:s=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Cc:o=t,l=2*n-e;break;case Dm:o=1,l=n+r[1]-r[0];break;default:o=t-1,l=e}let u=(n-e)*.5,c=this.valueSize;this._weightPrev=u/(e-a),this._weightNext=u/(l-n),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-e)/(r-e),m=p*p,g=m*p,y=-d*g+2*d*m-d*p,v=(1+d)*g+(-1.5-2*d)*m+(-.5+d)*p+1,x=(-1-f)*g+(1.5+f)*m+.5*p,b=f*g-f*m;for(let w=0;w!==a;++w)s[w]=y*o[c+w]+v*o[u+w]+x*o[l+w]+b*o[h+w];return s}},Hm=class extends Wc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(n-e)/(r-e),h=1-c;for(let d=0;d!==a;++d)s[d]=o[u+d]*h+o[l+d]*c;return s}},tb=class extends Wc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t){return this.copySampleValue_(t-1)}},Ii=class{constructor(t,e,n,r){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Am(e,this.TimeBufferType),this.values=Am(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Am(t.times,Array),values:Am(t.values,Array)};let r=t.getInterpolation();r!==t.DefaultInterpolation&&(n.interpolation=r)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new tb(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Hm(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new eb(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Cm:e=this.InterpolantFactoryMethodDiscrete;break;case Pm:e=this.InterpolantFactoryMethodLinear;break;case $0:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Cm;case this.InterpolantFactoryMethodLinear:return Pm;case this.InterpolantFactoryMethodSmooth:return $0}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]*=t}return this}trim(t,e){let n=this.times,r=n.length,s=0,o=r-1;for(;s!==r&&n[s]<t;)++s;for(;o!==-1&&n[o]>e;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=ia(n,s,o),this.values=ia(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(r!==void 0&&C_(r))for(let a=0,l=r.length;a!==l;++a){let u=r[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}return t}optimize(){let t=ia(this.times),e=ia(this.values),n=this.getValueSize(),r=this.getInterpolation()===$0,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=t[a],c=t[a+1];if(u!==c&&(a!==1||u!==t[0]))if(r)l=!0;else{let h=a*n,d=h-n,f=h+n;for(let p=0;p!==n;++p){let m=e[h+p];if(m!==e[d+p]||m!==e[f+p]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let h=a*n,d=o*n;for(let f=0;f!==n;++f)e[d+f]=e[h+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*n,l=o*n,u=0;u!==n;++u)e[l+u]=e[a+u];++o}return o!==t.length?(this.times=ia(t,0,o),this.values=ia(e,0,o*n)):(this.times=t,this.values=e),this}clone(){let t=ia(this.times,0),e=ia(this.values,0),n=this.constructor,r=new n(this.name,t,e);return r.createInterpolant=this.createInterpolant,r}};Ii.prototype.TimeBufferType=Float32Array;Ii.prototype.ValueBufferType=Float32Array;Ii.prototype.DefaultInterpolation=Pm;var ha=class extends Ii{};ha.prototype.ValueTypeName="bool";ha.prototype.ValueBufferType=Array;ha.prototype.DefaultInterpolation=Cm;ha.prototype.InterpolantFactoryMethodLinear=void 0;ha.prototype.InterpolantFactoryMethodSmooth=void 0;var jm=class extends Ii{};jm.prototype.ValueTypeName="color";var qc=class extends Ii{};qc.prototype.ValueTypeName="number";var nb=class extends Wc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(r-e),u=t*a;for(let c=u+a;u!==c;u+=4)Ye.slerpFlat(s,0,o,u-a,o,u,l);return s}},Ml=class extends Ii{InterpolantFactoryMethodLinear(t){return new nb(this.times,this.values,this.getValueSize(),t)}};Ml.prototype.ValueTypeName="quaternion";Ml.prototype.DefaultInterpolation=Pm;Ml.prototype.InterpolantFactoryMethodSmooth=void 0;var da=class extends Ii{};da.prototype.ValueTypeName="string";da.prototype.ValueBufferType=Array;da.prototype.DefaultInterpolation=Cm;da.prototype.InterpolantFactoryMethodLinear=void 0;da.prototype.InterpolantFactoryMethodSmooth=void 0;var Yc=class extends Ii{};Yc.prototype.ValueTypeName="vector";var Xc=class{constructor(t,e=-1,n,r=mb){this.name=t,this.tracks=n,this.duration=e,this.blendMode=r,this.uuid=Mi(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],n=t.tracks,r=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(MU(n[o]).scale(r));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=n.length;s!==o;++s)e.push(Ii.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(t,e,n,r){let s=e.length,o=[];for(let a=0;a<s;a++){let l=[],u=[];l.push((a+s-1)%s,a,(a+1)%s),u.push(0,1,0);let c=_U(l);l=$E(l,1,c),u=$E(u,1,c),!r&&l[0]===0&&(l.push(s),u.push(u[0])),o.push(new qc(".morphTargetInfluences["+e[a].name+"]",l,u).scale(1/n))}return new this(t,-1,o)}static findByName(t,e){let n=t;if(!Array.isArray(t)){let r=t;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===e)return n[r];return null}static CreateClipsFromMorphTargetSequences(t,e,n){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){let u=t[a],c=u.name.match(s);if(c&&c.length>1){let h=c[1],d=r[h];d||(r[h]=d=[]),d.push(u)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],e,n));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(h,d,f,p,m){if(f.length!==0){let g=[],y=[];P_(f,g,y,p),g.length!==0&&m.push(new h(d,g,y))}},r=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,u=t.hierarchy||[];for(let h=0;h<u.length;h++){let d=u[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let f={},p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let m=0;m<d[p].morphTargets.length;m++)f[d[p].morphTargets[m]]=-1;for(let m in f){let g=[],y=[];for(let v=0;v!==d[p].morphTargets.length;++v){let x=d[p];g.push(x.time),y.push(x.morphTarget===m?1:0)}r.push(new qc(".morphTargetInfluence["+m+"]",g,y))}l=f.length*o}else{let f=".bones["+e[h].name+"]";n(Yc,f+".position",d,"pos",r),n(Ml,f+".quaternion",d,"rot",r),n(Yc,f+".scale",d,"scl",r)}}return r.length===0?null:new this(s,l,r,a)}resetDuration(){let t=this.tracks,e=0;for(let n=0,r=t.length;n!==r;++n){let s=this.tracks[n];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function TU(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return qc;case"vector":case"vector2":case"vector3":case"vector4":return Yc;case"color":return jm;case"quaternion":return Ml;case"bool":case"boolean":return ha;case"string":return da}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function MU(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=TU(i.type);if(i.times===void 0){let e=[],n=[];P_(i.keys,e,n,"value"),i.times=e,i.values=n}return t.parse!==void 0?t.parse(i):new t(i.name,i.times,i.values,i.interpolation)}var e_={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(this.files[i]=t)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}},uf=class{constructor(t,e,n){let r=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(c){a++,s===!1&&r.onStart!==void 0&&r.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,r.onProgress!==void 0&&r.onProgress(c,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(c){r.onError!==void 0&&r.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,h){return u.push(c,h),this},this.removeHandler=function(c){let h=u.indexOf(c);return h!==-1&&u.splice(h,2),this},this.getHandler=function(c){for(let h=0,d=u.length;h<d;h+=2){let f=u[h],p=u[h+1];if(f.global&&(f.lastIndex=0),f.test(c))return p}return null}}},CU=new uf,Kc=class{constructor(t){this.manager=t!==void 0?t:CU,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(r,s){n.load(t,r,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}},vo={},rb=class extends Error{constructor(t,e){super(t),this.response=e}},Qc=class extends Kc{constructor(t){super(t)}load(t,e,n,r){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=e_.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(vo[t]!==void 0){vo[t].push({onLoad:e,onProgress:n,onError:r});return}vo[t]=[],vo[t].push({onLoad:e,onProgress:n,onError:r});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=vo[t],h=u.body.getReader(),d=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=d?parseInt(d):0,p=f!==0,m=0,g=new ReadableStream({start(y){v();function v(){h.read().then(({done:x,value:b})=>{if(x)y.close();else{m+=b.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let E=0,_=c.length;E<_;E++){let S=c[E];S.onProgress&&S.onProgress(w)}y.enqueue(b),v()}})}}});return new Response(g)}else throw new rb(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return u.arrayBuffer().then(p=>f.decode(p))}}}).then(u=>{e_.add(t,u);let c=vo[t];delete vo[t];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=vo[t];if(c===void 0)throw this.manager.itemError(t),u;delete vo[t];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onError&&f.onError(u)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var fa=class extends mt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Fe(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},Wm=class extends fa{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Fe(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},Cx=new se,t_=new A,n_=new A,hf=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new B(512,512),this.map=null,this.mapPass=null,this.matrix=new se,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new tf,this._frameExtents=new B(1,1),this._viewportCount=1,this._viewports=[new Xe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;t_.setFromMatrixPosition(t.matrixWorld),e.position.copy(t_),n_.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(n_),e.updateMatrixWorld(),Cx.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Cx),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Cx)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},ib=class extends hf{constructor(){super(new An(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,n=$d*2*t.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(n!==e.fov||r!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=r,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},qm=class extends fa{constructor(t,e,n=0,r=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.target=new mt,this.distance=n,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new ib}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},r_=new se,jd=new A,Px=new A,sb=class extends hf{constructor(){super(new An(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new B(4,2),this._viewportCount=6,this._viewports=[new Xe(2,1,1,1),new Xe(0,1,1,1),new Xe(3,1,1,1),new Xe(1,1,1,1),new Xe(3,0,1,1),new Xe(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,r=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),jd.setFromMatrixPosition(t.matrixWorld),n.position.copy(jd),Px.copy(n.position),Px.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Px),n.updateMatrixWorld(),r.makeTranslation(-jd.x,-jd.y,-jd.z),r_.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(r_)}},Ym=class extends fa{constructor(t,e,n=0,r=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new sb}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},ob=class extends hf{constructor(){super(new Nc(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Xm=class extends fa{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.target=new mt,this.shadow=new ob}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var ab=class extends Ae{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Zc=class extends Kc{constructor(t){super(t)}load(t,e,n,r){let s=this,o=new Qc(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(t)}},n,r)}parse(t){let e={},n={};function r(f,p){if(e[p]!==void 0)return e[p];let g=f.interleavedBuffers[p],y=s(f,g.buffer),v=em(g.type,y),x=new Vm(v,g.stride);return x.uuid=g.uuid,e[p]=x,x}function s(f,p){if(n[p]!==void 0)return n[p];let g=f.arrayBuffers[p],y=new Uint32Array(g).buffer;return n[p]=y,y}let o=t.isInstancedBufferGeometry?new ab:new Ae,a=t.data.index;if(a!==void 0){let f=em(a.type,a.array);o.setIndex(new Ge(f,1))}let l=t.data.attributes;for(let f in l){let p=l[f],m;if(p.isInterleavedBufferAttribute){let g=r(t.data,p.data);m=new xl(g,p.itemSize,p.offset,p.normalized)}else{let g=em(p.type,p.array),y=p.isInstancedBufferAttribute?zm:Ge;m=new y(g,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),p.updateRange!==void 0&&(m.updateRange.offset=p.updateRange.offset,m.updateRange.count=p.updateRange.count),o.setAttribute(f,m)}let u=t.data.morphAttributes;if(u)for(let f in u){let p=u[f],m=[];for(let g=0,y=p.length;g<y;g++){let v=p[g],x;if(v.isInterleavedBufferAttribute){let b=r(t.data,v.data);x=new xl(b,v.itemSize,v.offset,v.normalized)}else{let b=em(v.type,v.array);x=new Ge(b,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),m.push(x)}o.morphAttributes[f]=m}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=t.data.groups||t.data.drawcalls||t.data.offsets;if(h!==void 0)for(let f=0,p=h.length;f!==p;++f){let m=h[f];o.addGroup(m.start,m.count,m.materialIndex)}let d=t.data.boundingSphere;if(d!==void 0){let f=new A;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new ln(f,d.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var Km=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=i_(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=i_();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function i_(){return(typeof performance>"u"?Date:performance).now()}var lb=class{constructor(t,e,n){this.binding=t,this.valueSize=n;let r,s,o;switch(e){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let n=this.buffer,r=this.valueSize,s=t*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)n[s+a]=n[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(n,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,r,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,n=this.buffer,r=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=e*this._origIndex;this._mixBufferRegion(n,r,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*e,1,e);for(let l=e,u=e+e;l!==u;++l)if(n[l]!==n[l+e]){a.setValue(n,r);break}}saveOriginalState(){let t=this.binding,e=this.buffer,n=this.valueSize,r=n*this._origIndex;t.getValue(e,r);for(let s=n,o=r;s!==o;++s)e[s]=e[r+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,r,s){if(r>=.5)for(let o=0;o!==s;++o)t[e+o]=t[n+o]}_slerp(t,e,n,r){Ye.slerpFlat(t,e,t,e,t,n,r)}_slerpAdditive(t,e,n,r,s){let o=this._workIndex*s;Ye.multiplyQuaternionsFlat(t,o,t,e,t,n),Ye.slerpFlat(t,e,t,e,t,o,r)}_lerp(t,e,n,r,s){let o=1-r;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[n+a]*r}}_lerpAdditive(t,e,n,r,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[n+o]*r}}},Sb="\\[\\]\\.:\\/",PU=new RegExp("["+Sb+"]","g"),wb="[^"+Sb+"]",DU="[^"+Sb.replace("\\.","")+"]",IU=/((?:WC+[\/:])*)/.source.replace("WC",wb),OU=/(WCOD+)?/.source.replace("WCOD",DU),RU=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",wb),LU=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",wb),NU=new RegExp("^"+IU+OU+RU+LU+"$"),BU=["material","materials","bones","map"],cb=class{constructor(t,e,n){let r=n||Rt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},Rt=class{constructor(t,e,n){this.path=e,this.parsedPath=n||Rt.parseTrackName(e),this.node=Rt.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Rt.Composite(t,e,n):new Rt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(PU,"")}static parseTrackName(t){let e=NU.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=n.nodeName.substring(r+1);BU.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=n(a.children);if(l)return l}return null},r=n(t.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)t[e++]=n[r]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,r=e.propertyName,s=e.propertyIndex;if(t||(t=Rt.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let u=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===u){u=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(u!==void 0){if(t[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[u]}}let o=t[r];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+r+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Rt.Composite=cb;Rt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Rt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Rt.prototype.GetterByBindingType=[Rt.prototype._getValue_direct,Rt.prototype._getValue_array,Rt.prototype._getValue_arrayElement,Rt.prototype._getValue_toArray];Rt.prototype.SetterByBindingTypeAndVersioning=[[Rt.prototype._setValue_direct,Rt.prototype._setValue_direct_setNeedsUpdate,Rt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Rt.prototype._setValue_array,Rt.prototype._setValue_array_setNeedsUpdate,Rt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Rt.prototype._setValue_arrayElement,Rt.prototype._setValue_arrayElement_setNeedsUpdate,Rt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Rt.prototype._setValue_fromArray,Rt.prototype._setValue_fromArray_setNeedsUpdate,Rt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var ub=class{constructor(t,e,n=null,r=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=r;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:Mc,endingEnd:Mc};for(let u=0;u!==o;++u){let c=s[u].createInterpolant(null);a[u]=c,c.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=pb,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){let r=this._clip.duration,s=t._clip.duration,o=s/r,a=r/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,u=a.sampleValues;return l[0]=s,l[1]=s+n,u[0]=t/o,u[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,r){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*n;l<0||n===0?e=0:(this._startTime=null,e=n*l)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let l=this._interpolants,u=this._propertyBindings;switch(this.blendMode){case ZL:for(let c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulateAdditive(a);break;case mb:default:for(let c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulate(r,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,n=this.loop,r=this.time+t,s=this._loopCount,o=n===ff;if(t===0)return s===-1?r:o&&(s&1)===1?e-r:r;if(n===fb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=e)r=e;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=e||r<0){let a=Math.floor(r/e);r-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?e:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let u=t<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return e-r}return r}_setEndings(t,e,n){let r=this._interpolantSettings;n?(r.endingStart=Cc,r.endingEnd=Cc):(t?r.endingStart=this.zeroSlopeAtStart?Cc:Mc:r.endingStart=Dm,e?r.endingEnd=this.zeroSlopeAtEnd?Cc:Mc:r.endingEnd=Dm)}_scheduleFading(t,e,n){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=n,this}},FU=new Float32Array(1),Qm=class extends Ht{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let n=t._localRoot||this._root,r=t._clip.tracks,s=r.length,o=t._propertyBindings,a=t._interpolants,l=n.uuid,u=this._bindingsByRootAndName,c=u[l];c===void 0&&(c={},u[l]=c);for(let h=0;h!==s;++h){let d=r[h],f=d.name,p=c[f];if(p!==void 0)++p.referenceCount,o[h]=p;else{if(p=o[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let m=e&&e._propertyBindings[h].binding.parsedPath;p=new lb(Rt.create(n,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[h]=p}a[h].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let n=(t._localRoot||this._root).uuid,r=t._clip.uuid,s=this._actionsByClip[r];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,r,n)}let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,n){let r=this._actions,s=this._actionsByClip,o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=r.length,r.push(t),o.actionByRoot[n]=t}_removeInactiveAction(t){let e=this._actions,n=e[e.length-1],r=t._cacheIndex;n._cacheIndex=r,e[r]=n,e.pop(),t._cacheIndex=null;let s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,u=l[l.length-1],c=t._byClipCacheIndex;u._byClipCacheIndex=c,l[c]=u,l.pop(),t._byClipCacheIndex=null;let h=a.actionByRoot,d=(t._localRoot||this._root).uuid;delete h[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,n=t._cacheIndex,r=this._nActiveActions++,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_takeBackAction(t){let e=this._actions,n=t._cacheIndex,r=--this._nActiveActions,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_addInactiveBinding(t,e,n){let r=this._bindingsByRootAndName,s=this._bindings,o=r[e];o===void 0&&(o={},r[e]=o),o[n]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,n=t.binding,r=n.rootNode.uuid,s=n.path,o=this._bindingsByRootAndName,a=o[r],l=e[e.length-1],u=t._cacheIndex;l._cacheIndex=u,e[u]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(t){let e=this._bindings,n=t._cacheIndex,r=this._nActiveBindings++,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_takeBackBinding(t){let e=this._bindings,n=t._cacheIndex,r=--this._nActiveBindings,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,n=t[e];return n===void 0&&(n=new Hm(new Float32Array(2),new Float32Array(2),1,FU),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){let e=this._controlInterpolants,n=t.__cacheIndex,r=--this._nActiveControlInterpolants,s=e[r];t.__cacheIndex=r,e[r]=t,s.__cacheIndex=n,e[n]=s}clipAction(t,e,n){let r=e||this._root,s=r.uuid,o=typeof t=="string"?Xc.findByName(r,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],u=null;if(n===void 0&&(o!==null?n=o.blendMode:n=mb),l!==void 0){let h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===n)return h;u=l.knownActions[0],o===null&&(o=u._clip)}if(o===null)return null;let c=new ub(this,o,e,n);return this._bindAction(c,u),this._addInactiveAction(c,a,s),c}existingAction(t,e){let n=e||this._root,r=n.uuid,s=typeof t=="string"?Xc.findByName(n,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let n=e-1;n>=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;let e=this._actions,n=this._nActiveActions,r=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let u=0;u!==n;++u)e[u]._update(r,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let u=0;u!==l;++u)a[u].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,n=t.uuid,r=this._actionsByClip,s=r[n];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let u=o[a];this._deactivateAction(u);let c=u._cacheIndex,h=e[e.length-1];u._cacheIndex=null,u._byClipCacheIndex=null,h._cacheIndex=c,e[c]=h,e.pop(),this._removeInactiveBindingsForAction(u)}delete r[n]}}uncacheRoot(t){let e=t.uuid,n=this._actionsByClip;for(let o in n){let a=n[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let r=this._bindingsByRootAndName,s=r[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let n=this.existingAction(t,e);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},oe=class{constructor(t){this.value=t}clone(){return new oe(this.value.clone===void 0?this.value:this.value.clone())}};var Jc=class{constructor(t,e,n=0,r=1/0){this.ray=new Ji(t,e),this.near=n,this.far=r,this.camera=null,this.layers=new ef,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,n=[]){return hb(t,this,n,e),n.sort(s_),n}intersectObjects(t,e=!0,n=[]){for(let r=0,s=t.length;r<s;r++)hb(t[r],this,n,e);return n.sort(s_),n}};function s_(i,t){return i.distance-t.distance}function hb(i,t,e,n){if(i.layers.test(t.layers)&&i.raycast(t,e),n===!0){let r=i.children;for(let s=0,o=r.length;s<o;s++)hb(r[s],t,e,!0)}}var df=class{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Wn(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var o_=new B,Zm=class{constructor(t=new B(1/0,1/0),e=new B(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=o_.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return o_.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},a_=new A,Em=new A,Xn=class{constructor(t=new A,e=new A){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){a_.subVectors(t,this.start),Em.subVectors(this.end,this.start);let n=Em.dot(Em),s=Em.dot(a_)/n;return e&&(s=Wn(s,0,1)),s}closestPointToPoint(t,e,n){let r=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},l_=new A,Jm=class extends mt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Ae,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;r.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new be(r,3));let s=new Pi({fog:!1,toneMapped:!1});this.cone=new ua(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),l_.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(l_),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var $m=class extends Fn{constructor(t,e,n){let r=new Tl(e,4,2),s=new wo({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=t,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var c_=new A,_m=new A,u_=new A,eg=class extends mt{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let r=new Ae;r.setAttribute("position",new be([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new Pi({fog:!1,toneMapped:!1});this.lightPlane=new bl(r,s),this.add(this.lightPlane),r=new Ae,r.setAttribute("position",new be([0,0,0,0,0,1],3)),this.targetLine=new bl(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),c_.setFromMatrixPosition(this.light.matrixWorld),_m.setFromMatrixPosition(this.light.target.matrixWorld),u_.subVectors(_m,c_),this.lightPlane.lookAt(_m),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(_m),this.targetLine.scale.z=u_.length()}},Tm=new A,gn=new $i,pa=class extends ua{constructor(t){let e=new Ae,n=new Pi({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,m){l(p),l(m)}function l(p){r.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(r.length/3-1)}e.setAttribute("position",new be(r,3)),e.setAttribute("color",new be(s,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Fe(16755200),c=new Fe(16711680),h=new Fe(43775),d=new Fe(16777215),f=new Fe(3355443);this.setColors(u,c,h,d,f)}setColors(t,e,n,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,n=1,r=1;gn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),wn("c",e,t,gn,0,0,-1),wn("t",e,t,gn,0,0,1),wn("n1",e,t,gn,-n,-r,-1),wn("n2",e,t,gn,n,-r,-1),wn("n3",e,t,gn,-n,r,-1),wn("n4",e,t,gn,n,r,-1),wn("f1",e,t,gn,-n,-r,1),wn("f2",e,t,gn,n,-r,1),wn("f3",e,t,gn,-n,r,1),wn("f4",e,t,gn,n,r,1),wn("u1",e,t,gn,n*.7,r*1.1,-1),wn("u2",e,t,gn,-n*.7,r*1.1,-1),wn("u3",e,t,gn,0,r*2,-1),wn("cf1",e,t,gn,-n,0,1),wn("cf2",e,t,gn,n,0,1),wn("cf3",e,t,gn,0,-r,1),wn("cf4",e,t,gn,0,r,1),wn("cn1",e,t,gn,-n,0,-1),wn("cn2",e,t,gn,n,0,-1),wn("cn3",e,t,gn,0,-r,-1),wn("cn4",e,t,gn,0,r,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function wn(i,t,e,n,r,s,o){Tm.set(r,s,o).unproject(n);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],Tm.x,Tm.y,Tm.z)}}var ma=class extends ua{constructor(t,e=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ae;s.setIndex(new Ge(n,1)),s.setAttribute("position",new be(r,3)),super(s,new Pi({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var tg=class extends ua{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ae;r.setAttribute("position",new be(e,3)),r.setAttribute("color",new be(n,3));let s=new Pi({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(t,e,n){let r=new Fe,s=this.geometry.attributes.color.array;return r.set(t),r.toArray(s,0),r.toArray(s,3),r.set(e),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:To}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=To);var tu=".",pf=Symbol("target"),Ab=Symbol("unsubscribe");function mf(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function D_(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var yi=Array.isArray;function Cl(i){return typeof i=="symbol"}var kU={after:(i,t)=>yi(i)?i.slice(t.length):t===""?i:i.slice(t.length+1),concat:(i,t)=>yi(i)?(i=[...i],t&&i.push(t),i):t&&t.toString!==void 0?(i!==""&&(i+=tu),Cl(t)?i+t.toString():i+t):i,initial:i=>{if(yi(i))return i.slice(0,-1);if(i==="")return i;let t=i.lastIndexOf(tu);return t===-1?"":i.slice(0,t)},last:i=>{if(yi(i))return i[i.length-1]||"";if(i==="")return i;let t=i.lastIndexOf(tu);return t===-1?i:i.slice(t+1)},walk:(i,t)=>{if(yi(i))for(let e of i)t(e);else if(i!==""){let e=0,n=i.indexOf(tu);if(n===-1)t(i);else for(;e<i.length;)n===-1&&(n=i.length),t(i.slice(e,n)),e=n+1,n=i.indexOf(tu,e)}},get(i,t){return this.walk(t,e=>{i&&(i=i[e])}),i}},Vr=kU;function Eb(i){return typeof i=="object"&&typeof i.next=="function"}function _b(i,t,e,n,r){let s=i.next;if(t.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=r(o.value[0],t,o.value[0],n),o.value[1]=r(o.value[1],t,o.value[0],n)),o};else if(t.name==="values"){let o=e[pf].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=r(a.value,t,o.next().value,n)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=r(o.value,t,o.value,n)),o};return i}function sg(i,t,e){return i.isUnsubscribed||t.ignoreSymbols&&Cl(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var gf=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let n=this._getProperties(t),r=n[e];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(t,e),n[e]=r),r}getProxy(t,e,n,r){if(this.isUnsubscribed)return t;let s=t[r],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,n):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,Vr.get(e,this.getPath(t)))}defineProperty(t,e,n){return Reflect.defineProperty(t,e,n)?(this.isUnsubscribed||(this._getProperties(t)[e]=n),!0):!1}setProperty(t,e,n,r,s){if(!this._equals(s,n)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,n,r):Reflect.set(t,e,n)}return!0}deleteProperty(t,e,n){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(t);r&&(delete r[e],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(t,e,n){let r=this._getOwnPropertyDescriptor(e,n);return t!==void 0&&r!==void 0&&Object.is(t.value,r.value)&&(t.writable||!1)===(r.writable||!1)&&(t.enumerable||!1)===(r.enumerable||!1)&&(t.configurable||!1)===(r.configurable||!1)&&t.get===r.get&&t.set===r.set}isGetInvariant(t,e){let n=this._getOwnPropertyDescriptor(t,e);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function nu(i){return toString.call(i)==="[object Object]"}function ru(){return!0}function ga(i,t){return i.length!==t.length||i.some((e,n)=>t[n]!==e)}var og=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var UU=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Tb={push:ru,pop:ru,shift:ru,unshift:ru,copyWithin:ga,reverse:ga,sort:ga,splice:ga,flat:ga,fill:ga},I_=new Set([...og,...UU,...Object.keys(Tb)]);function iu(i,t){if(i.size!==t.size)return!0;for(let e of i)if(!t.has(e))return!0;return!1}var Mb=["keys","values","entries"],Cb=new Set(["has","toString"]),Pb={add:iu,clear:iu,delete:iu,forEach:iu},O_=new Set([...Cb,...Object.keys(Pb),...Mb]);function su(i,t){if(i.size!==t.size)return!0;let e;for(let[n,r]of i)if(e=t.get(n),e!==r||e===void 0&&!t.has(n))return!0;return!1}var VU=new Set([...Cb,"get"]),Db={set:su,clear:su,delete:su,forEach:su},R_=new Set([...VU,...Object.keys(Db),...Mb]);var ar=class{constructor(t,e,n,r){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return og.has(t)}_shallowClone(t){let e=t;if(nu(t))e={...t};else if(yi(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(n=>this._shallowClone(n)));else if(t instanceof Map){e=new Map;for(let[n,r]of t.entries())e.set(n,this._shallowClone(r))}return this._clonedCache.add(e),e}preferredThisArg(t,e,n,r){return t?(yi(r)?this._onIsChanged=Tb[e]:r instanceof Set?this._onIsChanged=Pb[e]:r instanceof Map&&(this._onIsChanged=Db[e]),r):n}update(t,e,n){let r=Vr.after(t,this._path);if(e!=="length"){let s=this.clone;Vr.walk(r,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:r,property:e,previous:n}),s&&s[e]&&(s[e]=n)}this._isChanged=!0}undo(t){let e;for(let n=this._changes.length-1;n!==-1;n--)e=this._changes[n],Vr.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var ou=class extends ar{static isHandledMethod(t){return I_.has(t)}};var yf=class extends ar{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var au=class extends ar{static isHandledMethod(t){return O_.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var lu=class extends ar{static isHandledMethod(t){return R_.has(t)}undo(t){for(let[e,n]of this.clone.entries())t.set(e,n);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var vf=class extends ar{constructor(t,e,n,r){super(void 0,e,n,r),this._arg1=n[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var xf=class extends ar{constructor(t,e,n,r){super(void 0,e,n,r),this._weakKey=n[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var ts=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return nu(t)||yi(t)||mf(t)}static isHandledMethod(t,e){return nu(t)?ar.isHandledMethod(e):yi(t)?ou.isHandledMethod(e):t instanceof Set?au.isHandledMethod(e):t instanceof Map?lu.isHandledMethod(e):mf(t)}get isCloning(){return this._stack.length>0}start(t,e,n){let r=ar;yi(t)?r=ou:t instanceof Date?r=yf:t instanceof Set?r=au:t instanceof Map?r=lu:t instanceof WeakSet?r=vf:t instanceof WeakMap&&(r=xf),this._stack.push(new r(t,e,n,this._hasOnValidate))}update(t,e,n){this._stack[this._stack.length-1].update(t,e,n)}preferredThisArg(t,e,n){let{name:r}=t,s=ts.isHandledMethod(n,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,e,n)}isChanged(t,e,n){return this._stack[this._stack.length-1].isChanged(t,e,n)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var zU={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Ib=(i,t,e={})=>{e={...zU,...e};let n=Symbol("ProxyTarget"),{equals:r,isShallow:s,ignoreDetached:o,details:a}=e,l=new gf(r),u=typeof e.onValidate=="function",c=new ts(u),h=(v,x,b,w,E)=>!u||c.isCloning||e.onValidate(Vr.concat(l.getPath(v),x),b,w,E)===!0,d=(v,x,b,w)=>{!sg(l,e,x)&&!(o&&l.isDetached(v,i))&&f(l.getPath(v),x,b,w)},f=(v,x,b,w,E)=>{c.isCloning?c.update(v,x,w):t(Vr.concat(v,x),b,w,E)},p=v=>v&&(v[n]||v),m=(v,x,b,w)=>D_(v)||b==="constructor"||s&&!ts.isHandledMethod(x,b)||sg(l,e,b)||l.isGetInvariant(x,b)||o&&l.isDetached(x,i)?v:(w===void 0&&(w=l.getPath(x)),l.getProxy(v,Vr.concat(w,b),g,n)),g={get(v,x,b){if(Cl(x)){if(x===n||x===pf)return v;if(x===Ab&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let w=mf(v)?Reflect.get(v,x):Reflect.get(v,x,b);return m(w,v,x)},set(v,x,b,w){b=p(b);let E=v[n]||v,_=E[x];if(r(_,b)&&x in v)return!0;let S=h(v,x,b,_);return S&&l.setProperty(E,x,b,w,_)?(d(v,x,v[x],_),!0):!S},defineProperty(v,x,b){if(!l.isSameDescriptor(b,v,x)){let w=v[x];h(v,x,b.value,w)&&l.defineProperty(v,x,b,w)&&d(v,x,b.value,w)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let b=Reflect.get(v,x),w=h(v,x,void 0,b);return w&&l.deleteProperty(v,x,b)?(d(v,x,void 0,b),!0):!w},apply(v,x,b){let w=x[n]||x;if(l.isUnsubscribed)return Reflect.apply(v,w,b);if((a===!1||a!==!0&&!a.includes(v.name))&&ts.isHandledType(w)){let E=Vr.initial(l.getPath(v)),_=ts.isHandledMethod(w,v.name);c.start(w,E,b);let S=Reflect.apply(v,c.preferredThisArg(v,x,w),_?b.map(C=>p(C)):b),T=c.isChanged(w,r),M=c.stop();if(ts.isHandledType(S)&&_&&(x instanceof Map&&v.name==="get"&&(E=Vr.concat(E,b[0])),S=l.getProxy(S,E,g)),T){let C={name:v.name,args:b,result:S},D=c.isCloning?Vr.initial(E):E,P=c.isCloning?Vr.last(E):"";h(Vr.get(i,D),P,w,M,C)?f(D,P,w,M,C):c.undo(w)}return(x instanceof Map||x instanceof Set)&&Eb(S)?_b(S,v,x,E,m):S}return Reflect.apply(v,x,b)}},y=l.getProxy(i,e.pathAsArray?[]:"",g);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};Ib.target=i=>i&&i[pf]||i;Ib.unsubscribe=i=>i[Ab]||i;var Ob=Ib;var GU=typeof global=="object"&&global&&global.Object===Object&&global,ag=GU;var HU=typeof self=="object"&&self&&self.Object===Object&&self,jU=ag||HU||Function("return this")(),yn=jU;var WU=yn.Symbol,lr=WU;var L_=Object.prototype,qU=L_.hasOwnProperty,YU=L_.toString,bf=lr?lr.toStringTag:void 0;function XU(i){var t=qU.call(i,bf),e=i[bf];try{i[bf]=void 0;var n=!0}catch{}var r=YU.call(i);return n&&(t?i[bf]=e:delete i[bf]),r}var N_=XU;var KU=Object.prototype,QU=KU.toString;function ZU(i){return QU.call(i)}var B_=ZU;var JU="[object Null]",$U="[object Undefined]",F_=lr?lr.toStringTag:void 0;function eV(i){return i==null?i===void 0?$U:JU:F_&&F_ in Object(i)?N_(i):B_(i)}var vi=eV;function tV(i){return i!=null&&typeof i=="object"}var Ar=tV;var nV="[object Symbol]";function rV(i){return typeof i=="symbol"||Ar(i)&&vi(i)==nV}var ya=rV;function iV(i,t){for(var e=-1,n=i==null?0:i.length,r=Array(n);++e<n;)r[e]=t(i[e],e,i);return r}var lg=iV;var sV=Array.isArray,Kn=sV;var oV=1/0,k_=lr?lr.prototype:void 0,U_=k_?k_.toString:void 0;function V_(i){if(typeof i=="string")return i;if(Kn(i))return lg(i,V_)+"";if(ya(i))return U_?U_.call(i):"";var t=i+"";return t=="0"&&1/i==-oV?"-0":t}var z_=V_;var aV=/\s/;function lV(i){for(var t=i.length;t--&&aV.test(i.charAt(t)););return t}var G_=lV;var cV=/^\s+/;function uV(i){return i&&i.slice(0,G_(i)+1).replace(cV,"")}var H_=uV;function hV(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var Un=hV;var j_=0/0,dV=/^[-+]0x[0-9a-f]+$/i,fV=/^0b[01]+$/i,pV=/^0o[0-7]+$/i,mV=parseInt;function gV(i){if(typeof i=="number")return i;if(ya(i))return j_;if(Un(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=Un(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=H_(i);var e=fV.test(i);return e||pV.test(i)?mV(i.slice(2),e?2:8):dV.test(i)?j_:+i}var Rb=gV;function yV(i){return i}var W_=yV;var vV="[object AsyncFunction]",xV="[object Function]",bV="[object GeneratorFunction]",SV="[object Proxy]";function wV(i){if(!Un(i))return!1;var t=vi(i);return t==xV||t==bV||t==vV||t==SV}var cg=wV;var AV=yn["__core-js_shared__"],ug=AV;var q_=function(){var i=/[^.]+$/.exec(ug&&ug.keys&&ug.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function EV(i){return!!q_&&q_ in i}var Y_=EV;var _V=Function.prototype,TV=_V.toString;function MV(i){if(i!=null){try{return TV.call(i)}catch{}try{return i+""}catch{}}return""}var Mo=MV;var CV=/[\\^$.*+?()[\]{}|]/g,PV=/^\[object .+?Constructor\]$/,DV=Function.prototype,IV=Object.prototype,OV=DV.toString,RV=IV.hasOwnProperty,LV=RegExp("^"+OV.call(RV).replace(CV,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function NV(i){if(!Un(i)||Y_(i))return!1;var t=cg(i)?LV:PV;return t.test(Mo(i))}var X_=NV;function BV(i,t){return i?.[t]}var K_=BV;function FV(i,t){var e=K_(i,t);return X_(e)?e:void 0}var Kr=FV;var kV=Kr(yn,"WeakMap"),hg=kV;var Q_=Object.create,UV=function(){function i(){}return function(t){if(!Un(t))return{};if(Q_)return Q_(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),Z_=UV;function VV(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var J_=VV;function zV(i,t){var e=-1,n=i.length;for(t||(t=Array(n));++e<n;)t[e]=i[e];return t}var $_=zV;var GV=800,HV=16,jV=Date.now;function WV(i){var t=0,e=0;return function(){var n=jV(),r=HV-(n-e);if(e=n,r>0){if(++t>=GV)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var eT=WV;function qV(i){return function(){return i}}var tT=qV;var YV=function(){try{var i=Kr(Object,"defineProperty");return i({},"",{}),i}catch{}}(),cu=YV;var XV=cu?function(i,t){return cu(i,"toString",{configurable:!0,enumerable:!1,value:tT(t),writable:!0})}:W_,nT=XV;var KV=eT(nT),rT=KV;function QV(i,t){for(var e=-1,n=i==null?0:i.length;++e<n&&t(i[e],e,i)!==!1;);return i}var iT=QV;var ZV=9007199254740991,JV=/^(?:0|[1-9]\d*)$/;function $V(i,t){var e=typeof i;return t=t??ZV,!!t&&(e=="number"||e!="symbol"&&JV.test(i))&&i>-1&&i%1==0&&i<t}var uu=$V;function ez(i,t,e){t=="__proto__"&&cu?cu(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var dg=ez;function tz(i,t){return i===t||i!==i&&t!==t}var hu=tz;var nz=Object.prototype,rz=nz.hasOwnProperty;function iz(i,t,e){var n=i[t];(!(rz.call(i,t)&&hu(n,e))||e===void 0&&!(t in i))&&dg(i,t,e)}var du=iz;function sz(i,t,e,n){var r=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=n?n(e[a],i[a],a,e,i):void 0;l===void 0&&(l=i[a]),r?dg(e,a,l):du(e,a,l)}return e}var Cs=sz;var sT=Math.max;function oz(i,t,e){return t=sT(t===void 0?i.length-1:t,0),function(){for(var n=arguments,r=-1,s=sT(n.length-t,0),o=Array(s);++r<s;)o[r]=n[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=n[r];return a[t]=e(o),J_(i,this,a)}}var oT=oz;var az=9007199254740991;function lz(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=az}var fu=lz;function cz(i){return i!=null&&fu(i.length)&&!cg(i)}var fg=cz;var uz=Object.prototype;function hz(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||uz;return i===e}var pu=hz;function dz(i,t){for(var e=-1,n=Array(i);++e<i;)n[e]=t(e);return n}var aT=dz;var fz="[object Arguments]";function pz(i){return Ar(i)&&vi(i)==fz}var Lb=pz;var lT=Object.prototype,mz=lT.hasOwnProperty,gz=lT.propertyIsEnumerable,yz=Lb(function(){return arguments}())?Lb:function(i){return Ar(i)&&mz.call(i,"callee")&&!gz.call(i,"callee")},mu=yz;function vz(){return!1}var cT=vz;var dT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,uT=dT&&typeof module=="object"&&module&&!module.nodeType&&module,xz=uT&&uT.exports===dT,hT=xz?yn.Buffer:void 0,bz=hT?hT.isBuffer:void 0,Sz=bz||cT,Pl=Sz;var wz="[object Arguments]",Az="[object Array]",Ez="[object Boolean]",_z="[object Date]",Tz="[object Error]",Mz="[object Function]",Cz="[object Map]",Pz="[object Number]",Dz="[object Object]",Iz="[object RegExp]",Oz="[object Set]",Rz="[object String]",Lz="[object WeakMap]",Nz="[object ArrayBuffer]",Bz="[object DataView]",Fz="[object Float32Array]",kz="[object Float64Array]",Uz="[object Int8Array]",Vz="[object Int16Array]",zz="[object Int32Array]",Gz="[object Uint8Array]",Hz="[object Uint8ClampedArray]",jz="[object Uint16Array]",Wz="[object Uint32Array]",rn={};rn[Fz]=rn[kz]=rn[Uz]=rn[Vz]=rn[zz]=rn[Gz]=rn[Hz]=rn[jz]=rn[Wz]=!0;rn[wz]=rn[Az]=rn[Nz]=rn[Ez]=rn[Bz]=rn[_z]=rn[Tz]=rn[Mz]=rn[Cz]=rn[Pz]=rn[Dz]=rn[Iz]=rn[Oz]=rn[Rz]=rn[Lz]=!1;function qz(i){return Ar(i)&&fu(i.length)&&!!rn[vi(i)]}var fT=qz;function Yz(i){return function(t){return i(t)}}var gu=Yz;var pT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sf=pT&&typeof module=="object"&&module&&!module.nodeType&&module,Xz=Sf&&Sf.exports===pT,Nb=Xz&&ag.process,Kz=function(){try{var i=Sf&&Sf.require&&Sf.require("util").types;return i||Nb&&Nb.binding&&Nb.binding("util")}catch{}}(),Co=Kz;var mT=Co&&Co.isTypedArray,Qz=mT?gu(mT):fT,pg=Qz;var Zz=Object.prototype,Jz=Zz.hasOwnProperty;function $z(i,t){var e=Kn(i),n=!e&&mu(i),r=!e&&!n&&Pl(i),s=!e&&!n&&!r&&pg(i),o=e||n||r||s,a=o?aT(i.length,String):[],l=a.length;for(var u in i)(t||Jz.call(i,u))&&!(o&&(u=="length"||r&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||uu(u,l)))&&a.push(u);return a}var mg=$z;function eG(i,t){return function(e){return i(t(e))}}var gg=eG;var tG=gg(Object.keys,Object),gT=tG;var nG=Object.prototype,rG=nG.hasOwnProperty;function iG(i){if(!pu(i))return gT(i);var t=[];for(var e in Object(i))rG.call(i,e)&&e!="constructor"&&t.push(e);return t}var yT=iG;function sG(i){return fg(i)?mg(i):yT(i)}var yu=sG;function oG(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var vT=oG;var aG=Object.prototype,lG=aG.hasOwnProperty;function cG(i){if(!Un(i))return vT(i);var t=pu(i),e=[];for(var n in i)n=="constructor"&&(t||!lG.call(i,n))||e.push(n);return e}var xT=cG;function uG(i){return fg(i)?mg(i,!0):xT(i)}var vu=uG;var hG=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,dG=/^\w*$/;function fG(i,t){if(Kn(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||ya(i)?!0:dG.test(i)||!hG.test(i)||t!=null&&i in Object(t)}var bT=fG;var pG=Kr(Object,"create"),Po=pG;function mG(){this.__data__=Po?Po(null):{},this.size=0}var ST=mG;function gG(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var wT=gG;var yG="__lodash_hash_undefined__",vG=Object.prototype,xG=vG.hasOwnProperty;function bG(i){var t=this.__data__;if(Po){var e=t[i];return e===yG?void 0:e}return xG.call(t,i)?t[i]:void 0}var AT=bG;var SG=Object.prototype,wG=SG.hasOwnProperty;function AG(i){var t=this.__data__;return Po?t[i]!==void 0:wG.call(t,i)}var ET=AG;var EG="__lodash_hash_undefined__";function _G(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Po&&t===void 0?EG:t,this}var _T=_G;function xu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}xu.prototype.clear=ST;xu.prototype.delete=wT;xu.prototype.get=AT;xu.prototype.has=ET;xu.prototype.set=_T;var Bb=xu;function TG(){this.__data__=[],this.size=0}var TT=TG;function MG(i,t){for(var e=i.length;e--;)if(hu(i[e][0],t))return e;return-1}var va=MG;var CG=Array.prototype,PG=CG.splice;function DG(i){var t=this.__data__,e=va(t,i);if(e<0)return!1;var n=t.length-1;return e==n?t.pop():PG.call(t,e,1),--this.size,!0}var MT=DG;function IG(i){var t=this.__data__,e=va(t,i);return e<0?void 0:t[e][1]}var CT=IG;function OG(i){return va(this.__data__,i)>-1}var PT=OG;function RG(i,t){var e=this.__data__,n=va(e,i);return n<0?(++this.size,e.push([i,t])):e[n][1]=t,this}var DT=RG;function bu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}bu.prototype.clear=TT;bu.prototype.delete=MT;bu.prototype.get=CT;bu.prototype.has=PT;bu.prototype.set=DT;var xa=bu;var LG=Kr(yn,"Map"),ba=LG;function NG(){this.size=0,this.__data__={hash:new Bb,map:new(ba||xa),string:new Bb}}var IT=NG;function BG(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var OT=BG;function FG(i,t){var e=i.__data__;return OT(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Sa=FG;function kG(i){var t=Sa(this,i).delete(i);return this.size-=t?1:0,t}var RT=kG;function UG(i){return Sa(this,i).get(i)}var LT=UG;function VG(i){return Sa(this,i).has(i)}var NT=VG;function zG(i,t){var e=Sa(this,i),n=e.size;return e.set(i,t),this.size+=e.size==n?0:1,this}var BT=zG;function Su(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}Su.prototype.clear=IT;Su.prototype.delete=RT;Su.prototype.get=LT;Su.prototype.has=NT;Su.prototype.set=BT;var Dl=Su;var GG="Expected a function";function Fb(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(GG);var e=function(){var n=arguments,r=t?t.apply(this,n):n[0],s=e.cache;if(s.has(r))return s.get(r);var o=i.apply(this,n);return e.cache=s.set(r,o)||s,o};return e.cache=new(Fb.Cache||Dl),e}Fb.Cache=Dl;var FT=Fb;var HG=500;function jG(i){var t=FT(i,function(n){return e.size===HG&&e.clear(),n}),e=t.cache;return t}var kT=jG;var WG=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,qG=/\\(\\)?/g,YG=kT(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(WG,function(e,n,r,s){t.push(r?s.replace(qG,"$1"):n||e)}),t}),UT=YG;function XG(i){return i==null?"":z_(i)}var VT=XG;function KG(i,t){return Kn(i)?i:bT(i,t)?[i]:UT(VT(i))}var Oi=KG;var QG=1/0;function ZG(i){if(typeof i=="string"||ya(i))return i;var t=i+"";return t=="0"&&1/i==-QG?"-0":t}var wa=ZG;function JG(i,t){t=Oi(t,i);for(var e=0,n=t.length;i!=null&&e<n;)i=i[wa(t[e++])];return e&&e==n?i:void 0}var yg=JG;function $G(i,t){for(var e=-1,n=t.length,r=i.length;++e<n;)i[r+e]=t[e];return i}var wu=$G;var zT=lr?lr.isConcatSpreadable:void 0;function e4(i){return Kn(i)||mu(i)||!!(zT&&i&&i[zT])}var GT=e4;function HT(i,t,e,n,r){var s=-1,o=i.length;for(e||(e=GT),r||(r=[]);++s<o;){var a=i[s];t>0&&e(a)?t>1?HT(a,t-1,e,n,r):wu(r,a):n||(r[r.length]=a)}return r}var jT=HT;function t4(i){var t=i==null?0:i.length;return t?jT(i,1):[]}var WT=t4;function n4(i){return rT(oT(i,void 0,WT),i+"")}var vg=n4;var r4=gg(Object.getPrototypeOf,Object),Au=r4;var i4="[object Object]",s4=Function.prototype,o4=Object.prototype,qT=s4.toString,a4=o4.hasOwnProperty,l4=qT.call(Object);function c4(i){if(!Ar(i)||vi(i)!=i4)return!1;var t=Au(i);if(t===null)return!0;var e=a4.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&qT.call(e)==l4}var YT=c4;function u4(i,t,e){var n=-1,r=i.length;t<0&&(t=-t>r?0:r+t),e=e>r?r:e,e<0&&(e+=r),r=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(r);++n<r;)s[n]=i[n+t];return s}var XT=u4;function h4(){this.__data__=new xa,this.size=0}var KT=h4;function d4(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var QT=d4;function f4(i){return this.__data__.get(i)}var ZT=f4;function p4(i){return this.__data__.has(i)}var JT=p4;var m4=200;function g4(i,t){var e=this.__data__;if(e instanceof xa){var n=e.__data__;if(!ba||n.length<m4-1)return n.push([i,t]),this.size=++e.size,this;e=this.__data__=new Dl(n)}return e.set(i,t),this.size=e.size,this}var $T=g4;function Eu(i){var t=this.__data__=new xa(i);this.size=t.size}Eu.prototype.clear=KT;Eu.prototype.delete=QT;Eu.prototype.get=ZT;Eu.prototype.has=JT;Eu.prototype.set=$T;var _u=Eu;function y4(i,t){return i&&Cs(t,yu(t),i)}var eM=y4;function v4(i,t){return i&&Cs(t,vu(t),i)}var tM=v4;var sM=typeof exports=="object"&&exports&&!exports.nodeType&&exports,nM=sM&&typeof module=="object"&&module&&!module.nodeType&&module,x4=nM&&nM.exports===sM,rM=x4?yn.Buffer:void 0,iM=rM?rM.allocUnsafe:void 0;function b4(i,t){if(t)return i.slice();var e=i.length,n=iM?iM(e):new i.constructor(e);return i.copy(n),n}var oM=b4;function S4(i,t){for(var e=-1,n=i==null?0:i.length,r=0,s=[];++e<n;){var o=i[e];t(o,e,i)&&(s[r++]=o)}return s}var aM=S4;function w4(){return[]}var xg=w4;var A4=Object.prototype,E4=A4.propertyIsEnumerable,lM=Object.getOwnPropertySymbols,_4=lM?function(i){return i==null?[]:(i=Object(i),aM(lM(i),function(t){return E4.call(i,t)}))}:xg,Tu=_4;function T4(i,t){return Cs(i,Tu(i),t)}var cM=T4;var M4=Object.getOwnPropertySymbols,C4=M4?function(i){for(var t=[];i;)wu(t,Tu(i)),i=Au(i);return t}:xg,bg=C4;function P4(i,t){return Cs(i,bg(i),t)}var uM=P4;function D4(i,t,e){var n=t(i);return Kn(i)?n:wu(n,e(i))}var Sg=D4;function I4(i){return Sg(i,yu,Tu)}var wf=I4;function O4(i){return Sg(i,vu,bg)}var wg=O4;var R4=Kr(yn,"DataView"),Ag=R4;var L4=Kr(yn,"Promise"),Eg=L4;var N4=Kr(yn,"Set"),_g=N4;var hM="[object Map]",B4="[object Object]",dM="[object Promise]",fM="[object Set]",pM="[object WeakMap]",mM="[object DataView]",F4=Mo(Ag),k4=Mo(ba),U4=Mo(Eg),V4=Mo(_g),z4=Mo(hg),Il=vi;(Ag&&Il(new Ag(new ArrayBuffer(1)))!=mM||ba&&Il(new ba)!=hM||Eg&&Il(Eg.resolve())!=dM||_g&&Il(new _g)!=fM||hg&&Il(new hg)!=pM)&&(Il=function(i){var t=vi(i),e=t==B4?i.constructor:void 0,n=e?Mo(e):"";if(n)switch(n){case F4:return mM;case k4:return hM;case U4:return dM;case V4:return fM;case z4:return pM}return t});var Do=Il;var G4=Object.prototype,H4=G4.hasOwnProperty;function j4(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&H4.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var gM=j4;var W4=yn.Uint8Array,Mu=W4;function q4(i){var t=new i.constructor(i.byteLength);return new Mu(t).set(new Mu(i)),t}var Cu=q4;function Y4(i,t){var e=t?Cu(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var yM=Y4;var X4=/\w*$/;function K4(i){var t=new i.constructor(i.source,X4.exec(i));return t.lastIndex=i.lastIndex,t}var vM=K4;var xM=lr?lr.prototype:void 0,bM=xM?xM.valueOf:void 0;function Q4(i){return bM?Object(bM.call(i)):{}}var SM=Q4;function Z4(i,t){var e=t?Cu(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var wM=Z4;var J4="[object Boolean]",$4="[object Date]",eH="[object Map]",tH="[object Number]",nH="[object RegExp]",rH="[object Set]",iH="[object String]",sH="[object Symbol]",oH="[object ArrayBuffer]",aH="[object DataView]",lH="[object Float32Array]",cH="[object Float64Array]",uH="[object Int8Array]",hH="[object Int16Array]",dH="[object Int32Array]",fH="[object Uint8Array]",pH="[object Uint8ClampedArray]",mH="[object Uint16Array]",gH="[object Uint32Array]";function yH(i,t,e){var n=i.constructor;switch(t){case oH:return Cu(i);case J4:case $4:return new n(+i);case aH:return yM(i,e);case lH:case cH:case uH:case hH:case dH:case fH:case pH:case mH:case gH:return wM(i,e);case eH:return new n;case tH:case iH:return new n(i);case nH:return vM(i);case rH:return new n;case sH:return SM(i)}}var AM=yH;function vH(i){return typeof i.constructor=="function"&&!pu(i)?Z_(Au(i)):{}}var EM=vH;var xH="[object Map]";function bH(i){return Ar(i)&&Do(i)==xH}var _M=bH;var TM=Co&&Co.isMap,SH=TM?gu(TM):_M,MM=SH;var wH="[object Set]";function AH(i){return Ar(i)&&Do(i)==wH}var CM=AH;var PM=Co&&Co.isSet,EH=PM?gu(PM):CM,DM=EH;var _H=1,TH=2,MH=4,IM="[object Arguments]",CH="[object Array]",PH="[object Boolean]",DH="[object Date]",IH="[object Error]",OM="[object Function]",OH="[object GeneratorFunction]",RH="[object Map]",LH="[object Number]",RM="[object Object]",NH="[object RegExp]",BH="[object Set]",FH="[object String]",kH="[object Symbol]",UH="[object WeakMap]",VH="[object ArrayBuffer]",zH="[object DataView]",GH="[object Float32Array]",HH="[object Float64Array]",jH="[object Int8Array]",WH="[object Int16Array]",qH="[object Int32Array]",YH="[object Uint8Array]",XH="[object Uint8ClampedArray]",KH="[object Uint16Array]",QH="[object Uint32Array]",tn={};tn[IM]=tn[CH]=tn[VH]=tn[zH]=tn[PH]=tn[DH]=tn[GH]=tn[HH]=tn[jH]=tn[WH]=tn[qH]=tn[RH]=tn[LH]=tn[RM]=tn[NH]=tn[BH]=tn[FH]=tn[kH]=tn[YH]=tn[XH]=tn[KH]=tn[QH]=!0;tn[IH]=tn[OM]=tn[UH]=!1;function Tg(i,t,e,n,r,s){var o,a=t&_H,l=t&TH,u=t&MH;if(e&&(o=r?e(i,n,r,s):e(i)),o!==void 0)return o;if(!Un(i))return i;var c=Kn(i);if(c){if(o=gM(i),!a)return $_(i,o)}else{var h=Do(i),d=h==OM||h==OH;if(Pl(i))return oM(i,a);if(h==RM||h==IM||d&&!r){if(o=l||d?{}:EM(i),!a)return l?uM(i,tM(o,i)):cM(i,eM(o,i))}else{if(!tn[h])return r?i:{};o=AM(i,h,a)}}s||(s=new _u);var f=s.get(i);if(f)return f;s.set(i,o),DM(i)?i.forEach(function(g){o.add(Tg(g,t,e,g,i,s))}):MM(i)&&i.forEach(function(g,y){o.set(y,Tg(g,t,e,y,i,s))});var p=u?l?wg:wf:l?vu:yu,m=c?void 0:p(i);return iT(m||i,function(g,y){m&&(y=g,g=i[y]),du(o,y,Tg(g,t,e,y,i,s))}),o}var Mg=Tg;var ZH=1,JH=4;function $H(i){return Mg(i,ZH|JH)}var Io=$H;var e5="__lodash_hash_undefined__";function t5(i){return this.__data__.set(i,e5),this}var LM=t5;function n5(i){return this.__data__.has(i)}var NM=n5;function Cg(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new Dl;++t<e;)this.add(i[t])}Cg.prototype.add=Cg.prototype.push=LM;Cg.prototype.has=NM;var BM=Cg;function r5(i,t){for(var e=-1,n=i==null?0:i.length;++e<n;)if(t(i[e],e,i))return!0;return!1}var FM=r5;function i5(i,t){return i.has(t)}var kM=i5;var s5=1,o5=2;function a5(i,t,e,n,r,s){var o=e&s5,a=i.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var u=s.get(i),c=s.get(t);if(u&&c)return u==t&&c==i;var h=-1,d=!0,f=e&o5?new BM:void 0;for(s.set(i,t),s.set(t,i);++h<a;){var p=i[h],m=t[h];if(n)var g=o?n(m,p,h,t,i,s):n(p,m,h,i,t,s);if(g!==void 0){if(g)continue;d=!1;break}if(f){if(!FM(t,function(y,v){if(!kM(f,v)&&(p===y||r(p,y,e,n,s)))return f.push(v)})){d=!1;break}}else if(!(p===m||r(p,m,e,n,s))){d=!1;break}}return s.delete(i),s.delete(t),d}var Pg=a5;function l5(i){var t=-1,e=Array(i.size);return i.forEach(function(n,r){e[++t]=[r,n]}),e}var UM=l5;function c5(i){var t=-1,e=Array(i.size);return i.forEach(function(n){e[++t]=n}),e}var VM=c5;var u5=1,h5=2,d5="[object Boolean]",f5="[object Date]",p5="[object Error]",m5="[object Map]",g5="[object Number]",y5="[object RegExp]",v5="[object Set]",x5="[object String]",b5="[object Symbol]",S5="[object ArrayBuffer]",w5="[object DataView]",zM=lr?lr.prototype:void 0,kb=zM?zM.valueOf:void 0;function A5(i,t,e,n,r,s,o){switch(e){case w5:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case S5:return!(i.byteLength!=t.byteLength||!s(new Mu(i),new Mu(t)));case d5:case f5:case g5:return hu(+i,+t);case p5:return i.name==t.name&&i.message==t.message;case y5:case x5:return i==t+"";case m5:var a=UM;case v5:var l=n&u5;if(a||(a=VM),i.size!=t.size&&!l)return!1;var u=o.get(i);if(u)return u==t;n|=h5,o.set(i,t);var c=Pg(a(i),a(t),n,r,s,o);return o.delete(i),c;case b5:if(kb)return kb.call(i)==kb.call(t)}return!1}var GM=A5;var E5=1,_5=Object.prototype,T5=_5.hasOwnProperty;function M5(i,t,e,n,r,s){var o=e&E5,a=wf(i),l=a.length,u=wf(t),c=u.length;if(l!=c&&!o)return!1;for(var h=l;h--;){var d=a[h];if(!(o?d in t:T5.call(t,d)))return!1}var f=s.get(i),p=s.get(t);if(f&&p)return f==t&&p==i;var m=!0;s.set(i,t),s.set(t,i);for(var g=o;++h<l;){d=a[h];var y=i[d],v=t[d];if(n)var x=o?n(v,y,d,t,i,s):n(y,v,d,i,t,s);if(!(x===void 0?y===v||r(y,v,e,n,s):x)){m=!1;break}g||(g=d=="constructor")}if(m&&!g){var b=i.constructor,w=t.constructor;b!=w&&"constructor"in i&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof w=="function"&&w instanceof w)&&(m=!1)}return s.delete(i),s.delete(t),m}var HM=M5;var C5=1,jM="[object Arguments]",WM="[object Array]",Dg="[object Object]",P5=Object.prototype,qM=P5.hasOwnProperty;function D5(i,t,e,n,r,s){var o=Kn(i),a=Kn(t),l=o?WM:Do(i),u=a?WM:Do(t);l=l==jM?Dg:l,u=u==jM?Dg:u;var c=l==Dg,h=u==Dg,d=l==u;if(d&&Pl(i)){if(!Pl(t))return!1;o=!0,c=!1}if(d&&!c)return s||(s=new _u),o||pg(i)?Pg(i,t,e,n,r,s):GM(i,t,l,e,n,r,s);if(!(e&C5)){var f=c&&qM.call(i,"__wrapped__"),p=h&&qM.call(t,"__wrapped__");if(f||p){var m=f?i.value():i,g=p?t.value():t;return s||(s=new _u),r(m,g,e,n,s)}}return d?(s||(s=new _u),HM(i,t,e,n,r,s)):!1}var YM=D5;function XM(i,t,e,n,r){return i===t?!0:i==null||t==null||!Ar(i)&&!Ar(t)?i!==i&&t!==t:YM(i,t,e,n,XM,r)}var KM=XM;function I5(i,t){return i!=null&&t in Object(i)}var QM=I5;function O5(i,t,e){t=Oi(t,i);for(var n=-1,r=t.length,s=!1;++n<r;){var o=wa(t[n]);if(!(s=i!=null&&e(i,o)))break;i=i[o]}return s||++n!=r?s:(r=i==null?0:i.length,!!r&&fu(r)&&uu(o,r)&&(Kn(i)||mu(i)))}var ZM=O5;function R5(i,t){return i!=null&&ZM(i,t,QM)}var JM=R5;var L5=function(){return yn.Date.now()},Ig=L5;var N5="Expected a function",B5=Math.max,F5=Math.min;function k5(i,t,e){var n,r,s,o,a,l,u=0,c=!1,h=!1,d=!0;if(typeof i!="function")throw new TypeError(N5);t=Rb(t)||0,Un(e)&&(c=!!e.leading,h="maxWait"in e,s=h?B5(Rb(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function f(E){var _=n,S=r;return n=r=void 0,u=E,o=i.apply(S,_),o}function p(E){return u=E,a=setTimeout(y,t),c?f(E):o}function m(E){var _=E-l,S=E-u,T=t-_;return h?F5(T,s-S):T}function g(E){var _=E-l,S=E-u;return l===void 0||_>=t||_<0||h&&S>=s}function y(){var E=Ig();if(g(E))return v(E);a=setTimeout(y,m(E))}function v(E){return a=void 0,d&&n?f(E):(n=r=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,n=l=r=a=void 0}function b(){return a===void 0?o:v(Ig())}function w(){var E=Ig(),_=g(E);if(n=arguments,r=this,l=E,_){if(a===void 0)return p(l);if(h)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return w.cancel=x,w.flush=b,w}var Ol=k5;function U5(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var $M=U5;function V5(i,t){return t.length<2?i:yg(i,XT(t,0,-1))}var eC=V5;function z5(i,t){return KM(i,t)}var Af=z5;function G5(i,t){return t=Oi(t,i),i=eC(i,t),i==null||delete i[wa($M(t))]}var tC=G5;function H5(i){return YT(i)?void 0:i}var nC=H5;var j5=1,W5=2,q5=4,Y5=vg(function(i,t){var e={};if(i==null)return e;var n=!1;t=lg(t,function(s){return s=Oi(s,i),n||(n=s.length>1),s}),Cs(i,wg(i),e),n&&(e=Mg(e,j5|W5|q5,nC));for(var r=t.length;r--;)tC(e,t[r]);return e}),Ub=Y5;function X5(i,t,e,n){if(!Un(i))return i;t=Oi(t,i);for(var r=-1,s=t.length,o=s-1,a=i;a!=null&&++r<s;){var l=wa(t[r]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(r!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=Un(c)?c:uu(t[r+1])?[]:{})}du(a,l,u),a=a[l]}return i}var rC=X5;function K5(i,t,e){for(var n=-1,r=t.length,s={};++n<r;){var o=t[n],a=yg(i,o);e(a,o)&&rC(s,Oi(o,i),a)}return s}var iC=K5;function Q5(i,t){return iC(i,t,function(e,n){return JM(i,n)})}var sC=Q5;var Z5=vg(function(i,t){return i==null?{}:sC(i,t)}),xi=Z5;var J5="Expected a function";function $5(i,t,e){var n=!0,r=!0;if(typeof i!="function")throw new TypeError(J5);return Un(e)&&(n="leading"in e?!!e.leading:n,r="trailing"in e?!!e.trailing:r),Ol(i,t,{leading:n,maxWait:t,trailing:r})}var Vb=$5;function oC(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function Qr(i,t){return Object.setPrototypeOf(i,t),i}var ej=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),tj=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),nj=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Rl&&"ontouchend"in document,rj=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,ij=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,sj=()=>{if(typeof window>"u")return!1;let i=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(i)&&/Apple Computer/.test(t)},oj=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},aj=()=>{if(typeof window>"u")return;let t=new URLSearchParams(window.location.search).get("desktop-app-version");return t?(window.localStorage.setItem("desktop-app-version",t),t):window.localStorage.getItem("desktop-app-version")??"0.0.6"},lj=ej(),Qre=lj?aj():void 0,Rl=tj(),Og=nj(),aC=rj(),Qn=ij(),zb=sj(),Gb=Number(oj());function Rg(i){return Array.isArray(i)?i:[i]}function lC(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}function Ef(i){return Rl?i.metaKey:i.ctrlKey}var We=[],Ng={},_f={},Lg={};function cC(i){We.includes(i)||We.push(i)}function Pu(i){delete Ng[i.pointerId];for(let t=0;t<We.length;t++)if(We[t].pointerId===i.pointerId){We.splice(t,1);break}}function uC(){We.splice(0,We.length)}function Bg(i){if(i.pointerType!=="touch")return;let t=Ng[i.pointerId];t===void 0&&(t={x:0,y:0},Ng[i.pointerId]=t),t.x=i.pageX,t.y=i.pageY}function Fg(i){let t=i.pointerId===We[0].pointerId?We[1]:We[0];return Ng[t.pointerId]}function hC(i){_f[i.key]=!0,Lg[i.key]=Lg[i.key]===void 0?1:Lg[i.key]+1}function dC(i){if(Rl&&_f.Meta)for(let t in _f)_f[t]=!1;else _f[i.key]=!1;Lg={}}function fC(i){i.addEventListener("pointerdown",cC,!0),i.addEventListener("pointerdown",Bg,!0),i.addEventListener("pointermove",Bg,!0),i.addEventListener("pointerup",Pu,!0),i.addEventListener("pointercancel",Pu,!0),i.addEventListener("pointerleave",Pu,!0),window.addEventListener("keydown",hC,!0),window.addEventListener("keyup",dC,!0)}function pC(i){i.removeEventListener("pointerdown",cC,!0),i.removeEventListener("pointerdown",Bg,!0),i.removeEventListener("pointermove",Bg,!0),i.removeEventListener("pointerup",Pu,!0),i.removeEventListener("pointercancel",Pu,!0),i.removeEventListener("pointerleave",Pu,!0),window.removeEventListener("keydown",hC,!0),window.removeEventListener("keyup",dC,!0)}var mC,gC=new Promise(i=>{mC=i});var kg;function yC(){if(kg)return kg;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@0.9.458/build",r=import("./navmesh.js"),[s,o]=await Promise.all([r,fetch(`${e}/navmesh.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});mC(l)}return kg=i(),kg}var vC,xC=new Promise(i=>{vC=i});var Ug;function bC(){if(Ug)return Ug;async function i(){let e=await import("./physics.js");await e.init(),vC(e)}return Ug=i(),Ug}var tt=class{modifyById(t,e){let n=this;if(n[t]===void 0)throw new Error("not expected");{let s={...n,[t]:e};return Object.setPrototypeOf(s,tt.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let n=e[t.id],r;n===void 0?r={type:2,id:t.id}:r={type:1,id:t.id,data:n};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,tt.prototype),{data:a,actual:t,reverse:r}}else if(t.type===2){let{id:n}=t,r=e[n];if(r===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,tt.prototype),delete s[n],{data:s,actual:t,reverse:{type:1,id:n,data:r}}}}return null}};function Tf(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let n=i[e];n&&typeof n=="object"&&Tf(n)}return Object.freeze(i)}function SC(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var Du=class extends Error{};function Vg(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function Ps(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let s=i;i=t,t=s}let n=[],r=1/(e+1);for(let s=0;s<e;s++){let o=i+(t-i)*(s+.75+Math.random()*.5)*r;n.push(o)}return n}function Iu(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function wC(){return typeof process<"u"}function AC(i,t){for(let e of i)t(e.id,e.data)!==!0&&AC(e.children,t)}function EC(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)EC(e,t)}var cn=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,cn.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Tf(this[e]),e++}fillCaches0(e,n){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,n);for(let r of e.children)this.fillCaches0(r,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,n){if(!this.has(e))return!0;for(;e;){let r=this.parent(e);if(r===n)return!0;e=r}return!1}rootAcestor(e){for(;e;){let n=this.parent(e);if(n)e=n;else return e}return e}isDescendantOf(e,n){for(;e;){let r=this.parent(e);if(r===n)return!0;e=r}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,n){if(e===null)this.traverse(n);else{let r=this.get(e);r&&EC(r,n)}}traverse(e){AC(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:n},this.modifyArrayBy(s,o)}}modifyArrayBy(e,n){let r=e,s=n;for(;r!==null;){let a=s,l=r;if(r=this.parent(r),r===void 0)throw new Error;s=this.childrenArray(r);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,cn.prototype);let o=s;return o.fillCaches(),o}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:n}){if(this.get(e)!==void 0)return!0;for(let r of n)if(this.checkDuplicatedIdRec(r))return!0;return!1}addOp(e){let{parent:n,fi:r,id:s,data:o,children:a}=e;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=n,u=this.childrenArray(l),c={fi:r,id:s,data:o,children:a};return u=[...u,c],u.sort((d,f)=>d.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:n}=e;if(this.get(n)===null)return null;{let r=this.parent(n);if(r===void 0)return null;let s=this.childrenArray(r),o=s.findIndex(u=>u.id===n);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(r,s),actual:e,reverse:{type:7,...a,parent:r}}}}moveOp(e){let{parent:n,fi:r,id:s}=e;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let f=n;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new Du("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],h=this.modifyArrayBy(o,l);o=n,l=h.childrenArray(o);let d=c.fi;return c={...c,fi:r},l=[...l,c],l.sort((f,p)=>f.fi-p.fi),e.localIndex=l.indexOf(c),h=h.modifyArrayBy(o,l),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,id:s}}}previous(e,n){if(n===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let r=null;for(let s of this.childrenArray(e)){if(s.id===n)return r;r=s.id}return null}traverseSortNext(e){let n=this.parent(e);if(n!==void 0){let r=this.childrenArray(n),s=r.findIndex(o=>o.id===e)+1;if(s<r.length)return r[s].id;if(n)return this.traverseSortNext(n)}}sortNext(e){let n=this.childrenArray(e);return n.length>0?n[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let n=this.childrenArray(e);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):e}sortPrevious(e){let n=this.parent(e);if(n!==void 0){let r=this.childrenArray(n),s=r.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(r[s].id):n}}getAllSorted(e){let n=[];for(let r of e){let s=this.getWithSortKey(r.id);s!==void 0&&n.push({...r,...s})}n.sort((r,s)=>SC(r.sortKey,s.sortKey));for(let r of n)delete r.sortKey;return n}getWithSortKey(e){var n=e;let r=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)r.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:r}}}insertBeforeHelper(e,n,r){return this.insertAfterHelper(e,this.previous(e,n),r)}insertAfterHelper(e,n,r){let s=this.childrenArray(e);if(n===null){if(s.length===0)return Ps(0,r,r);{let o=s[0].fi;return Ps(o-r,o,r)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return Ps(l,l+r,r)}else return Ps(o.fi,a.fi,r)}}};var Ou;(t=>{function i(e,n){if(n.type!==0)return null;if(Array.isArray(e)){let r=n.props,s={},o=[...e],a=!1;if(r)for(let l of Object.keys(r)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=r[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let r=n.props,s={},o={...e},a=!1;if(r)for(let l of Object.keys(r)){s[l]=o[l];let u=r[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}t.runOp=i})(Ou||(Ou={}));var Re=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Re.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Tf(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:n},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,Re.prototype);let n=e;return wC()||n.fillCaches(),n}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:n,id:r,data:s}=e,o=this,a={fi:n,id:r,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:r}}}deleteOp(e){let{id:n}=e,r=this,s=r.findIndex(l=>l.id===n);if(s===-1)return null;e.localIndex=s,r=[...r];let o=r.splice(s,1)[0];return{data:this.modifyArrayBy(r),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:n,id:r}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===r);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,h)=>c.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:r}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let r of this){if(r.id===e)return n;n=r.id}return null}insertBeforeHelper(e,n){return this.insertAfterHelper(this.previous(e),n)}insertAfterHelper(e,n){let r=this;if(e===null){if(r.length===0)return Ps(0,n,n);{let s=r[0].fi;return Ps(s-n,s,n)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=r.find(a=>a.fi>s.fi);if(o===void 0){let a=r[r.length-1].fi;return Ps(a,a+n,n)}else return Ps(s.fi,o.fi,n)}}};function Ru(i){return i&&typeof i=="object"&&i instanceof Yt}var Yt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],n=this,r=0,s={};for(;r<t.path.length;){if(e.push(n),n=n===void 0?void 0:n[t.path[r]],n!==void 0&&!Ru(n))return null;r+=1}n=n?Vg(n):new Yt;for(let[l,u]of Object.entries(t.props)){let c=n[l];s[l]=c,u===void 0?delete n[l]:n[l]=u}for(;r>0;){if(Object.keys(n).length===0){let l=e[r-1];l&&(n=Vg(l),delete n[t.path[r-1]])}else{let l=e[r-1];if(l){let u=Vg(l);u[t.path[r-1]]=n,n=u}else{let u=new Yt;u[t.path[r-1]]=n,n=u}}r-=1}let o=Object.setPrototypeOf(n,Yt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},Ds;(n=>{function i(r,s){return Mf(r,s)??r}n.apply=i;function t(r,s){return jb(r,s)}n.merge=t;function e(r,s){let o=0,a=s.path,l=r;for(;o<a.length&&l!==void 0;){if(l=Vn.zoomOnce(l,a[o]),l===void 0)return s;if(!Ru(l))return;o+=1}if(l===void 0)return s;if(!!Ru(l))if(s.type===0){let u={...s.props};for(let c of Object.keys(l))delete u[c];return{...s,props:u}}else if(s.type===1||s.type===4||s.type===7){let u=Hb([s],l);return u?(console.log(u),u):s}else return s}n.filterOp=e})(Ds||(Ds={}));function Hb(i,t){if(t===void 0)return;let e=!1,n=i.map(r=>{let s=r.id,o=Mf(r.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=r.data),r.children){let a=Hb(r.children,t);return a!==void 0?e=!0:a=r.children,{...r,id:s,data:o,children:a}}else return{...r,id:s,data:o}});if(e)return n}function cj(i,t){if(t===void 0)return;let e=!1,n=i.map(r=>{let s=r.id,o=Mf(r.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=r.data),{...r,id:s,data:o}});if(e)return Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}function Mf(i,t){if(!Ru(t))return t;if(i instanceof cn){let e=Hb(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof Re)return cj(i,t);if(Array.isArray(i)){let e=!1,n=i.map((r,s)=>{let o=Mf(r,t[s]);return e=e||o!==void 0,o===void 0&&(o=r),o});return e?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else{if(i instanceof Yt)return jb(i,t);if(i&&typeof i=="object"){let e={},n=!1;for(let[r,s]of Object.entries(i)){let o=Mf(s,t[r]);n=n||o!==void 0,o===void 0&&(o=s),e[r]=o}return n?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function jb(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!Ru(t))return t;if(!Ru(i))return Ds.apply(i,t);let e=new Set;for(let r of Object.keys(i))e.add(r);for(let r of Object.keys(t))e.add(r);let n=new Yt;for(let r of e){let s=jb(i===void 0?void 0:i[r],t===void 0?void 0:t[r]);n[r]=s}return n}function _C(i,t){let e={cur:[],result:[],len:0};return i=Cf(i,t,e)??i,[i,e.result]}function zg(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function Gg(i){i&&(i.len-=1)}function uj(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function TC(i,t,e){let n=!1,r=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Cf(s.data,t,zg(e,o));Gg(e),n=n||l!==void 0,l===void 0&&(l=s.data);let u=TC(s.children,t,e);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return r}function hj(i,t,e){let n=!1,r=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Cf(s.data,t,zg(e,o));return Gg(e),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function Cf(i,t,e){if(i instanceof cn){let n=TC(i,t,e);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}else{if(i instanceof Re)return hj(i,t,e);if(Array.isArray(i)){let n=!1,r=i.map((s,o)=>{let a=Cf(s,t,zg(e,o));return Gg(e),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(i&&typeof i=="object"&&!Iu(i)){let n={},r=!1;for(let[s,o]of Object.entries(i))if(s!=="name"&&s!=="text"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");r=!0,s=a}let l=Cf(o,t,zg(e,s));Gg(e),r=r||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else if(typeof i=="string"){let n=t[i];return n!==void 0&&uj(e),n}else return}}var Hg;(t=>{function i(e,n){let r=Vn.zoom(n,e.path);if(typeof r=="object"){let s={};for(let o of Object.keys(e.props))s[o]=r[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=i})(Hg||(Hg={}));var zn;(a=>{function i(l,u){return{...l,path:l.path.slice(u)}}a.drop=i;function t(l,u){return e(l,u)?.data??l}a.applySimple=t;function e(l,u){let c=u.path;for(var h=[];;){let d;if(l instanceof Yt&&u.type===0&&(d=l.runOp({...u,path:c.slice(h.length)}),d===null&&(d=void 0)),d===void 0&&h.length===c.length&&(l instanceof cn||l instanceof Re||l instanceof tt?d=l.runOp(u):d=Ou.runOp(l,u)),d!==void 0)if(d!==null){let m=d.data;for(let g=h.length-1;g>=0;g--){let y=c[g],v=h[g];if(v instanceof cn){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Re){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof tt){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Yt){let x={...v,[y]:m};m=Object.setPrototypeOf(x,Yt.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=m;m=[...v],m[y]=x}else m={...v,[y]:m};else return null}return{data:m,actual:{...d.actual,path:c},reverse:{...d.reverse,path:c}}}else return null;let f=c[h.length],p;if(l instanceof cn){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof Re){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else l!==null&&(p=l[f]);if(p!==void 0)h.push(l),l=p;else return null}}a.apply=e;function n(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=n;function r(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=r;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&r(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(zn||(zn={}));var Pf;(l=>{function i(){return[]}l.empty=i;function t(u,c){let h=[];for(let d of u){let[f,...p]=d.path;f===c&&h.push({...d,path:p})}return h}l.removePrefix=t;function e(u,c){return u.map(h=>({...h,path:[c,...h.path]}))}l.addPrefix=e;function n(u,c){return[...u,...c]}l.concat=n;function r(u,c){return[...u.filter(d=>!c.some(f=>zn.subsumed(d,f))),...c]}l.compress=r;function s(u,c){return u.every(h=>c.every(d=>zn.commutative(h,d)))}l.commutative=s;function o(u,c){for(let h of c){let d=a(u,h);d!==null&&(u=d.data)}return u}l.applyAll=o;function a(u,c){var h=u;let d=[],f=[];for(let p of c)try{if(p.type===3){let m,g;p.path[p.path.length-1]==="variables"?m=Vn.zoom(h,[...p.path,p.id,"value"]):m=Vn.zoom(h,[...p.path,p.id]);let y=zn.apply(h,{...p,type:2});if(y!==null){h=y.data;let[v,x]=_C(h,{[p.id]:m});h=v;for(let b=0;b<x.length;b++){let w=x[b],E=w.pop();if(typeof E=="number"){let _=[E];for(let T=b+1;T<x.length;T++){let M=x[T],C=M[M.length-1];if(typeof C=="number"&&Vn.equal(w,M.slice(0,M.length-1)))_.push(C),x.splice(T,1);else break}let S=Vn.zoom(h,w);g=S.map((T,M)=>_.includes(M)?p.id:T),m=S,E=w.pop()}else g=p.id;d.push({type:0,path:w,props:{[E]:m}}),f.push({type:0,path:w,props:{[E]:g}})}f.push(y.reverse),d.push(y.actual)}}else{let m=zn.apply(h,p);m!==null&&(d.push(m.actual),h=m.data,f.push(m.reverse))}}catch(m){if(m instanceof Du)return null;throw m}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(Pf||(Pf={}));var MC=Symbol(),dj=Symbol(),Wg=Symbol(),Ll=class{reportOp(t,e,n=[]){let r=this;if(e===null)return;r._current=e.data;let s=n;for(;!(r instanceof jg);){let o=r._path,a=r._current;if(o!==""&&s.splice(0,0,o),r=r._parent,r===null)return;r.update(o,a)}r.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let n=e[Wg];n&&n(),delete this._children[t]}}}},qb=class extends Ll{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,Ou.runOp(this._current,t),t.path)}},Yb=class extends Ll{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,tt.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},CC={get(i,t){if(t===Wg)return()=>{i._parent=null};if(t===MC)return i._current;if(t===dj)return i;let{_current:e,_children:n}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e[t],o=qg(i,t,s);return o!==s?(n===void 0&&(n={},i._children=n),n[t]=o,o):s},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,n=Reflect.getOwnPropertyDescriptor(e,t);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:e[t]}}},fj={...CC,set(i,t,e){let n={type:0,props:{[t]:vn(e)??e}};return i.deleteChildren(t),i.runOp(n),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},pj={...CC,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},Lu=class extends Ll{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[Wg]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,n)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:n}=this,r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e.get(t)?.data,o=qg(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}add(t,e,n,r,s){this.runOp({type:7,parent:t,fi:e,id:n,data:r,children:s})}move(t,e,n){this.runOp({type:9,parent:t,fi:e,id:n})}insertAfter(t,e,n){let r=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,r[s],o.id,o.data,o.children)}}insertBefore(t,e,n){let r=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,r[s],o.id,o.data,o.children)}}moveAfter(t,e,n){let r=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,r[s],o)}}moveBefore(t,e,n){let r=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,r[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},Nu=class extends Ll{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[Wg]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let n=0;n<e;n++){let r=this._current[n].id,s=this._current[n].fi;t(this.data(this._current[n].id),r,s)}}find(t){let e=this.length;for(let n=0;n<e;n++){let r=this._current[n].id;if(t(this.data(r),r))return this.get(r)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:n}=this,r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e.get(t)?.data,o=qg(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,n){this.runOp({type:4,fi:t,id:e,data:n})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(n[r],s.id,s.data)}}insertBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(n[r],s.id,s.data)}}moveAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(n[r],s)}}moveBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(n[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Wb(i,t,e){if(i.length>0){let n=i[i.length-1];if(n.type===0&&t.type===0&&Vn.equal(n.path,e)){Object.assign(n.props,t.props);return}}i.push({...t,path:e})}var jg=class extends Ll{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,n,r){Wb(this.ts,e,t),Wb(this.actual,n,t),Wb(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function qg(i,t,e){return e instanceof cn?new Lu(i,t,e):e instanceof Re?new Nu(i,t,e):e instanceof tt?new Proxy(new Yb(i,t,e),pj):e!==null&&typeof e=="object"?Iu(e)?e:new Proxy(new qb(i,t,e),fj):e}function Xb(i){let t=new jg(i);return[qg(t,"",i),t]}function Aa(i,t){let[e,n]=Xb(i);return t(e),n.result()}function vn(i){return i instanceof Lu||i instanceof Nu?i._current:i!==null&&typeof i=="object"?i[MC]:i}var Vn;(r=>{function i(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}r.equal=i;function t(s,o,a){let l=n(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...o};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return o}r.removeOverridden=t;function e(s,o){if((s instanceof cn||s instanceof Lu)&&typeof o=="string")return s.data(o);if((s instanceof Re||s instanceof Nu)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}r.zoomOnce=e;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}r.zoom=n})(Vn||(Vn={}));function PC(i,t){let e=[];if(t.length===i.length)for(var n=0;n<i.length;){if(t[n]==="*")e.push(i[n]);else if(i[n]!==t[n])return null;n+=1}else return null;return e}function Or(i,t){let e=[];if(t.length<=i.length)for(var n=0;n<t.length;){if(t[n]==="*")e.push(i[n]);else if(i[n]!==t[n])return null;n+=1}else return null;return e}var Yg=class{},Df=class extends Yg{constructor(e){super();this.id=e}},If=class extends Yg{constructor(e){super();this.data=e}};var Qb;try{Qb=new TextDecoder}catch{}var Ne,_a,J=0;var FC=[],Zb=FC,Jb=0,Zr={},Ot,Ea,Ri=0,Is=0,bi,Oo,zr=[],kt,DC={useRecords:!1,mapsAsObjects:!0},Of=class{},eS=new Of;eS.name="MessagePack 0xC1";var Bu=!1,Os=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(Ne)return GC(()=>(Kg(),this?this.unpack(t,e):Os.prototype.unpack.call(DC,t,e)));_a=e>-1?e:t.length,J=0,Jb=0,Is=0,Ea=null,Zb=FC,bi=null,Ne=t;try{kt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw Ne=null,t instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Os){if(Zr=this,this.structures)return Ot=this.structures,Xg();(!Ot||Ot.length>0)&&(Ot=[])}else Zr=DC,(!Ot||Ot.length>0)&&(Ot=[]);return Xg()}unpackMultiple(t,e){let n,r=0;try{Bu=!0;let s=t.length,o=this?this.unpack(t,s):Jg.unpack(t,s);if(e){for(e(o);J<s;)if(r=J,e(Xg())===!1)return}else{for(n=[o];J<s;)r=J,n.push(Xg());return n}}catch(s){throw s.lastPosition=r,s.values=n,s}finally{Bu=!1,Kg()}}_mergeStructures(t,e){t=t||[];for(let n=0,r=t.length;n<r;n++){let s=t[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}t.sharedLength=t.length;for(let n in e||[])if(n>=0){let r=t[n],s=e[n];s&&(r&&((t.restoreStructures||(t.restoreStructures=[]))[n]=r),t[n]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Xg(){try{if(!Zr.trusted&&!Bu){let t=Ot.sharedLength||0;t<Ot.length&&(Ot.length=t)}let i=xn();if(J==_a)Ot.restoreStructures&&IC(),Ot=null,Ne=null,Oo&&(Oo=null);else if(J>_a){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Bu)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Ot.restoreStructures&&IC(),Kg(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function IC(){for(let i in Ot.restoreStructures)Ot[i]=Ot.restoreStructures[i];Ot.restoreStructures=null}function xn(){let i=Ne[J++];if(i<160)if(i<128){if(i<64)return i;{let t=Ot[i&63]||Zr.getStructures&&kC()[i&63];return t?(t.read||(t.read=tS(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,Zr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[VC()]=xn();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(xn(),xn());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=xn();return t}else if(i<192){let t=i-160;if(Is>=J)return Ea.slice(J-Ri,(J+=t)-Ri);if(Is==0&&_a<140){let e=t<16?nS(t):UC(t);if(e!=null)return e}return $b(t)}else{let t;switch(i){case 192:return null;case 193:return bi?(t=xn(),t>0?bi[1].slice(bi.position1,bi.position1+=t):bi[0].slice(bi.position0,bi.position0-=t)):eS;case 194:return!1;case 195:return!0;case 196:return Kb(Ne[J++]);case 197:return t=kt.getUint16(J),J+=2,Kb(t);case 198:return t=kt.getUint32(J),J+=4,Kb(t);case 199:return Nl(Ne[J++]);case 200:return t=kt.getUint16(J),J+=2,Nl(t);case 201:return t=kt.getUint32(J),J+=4,Nl(t);case 202:if(t=kt.getFloat32(J),Zr.useFloat32>2){let e=Zg[(Ne[J]&127)<<1|Ne[J+1]>>7];return J+=4,(e*t+(t>0?.5:-.5)>>0)/e}return J+=4,t;case 203:return t=kt.getFloat64(J),J+=8,t;case 204:return Ne[J++];case 205:return t=kt.getUint16(J),J+=2,t;case 206:return t=kt.getUint32(J),J+=4,t;case 207:return Zr.int64AsNumber?(t=kt.getUint32(J)*4294967296,t+=kt.getUint32(J+4)):t=kt.getBigUint64(J),J+=8,t;case 208:return kt.getInt8(J++);case 209:return t=kt.getInt16(J),J+=2,t;case 210:return t=kt.getInt32(J),J+=4,t;case 211:return Zr.int64AsNumber?(t=kt.getInt32(J)*4294967296,t+=kt.getUint32(J+4)):t=kt.getBigInt64(J),J+=8,t;case 212:if(t=Ne[J++],t==114)return BC(Ne[J++]&63);{let e=zr[t];if(e)return e.read?(J++,e.read(xn())):e.noBuffer?(J++,e()):e(Ne.subarray(J,++J));throw new Error("Unknown extension "+t)}case 213:return t=Ne[J],t==114?(J++,BC(Ne[J++]&63,Ne[J++])):Nl(2);case 214:return Nl(4);case 215:return Nl(8);case 216:return Nl(16);case 217:return t=Ne[J++],Is>=J?Ea.slice(J-Ri,(J+=t)-Ri):gj(t);case 218:return t=kt.getUint16(J),J+=2,Is>=J?Ea.slice(J-Ri,(J+=t)-Ri):yj(t);case 219:return t=kt.getUint32(J),J+=4,Is>=J?Ea.slice(J-Ri,(J+=t)-Ri):vj(t);case 220:return t=kt.getUint16(J),J+=2,RC(t);case 221:return t=kt.getUint32(J),J+=4,RC(t);case 222:return t=kt.getUint16(J),J+=2,LC(t);case 223:return t=kt.getUint32(J),J+=4,LC(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var mj=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function tS(i,t){function e(){if(e.count++>2){let r=i.read=new Function("r","return function(){return {"+i.map(s=>mj.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(xn);return i.highByte===0&&(i.read=OC(t,i.read)),r()}let n={};for(let r=0,s=i.length;r<s;r++){let o=i[r];n[o]=xn()}return n}return e.count=0,i.highByte===0?OC(t,e):e}var OC=(i,t)=>function(){let e=Ne[J++];if(e===0)return t();let n=i<32?-(i+(e<<5)):i+(e<<5),r=Ot[n]||kC()[n];if(!r)throw new Error("Record id is not defined for "+n);return r.read||(r.read=tS(r,i)),r.read()};function kC(){let i=GC(()=>(Ne=null,Zr.getStructures()));return Ot=Zr._mergeStructures(i,Ot)}var $b=Qg,gj=Qg,yj=Qg,vj=Qg;function Qg(i){let t;if(i<16&&(t=nS(i)))return t;if(i>64&&Qb)return Qb.decode(Ne.subarray(J,J+=i));let e=J+i,n=[];for(t="";J<e;){let r=Ne[J++];if((r&128)===0)n.push(r);else if((r&224)===192){let s=Ne[J++]&63;n.push((r&31)<<6|s)}else if((r&240)===224){let s=Ne[J++]&63,o=Ne[J++]&63;n.push((r&31)<<12|s<<6|o)}else if((r&248)===240){let s=Ne[J++]&63,o=Ne[J++]&63,a=Ne[J++]&63,l=(r&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(r);n.length>=4096&&(t+=ur.apply(String,n),n.length=0)}return n.length>0&&(t+=ur.apply(String,n)),t}function RC(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=xn();return t}function LC(i){if(Zr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[VC()]=xn();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(xn(),xn());return t}}var ur=String.fromCharCode;function UC(i){let t=J,e=new Array(i);for(let n=0;n<i;n++){let r=Ne[J++];if((r&128)>0){J=t;return}e[n]=r}return ur.apply(String,e)}function nS(i){if(i<4)if(i<2){if(i===0)return"";{let t=Ne[J++];if((t&128)>1){J-=1;return}return ur(t)}}else{let t=Ne[J++],e=Ne[J++];if((t&128)>0||(e&128)>0){J-=2;return}if(i<3)return ur(t,e);let n=Ne[J++];if((n&128)>0){J-=3;return}return ur(t,e,n)}else{let t=Ne[J++],e=Ne[J++],n=Ne[J++],r=Ne[J++];if((t&128)>0||(e&128)>0||(n&128)>0||(r&128)>0){J-=4;return}if(i<6){if(i===4)return ur(t,e,n,r);{let s=Ne[J++];if((s&128)>0){J-=5;return}return ur(t,e,n,r,s)}}else if(i<8){let s=Ne[J++],o=Ne[J++];if((s&128)>0||(o&128)>0){J-=6;return}if(i<7)return ur(t,e,n,r,s,o);let a=Ne[J++];if((a&128)>0){J-=7;return}return ur(t,e,n,r,s,o,a)}else{let s=Ne[J++],o=Ne[J++],a=Ne[J++],l=Ne[J++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){J-=8;return}if(i<10){if(i===8)return ur(t,e,n,r,s,o,a,l);{let u=Ne[J++];if((u&128)>0){J-=9;return}return ur(t,e,n,r,s,o,a,l,u)}}else if(i<12){let u=Ne[J++],c=Ne[J++];if((u&128)>0||(c&128)>0){J-=10;return}if(i<11)return ur(t,e,n,r,s,o,a,l,u,c);let h=Ne[J++];if((h&128)>0){J-=11;return}return ur(t,e,n,r,s,o,a,l,u,c,h)}else{let u=Ne[J++],c=Ne[J++],h=Ne[J++],d=Ne[J++];if((u&128)>0||(c&128)>0||(h&128)>0||(d&128)>0){J-=12;return}if(i<14){if(i===12)return ur(t,e,n,r,s,o,a,l,u,c,h,d);{let f=Ne[J++];if((f&128)>0){J-=13;return}return ur(t,e,n,r,s,o,a,l,u,c,h,d,f)}}else{let f=Ne[J++],p=Ne[J++];if((f&128)>0||(p&128)>0){J-=14;return}if(i<15)return ur(t,e,n,r,s,o,a,l,u,c,h,d,f,p);let m=Ne[J++];if((m&128)>0){J-=15;return}return ur(t,e,n,r,s,o,a,l,u,c,h,d,f,p,m)}}}}}function Kb(i){return Zr.copyBuffers?Uint8Array.prototype.slice.call(Ne,J,J+=i):Ne.subarray(J,J+=i)}function Nl(i){let t=Ne[J++];if(zr[t])return zr[t](Ne.subarray(J,J+=i));throw new Error("Unknown extension type "+t)}var NC=new Array(4096);function VC(){let i=Ne[J++];if(i>=160&&i<192){if(i=i-160,Is>=J)return Ea.slice(J-Ri,(J+=i)-Ri);if(!(Is==0&&_a<180))return $b(i)}else return J--,xn();let t=(i<<5^(i>1?kt.getUint16(J):i>0?Ne[J]:0))&4095,e=NC[t],n=J,r=J+i-3,s,o=0;if(e&&e.bytes==i){for(;n<r;){if(s=kt.getUint32(n),s!=e[o++]){n=1879048192;break}n+=4}for(r+=3;n<r;)if(s=Ne[n++],s!=e[o++]){n=1879048192;break}if(n===r)return J=n,e.string;r-=3,n=J}for(e=[],NC[t]=e,e.bytes=i;n<r;)s=kt.getUint32(n),e.push(s),n+=4;for(r+=3;n<r;)s=Ne[n++],e.push(s);let a=i<16?nS(i):UC(i);return a!=null?e.string=a:e.string=$b(i)}var BC=(i,t)=>{var e=xn();let n=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let r=Ot[i];return r&&r.isShared&&((Ot.restoreStructures||(Ot.restoreStructures=[]))[i]=r),Ot[i]=e,e.read=tS(e,n),e.read()},zC=typeof self=="object"?self:global;zr[0]=()=>{};zr[0].noBuffer=!0;zr[101]=()=>{let i=xn();return(zC[i[0]]||Error)(i[1])};zr[105]=i=>{let t=kt.getUint32(J-4);Oo||(Oo=new Map);let e=Ne[J],n;e>=144&&e<160||e==220||e==221?n=[]:n={};let r={target:n};Oo.set(t,r);let s=xn();return r.used?Object.assign(n,s):(r.target=s,s)};zr[112]=i=>{let t=kt.getUint32(J-4),e=Oo.get(t);return e.used=!0,e.target};zr[115]=()=>new Set(xn());var rS=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");zr[116]=i=>{let t=i[0],e=rS[t];if(!e)throw new Error("Could not find typed array for code "+t);return new zC[e](Uint8Array.prototype.slice.call(i,1).buffer)};zr[120]=()=>{let i=xn();return new RegExp(i[0],i[1])};zr[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=J;J+=t-4,bi=[xn(),xn()],bi.position0=0,bi.position1=0;let n=J;J=e;try{return xn()}finally{J=n}};zr[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function GC(i){let t=_a,e=J,n=Jb,r=Ri,s=Is,o=Ea,a=Zb,l=Oo,u=bi,c=new Uint8Array(Ne.slice(0,_a)),h=Ot,d=Ot.slice(0,Ot.length),f=Zr,p=Bu,m=i();return _a=t,J=e,Jb=n,Ri=r,Is=s,Ea=o,Zb=a,Oo=l,bi=u,Ne=c,Bu=p,Ot=h,Ot.splice(0,Ot.length,...d),Zr=f,kt=new DataView(Ne.buffer,Ne.byteOffset,Ne.byteLength),m}function Kg(){Ne=null,Oo=null,Ot=null}function HC(i){i.unpack?zr[i.type]=i.unpack:zr[i.type]=i}var Zg=new Array(147);for(let i=0;i<256;i++)Zg[i]=+("1e"+Math.floor(45.15-i*.30103));var Jg=new Os({useRecords:!1}),xj=Jg.unpack,bj=Jg.unpackMultiple,Sj=Jg.unpack,$g={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},wj=new Float32Array(1),ase=new Uint8Array(wj.buffer,0,4);var ey;try{ey=new TextEncoder}catch{}var ty,sS,ny=typeof Buffer<"u",iS=ny?Buffer.allocUnsafeSlow:Uint8Array,YC=ny?Buffer:Uint8Array,jC=ny?4294967296:2144337920,de,_n,re=0,Rs,Ls=null,Aj=/[\u0080-\uFFFF]/,Rf=Symbol("record-id"),Bl=class extends Os{constructor(t){super(t),this.offset=0;let e,n,r,s,o,a,l=0,u=YC.prototype.utf8Write?function(S,T,M){return de.utf8Write(S,T,M)}:ey&&ey.encodeInto?function(S,T){return ey.encodeInto(S,de.subarray(T)).written}:!1,c=this;t||(t={});let h=t&&t.sequential,d=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=t.maxOwnStructures;p==null&&(p=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let m=f>32||p+f>64,g=f+64,y=f+p+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,b=0;this.pack=this.encode=function(S,T){if(de||(de=new iS(8192),_n=new DataView(de.buffer,0,8192),re=0),Rs=de.length-10,Rs-re<2048?(de=new iS(de.length),_n=new DataView(de.buffer,0,de.length),Rs=de.length-10,re=0):re=re+7&2147483640,n=re,a=c.structuredClone?new Map:null,c.bundleStrings?(Ls=["",""],de[re++]=214,de[re++]=98,Ls.position=re-n,re+=4):Ls=null,r=c.structures,r){r.uninitialized&&(r=c._mergeStructures(c.getStructures()));let M=r.sharedLength||0;if(M>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let C=0;C<M;C++){let D=r[C];if(!D)continue;let P,I=r.transitions;for(let L=0,H=D.length;L<H;L++){let U=D[L];P=I[U],P||(P=I[U]=Object.create(null)),I=P}I[Rf]=C+64}l=M}h||(r.nextId=M+64)}s&&(s=!1),o=r||[];try{if(w(S),Ls){_n.setUint32(Ls.position+n,re-Ls.position-n);let M=Ls;Ls=null,w(M[0]),w(M[1])}if(c.offset=re,a&&a.idsToInsert){re+=a.idsToInsert.length*6,re>Rs&&_(re),c.offset=re;let M=_j(de.subarray(n,re),a.idsToInsert);return a=null,M}return T&KC?(de.start=n,de.end=re,de):de.subarray(n,re)}finally{if(r){if(b<10&&b++,x>1e4)r.transitions=null,b=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!h){for(let M=0,C=v.length;M<C;M++)v[M][Rf]=0;v=[]}if(s&&c.saveStructures){let M=r.sharedLength||f;r.length>M&&(r=r.slice(0,M));let C=de.subarray(n,re);return c.saveStructures(r,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(S)):(l=M,C)}}T&Oj&&(re=n)}};let w=S=>{re>Rs&&(de=_(re));var T=typeof S,M;if(T==="string"){let C=S.length;if(Ls&&C>=8&&C<4096){let I=Aj.test(S);Ls[I?0:1]+=S,de[re++]=193,w(I?-C:C);return}let D;C<32?D=1:C<256?D=2:C<65536?D=3:D=5;let P=C*3;if(re+P>Rs&&(de=_(re+P)),C<64||!u){let I,L,H,U=re+D;for(I=0;I<C;I++)L=S.charCodeAt(I),L<128?de[U++]=L:L<2048?(de[U++]=L>>6|192,de[U++]=L&63|128):(L&64512)===55296&&((H=S.charCodeAt(I+1))&64512)===56320?(L=65536+((L&1023)<<10)+(H&1023),I++,de[U++]=L>>18|240,de[U++]=L>>12&63|128,de[U++]=L>>6&63|128,de[U++]=L&63|128):(de[U++]=L>>12|224,de[U++]=L>>6&63|128,de[U++]=L&63|128);M=U-re-D}else M=u(S,re+D,P);M<32?de[re++]=160|M:M<256?(D<2&&de.copyWithin(re+2,re+1,re+1+M),de[re++]=217,de[re++]=M):M<65536?(D<3&&de.copyWithin(re+3,re+2,re+2+M),de[re++]=218,de[re++]=M>>8,de[re++]=M&255):(D<5&&de.copyWithin(re+5,re+3,re+3+M),de[re++]=219,_n.setUint32(re,M),re+=4),re+=M}else if(T==="number")if(S>>>0===S)S<64?de[re++]=S:S<256?(de[re++]=204,de[re++]=S):S<65536?(de[re++]=205,de[re++]=S>>8,de[re++]=S&255):(de[re++]=206,_n.setUint32(re,S),re+=4);else if(S>>0===S)S>=-32?de[re++]=256+S:S>=-128?(de[re++]=208,de[re++]=S+256):S>=-32768?(de[re++]=209,_n.setInt16(re,S),re+=2):(de[re++]=210,_n.setInt32(re,S),re+=4);else{let C;if((C=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){de[re++]=202,_n.setFloat32(re,S);let D;if(C<4||(D=S*Zg[(de[re]&127)<<1|de[re+1]>>7])>>0===D){re+=4;return}else re--}de[re++]=203,_n.setFloat64(re,S),re+=8}else if(T==="object")if(!S)de[re++]=192;else{if(a){let D=a.get(S);if(D){if(!D.id){let P=a.idsToInsert||(a.idsToInsert=[]);D.id=P.push(D)}de[re++]=214,de[re++]=112,_n.setUint32(re,D.id),re+=4;return}else a.set(S,{offset:re-n})}let C=S.constructor;if(C===Object)E(S,!0);else if(C===Array){M=S.length,M<16?de[re++]=144|M:M<65536?(de[re++]=220,de[re++]=M>>8,de[re++]=M&255):(de[re++]=221,_n.setUint32(re,M),re+=4);for(let D=0;D<M;D++)w(S[D])}else if(C===Map){M=S.size,M<16?de[re++]=128|M:M<65536?(de[re++]=222,de[re++]=M>>8,de[re++]=M&255):(de[re++]=223,_n.setUint32(re,M),re+=4);for(let[D,P]of S)w(D),w(P)}else{for(let D=0,P=ty.length;D<P;D++){let I=sS[D];if(S instanceof I){let L=ty[D];if(L.write){L.type&&(de[re++]=212,de[re++]=L.type,de[re++]=0),w(L.write.call(this,S));return}let H=de,U=_n,G=re;de=null;let z;try{z=L.pack.call(this,S,V=>(de=H,H=null,re+=V,re>Rs&&_(re),{target:de,targetView:_n,position:re-V}),w)}finally{H&&(de=H,_n=U,re=G,Rs=de.length-10)}z&&(z.length+re>Rs&&_(z.length+re),re=Ej(z,de,re,L.type));return}}E(S,!S.hasOwnProperty)}}else if(T==="boolean")de[re++]=S?195:194;else if(T==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))de[re++]=211,_n.setBigInt64(re,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)de[re++]=207,_n.setBigUint64(re,S);else if(this.largeBigIntToFloat)de[re++]=203,_n.setFloat64(re,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");re+=8}else if(T==="undefined")this.encodeUndefinedAsNil?de[re++]=192:(de[re++]=212,de[re++]=0,de[re++]=0);else if(T==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},E=this.useRecords===!1?this.variableMapSize?S=>{let T=Object.keys(S),M=T.length;M<16?de[re++]=128|M:M<65536?(de[re++]=222,de[re++]=M>>8,de[re++]=M&255):(de[re++]=223,_n.setUint32(re,M),re+=4);let C;for(let D=0;D<M;D++)w(C=T[D]),w(S[C])}:(S,T)=>{de[re++]=222;let M=re-n;re+=2;let C=0;for(let D in S)(T||S.hasOwnProperty(D))&&(w(D),w(S[D]),C++);de[M+++n]=C>>8,de[M+n]=C&255}:S=>{let T=Object.keys(S),M,C=o.transitions||(o.transitions=Object.create(null)),D=0;for(let I=0,L=T.length;I<L;I++){let H=T[I];M=C[H],M||(M=C[H]=Object.create(null),D++),C=M}let P=C[Rf];if(P)P>=96&&m?(de[re++]=((P-=96)&31)+96,de[re++]=P>>5):de[re++]=P;else{P=o.nextId,P||(P=64),P<g&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(P=o.nextOwnId,P<y||(P=g),o.nextOwnId=P+1):(P>=y&&(P=g),o.nextId=P+1);let I=T.highByte=P>=96&&m?P-96>>5:-1;C[Rf]=P,o[P-64]=T,P<g?(T.isShared=!0,o.sharedLength=P-63,s=!0,I>=0?(de[re++]=(P&31)+96,de[re++]=I):de[re++]=P):(I>=0?(de[re++]=213,de[re++]=114,de[re++]=(P&31)+96,de[re++]=I):(de[re++]=212,de[re++]=114,de[re++]=P),D&&(x+=b*D),v.length>=p&&(v.shift()[Rf]=0),v.push(C),w(T))}for(let I=0,L=T.length;I<L;I++)w(S[T[I]])},_=S=>{let T;if(S>16777216){if(S-n>jC)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(jC,Math.round(Math.max((S-n)*(S>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(S-n<<2,de.length-1)>>12)+1<<12;let M=new iS(T);return _n=new DataView(M.buffer,0,T),de.copy?de.copy(M,0,n,S):M.set(de.slice(n,S)),re-=n,n=0,Rs=M.length-10,de=M}}useBuffer(t){de=t,_n=new DataView(de.buffer,de.byteOffset,de.byteLength),re=0}};sS=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Of];ty=[{pack(i,t,e){let n=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:r,targetView:s,position:o}=t(6);r[o++]=214,r[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:r,targetView:s,position:o}=t(10);r[o++]=215,r[o++]=255,s.setUint32(o,i.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:r,targetView:s,position:o}=t(3);r[o++]=212,r[o++]=255,r[o++]=255}else{let{target:r,targetView:s,position:o}=t(15);r[o++]=199,r[o++]=12,r[o++]=255,s.setUint32(o,i.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(i,t,e){let n=Array.from(i),{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=115,r[s++]=0),e(n)}},{pack(i,t,e){let{target:n,position:r}=t(this.structuredClone?3:0);this.structuredClone&&(n[r++]=212,n[r++]=101,n[r++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:n,position:r}=t(this.structuredClone?3:0);this.structuredClone&&(n[r++]=212,n[r++]=120,n[r++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?WC(i,16,t):qC(ny?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==YC&&this.structuredClone?WC(i,rS.indexOf(e.name),t):qC(i,t)}},{pack(i,t){let{target:e,position:n}=t(1);e[n]=193}}];function WC(i,t,e,n){let r=i.byteLength;if(r+1<256){var{target:s,position:o}=e(4+r);s[o++]=199,s[o++]=r+1}else if(r+1<65536){var{target:s,position:o}=e(5+r);s[o++]=200,s[o++]=r+1>>8,s[o++]=r+1&255}else{var{target:s,position:o,targetView:a}=e(7+r);s[o++]=201,a.setUint32(o,r+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),o)}function qC(i,t){let e=i.byteLength;var n,r;if(e<256){var{target:n,position:r}=t(e+2);n[r++]=196,n[r++]=e}else if(e<65536){var{target:n,position:r}=t(e+3);n[r++]=197,n[r++]=e>>8,n[r++]=e&255}else{var{target:n,position:r,targetView:s}=t(e+5);n[r++]=198,s.setUint32(r,e),r+=4}n.set(i,r)}function Ej(i,t,e,n){let r=i.length;switch(r){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:r<256?(t[e++]=199,t[e++]=r):r<65536?(t[e++]=200,t[e++]=r>>8,t[e++]=r&255):(t[e++]=201,t[e++]=r>>24,t[e++]=r>>16&255,t[e++]=r>>8&255,t[e++]=r&255)}return t[e++]=n,t.set(i,e),e+=r,e}function _j(i,t){let e,n=t.length*6,r=i.length-n;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;i.copyWithin(s+n,s,r),n-=6;let a=s+n;i[a++]=214,i[a++]=105,i[a++]=o>>24,i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=o&255,r=s}return i}function Ta(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");sS.unshift(i.Class),ty.unshift(i)}HC(i)}var XC=new Bl({useRecords:!1}),Tj=XC.pack,Mj=XC.pack;var{NEVER:Cj,ALWAYS:Pj,DECIMAL_ROUND:Dj,DECIMAL_FIT:Ij}=$g,KC=512,Oj=1024;var QC=new Bl({structuredClone:!0});Ta({Class:tt.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,tt.prototype),i}});Ta({Class:Re.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Re.prototype),i}});Ta({Class:cn.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,cn.prototype),i}});Ta({Class:Df.prototype.constructor,type:4,write(i){return i.id},read(i){return new Df(i)}});Ta({Class:If.prototype.constructor,type:5,write(i){return i.data},read(i){return new If(i)}});Ta({Class:Yt.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Yt.prototype),i}});function Rj(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let n=i[e];t=(t<<5)-t+n,t=t&t}return t}function oS(i){if(Iu(i))return i;if(Array.isArray(i))return i.map(oS);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=oS(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var ry;(n=>{function i(r){return QC.pack(r)}n.serialize=i;function t(r){return QC.unpack(r)}n.deserialize=t;function e(r){return Rj(i(oS(r))).toString()}n.checksum=e})(ry||(ry={}));var ZC;(e=>{function i(n){return n.type==="Conditional"?n.condition.type==="Distance"?"Distance":"StateChange":n.type}e.toEventUIType=i;function t(n){return n==="Distance"||n==="StateChange"?"Conditional":n}e.fromEventUIType=t})(ZC||(ZC={}));var Si={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Create","SetVariable","Conditional"],["MouseHover"]:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","Conditional"],["Scroll"]:["Transition","Animation","Create","SetVariable","Conditional"],["Start"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","Conditional"],["Conditional"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["MouseDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["MouseUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["MousePress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["KeyDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["KeyUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["KeyPress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset","SetVariable","Conditional"],["GameControl"]:["Transition","Animation","Audio","Create","Conditional"],["Collision"]:["Transition","Animation","Audio","Video","Create","Destroy","Reset","SetVariable","Conditional"],["Trigger"]:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["Resize"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["VariableChange"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"]},JC;(e=>{function i(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"}e.is=i;function t(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,mode:"Object",disabled:!1,runMode:"Once",actions:new Re}:{type:n,disabled:!1,key:void 0,runMode:"Once",actions:new Re}}e.defaultData=t})(JC||(JC={}));var iy;(e=>{function i(n){return{type:"Property",value:[n??null,"position","x"]}}e.propertyDefaultData=i,e.valueDefaultData={type:"Literal",value:0}})(iy||(iy={}));var aS;(n=>{function i(r){return{type:"Comparison",operator:"==",lOperand:iy.propertyDefaultData(r),rOperand:{...iy.valueDefaultData}}}n.comparisonDefaultData=i;function t(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}}n.distanceDefaultData=t;function e(r,s){return{type:"State",object:r??null,state:s??null}}n.stateDefaultData=e})(aS||(aS={}));var $C;(e=>{function i(n){return n.type==="Conditional"}e.is=i;function t(n){return{type:"Conditional",disabled:!1,inActions:new Re,outActions:new Re,condition:aS.distanceDefaultData(n)}}e.defaultData=t})($C||($C={}));var eP;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new Re,drop:new Re}})(eP||(eP={}));var sy;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new Re})(sy||(sy={}));var oy;(t=>t.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(oy||(oy={}));var tP;(e=>{function i(n){return n.type==="MouseHover"}e.is=i;function t(){return{type:"MouseHover",disabled:!1,actions:new Re}}e.defaultData=t})(tP||(tP={}));var nP;(e=>{function i(n){return n.type==="Scroll"}e.is=i;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Re}}e.defaultData=t})(nP||(nP={}));var rP;(e=>{function i(n){return n.type==="Start"}e.is=i;function t(){return{type:"Start",disabled:!1,actions:new Re}}e.defaultData=t})(rP||(rP={}));var iP;(e=>{function i(n){return n.type==="Collision"}e.is=i;function t(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new Re}}e.defaultData=t})(iP||(iP={}));var sP;(e=>{function i(n){return n.type==="Trigger"}e.is=i;function t(n,r){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new Re,triggerZone:"box",position:r.toArray(),rotation:[0,0,0],size:n.toArray(),radius:n.length()/2,helperVisible:!0}}e.defaultData=t})(sP||(sP={}));var ay;(o=>{o.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(a){return a.type==="Resize"}o.is=t;function e(a){return typeof a=="string"?a:"custom"}o.sizeToDevice=e;function n(a){return typeof a=="string"?[...o.defaultSizes[a]]:[...a]}o.deviceToSize=n;function r(){let a={size:"mobile",operator:"<",actions:new Re},l={size:"tablet",operator:"<",actions:new Re},u={size:[...o.defaultSizes.custom],operator:"<>",actions:new Re},c=new Re;return c.push({id:Te.generateUUID(),fi:0,data:a},{id:Te.generateUUID(),fi:1,data:l},{id:Te.generateUUID(),fi:2,data:u}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:c}}o.defaultData=r;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new Re}}o.defaultBreakpointData=s})(ay||(ay={}));var ly;(n=>{n.propertyPaths={"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}n.is=t;function e(){return{disabled:!1,type:"VariableChange",actions:new Re,variableId:"",objectId:null,property:"Position X"}}n.defaultData=e})(ly||(ly={}));var Li="personal camera",Ca="a218fcc3-276b-49b9-b485-49037fd14f5f",lP=2960946,Zn=5526619;var Fl;(e=>{function i(n,r){return n[0]===r[0]&&n[1]===r[1]}e.isEqual=i;function t(n,r,s){return[n[0]+(r[0]-n[0])*s,n[1]+(r[1]-n[1])*s]}e.lerp=t})(Fl||(Fl={}));var Ns;(a=>{function i(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}a.isEqual=i;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}a.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}a.sub=e;function n(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}a.div=n;function r(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=r;function s(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}a.dist=s;function o(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}a.lerp=o})(Ns||(Ns={}));var Lf;(e=>{function i(n,r){return n[0]===r[0]&&n[1]===r[1]&&n[2]===r[2]&&n[3]===r[3]}e.isEqual=i;function t(n,r,s){return[n[0]+(r[0]-n[0])*s,n[1]+(r[1]-n[1])*s,n[2]+(r[2]-n[2])*s,n[3]+(r[3]-n[3])*s]}e.lerp=t})(Lf||(Lf={}));var Ma;(r=>{r.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}r.isEqual=t;function e(s){return s??r.identity}r.simplify=e;function n(s,o){let a=o.slice(0);for(var l=0,u=o.length;l<u;l+=3){let c=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/c,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/c,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/c}return a}r.applyMatrix4=n})(Ma||(Ma={}));var hr;(c=>{function i(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}c.isRGB=i,c.white={r:1,g:1,b:1},c.red={r:1,g:0,b:0},c.black={r:0,g:0,b:0};function r(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}c.toRgb255a1=r;function s(h){return{r:h.r,g:h.g,b:h.b}}c.clone=s;function o(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}c.fromHex=o;function a(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}c.toHex=a;function l(h,d){return h.r===d.r&&h.g===d.g&&h.b===d.b}c.equals=l;function u(h,d,f){return{r:h.r+(d.r-h.r)*f,g:h.g+(d.g-h.g)*f,b:h.b+(d.b-h.b)*f}}c.lerp=u})(hr||(hr={}));var Gr;(a=>{a.white={...hr.white,a:1},a.transparent={...hr.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=e;function n(l,u){return{...hr.fromHex(l),a:u}}a.fromHexAndA=n;function r(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=r;function s(l,u){return hr.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(Gr||(Gr={}));var cy;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(cy||(cy={}));var oP;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(oP||(oP={}));var aP;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(aP||(aP={}));var Ro;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))(Ro||(Ro={}));function cP(i){return typeof i=="string"&&i.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i):!1}var ns;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(n){return e.all.includes(n)}e.is=t})(ns||(ns={}));var Pa;(r=>{r.DefaultUp=[0,1,0],r.DefaultTargetOffset=1e3,r.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:r.DefaultUp,isUpVectorFlipped:!1,targetOffset:r.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}r.getZoom=n})(Pa||(Pa={}));var Bs;(e=>{function i(n,r=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(n[0],n[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[n[0]+n[0]*r,0,0]},grid:{count:[2,2,2],size:n.map(s=>s*(1+r)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=i;function t(n,r){let s={...n};if(lS.forEach(o=>{Object.assign(s,{[o]:r[o]??n[o]})}),s.radial={...n.radial},r.radial){let o=n.radial,a=r.radial;cS.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...n.linear},r.linear){let o=n.linear,a=r.linear;uS.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...n.grid},r.grid){let o=n.grid,a=r.grid;hS.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...n.toObject},r.toObject){let o=n.toObject,a=r.toObject;dS.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...n.randomnessObject},r.randomnessObject){let o=n.randomnessObject,a=r.randomnessObject;fS.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(Bs||(Bs={}));var uy;(n=>{n.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(r,s){let o=[];r.count!==void 0&&o.push({type:0,path:s,props:{count:r.count}});for(let a of t){let l=r[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}n.toOps=e})(uy||(uy={}));var lS=["count"],cS=["radius","start","end","position","scale","rotation"],uS=["position","scale","rotation"],hS=["count","size"],dS=["count","position","scale","rotation"],fS=["strength","scale","rotation","position","movement","seed","freqScale"];var hy;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(n){return e.all.includes(n)}e.is=t})(hy||(hy={}));var dy;(e=>{function i(n){return t(n)}e.defaultData=i;function t(n){if(n==="PointLight")return{type:n,color:Gr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(n==="SpotLight")return{type:n,color:Gr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(n==="DirectionalLight")return{type:n,color:Gr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(dy||(dy={}));var Da;(t=>t.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Da||(Da={}));var pS;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(n,r){return n.castShadow===r.castShadow&&n.receiveShadow===r.receiveShadow}e.equals=t})(pS||(pS={}));var mS;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(n,r){return n.flatShading===r.flatShading&&n.side===r.side&&n.wireframe===r.wireframe}e.equals=t})(mS||(mS={}));var fy;(t=>t.defaultData={...mS.defaultData,...pS.defaultData})(fy||(fy={}));var uP;(t=>{function i(e,n){let r=[];if("material"in e){let s=typeof e.material=="string"?n.materials[e.material]??n.lib.materials[e.material]?.asset:e.material;s&&r.push(s)}else if("materials"in e)for(let s of e.materials){let o=typeof s=="string"?n.materials[s]??n.lib.materials[s]?.asset:s;o&&r.push(o)}return r}t.getMaterialData=i})(uP||(uP={}));var Fu;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Fu||(Fu={}));var hP;(t=>{function i(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=i})(hP||(hP={}));function fP(i){return i.type!=="displace"}var dP;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(dP||(dP={}));var py=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],pP=["wrapping","image","video","name"],dr;(r=>{function i(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}r.patch=i;function t(s,o){return s==="light"&&o?e(o):n(s)}r.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function n(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Fu.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...o,type:"color",color:hr.fromHex(Zn)};case"depth":return{...o,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...hr.fromHex(6710886),a:1},colorB:{...hr.fromHex(6710886),a:1},colorC:{...hr.fromHex(16777215),a:1},colorD:{...hr.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...o,type:"fresnel",color:Gr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Gr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:Gr.fromHexAndA(0,1),contourColor:Gr.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...o,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...hr.fromHex(0),a:1},colorB:{...hr.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}}}})(dr||(dr={}));var Tn;(l=>{function i(u){return!u.layers.some(h=>h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="displace")}l.isMergable=i;function t(u){let c="";return u.layers.forEach(h=>{Object.entries(h.data).forEach(([d,f])=>{c+=`${d}${f}`,Array.isArray(f)?f.forEach(p=>c+=`${p}`):typeof f=="object"?Object.values(f).forEach(p=>{typeof p=="number"?c+=`${p.toFixed(4)}`:c+=`${p}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new Re}}l.defaultEmptyData=e;function n(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=n;function r(u,c){return{...u,name:c}}l.withName=r;function s(u,c="layer1",h="layer2"){let d=new Re;return d.push({fi:0,data:dr.defaultData("light",u),id:c}),d.push({fi:1,data:dr.defaultData("color"),id:h}),{layers:d}}l.defaultTwoLayerData=s;function o(u,c="phong",h="layer1",d="layer2"){let f=dr.defaultData("texture");Object.assign(f.texture,{image:u});let p=new Re;return p.push({fi:0,data:f,id:h}),p.push({fi:1,data:dr.defaultData("light",c),id:d}),{layers:p}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",h="layer1",d="layer2"){let f=dr.defaultData("video");Object.assign(f.texture,{video:u});let p=new Re;return p.push({fi:0,data:f,id:h}),p.push({fi:1,data:dr.defaultData("light",c),id:d}),{layers:p}}l.defaultTwoLayerVideoTextureData=a})(Tn||(Tn={}));var ku;(t=>{function i(){return{points:new Re,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(ku||(ku={}));var Uu;(t=>{function i(){return{points:new Re,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(Uu||(Uu={}));var gS={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var my;(t=>{function i(e,n){let r={...e};return yS.forEach(s=>{Object.assign(r,{[s]:n[s]??e[s]})}),r}t.merge=i})(my||(my={}));var gy={shape:gS,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},yS=["depth","offset","angle","twist","startScale","endScale"];var Nf;(e=>{function i(n){return n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"}e.is2DParametricMesh=i;function t(n){return n==="PolygonGeometry"||n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"||n==="PathGeometry"||n==="VectorGeometry"||n==="ConeGeometry"||n==="CubeGeometry"||n==="CylinderGeometry"||n==="DodecahedronGeometry"||n==="HelixGeometry"||n==="IcosahedronGeometry"||n==="LatheGeometry"||n==="PyramidGeometry"||n==="SphereGeometry"||n==="PlaneGeometry"||n==="BackdropGeometry"||n==="TorusGeometry"||n==="TorusKnotGeometry"||n==="BooleanGeometry"||n==="TextGeometry"}e.isParametricMesh=t})(Nf||(Nf={}));var yy;(t=>{function i(e,n){let r={...e};return Object.assign(r,n),r.type==="PathGeometry"&&"extrusion"in n&&n.extrusion&&(r.extrusion={...e.extrusion},Object.assign(r.extrusion,my.merge(r.extrusion,n.extrusion))),r}t.merge=i})(yy||(yy={}));var Ia;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:Uu.defaultData(),extrusion:gy};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:ku.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}t.defaultData=i})(Ia||(Ia={}));var vS=["width","height","depth"];var vy;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:hr.white,near:.1,far:2e3})(vy||(vy={}));var Vu;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focalLength:2,focusDistance:2,bokehScale:2},noise:{...i,blendFunction:16}}})(Vu||(Vu={}));var xS;(t=>t.defaultData={softShadowQuality:"low"})(xS||(xS={}));var bS;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(bS||(bS={}));var SS;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(SS||(SS={}));var Oa;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Oa||(Oa={}));var wS;(t=>t.defaultData={playCamera:Li,gameControlObject:null})(wS||(wS={}));var xy;(t=>t.defaultData={backgroundColor:Gr.fromHexAndA(lP,1),postprocessing:Vu.defaultData,fog:vy.defaultData,globalPhysics:Oa.defaultData,ambient:bS.defaultData,ao:SS.defaultData,shadow:xS.defaultData,publish:wS.defaultData})(xy||(xy={}));var mP;(e=>{function i(n){return n==="Component"||n==="Instance"}e.isComponentRelated=i;function t(n){return n==="Empty"||n==="Instance"}e.isEmptyOrComponent=t})(mP||(mP={}));var zu;(r=>{r.identity={...cy.identity,hiddenMatrix:Ma.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}r.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}r.merge=e;function n(s,o){return oC({position:Ns.isEqual(s.position,o.position)?void 0:o.position,rotation:Ns.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:Ns.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:Ma.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}r.diff=n})(zu||(zu={}));var Er;(t=>t.defaultData={states:new Re,events:new Re,visible:!0,raycastLock:!1,physics:Da.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...zu.identity,cloner:null})(Er||(Er={}));var by;(t=>t.defaultData={type:"Empty",...Er.defaultData})(by||(by={}));var gP;(t=>t.defaultData={type:"Component",...Er.defaultData})(gP||(gP={}));var kl;(t=>t.defaultData={type:"Mesh",...Er.defaultData,...fy.defaultData})(kl||(kl={}));var Ul;(t=>t.defaultData={...Er.defaultData,...zu.identity,position:[0,0,Pa.DefaultTargetOffset],...Pa.defaultData})(Ul||(Ul={}));var Sy;(e=>{function i(n){return{...Er.defaultData,...dy.defaultData(n)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Sy||(Sy={}));var Gu;(e=>{function i(n,r,s=0){for(;s<r.length;){let o=n?n[r[s]]:void 0;if(r.length===s+1)return o;if(o)n=o.descendants,s+=1;else return}}e.resolveWithDes=i;function t(n,r,s=0){let o=i(n,r,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(Gu||(Gu={}));var Fs;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function n(o,a){return{...Er.defaultData,...a,component:o,overrides:new Yt,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=n;function r(o){let a=zu.fromObject(o.data);return n(o.id,a)}s.fromComponentData=r})(Fs||(Fs={}));var Lo;(t=>t.defaultData={type:"Page",...Er.defaultData,physics:{...Da.defaultData,fusedBody:!1},...xy.defaultData,camera:Ul.defaultData})(Lo||(Lo={}));var wy;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Ma.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Da.defaultData,states:new Re,events:new Re,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Pa.defaultData},s.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},s.defaultMeshObject={name:"Rectangle",...Er.defaultData,...kl.defaultData,geometry:Ia.defaultData("RectangleGeometry"),material:Tn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Er.defaultData,...kl.defaultData,geometry:Ia.defaultData("BooleanGeometry"),material:Tn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Er.defaultData,...kl.defaultData,geometry:Ia.defaultData("TextGeometry"),material:Tn.defaultTwoLayerData("phong","layer1","layer2")}))(wy||(wy={}));var No;(r=>{function i(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Yt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Yt})))):ns.is(s.type)&&(a.perspective={},a.orthographic={}),a}r.newEmpty=i;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Aa(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let h=l.layers.data(u);h&&dr.patch(h,c)}}).data),a.materials&&o.materials&&(a.materials=Aa(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[h,d]of Object.entries(c.layers)){let f=l[u]?.layers?.data(h);f&&dr.patch(f,d)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(h,d){for(let[f,p]of Object.entries(d.layers)){let{texture:m,...g}=p;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...h,"layers",f,"texture"],props:m,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...h,"layers",f],props:g,type:0};l.push(y)}}}for(let[h,d]of Object.entries(o))if(h!=="name")if(h==="cloner")l.push(...uy.toOps(d,["cloner"]));else if(h==="pathSnapping")l.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")c(["material"],d);else if(h==="materials")for(let[f,p]of Object.entries(d))c(["materials",f],p);else if(u[h]===0){if(h==="geometry"&&d.extrusion!==void 0){let f={path:[h,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[h],props:d,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[h]=d;return l}r.toOps=e;function n(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,zu.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),ns.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:yy.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Bs.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Bs.merge(a.cloner,o.cloner)});else if(hy.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=hr.clone(l.color))}return a}r.patch=n})(No||(No={}));var ju;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(ju||(ju={}));var ks;(t=>t.defaultData={orbitControls:ju.defaultData,playPage:Ca,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,n)=>{let r=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?r=30:(n===4||n===11||n===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(ks||(ks={}));var AS;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(AS||(AS={}));var ES;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(ES||(ES={}));var Ra;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...AS.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:ES.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Ra||(Ra={}));var La;(e=>{function i(n){return n.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(n,r,s){n.scene.objects.traverseFrom(r,(o,a)=>{if(a.type==="Instance"){let l=Wu.getComponentData(n,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(La||(La={}));var Na;(a=>{a.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(l={withLight:!0,withSquare:!0}){let u=[],c=wy.defaultMeshObject;l.withLight===!0&&u.push({fi:-1,data:Sy.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),l.withSquare===!0&&u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:c,children:[]});let h=new cn;return h.push({fi:1,id:Ca,data:{...Lo.defaultData,name:"Scene 1"},children:u}),h}a.defaultData={objects:t(),publish:ks.defaultData,styles:Ra.defaultData()},a.emptyDataWithoutPage=function(){return{objects:new cn,publish:ks.defaultData,styles:Ra.defaultData()}},a.emptyDataWithPage=function(l){return{objects:t(l),publish:ks.defaultData,styles:Ra.defaultData()}};function s(l){return{...a.defaultData,objects:Qr(l,cn.prototype)}}a.withObjs=s;function o(l,u){return s([{id:l,data:u,children:[],fi:0}])}a.withObj=o})(Na||(Na={}));var qu;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(qu||(qu={}));var Yu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Yu||(Yu={}));var Hr;(s=>{function i(o){return o.textValue!==void 0}s.isTextValue=i;function t(o){return typeof o=="number"}s.isNumber=t;function e(o){return typeof o=="boolean"}s.isBoolean=e;function n(o){return i(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=n;function r(o){return s.isTextValue(o)?Array.isArray(o.textValue)?o.textValue.map(a=>a.toString().padStart(o.padding??2,"0")).join(o.deliminator??":")+(o.suffix!==void 0?" "+o.suffix:""):o.textValue.toString():s.isBoolean(o)?o?"True":"False":s.isNumber(o)?parseFloat(o.toFixed(3)).toString():o.toString()}s.getDisplayedValue=r})(Hr||(Hr={}));var _S;(t=>t.all=["images","videos","colors","audios","fonts","materials","variables"])(_S||(_S={}));var yP;(t=>t.all=[..._S.all,"components"])(yP||(yP={}));var vP;(t=>{function i(){return{images:new tt,videos:new tt,colors:new tt,audios:new tt,fonts:new tt,materials:new tt,components:new tt,variables:new tt}}t.defaultData=i})(vP||(vP={}));var Ba;(t=>{function i(){return{images:new tt,videos:new tt,colors:new tt,audios:new tt,fonts:new tt,materials:new tt,components:new tt,variables:new tt}}t.defaultData=i})(Ba||(Ba={}));var wi;(s=>{function i(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Qr(o,tt.prototype)}s.defaultColors=i;function t(o){let a={};return o?.withAITexture&&(a["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Yu.emptyImage,name:"AI generated image"}),Qr(a,tt.prototype)}s.defaultImages=t;function e(){return{catelogs:new tt,materials:new tt,images:new tt,videos:new tt,colors:new tt,audios:new tt,fonts:new tt,variables:new Re,lib:Ba.defaultData()}}s.emptyData=e;function n(o){switch(o){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let a=[0,0,0];return{name:"Time",value:{textValue:a,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:a,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",o)}}s.defaultVariables=n;function r(o,a){if(a.format==="HH:mm:ss"){let l=Math.floor(o/3600),u=Math.floor((o-l*3600)/60),c=Math.round(o-l*3600-u*60);return{textValue:[l,u,c]}}else if(a.format==="mm:ss"){let l=Math.floor(o/60),u=Math.round(o-l*60);return{textValue:[l,u]}}else return a.format==="number"?o=Math.round(o):o=Math.round(o*1e3)/1e3,o}s.getFormattedTimerTime=r})(wi||(wi={}));var Xu;(t=>t.list=["idle","move","jump","run"])(Xu||(Xu={}));var Ku;(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 Re,move:new Re,jump:new Re,run:new Re},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Gr.fromHexAndA(3728051,1)}}))(Ku||(Ku={}));function xP(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,n=t.colorB,r=[[e.r,e.g,e.b,e.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let a=2;a<10;a++)r.push(r[1]),s.push(1);let o={...xi(vn(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:r,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...vn(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Bo(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function Fo(i,t){i.scene.objects.traverse((e,n)=>{"materials"in n?n.materials.forEach((r,s)=>{r===void 0&&(n.materials[s]=Tn.defaultData(),r=n.materials[s]),typeof r!="string"&&t(r)}):"material"in n?typeof n.material!="string"&&(n.material===void 0&&(n.material=Tn.defaultData()),t(n.material)):n.type==="Mesh"&&(n.material===void 0&&(n.material=Tn.defaultData()),t(n.material)),"overrides"in n&&Object.values(n.overrides).forEach(r=>{r.material&&typeof r.material!="string"&&t(r.material)})})}function Nj(i){Object.assign(i.scene.publish,{orbitControls:{...ju.defaultData,...vn(i.scene.publish.orbitControls)}})}function Bj(i){Object.assign(i.scene.publish.settings,{video:{...ks.defaultData.settings.video,...vn(i.scene.publish.settings.video)}})}function Fj(i){function t(e){if(e.layers){for(let n of Object.values(e.layers))if(n){for(let[r,s]of Object.entries(n))if((py.includes(r)||typeof s=="boolean")&&delete n[r],r==="texture")for(let[o,a]of Object.entries(s))(pP.includes(o)||typeof a=="boolean")&&delete s[o]}}}i.scene.objects.traverse((e,n)=>{n.states.forEach(r=>{let s=r;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function kj(i){i.scene.publish.withBackground=!0}function Uj(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function Vj(i){i.scene.objects.traverse((t,e)=>{let n=e.cloner;n&&(n.radial.scale=n.radial.scale.map(r=>r+1),n.linear.scale=n.linear.scale.map(r=>r+1))})}function zj(i){i.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function Gj(i){i.scene.objects.traverse((t,e)=>{let n=i.scene.objects.unproxy().parent(t);if(n){let r=vn(i.scene.objects.data(n));r&&r.type==="Mesh"&&r.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=vn(e).booleanExclude!==!0)}})}function Hj(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let n=e;e.geometry.type==="NonParametricGeometry"?n.material!==void 0&&delete n.material:n.materials!==void 0&&delete n.materials}})}function jj(i){function t(n){Object.setPrototypeOf(n,Yt.prototype),n.texture&&Object.setPrototypeOf(n.texture,Yt.prototype)}function e(n){Object.setPrototypeOf(n,Yt.prototype);for(let r in n)t(n[r])}i.scene.objects.traverse((n,r)=>{r.states.forEach(s=>{let o=s;if(o.material){let a=vn(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],u=vn(l).layers;e(u),l.layers=u}})})}function bP(i){i.layers===void 0&&Object.assign(i,Tn.defaultTwoLayerData("lambert"))}function TS(i){!i.layers||i.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let n=[...t.steps];n.push(t.steps[9]);let r={...vn(t),colors:e,steps:n};Object.assign(t,r)}})}function Wj(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function SP(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(n=>{typeof n!="string"&&TS(n)}):"material"in e&&typeof e.material!="string"&&TS(e.material)}),Object.values(i.shared.materials).forEach(t=>TS(t))}function qj(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function Yj(i){i.shared.audios=Qr({},tt.prototype)}function Xj(i){i.shared.videos=Qr({},tt.prototype)}function Kj(i){let t=i.shared.materials;Object.entries(t).forEach(([e,n])=>{if(!n.layers){let r={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:r})}})}function Qj(i){Object.entries(vn(i.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete i.shared.images[n]}),Object.entries(vn(i.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete i.shared.audios[n]})}function Zj(i){i.scene.publish.settings.web.preload=!1}function wP(i){i.layers&&i.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function AP(i){i.layers&&i.layers.forEach(t=>{fP(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 Jj(i){i.shared.fonts=Qr({},tt.prototype)}function $j(i){return i.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function eW(i){let t=[];i.scene.objects.traverse((e,n)=>{let r=n;if(r.type==="TextFrame"){let s=Tn.defaultTwoLayerData("phong"),o=typeof r.color=="string"?i.shared.colors[r.color]:r.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=r.alpha;let a=$j(r.font);i.shared.fonts[a]===void 0&&(i.shared.fonts[a]={name:a});let l={name:r.name,...Er.defaultData,...kl.defaultData,flatShading:!1,wireframe:!1,geometry:{...Ia.defaultData("TextGeometry"),width:r.width,height:r.height,font:a,depth:0,horizontalAlign:r.horizontalAlign,verticalAlign:r.verticalAlign,fontSize:r.fontSize*1.40625,lineHeight:r.lineHeight/1.40625,letterSpacing:r.letterSpacing-1,text:r.text,textTransform:r.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:vn(r.states),events:vn(r.events),visible:r.visible,raycastLock:r.raycastLock,position:r.position,rotation:r.rotation,scale:r.scale,hiddenMatrix:r.hiddenMatrix},u=vn(i.scene.objects).parent(e);i.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function tW(i){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.scene.objects.traverse((e,n)=>{n.events.forEach(r=>{if(!!t[Number(r.type)])if(Object.assign(r,{type:t[Number(r.type)]}),r.type==="Audio"&&"audioEvent"in r&&(Object.assign(r,{playAudio:r.audioEvent}),delete r.audioEvent),r.type==="GameControl")Object.assign(r,{gameActions:{idle:new Re,move:new Re,jump:new Re}});else{let s=new Re;Object.assign(r,{actions:s}),(r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp")&&"url"in r&&s.push({fi:0,id:Te.generateUUID(),data:{type:"Link",url:r.url,delay:0}}),"targets"in r&&(r.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,xi(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Re({fi:0,id:Te.generateUUID(),data:u},{fi:1,id:Te.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete r.targets)}})})}function nW(i){i.scene.objects.traverse((t,e)=>{function n(r,s){let o=new Re,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(u),l.interaction==="play"?h={...xi(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(h={...xi(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:c,id:u,data:h})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===r)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:Te.generateUUID(),data:{type:r,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}function EP(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=dr.defaultData("light","phong"),n=t;Object.assign(n,e),n.visible=!1}}function _P(i){Bo(i,EP),Fo(i,EP)}function rW(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function iW(i){i.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function sW(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Tn.defaultTwoLayerData("phong"))})}function oW(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function aW(i){i.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function lW(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function cW(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function uW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.resetYPosition=Math.abs(n.resetYPosition-e.position[1]))})})}function hW(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,n)=>{t&&n.physics===null?n.collision=!1:n.collision="visibility"})}function dW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.navmesh=Ku.defaultDataThirdPerson.navmesh)})})}function fW(i){i.scene.styles||(i.scene.styles=Ra.defaultData())}function TP(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function pW(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Fo(i,TP),Bo(i,TP)}function mW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&Object.assign(n.gameActions,{run:new Re})})})}function gW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.keyAssignments=[...n.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function MP(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function CP(i,t){if(t<1&&(Fo(i,xP),Bo(i,xP),i.schema=1),t<2&&(Nj(i),i.schema=2),t<3&&(Fj(i),i.schema=3),t<4&&(kj(i),i.schema=4),t<5&&(Uj(i),i.schema=5),t<6&&(Vj(i),i.schema=6),t<7&&(zj(i),i.schema=7),t<8&&(i.schema=8),t<9&&(SP(i),i.schema=9),t<10&&(Wj(i),i.schema=10),t<11&&(qj(i),i.schema=11),t<12&&(SP(i),i.schema=12),t<13&&(Yj(i),i.schema=13),t<14&&(Kj(i),i.schema=14),t<15&&(Qj(i),i.schema=15),t<16&&(Zj(i),i.schema=16),t<17&&(Fo(i,wP),Bo(i,wP),i.schema=17),t<18&&(Fo(i,bP),Bo(i,bP),i.schema=18),t<19&&(Bj(i),i.schema=19),t<20&&(Jj(i),eW(i),i.schema=20),t<21&&(tW(i),nW(i),i.schema=21),t<22&&(_P(i),i.schema=22),t<23&&(rW(i),i.schema=23),t<24&&(iW(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(Xj(i),t<25&&(i.schema=25)),t<26&&(Gj(i),i.schema=26),t<27&&(Hj(i),i.schema=27),t<28&&(_P(i),i.schema=28),t<29&&(jj(i),i.schema=29),t<30&&(sW(i),i.schema=30),t<31&&(oW(i),i.schema=31),t<33&&(aW(i),i.schema=33),t<34&&(lW(i),i.schema=34),t<35&&(cW(i),i.schema=35),t<36&&(uW(i),i.schema=36),t<37&&(hW(i),i.schema=37),t<38&&(Fo(i,AP),Bo(i,AP),i.schema=38),t<39&&(dW(i),i.schema=39),t<40&&(fW(i),i.schema=40),t<41&&(pW(i),i.schema=41),t<42&&(mW(i),i.schema=42),t<43&&(gW(i),i.schema=43),t<99){Fo(i,MP),Bo(i,MP),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=Li);let e=vn(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=Ca,n.insertBefore(null,null,[{id:Ca,data:{...Lo.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:xi(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:xi(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Oa.defaultData,...xi(i.scene.environment,"usePhysics","gravity")},camera:vn(i.scene.ownerCamera)??Lo.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==Na.TRASH_CAN_ID&&n.move(Ca,o.fi,o.id);let r=0,s=0;i.shared.penumbraSize&&i.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=i.shared.penumbraSize[Math.min(r,2)],r+=1):a.type==="SpotLight"&&(a.penumbraSize=i.shared.penumbraSize[3+Math.min(s,1)],s+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,Da.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),i.schema=99}}function PP(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function yW(i){i.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&n.type==="PathGeometry"&&(n.extrusion.capType="flat",n.extrusion.bevel=50,n.extrusion.bevelSides=6,n.extrusion.shape.type==="Custom"&&(n.extrusion.shape.shapeQuality="low"))})}var Qu=180/Math.PI;function DP(i){i.rotation=i.rotation.slice(0,3).map(t=>t*Qu)}function IP(i){DP(i),i.type==="Page"&&DP(i.camera),i.states.forEach(e=>{e.rotation!==void 0&&(e.rotation=e.rotation.slice(0,3).map(n=>n*Qu))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=t.thetaLength*Qu),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Qu),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Qu,t.extrusion.twist*=Qu),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),i.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Once")})}function vW(i){i.shared.variables=Qr({},tt.prototype)}function xW(i){let t=vn(i.shared.variables);i.shared.variables=Qr(Object.entries(t??{}).map(([e,n],r)=>({fi:r,id:e,data:n})),Re.prototype)}var ko=107;function OP(i,t){t(i.data);for(let e of i.children)OP(e,t)}function bW(i){let t=i.schema??104;t!==ko&&t<105&&(OP(i.asset,IP),i.schema=105)}function Ay(i){let t=i.schema??0;if(t!==ko){console.warn("updating from ",t,"to ",ko),CP(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=ks.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(Fo(i,PP),Bo(i,PP),i.schema=101),t<102&&(yW(i),i.schema=102),t<104&&(i.shared.catelogs=new tt,i.shared.lib=Ba.defaultData(),i.schema=104),t<105&&(vW(i),i.scene.objects.traverse((e,n)=>{IP(n)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))bW(e);t<106&&(xW(i),i.schema=106),t<107&&(i.shared.lib.variables=Ba.defaultData().variables,i.schema=107)}}var Wu;(a=>{a.defaultData={schema:ko,scene:Na.defaultData,frames:new tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",qu.defaultData),shared:{...wi.emptyData(),colors:wi.defaultColors()}},a.emptyDataForImports=function(l){let u=Na.emptyDataWithPage(l);return{schema:ko,scene:u,frames:new tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",qu.defaultData),shared:{...wi.emptyData(),colors:wi.defaultColors(),images:wi.defaultImages(l)}}},a.emptyData=function(){return{schema:ko,scene:Na.emptyDataWithPage(),frames:new tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",qu.defaultData),shared:wi.emptyData()}},a.collabHelper={...Pf,updateSchema(l){return(l.schema??0)<ko?Aa(l,Ay):(l.schema??0)-ko}};function r(l){let u=a.collabHelper.updateSchema(l);return typeof u=="number"?u===0?l:null:u.data}a.updateSchemaDirectly=r;function s(l){return{...l,shared:{...l.shared,lib:Ba.defaultData()}}}a.withoutLib=s;function o(l,u){let c=l.scene.objects.get(u);if(c&&c.data.type==="Component")return c;{let h=l.shared.lib.components[u];if(h)return h.asset}}a.getComponentData=o})(Wu||(Wu={}));function rs(i,t=!1){let e=i[0].index!==null,n=new Set(Object.keys(i[0].attributes)),r=new Set(Object.keys(i[0].morphAttributes)),s={},o={},a=i[0].morphTargetsRelative,l=new Ae,u=0;for(let c=0;c<i.length;++c){let h=i[c],d=0;if(e!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in h.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(h.attributes[f]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in h.morphAttributes){if(!r.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(t){let f;if(e)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,f,c),u+=f}}if(e){let c=0,h=[];for(let d=0;d<i.length;++d){let f=i[d].index;for(let p=0;p<f.count;++p)h.push(f.getX(p)+c);c+=i[d].attributes.position.count}l.setIndex(h)}for(let c in s){let h=RP(s[c]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,h)}for(let c in o){let h=o[c][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let d=0;d<h;++d){let f=[];for(let m=0;m<o[c].length;++m)f.push(o[c][m][d]);let p=RP(f);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(p)}}return l}function RP(i){let t,e,n,r=0;for(let a=0;a<i.length;++a){let l=i[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=l.itemSize),e!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;r+=l.array.length}let s=new t(r),o=0;for(let a=0;a<i.length;++a)s.set(i[a].array,o),o+=i[a].array.length;return new Ge(s,e,n)}var LP=Math.pow(2,-24);var Vl=class{constructor(){}};function Ni(i,t,e){return e.min.x=t[i],e.min.y=t[i+1],e.min.z=t[i+2],e.max.x=t[i+3],e.max.y=t[i+4],e.max.z=t[i+5],e}function MS(i){let t=-1,e=-1/0;for(let n=0;n<3;n++){let r=i[n+3]-i[n];r>e&&(e=r,t=n)}return t}function CS(i,t){t.set(i)}function PS(i,t,e){let n,r;for(let s=0;s<3;s++){let o=s+3;n=i[s],r=t[s],e[s]=n<r?n:r,n=i[o],r=t[o],e[o]=n>r?n:r}}function Bf(i,t,e){for(let n=0;n<3;n++){let r=t[i+2*n],s=t[i+2*n+1],o=r-s,a=r+s;o<e[n]&&(e[n]=o),a>e[n+3]&&(e[n+3]=a)}}function Zu(i){let t=i[3]-i[0],e=i[4]-i[1],n=i[5]-i[2];return 2*(t*e+e*n+n*t)}function AW(i,t){if(!i.index){let e=i.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,r;e>65535?r=new Uint32Array(new n(4*e)):r=new Uint16Array(new n(2*e)),i.setIndex(new Ge(r,1));for(let s=0;s<e;s++)r[s]=s}}function EW(i){if(!i.groups||!i.groups.length)return[{offset:0,count:i.index.count/3}];let t=[],e=new Set;for(let r of i.groups)e.add(r.start),e.add(r.start+r.count);let n=Array.from(e.values()).sort((r,s)=>r-s);for(let r=0;r<n.length-1;r++){let s=n[r],o=n[r+1];t.push({offset:s/3,count:(o-s)/3})}return t}function IS(i,t,e,n,r=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,h=1/0,d=1/0,f=1/0,p=-1/0,m=-1/0,g=-1/0,y=r!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let b=i[v+0],w=i[v+1],E=b-w,_=b+w;E<s&&(s=E),_>l&&(l=_),y&&b<h&&(h=b),y&&b>p&&(p=b);let S=i[v+2],T=i[v+3],M=S-T,C=S+T;M<o&&(o=M),C>u&&(u=C),y&&S<d&&(d=S),y&&S>m&&(m=S);let D=i[v+4],P=i[v+5],I=D-P,L=D+P;I<a&&(a=I),L>c&&(c=L),y&&D<f&&(f=D),y&&D>g&&(g=D)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,y&&(r[0]=h,r[1]=d,r[2]=f,r[3]=p,r[4]=m,r[5]=g)}function _W(i,t,e,n){let r=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,h=(t+e)*6;c<h;c+=6){let d=i[c+0];d<r&&(r=d),d>a&&(a=d);let f=i[c+2];f<s&&(s=f),f>l&&(l=f);let p=i[c+4];p<o&&(o=p),p>u&&(u=p)}n[0]=r,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function TW(i,t,e,n,r){let s=e,o=e+n-1,a=r.pos,l=r.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=i[s*3+u];i[s*3+u]=i[o*3+u],i[o*3+u]=c;let h=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=h;let d=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=d}s++,o--}else return s}}var Uo=32,MW=(i,t)=>i.candidate-t.candidate,Fa=new Array(Uo).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ey=new Float32Array(6);function CW(i,t,e,n,r,s){let o=-1,a=0;if(s===0)o=MS(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=MS(i),o!==-1&&(a=PW(e,n,r,o));else if(s===2){let l=Zu(i),u=1.25*r,c=n*6,h=(n+r)*6;for(let d=0;d<3;d++){let f=t[d],g=(t[d+3]-f)/Uo;if(r<Uo/4){let y=[...Fa];y.length=r;let v=0;for(let b=c;b<h;b+=6,v++){let w=y[v];w.candidate=e[b+2*d],w.count=0;let{bounds:E,leftCacheBounds:_,rightCacheBounds:S}=w;for(let T=0;T<3;T++)S[T]=1/0,S[T+3]=-1/0,_[T]=1/0,_[T+3]=-1/0,E[T]=1/0,E[T+3]=-1/0;Bf(b,e,E)}y.sort(MW);let x=r;for(let b=0;b<x;b++){let w=y[b];for(;b+1<x&&y[b+1].candidate===w.candidate;)y.splice(b+1,1),x--}for(let b=c;b<h;b+=6){let w=e[b+2*d];for(let E=0;E<x;E++){let _=y[E];w>=_.candidate?Bf(b,e,_.rightCacheBounds):(Bf(b,e,_.leftCacheBounds),_.count++)}}for(let b=0;b<x;b++){let w=y[b],E=w.count,_=r-w.count,S=w.leftCacheBounds,T=w.rightCacheBounds,M=0;E!==0&&(M=Zu(S)/l);let C=0;_!==0&&(C=Zu(T)/l);let D=1+1.25*(M*E+C*_);D<u&&(o=d,u=D,a=w.candidate)}}else{for(let x=0;x<Uo;x++){let b=Fa[x];b.count=0,b.candidate=f+g+x*g;let w=b.bounds;for(let E=0;E<3;E++)w[E]=1/0,w[E+3]=-1/0}for(let x=c;x<h;x+=6){let E=~~((e[x+2*d]-f)/g);E>=Uo&&(E=Uo-1);let _=Fa[E];_.count++,Bf(x,e,_.bounds)}let y=Fa[Uo-1];CS(y.bounds,y.rightCacheBounds);for(let x=Uo-2;x>=0;x--){let b=Fa[x],w=Fa[x+1];PS(b.bounds,w.rightCacheBounds,b.rightCacheBounds)}let v=0;for(let x=0;x<Uo-1;x++){let b=Fa[x],w=b.count,E=b.bounds,S=Fa[x+1].rightCacheBounds;w!==0&&(v===0?CS(E,Ey):PS(E,Ey,Ey)),v+=w;let T=0,M=0;v!==0&&(T=Zu(Ey)/l);let C=r-v;C!==0&&(M=Zu(S)/l);let D=1+1.25*(T*v+M*C);D<u&&(o=d,u=D,a=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function PW(i,t,e,n){let r=0;for(let s=t,o=t+e;s<o;s++)r+=i[s*6+n*2];return r/e}function DW(i,t){let e=i.attributes.position,n=i.index.array,r=n.length/3,s=new Float32Array(r*6),o=e.normalized,a=e.array,l=e.offset||0,u=3;e.isInterleavedBufferAttribute&&(u=e.data.stride);let c=["getX","getY","getZ"];for(let h=0;h<r;h++){let d=h*3,f=h*6,p,m,g;o?(p=n[d+0],m=n[d+1],g=n[d+2]):(p=n[d+0]*u+l,m=n[d+1]*u+l,g=n[d+2]*u+l);for(let y=0;y<3;y++){let v,x,b;o?(v=e[c[y]](p),x=e[c[y]](m),b=e[c[y]](g)):(v=a[p+y],x=a[m+y],b=a[g+y]);let w=v;x<w&&(w=x),b<w&&(w=b);let E=v;x>E&&(E=x),b>E&&(E=b);let _=(E-w)/2,S=y*2;s[f+S+0]=w+_,s[f+S+1]=_+(Math.abs(w)+_)*LP,w<t[y]&&(t[y]=w),E>t[y+3]&&(t[y+3]=E)}}return s}function IW(i,t){function e(y){d&&d(y/f)}function n(y,v,x,b=null,w=0){if(!p&&w>=l&&(p=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),x<=c||w>=l)return e(v+x),y.offset=v,y.count=x,y;let E=CW(y.boundingData,b,o,v,x,h);if(E.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let _=TW(a,o,v,x,E);if(_===v||_===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=E.axis;let S=new Vl,T=v,M=_-v;y.left=S,S.boundingData=new Float32Array(6),IS(o,T,M,S.boundingData,s),n(S,T,M,s,w+1);let C=new Vl,D=_,P=x-M;y.right=C,C.boundingData=new Float32Array(6),IS(o,D,P,C.boundingData,s),n(C,D,P,s,w+1)}return y}AW(i,t);let r=new Float32Array(6),s=new Float32Array(6),o=DW(i,r),a=i.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,h=t.strategy,d=t.onProgress,f=i.index.count/3,p=!1,m=[],g=EW(i);if(g.length===1){let y=g[0],v=new Vl;v.boundingData=r,_W(o,y.offset,y.count,s),n(v,y.offset,y.count,s),m.push(v)}else for(let y of g){let v=new Vl;v.boundingData=new Float32Array(6),IS(o,y.offset,y.count,v.boundingData,s),n(v,y.offset,y.count,s),m.push(v)}return m}function FP(i,t){let e=IW(i,t),n,r,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let h=e[c],d=l(h),f=new a(32*d);n=new Float32Array(f),r=new Uint32Array(f),s=new Uint16Array(f),u(0,h),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,h){let d=c/4,f=c/2,p=!!h.count,m=h.boundingData;for(let g=0;g<6;g++)n[d+g]=m[g];if(p){let g=h.offset,y=h.count;return r[d+6]=g,s[f+14]=y,s[f+15]=65535,c+32}else{let g=h.left,y=h.right,v=h.splitAxis,x;if(x=u(c+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return r[d+6]=x/4,x=u(x,y),r[d+7]=v,x}}}var Jr=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,r=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];n=l<n?l:n,r=l>r?l:r}this.min=n,this.max=r}setFromPoints(t,e){let n=1/0,r=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);n=l<n?l:n,r=l>r?l:r}this.min=n,this.max=r}isSeparated(t){return this.min>t.max||t.min>this.max}};Jr.prototype.setFromBox=function(){let i=new A;return function(e,n){let r=n.min,s=n.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){i.x=r.x*l+s.x*(1-l),i.y=r.y*u+s.y*(1-u),i.z=r.z*c+s.z*(1-c);let h=e.dot(i);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var lce=function(){let i=new Jr;return function(e,n){let r=e.points,s=e.satAxes,o=e.satBounds,a=n.points,l=n.satAxes,u=n.satBounds;for(let c=0;c<3;c++){let h=o[c],d=s[c];if(i.setFromPoints(d,a),h.isSeparated(i))return!1}for(let c=0;c<3;c++){let h=u[c],d=l[c];if(i.setFromPoints(d,r),h.isSeparated(i))return!1}}}();var OW=function(){let i=new A,t=new A,e=new A;return function(r,s,o){let a=r.start,l=i,u=s.start,c=t;e.subVectors(a,u),i.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let h=e.dot(c),d=c.dot(l),f=c.dot(c),p=e.dot(l),g=l.dot(l)*f-d*d,y,v;g!==0?y=(h*d-p*f)/g:y=0,v=(h+y*d)/f,o.x=y,o.y=v}}(),Ff=function(){let i=new B,t=new A,e=new A;return function(r,s,o,a){OW(r,s,i);let l=i.x,u=i.y;if(l>=0&&l<=1&&u>=0&&u<=1){r.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?r.at(0,o):r.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=r.start:c=r.end;let h;u<0?h=s.start:h=s.end;let d=t,f=e;if(r.closestPointToPoint(h,!0,t),s.closestPointToPoint(c,!0,e),d.distanceToSquared(h)<=f.distanceToSquared(c)){o.copy(d),a.copy(h);return}else{o.copy(c),a.copy(f);return}}}}(),kP=function(){let i=new A,t=new A,e=new En,n=new Xn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:h}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a||(n.start=u,n.end=h,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a)||(n.start=c,n.end=h,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a))return!0;let m=o.getPlane(e);if(Math.abs(m.distanceToPoint(l))<=a){let y=m.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var RW=1e-15;function Ju(i){return Math.abs(i)<RW}var $r=class extends an{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new Jr),this.points=[this.a,this.b,this.c],this.sphere=new ln,this.plane=new En,this.needsUpdate=!0}intersectsSphere(t){return kP(t,this)}update(){let t=this.a,e=this.b,n=this.c,r=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,r);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,r);let h=s[2],d=o[2];h.subVectors(e,n),d.setFromPoints(h,r);let f=s[3],p=o[3];f.subVectors(n,t),p.setFromPoints(f,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};$r.prototype.closestPointToSegment=function(){let i=new A,t=new A,e=new Xn;return function(r,s=null,o=null){let{start:a,end:l}=r,u=this.points,c,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;e.start.copy(u[d]),e.end.copy(u[f]),Ff(e,r,i,t),c=i.distanceToSquared(t),c<h&&(h=c,s&&s.copy(i),o&&o.copy(t))}return this.closestPointToPoint(a,i),c=a.distanceToSquared(i),c<h&&(h=c,s&&s.copy(i),o&&o.copy(a)),this.closestPointToPoint(l,i),c=l.distanceToSquared(i),c<h&&(h=c,s&&s.copy(i),o&&o.copy(l)),Math.sqrt(h)}}();$r.prototype.intersectsTriangle=function(){let i=new $r,t=new Array(3),e=new Array(3),n=new Jr,r=new Jr,s=new A,o=new A,a=new A,l=new A,u=new Xn,c=new Xn,h=new Xn;return function(f,p=null,m=!1){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(i.copy(f),i.update(),f=i);let g=this.plane,y=f.plane;if(Math.abs(g.normal.dot(y.normal))>1-1e-10){let v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let E=0;E<4;E++){let _=v[E],S=x[E];if(n.setFromPoints(S,e),_.isSeparated(n))return!1}let b=f.satBounds,w=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let E=0;E<4;E++){let _=b[E],S=w[E];if(n.setFromPoints(S,t),_.isSeparated(n))return!1}for(let E=0;E<4;E++){let _=x[E];for(let S=0;S<4;S++){let T=w[S];if(s.crossVectors(_,T),n.setFromPoints(s,t),r.setFromPoints(s,e),n.isSeparated(r))return!1}}return p&&(m||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,x=!1,b=0;for(let I=0;I<3;I++){let L=v[I],H=v[(I+1)%3];u.start.copy(L),u.end.copy(H),u.delta(o);let U=x?c.start:c.end,G=Ju(y.distanceToPoint(L));if(Ju(y.normal.dot(o))&&G){c.copy(u),b=2;break}if((y.intersectLine(u,U)||G)&&!Ju(U.distanceTo(H))){if(b++,x)break;x=!0}}if(b===1&&f.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(b!==2)return!1;let w=f.points,E=!1,_=0;for(let I=0;I<3;I++){let L=w[I],H=w[(I+1)%3];u.start.copy(L),u.end.copy(H),u.delta(a);let U=E?h.start:h.end,G=Ju(g.distanceToPoint(L));if(Ju(g.normal.dot(a))&&G){h.copy(u),_=2;break}if((g.intersectLine(u,U)||G)&&!Ju(U.distanceTo(H))){if(_++,E)break;E=!0}}if(_===1&&this.containsPoint(h.end))return p&&(p.start.copy(h.end),p.end.copy(h.end)),!0;if(_!==2)return!1;if(c.delta(o),h.delta(a),o.dot(a)<0){let I=h.start;h.start=h.end,h.end=I}let S=c.start.dot(o),T=c.end.dot(o),M=h.start.dot(o),C=h.end.dot(o),D=T<M,P=S<C;return S!==C&&M!==T&&D===P?!1:(p&&(l.subVectors(c.start,h.start),l.dot(o)>0?p.start.copy(c.start):p.start.copy(h.start),l.subVectors(c.end,h.end),l.dot(o)<0?p.end.copy(c.end):p.end.copy(h.end)),!0)}}}();$r.prototype.distanceToPoint=function(){let i=new A;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();$r.prototype.distanceToTriangle=function(){let i=new A,t=new A,e=["a","b","c"],n=new Xn,r=new Xn;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let h=0;h<3;h++){let d,f=e[h],p=o[f];this.closestPointToPoint(p,i),d=p.distanceToSquared(i),d<c&&(c=d,a&&a.copy(i),l&&l.copy(p));let m=this[f];o.closestPointToPoint(m,i),d=m.distanceToSquared(i),d<c&&(c=d,a&&a.copy(m),l&&l.copy(i))}for(let h=0;h<3;h++){let d=e[h],f=e[(h+1)%3];n.set(this[d],this[f]);for(let p=0;p<3;p++){let m=e[p],g=e[(p+1)%3];r.set(o[m],o[g]),Ff(n,r,i,t);let y=i.distanceToSquared(t);y<c&&(c=y,a&&a.copy(i),l&&l.copy(t))}}return Math.sqrt(c)}}();var ei=class{constructor(t,e,n){this.isOrientedBox=!0,this.min=new A,this.max=new A,this.matrix=new se,this.invMatrix=new se,this.points=new Array(8).fill().map(()=>new A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new Jr),this.alignedSatBounds=new Array(3).fill().map(()=>new Jr),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};ei.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,r=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){let d=1*u|2*c|4*h,f=r[d];f.x=u?n.x:e.x,f.y=c?n.y:e.y,f.z=h?n.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=r[0];for(let u=0;u<3;u++){let c=o[u],h=s[u],d=1<<u,f=r[d];c.subVectors(a,f),h.setFromPoints(c,r)}let l=this.alignedSatBounds;l[0].setFromPointsField(r,"x"),l[1].setFromPointsField(r,"y"),l[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();ei.prototype.intersectsBox=function(){let i=new Jr;return function(e){this.needsUpdate&&this.update();let n=e.min,r=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(i.min=n.x,i.max=r.x,a[0].isSeparated(i)||(i.min=n.y,i.max=r.y,a[1].isSeparated(i))||(i.min=n.z,i.max=r.z,a[2].isSeparated(i)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(i.setFromBox(u,e),c.isSeparated(i))return!1}return!0}}();ei.prototype.intersectsTriangle=function(){let i=new $r,t=new Array(3),e=new Jr,n=new Jr,r=new A;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(i.copy(o),i.update(),o=i);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let d=0;d<3;d++){let f=a[d],p=l[d];if(e.setFromPoints(p,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,h=this.points;for(let d=0;d<3;d++){let f=u[d],p=c[d];if(e.setFromPoints(p,h),f.isSeparated(e))return!1}for(let d=0;d<3;d++){let f=l[d];for(let p=0;p<4;p++){let m=c[p];if(r.crossVectors(f,m),e.setFromPoints(r,t),n.setFromPoints(r,h),e.isSeparated(n))return!1}}return!0}}();ei.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();ei.prototype.distanceToPoint=function(){let i=new A;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();ei.prototype.distanceToBox=function(){let i=["x","y","z"],t=new Array(12).fill().map(()=>new Xn),e=new Array(12).fill().map(()=>new Xn),n=new A,r=new A;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(r),this.closestPointToPoint(r,n),o.closestPointToPoint(n,r),l&&l.copy(n),u&&u.copy(r)),0;let c=a*a,h=o.min,d=o.max,f=this.points,p=1/0;for(let g=0;g<8;g++){let y=f[g];r.copy(y).clamp(h,d);let v=y.distanceToSquared(r);if(v<p&&(p=v,l&&l.copy(y),u&&u.copy(r),v<c))return Math.sqrt(v)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(g+1)%3,b=(g+2)%3,w=y<<x|v<<b,E=1<<g|y<<x|v<<b,_=f[w],S=f[E];t[m].set(_,S);let M=i[g],C=i[x],D=i[b],P=e[m],I=P.start,L=P.end;I[M]=h[M],I[C]=y?h[C]:d[C],I[D]=v?h[D]:d[C],L[M]=d[M],L[C]=y?h[C]:d[C],L[D]=v?h[D]:d[C],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){r.x=g?d.x:h.x,r.y=y?d.y:h.y,r.z=v?d.z:h.z,this.closestPointToPoint(r,n);let x=r.distanceToSquared(n);if(x<p&&(p=x,l&&l.copy(n),u&&u.copy(r),x<c))return Math.sqrt(x)}for(let g=0;g<12;g++){let y=t[g];for(let v=0;v<12;v++){let x=e[v];Ff(y,x,n,r);let b=n.distanceToSquared(r);if(b<p&&(p=b,l&&l.copy(n),u&&u.copy(r),b<c))return Math.sqrt(b)}}return Math.sqrt(p)}}();var $u=new A,eh=new A,th=new A,Ty=new B,My=new B,Cy=new B,UP=new A,VP=new A,zP=new A,Py=new A;function LW(i,t,e,n,r,s){let o;return s===kn?o=i.intersectTriangle(n,e,t,!0,r):o=i.intersectTriangle(t,e,n,s!==Ur,r),o===null?null:{distance:i.origin.distanceTo(r),point:r.clone()}}function NW(i,t,e,n,r,s,o,a,l){$u.fromBufferAttribute(t,s),eh.fromBufferAttribute(t,o),th.fromBufferAttribute(t,a);let u=LW(i,$u,eh,th,Py,l);if(u){n&&(Ty.fromBufferAttribute(n,s),My.fromBufferAttribute(n,o),Cy.fromBufferAttribute(n,a),u.uv=an.getInterpolation(Py,$u,eh,th,Ty,My,Cy,new B)),r&&(Ty.fromBufferAttribute(r,s),My.fromBufferAttribute(r,o),Cy.fromBufferAttribute(r,a),u.uv1=an.getInterpolation(Py,$u,eh,th,Ty,My,Cy,new B)),e&&(UP.fromBufferAttribute(e,s),VP.fromBufferAttribute(e,o),zP.fromBufferAttribute(e,a),u.normal=an.getInterpolation(Py,$u,eh,th,UP,VP,zP,new A),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let c={a:s,b:o,c:a,normal:new A,materialIndex:0};an.getNormal($u,eh,th,c.normal),u.face=c,u.faceIndex=s}return u}function RS(i,t,e,n,r){let s=n*3,o=i.index.getX(s),a=i.index.getX(s+1),l=i.index.getX(s+2),{position:u,normal:c,uv:h,uv1:d}=i.attributes,f=NW(e,u,c,h,d,o,a,l,t);return f?(f.faceIndex=n,r&&r.push(f),f):null}function GP(i,t,e,n,r,s){for(let o=n,a=n+r;o<a;o++)RS(i,t,e,o,s)}function HP(i,t,e,n,r){let s=1/0,o=null;for(let a=n,l=n+r;a<l;a++){let u=RS(i,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Bi(i,t,e,n){let r=i.a,s=i.b,o=i.c,a=t,l=t+1,u=t+2;e&&(a=e.getX(t),l=e.getX(t+1),u=e.getX(t+2)),r.x=n.getX(a),r.y=n.getY(a),r.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function LS(i,t,e,n,r,s,o){let a=e.index,l=e.attributes.position;for(let u=i,c=t+i;u<c;u++)if(Bi(o,u*3,a,l),o.needsUpdate=!0,n(o,u,r,s))return!0;return!1}var nh=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function Vo(i,t){return t[i+15]===65535}function zl(i,t){return t[i+6]}function rh(i,t){return t[i+14]}function ih(i){return i+8}function sh(i,t){return t[i+6]}function jP(i,t){return t[i+7]}var oh=new Tt,Iy=new A,FW=["x","y","z"];function Oy(i,t,e,n,r){let s=i*2,o=ah,a=ka,l=Ua;if(Vo(s,a)){let c=zl(i,l),h=rh(s,a);GP(t,e,n,c,h,r)}else{let c=ih(i);Ly(c,o,n,Iy)&&Oy(c,t,e,n,r);let h=sh(i,l);Ly(h,o,n,Iy)&&Oy(h,t,e,n,r)}}function Ry(i,t,e,n){let r=i*2,s=ah,o=ka,a=Ua;if(Vo(r,o)){let u=zl(i,a),c=rh(r,o);return HP(t,e,n,u,c)}else{let u=jP(i,a),c=FW[u],d=n.direction[c]>=0,f,p;d?(f=ih(i),p=sh(i,a)):(f=sh(i,a),p=ih(i));let g=Ly(f,s,n,Iy)?Ry(f,t,e,n):null;if(g){let x=g.point[c];if(d?x<=s[p+u]:x>=s[p+u+3])return g}let v=Ly(p,s,n,Iy)?Ry(p,t,e,n):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var WP=function(){let i,t,e=[],n=new nh(()=>new Tt);return function(...o){i=n.getPrimitive(),t=n.getPrimitive(),e.push(i,t);let a=r(...o);n.releasePrimitive(i),n.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],i=e[l-2]),a};function r(s,o,a,l,u=null,c=0,h=0){function d(x){let b=x*2,w=ka,E=Ua;for(;!Vo(b,w);)x=ih(x),b=x*2;return zl(x,E)}function f(x){let b=x*2,w=ka,E=Ua;for(;!Vo(b,w);)x=sh(x,E),b=x*2;return zl(x,E)+rh(b,w)}let p=s*2,m=ah,g=ka,y=Ua;if(Vo(p,g)){let x=zl(s,y),b=rh(p,g);return Ni(s,m,i),l(x,b,!1,h,c+s,i)}else{let x=ih(s),b=sh(s,y),w=x,E=b,_,S,T,M;if(u&&(T=i,M=t,Ni(w,m,T),Ni(E,m,M),_=u(T),S=u(M),S<_)){w=b,E=x;let U=_;_=S,S=U,T=M}T||(T=i,Ni(w,m,T));let C=Vo(w*2,g),D=a(T,C,_,h+1,c+w),P;if(D===2){let U=d(w),z=f(w)-U;P=l(U,z,!0,h+1,c+w,T)}else P=D&&r(w,o,a,l,u,c,h+1);if(P)return!0;M=t,Ni(E,m,M);let I=Vo(E*2,g),L=a(M,I,S,h+1,c+E),H;if(L===2){let U=d(E),z=f(E)-U;H=l(U,z,!0,h+1,c+E,M)}else H=L&&r(E,o,a,l,u,c,h+1);return!!H}}}(),qP=function(){let i=new $r,t=new $r,e=new se,n=new ei,r=new ei;return function s(o,a,l,u,c=null){let h=o*2,d=ah,f=ka,p=Ua;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),Vo(h,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,b=l.attributes.position,w=zl(o,p),E=rh(h,f);if(e.copy(u).invert(),l.boundsTree)return Ni(o,d,r),r.matrix.copy(e),r.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>r.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(u),S.b.applyMatrix4(u),S.c.applyMatrix4(u),S.needsUpdate=!0;for(let T=w*3,M=(E+w)*3;T<M;T+=3)if(Bi(t,T,y,v),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let _=w*3,S=E+w*3;_<S;_+=3){Bi(i,_,y,v),i.a.applyMatrix4(e),i.b.applyMatrix4(e),i.c.applyMatrix4(e),i.needsUpdate=!0;for(let T=0,M=x.count;T<M;T+=3)if(Bi(t,T,x,b),t.needsUpdate=!0,i.intersectsTriangle(t))return!0}}else{let g=o+8,y=p[o+6];return Ni(g,d,oh),!!(c.intersectsBox(oh)&&s(g,a,l,u,c)||(Ni(y,d,oh),c.intersectsBox(oh)&&s(y,a,l,u,c)))}}}();function Ly(i,t,e,n){return Ni(i,t,oh),e.intersectBox(oh,n)}var NS=[],Dy,ah,ka,Ua;function lh(i){Dy&&NS.push(Dy),Dy=i,ah=new Float32Array(i),ka=new Uint16Array(i),Ua=new Uint32Array(i)}function kf(){Dy=null,ah=null,ka=null,Ua=null,NS.length&&lh(NS.pop())}var BS=Symbol("skip tree generation"),FS=new Tt,kS=new Tt,ch=new se,Gl=new ei,Uf=new ei,Vf=new A,Ny=new A,kW=new A,UW=new A,VW=new A,YP=new Tt,Us=new nh(()=>new $r),Vs=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Vs.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let n=t.geometry,r=t._roots,s=n.getIndex(),o;return e.cloneBuffers?o={roots:r.map(a=>a.slice()),index:s.array.slice()}:o={roots:r,index:s.array},o}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Vs.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:r,roots:s}=t,o=new Vs(e,{...n,[BS]:!0});if(o._roots=s,n.setIndex){let a=e.getIndex();if(a===null){let l=new Ge(t.index,1,!1);e.setIndex(l)}else a.array!==r&&(a.array.set(r),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[BS]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[BS]||(this._roots=FP(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Tt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,r=e.attributes.position,s,o,a,l,u=0,c=this._roots;for(let d=0,f=c.length;d<f;d++)s=c[d],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),h(0,u),u+=s.byteLength;function h(d,f,p=!1){let m=d*2;if(a[m+15]===65535){let y=o[d+6],v=a[m+14],x=1/0,b=1/0,w=1/0,E=-1/0,_=-1/0,S=-1/0;for(let T=3*y,M=3*(y+v);T<M;T++){let C=n[T],D=r.getX(C),P=r.getY(C),I=r.getZ(C);D<x&&(x=D),D>E&&(E=D),P<b&&(b=P),P>_&&(_=P),I<w&&(w=I),I>S&&(S=I)}return l[d+0]!==x||l[d+1]!==b||l[d+2]!==w||l[d+3]!==E||l[d+4]!==_||l[d+5]!==S?(l[d+0]=x,l[d+1]=b,l[d+2]=w,l[d+3]=E,l[d+4]=_,l[d+5]=S,!0):!1}else{let y=d+8,v=o[d+6],x=y+f,b=v+f,w=p,E=!1,_=!1;t?w||(E=t.has(x),_=t.has(b),w=!E&&!_):(E=!0,_=!0);let S=w||E,T=w||_,M=!1;S&&(M=h(y,f,w));let C=!1;T&&(C=h(v,f,w));let D=M||C;if(D)for(let P=0;P<3;P++){let I=y+P,L=v+P,H=l[I],U=l[I+3],G=l[L],z=l[L+3];l[d+P]=H<G?H:G,l[d+P+3]=U>z?U:z}return D}}}traverse(t,e=0){let n=this._roots[e],r=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let h=r[a+6],d=s[u+14];t(l,c,new Float32Array(n,a*4,6),h,d)}else{let h=a+32/4,d=r[a+6],f=r[a+7];t(l,c,new Float32Array(n,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(t,e=fi){let n=this._roots,r=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=r.groups,u=o?e.side:e;for(let c=0,h=n.length;c<h;c++){let d=a?e[l[c].materialIndex].side:u,f=s.length;if(lh(n[c]),Oy(0,r,d,t,s),kf(),a){let p=l[c].materialIndex;for(let m=f,g=s.length;m<g;m++)s[m].face.materialIndex=p}}return s}raycastFirst(t,e=fi){let n=this._roots,r=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=r.groups,u=s?e.side:e;for(let c=0,h=n.length;c<h;c++){let d=o?e[l[c].materialIndex].side:u;lh(n[c]);let f=Ry(0,r,d,t);kf(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(t,e){let n=this.geometry,r=!1;for(let s of this._roots)if(lh(s),r=qP(0,n,t,e),kf(),r)break;return r}shapecast(t,e,n){let r=this.geometry;if(t instanceof Function){if(e){let d=e;e=(f,p,m,g)=>{let y=p*3;return d(f,y,y+1,y+2,m,g)}}t={boundsTraverseOrder:n,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=Us.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let d=l;l=(f,p,m,g,y)=>d(f,p,m,g,y)?!0:LS(f,p,r,u,m,g,s)}else l||(u?l=(d,f,p,m)=>LS(d,f,r,u,p,m,s):l=(d,f,p)=>p);let c=!1,h=0;for(let d of this._roots){if(lh(d),c=WP(0,r,a,l,o,h),kf(),c)break;h+=d.byteLength}return Us.releasePrimitive(s),c}bvhcast(t,e,n){let{intersectsRanges:r,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;ch.copy(e).invert();let c=Us.getPrimitive(),h=Us.getPrimitive();if(s){let f=function(p,m,g,y,v,x,b,w){for(let E=g,_=g+y;E<_;E++){Bi(h,E*3,l,u),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let S=p,T=p+m;S<T;S++)if(Bi(c,S*3,o,a),c.needsUpdate=!0,s(c,h,S,E,v,x,b,w))return!0}return!1};if(r){let p=r;r=function(m,g,y,v,x,b,w,E){return p(m,g,y,v,x,b,w,E)?!0:f(m,g,y,v,x,b,w,E)}}else r=f}t.getBoundingBox(kS),kS.applyMatrix4(e);let d=this.shapecast({intersectsBounds:f=>kS.intersectsBox(f),intersectsRange:(f,p,m,g,y,v)=>(FS.copy(v),FS.applyMatrix4(ch),t.shapecast({intersectsBounds:x=>FS.intersectsBox(x),intersectsRange:(x,b,w,E,_)=>r(f,p,x,b,g,y,E,_)}))});return Us.releasePrimitive(c),Us.releasePrimitive(h),d}intersectsBox(t,e){return Gl.set(t.min,t.max,e),Gl.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Gl.intersectsBox(n),intersectsTriangle:n=>Gl.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},r={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Gl.set(t.boundingBox.min,t.boundingBox.max,e),Gl.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,h=t.index,d=Us.getPrimitive(),f=Us.getPrimitive(),p=Ny,m=kW,g=null,y=null;r&&(g=UW,y=VW);let v=1/0,x=null,b=null;return ch.copy(e).invert(),Uf.matrix.copy(ch),this.shapecast({boundsTraverseOrder:w=>Gl.distanceToBox(w),intersectsBounds:(w,E,_)=>_<v&&_<o?(E&&(Uf.min.copy(w.min),Uf.max.copy(w.max),Uf.needsUpdate=!0),!0):!1,intersectsRange:(w,E)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:_=>Uf.distanceToBox(_),intersectsBounds:(_,S,T)=>T<v&&T<o,intersectsRange:(_,S)=>{for(let T=_*3,M=(_+S)*3;T<M;T+=3){Bi(f,T,h,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let C=w*3,D=(w+E)*3;C<D;C+=3){Bi(d,C,u,l),d.needsUpdate=!0;let P=d.distanceToTriangle(f,p,g);if(P<v&&(m.copy(p),y&&y.copy(g),v=P,x=C/3,b=T/3),P<s)return!0}}}});{let _=h?h.count:c.count;for(let S=0,T=_;S<T;S+=3){Bi(f,S,h,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let M=w*3,C=(w+E)*3;M<C;M+=3){Bi(d,M,u,l),d.needsUpdate=!0;let D=d.distanceToTriangle(f,p,g);if(D<v&&(m.copy(p),y&&y.copy(g),v=D,x=M/3,b=S/3),D<s)return!0}}}}}),Us.releasePrimitive(d),Us.releasePrimitive(f),v===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=v,n.faceIndex=x,r&&(r.point?r.point.copy(y):r.point=y.clone(),r.point.applyMatrix4(ch),m.applyMatrix4(ch),r.distance=m.sub(r.point).length(),r.faceIndex=b),n)}closestPointToPoint(t,e={},n=0,r=1/0){let s=n*n,o=r*r,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(Vf.copy(t).clamp(c.min,c.max),Vf.distanceToSquared(t)),intersectsBounds:(c,h,d)=>d<a&&d<o,intersectsTriangle:(c,h)=>{c.closestPointToPoint(t,Vf);let d=t.distanceToSquared(Vf);return d<a&&(Ny.copy(Vf),a=d,l=h),d<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(Ny):e.point=Ny.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{Ni(0,new Float32Array(n),YP),t.union(YP)}),t}};var ed=$o(KP());var zW=.5*(Math.sqrt(3)-1),zf=(3-Math.sqrt(3))/6,GW=1/3,zs=1/6,tue=(Math.sqrt(5)-1)/4,nue=(5-Math.sqrt(5))/20,Gf=i=>Math.floor(i)|0,QP=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]),VS=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 By(i=Math.random){let t=JP(i),e=new Float64Array(t).map(r=>QP[r%12*2]),n=new Float64Array(t).map(r=>QP[r%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*zW,h=Gf(s+c),d=Gf(o+c),f=(h+d)*zf,p=h-f,m=d-f,g=s-p,y=o-m,v,x;g>y?(v=1,x=0):(v=0,x=1);let b=g-v+zf,w=y-x+zf,E=g-1+2*zf,_=y-1+2*zf,S=h&255,T=d&255,M=.5-g*g-y*y;if(M>=0){let P=S+t[T],I=e[P],L=n[P];M*=M,a=M*M*(I*g+L*y)}let C=.5-b*b-w*w;if(C>=0){let P=S+v+t[T+x],I=e[P],L=n[P];C*=C,l=C*C*(I*b+L*w)}let D=.5-E*E-_*_;if(D>=0){let P=S+1+t[T+1],I=e[P],L=n[P];D*=D,u=D*D*(I*E+L*_)}return 70*(a+l+u)}}function ZP(i=Math.random){let t=JP(i),e=new Float64Array(t).map(s=>VS[s%12*3]),n=new Float64Array(t).map(s=>VS[s%12*3+1]),r=new Float64Array(t).map(s=>VS[s%12*3+2]);return function(o,a,l){let u,c,h,d,f=(o+a+l)*GW,p=Gf(o+f),m=Gf(a+f),g=Gf(l+f),y=(p+m+g)*zs,v=p-y,x=m-y,b=g-y,w=o-v,E=a-x,_=l-b,S,T,M,C,D,P;w>=E?E>=_?(S=1,T=0,M=0,C=1,D=1,P=0):w>=_?(S=1,T=0,M=0,C=1,D=0,P=1):(S=0,T=0,M=1,C=1,D=0,P=1):E<_?(S=0,T=0,M=1,C=0,D=1,P=1):w<_?(S=0,T=1,M=0,C=0,D=1,P=1):(S=0,T=1,M=0,C=1,D=1,P=0);let I=w-S+zs,L=E-T+zs,H=_-M+zs,U=w-C+2*zs,G=E-D+2*zs,z=_-P+2*zs,V=w-1+3*zs,$=E-1+3*zs,F=_-1+3*zs,j=p&255,X=m&255,q=g&255,k=.6-w*w-E*E-_*_;if(k<0)u=0;else{let W=j+t[X+t[q]];k*=k,u=k*k*(e[W]*w+n[W]*E+r[W]*_)}let Z=.6-I*I-L*L-H*H;if(Z<0)c=0;else{let W=j+S+t[X+T+t[q+M]];Z*=Z,c=Z*Z*(e[W]*I+n[W]*L+r[W]*H)}let Q=.6-U*U-G*G-z*z;if(Q<0)h=0;else{let W=j+C+t[X+D+t[q+P]];Q*=Q,h=Q*Q*(e[W]*U+n[W]*G+r[W]*z)}let K=.6-V*V-$*$-F*F;if(K<0)d=0;else{let W=j+1+t[X+1+t[q+1]];K*=K,d=K*K*(e[W]*V+n[W]*$+r[W]*F)}return 32*(u+c+h+d)}}function JP(i){let e=new Uint8Array(512);for(let n=0;n<512/2;n++)e[n]=n;for(let n=0;n<512/2-1;n++){let r=n+~~(i()*(256-n)),s=e[n];e[n]=e[r],e[r]=s}for(let n=256;n<512;n++)e[n]=e[n-256];return e}var is=new an,Fy=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let r=0;r<t.count;r+=3){let s=1;is.a.fromBufferAttribute(t,r),is.b.fromBufferAttribute(t,r+1),is.c.fromBufferAttribute(t,r+2),s*=is.getArea(),e[r/3]=s}this.distribution=new Float32Array(t.count/3);let n=0;for(let r=0;r<e.length;r++)n+=e[r],this.distribution[r]=n;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let n=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*n);return this.sampleFace(r,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,n=0,r=e.length-1,s=-1;for(;n<=r;){let o=Math.ceil((n+r)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?r=o-1:n=o+1}return s}sampleFace(t,e,n){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),is.a.fromBufferAttribute(this.positionAttribute,t*3),is.b.fromBufferAttribute(this.positionAttribute,t*3+1),is.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(is.a,r).addScaledVector(is.b,s).addScaledVector(is.c,1-(r+s)),is.getNormal(n),this}};var e2=$o(zS()),HW=new se,jW=new se,WW=new se,uh;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(uh||(uh={}));var hh=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new se;this.copyPreviousMatrix=!0;this.hiddenMatrix=new se;this.matrixWorldRigid=new se;this.shearScale=new se;this.shearScaleInv=new se}get __isSPEObject(){return!0}isDescendantOf(n){n instanceof mt&&(n=n.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===n)return!0;r=r.parent}return!1}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);for(let r of this.children)r.updateMatrixWorld(n)}updateWorldMatrix(n,r){let s=this.parent;if(n&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(n,r=0){for(let s of this.children)uh.is(s)&&s.traverseObject(n,r+1)}traverseObject(n,r=0){if(n(this,r)!==!0)for(let o of this.children)uh.is(o)&&o.traverseObject(n,r+1)}updateMatrixWorldSVD(){let n=this.matrixWorld.elements,r=[[n[0],n[4],n[8]],[n[1],n[5],n[9]],[n[2],n[6],n[10]]],{u:s,v:o,q:a}=(0,e2.SVD)(r),l=HW.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),u=jW.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=WW.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(n,r){this.updateWorldMatrix(!0,!1);let s=new se().copy(this.matrixWorld).invert();return n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),s.multiply(n.parent.matrixWorld)),"hiddenMatrix"in n&&n.hiddenMatrix instanceof se?n.hiddenMatrix.premultiply(s):n.applyMatrix4(s),n.updateWorldMatrix(!1,!1),this.add(n),r!==void 0&&(this.children.pop(),this.children.splice(r,0,n)),this}copy(n,r=!1){return super.copy(n,r),this.hasNonUniformScale=n.hasNonUniformScale,this}onAfterRender(n,r,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var GS=class extends hh(mt){},qW=i=>i.type==="Mesh",un=class extends GS{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,n){}expand(){let e=0,n=this.object.entityChildren(e);for(;n;){let r=this.children[e];r?.object!==n&&(r&&this.remove(r),r=new un(n),this.add(r),this.children.splice(e,0,this.children.pop()),r.matrixWorldNeedsUpdate=!0,r.matrixAutoUpdate=!1,r.matrix=n.matrix,r.hiddenMatrix=n.hiddenMatrix),r.expand(),e+=1,n=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return qW(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var Hl=new A,jl=new A,dh=new se,n2=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],YW=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],XW=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],t2=(i,t,e)=>{i.updateEntityBoxSize(Hl,jl),dh.copy(t).multiply(i.matrixWorld),jl.x===0&&jl.y===0&&jl.z===0?e.push(new A(Hl.x,Hl.y,Hl.z).applyMatrix4(dh)):n2.forEach(n=>{e.push(n.clone().multiply(jl).add(Hl).applyMatrix4(dh))})},Hf=class extends Tt{constructor(){super(...arguments);this.matrix=new se;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(n=>n.clone()),this.faces=e.faces.map(n=>n.clone()),this.edges=e.edges.map(n=>n.clone()),this.centerEdges=e.centerEdges.map(n=>n.clone()),this}setFromObjectSize(e,n=!1){e.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let r=new se().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,r,n)}expandByObjectSize(e,n,r=!1){let s=[];return r===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new A);return}t2(o,n,s)}}):t2(e,n,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(dh.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(jl).multiplyScalar(.5),this.getCenter(Hl),dh.copy(this.matrix).setPosition(Hl),this.vertices=n2.map(e=>e.clone().multiply(jl).applyMatrix4(dh))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=YW.map(([e,n])=>new Xn(this.vertices[e],this.vertices[n])),this.centerEdges=this.edges.map(e=>e.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=XW.map(([e,n])=>this.vertices[e].clone().add(this.vertices[n]).multiplyScalar(.5))}};var ss={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var jS=class extends of{constructor(){super()}getPoints(t=12){let e=[],n,r=this.getCurveLengths(),o=r[r.length-1]/r.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?r[a]:r[a]-r[a-1],h=Math.ceil(t*c/o),d=u.getPoints(h);for(let f=0;f<d.length;f++){let p=d[f];n&&n.equals(p)||(e.push(p),n=p)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var WS=.001;function qS(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=WS}function HS(i,t){let e=new A(...i.position),n=new A(...i.controlNext.position),r=new A(...t.controlPrevious.position),s=new A(...t.position);return qS(e,n,s)&&qS(e,r,s)}function Uy(i){let t=i.points.map(c=>new A(...c.data.position)),e=[i.points[0]],n=new A(...e[0].data.position);for(let c=0;c<i.points.length-1;c++)qS(n,t[c],t[c+1])||(e.push(i.points[c]),n=t[c]);e.push(i.points[i.points.length-1]);let r=i.isClosed,s=e.length-(r?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let h=e[c].data,d=new A(...h.position),f=new A(...h.controlPrevious.position),p=new A(...h.controlNext.position),m={position:d,baseRoundness:h.roundness,controlPrevious:f,controlNext:p};if(h.roundness===0||!i.isClosed&&(c===0||c===o-1)){a[c]={...m,removedLength:0};continue}let g=r&&c==0?o-1:c-1,y=r&&c==o-1?0:c+1,v=e[g].data,x=e[y].data,b=new A(...v.position),w=new A(...x.position),E=b.clone().sub(d).normalize(),_=w.clone().sub(d).normalize();Object.assign(m,{prevDir:E,nextDir:_});let S=HS(v,h),T=HS(h,x);if(!S||!T)a[c]={...m,removedLength:0};else{let M=E.clone().add(_).normalize(),C=M.clone().cross(E).length()/E.dot(M);a[c]={...m,tan:C,removedLength:h.roundness/C}}}for(let c=0;c<s;c++){let h=c,d=r&&c===o-1?0:c+1,f=a[h],p=a[d];if(f.removedLength!==0||p.removedLength!==0){let m=f.position.distanceTo(p.position);f.removedLength=Math.min(f.removedLength,m/2),p.removedLength=Math.min(p.removedLength,m/2)}}let l=[];for(let c=0;c<s;c++){let h=c,d=r&&c===o-1?0:c+1,f=a[h],p=a[d],m=null;if(!HS(e[h].data,e[d].data))f.position.distanceTo(p.position)>WS&&(m=new wl(f.position,f.controlNext,p.controlPrevious,p.position));else{let g=f.position.clone(),y=p.position.clone();(f.removedLength!==0||p.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),p.prevDir&&y.add(p.prevDir.clone().setLength(p.removedLength))),g.distanceTo(y)>WS&&(m=new wl(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*c+1]=m}for(let c=0;c<o;c++){let h=a[c];if(h.removedLength===0){l[2*c]=null;continue}let d=h.position,f=h.prevDir.clone().multiplyScalar(h.removedLength).add(d),p=h.nextDir.clone().multiplyScalar(h.removedLength).add(d),m=h.tan*h.removedLength,g=h.prevDir.clone().add(h.nextDir).normalize(),y=f.clone().lerp(p,.5),v=f.distanceTo(p)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(y),b=g.clone().multiplyScalar(-m).add(x),w=d.distanceTo(b)/d.distanceTo(y),E=h.prevDir.clone().multiplyScalar(w*d.distanceTo(f)).add(d),_=E.clone().lerp(b,2),S=f.clone().lerp(E,4/3),T=p.clone().lerp(_,4/3);l[2*c]=new wl(f,S,T,p)}let u=new jS;return l.forEach(c=>{c&&u.add(c)}),u}var at;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(at||(at={}));var Gs=i=>at.is(i),KW={type:"completeState",isfromEntity:!0},QW=["x","y","z"],YS=new A,ZW=new A().set(0,1,0),fh=i=>class extends hh(i){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Hf;this._recursiveBBox=new Hf;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(n){let r=this.children[n];if(at.is(r))return r}entityChildrenCount(){let n=this.children.length;for(;n--;)if(at.is(this.children[n]))return n+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let n=this;for(;n.data.type!=="Instance";){let r=n.parent;if(at.is(r))n=r;else return}return n}forInstancesRec(n){this.instances.forEach(r=>{r.disposed||n(r),r.forInstancesRec(n)})}super_Entity(n,r){typeof n=="string"&&(this.uuid=n),this.identity=n,this.data=r,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(n,r,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)No.toOps(this.data,o.data).forEach(l=>{let u=Hg.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,r)});if(n!==null){let o=this.data.states.data(n);o&&(this.dataPatched=No.patch(this.data,o),No.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,r)}))}s&&this.updateTransformState(this.dataPatched,r),this.stateSelection=n,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(n,r){n.setScalar(0),r.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(n=>{Gs(n)&&n.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(n=>{n.resetBBoxNeedsUpdateSelf()})}find(n){let r;return this.traverseEntity(s=>{s.uuid===n&&(r=s)}),r}traverseSortNextHelper(){let n=this.parent;if(n){let r=n.children,s=r.indexOf(this)+1;if(at.is(r[s]))return r[s];if(at.is(n))return n.traverseSortNextHelper()}}sortNext(){let n=this.children;return this.children.length>0&&at.is(this.children[0])?n[0]:this.traverseSortNextHelper()}goUp(n){let r=this;for(;n>0&&r!==null;)r=r.parent,n-=1;return r}hasAnccestorOrSelf(n){return this===n||this.hasAnccestor(n)}hasAnccestor(n){let r=this.parent;for(;r;){if(n===r)return!0;r=r.parent}return!1}countToAccestor(n){let r=0,s=this;for(;s!==n;){if(s===null)return-1;s=s.parent,r+=1}return r}forEachEntity(n){for(let r of this.children)Gs(r)&&n(r)}traverseEntityAncestors(n){this.traverseAncestors(r=>{at.is(r)&&n(r)})}traverseConcreteEntity(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Gs(o)&&o.isConcreteEntity&&o.traverseEntity(n,r+1)}traverseEntity(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Gs(o)&&o.traverseEntity(n,r+1)}traverseVisibleEntity(n){n(this);for(let r of this.children)Gs(r)&&r.visible&&r.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(n){super.updateMatrixWorld(n),this.dispatchEvent({type:"updateMatrixWorld"})}copy(n,r=!1){return super.copy(n,r),this.dataPatched=n.dataPatched,this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),this}hasEntityChild(){return this.children.some(n=>Gs(n))}isAncestorOf(n){if(this.uuid===n)return!1;let r=!1;return this.traverseEntity(s=>{s.uuid===n&&(r=!0)}),r}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x*Te.RAD2DEG,this.rotation.y*Te.RAD2DEG,this.rotation.z*Te.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return omit(r,n)}getTransformValues(n,r,s){return r[n].map((o,a)=>s?.shared.getVariable(o,[this.uuid,n,QW[a]])??o)}updateTransformState(n,r){let s=!1;return n.position&&(this.position.fromArray(this.getTransformValues("position",n,r)),s=!0),n.rotation&&(YS.fromArray(this.getTransformValues("rotation",n,r)).multiplyScalar(Te.DEG2RAD),this.rotation.setFromVector3(YS),s=!0),n.scale&&(this.scale.fromArray(this.getTransformValues("scale",n,r)),s=!0),n.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(n.hiddenMatrix??Ma.identity)),s&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})),n.position&&n.rotation&&n.scale&&n.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),s}onVariableUpdate(n=!1){if(n){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(r=>{r.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let n of this.children)at.is(n)&&n.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(n=>{at.is(n)&&n.disposeRecursively()})}toState(n=[]){let r={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return omit(r,n)}updateByObjUpdateOp(n,r){n!==void 0&&this.updateByOp({type:0,props:n,path:[]},{...this.data,...n},r,!1)}updateByOp(n,r,s,o){let a=this.data;this.data=r;let l=n,u=Or(n.path,["states","*"]);if(u!==null){if(n.type===0){let[c]=u;if(this?.stateSelection===c){let h={...n.props};if(delete h.name,Object.values(n.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let f=Vn.zoom(d,n.path.slice(2));if(f)for(let p in n.props)n.props[p]===void 0&&p in f&&(h[p]=f[p])}}l={...n,props:h,path:n.path.slice(2)}}}}else if(n.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(n.props.name!==void 0&&c.name){let{name:d,...f}=c;c=f}if(n.props.material!==void 0&&"material"in c){let{material:d,...f}=c;c=f}let h=Vn.removeOverridden(n.path,n.props,c);l={...n,props:h}}}if(this.updateByPatchedOpBase(l,No.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Or(n.path,["overrides"])){let c=[],h=[...n.path];for(c.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)c.push(h[1]),h.splice(0,2);if(c[c.length-1]===void 0){if(n.type===0)for(let d of Object.keys(n.props)){c[c.length-1]=d;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=n.props[d],f.updateState(Ds.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...c]);if(d){let f=Vn.zoom(d.component.data,h);if(n={...n,path:h},n.type===0){let p=n.props;if(f)for(let[m,g]of Object.entries(n.props))g===void 0&&(p===n.props&&(p={...n.props}),p[m]=f[m]);n={...n,props:p}}d.overrideData=Gu.resolve(r.overrides,c),d.updateByOp(n,zn.applySimple(d.data,n),s,!1)}}}else if(this.instances.length>0){let c;if(n.path.length===0&&n.type===0){let h;for(let d of Fs.rootOverrideProps)d in n.props&&(h===void 0&&(h={}),h[d]=n.props[d]);h&&(c={...n,props:h})}else for(let h of Fs.rootOverrideProps)if(Or(n.path,[h])){c=n;break}c!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=Ds.filterOp(h.overrideData,c);d&&h.updateByOp(d,zn.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=Ds.filterOp(h.overrideData,n);if(d){let f;a===h.data&&n===d?f=r:f=zn.applySimple(h.data,d),h.updateByOp(d,f,s,!0)}}})}}updateByPatchedOpBase(n,r,s){if(this.dataPatched=r,n.path.length===0&&n.type===0)n.props.type!==void 0&&!ns.is(n.props.type)&&ss.changeEntityProptotype(this,r,s);else if(n.path.length===1&&n.path[0]==="geometry"&&n.type===0&&"type"in n.props){ss.changeEntityProptotype(this,r,s);for(let o of this.children)at.is(o)&&o.updateVisible()}this.updateByPatchedOp(n,r,s)}updateByPatchedOp(n,r,s){if(n.path.length===0&&n.type===0&&this.updateState(n.props,s),Or(n.path,["pathSnapping"])!==null&&this.updatePathSnapping(r.pathSnapping),Or(n.path,["cloner"])!==null){let o=zn.drop(n,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(r.cloner,s.scene):(this.setFromClonerState(r.cloner,s),this.expandCloner(s.scene)),this.updateVisible()}}updatePathSnapping(n){this._updatedPathSnapping=n,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(n){let r=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(r===null)return;let l=n.find(r);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=Uy(u.geometry.path),h=(s+o)%1;s+o===1&&h===0&&(h=1);let d=c.getPointAt(h),f=this.parent?this.parent?.matrixWorld:new se;l.updateMatrixWorld();let p=new se().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(p);let m={position:d.toArray(),rotation:u.rotation};if(a==="tangential"){let g=new se().extractRotation(l.matrixWorld),y=c.getTangentAt(h).applyMatrix4(g).add(d),v=new se().lookAt(d,y,ZW),x=YS.setFromEuler(new qt().setFromRotationMatrix(v)).multiplyScalar(Te.RAD2DEG);m={...m,rotation:x.toArray()}}this.updateTransformState(m),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(KW)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(n,r){n.name!==void 0&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),r&&"cloner"in n&&n.cloner!==void 0&&(this.setFromClonerState(n.cloner,r),this.updateVisible()),this.updateTransformState(n,r)}get attachedSurfaceCloners(){return this.children.filter(n=>n instanceof ss.Cloner&&n.parameters.type==="toObject")}setFromClonerState(n,r){this.disposed||(n===null||n.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new ss.Cloner(this,n),r.scene.addPendingExpandCloner(this)):this.cloner.updateState(n,r.scene))}expandCloner(n){!this.disposed&&this.cloner&&this.cloner.expandClones(n)}invalidateClonerTransform(n){this.cloner&&this.cloner.invalidateTransform(n)}};var Vy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);e.thetaLength=Te.clamp(e.thetaLength,0,360);let n=e.width/2,r=e.radiusTop??n,s=e.radiusBottom??n;return r===s?(r=n,s=n):r>s?(r=n,s=s*n/r):(r=r*n/s,s=n),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:r,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:h,cornerSegments:d,hollow:f}=i.parameters,p;return l===0?(p=new Ae,p.setAttribute("position",new be([],3))):h||f?p=new jf(u,c,n,r,s,o,a,l*Math.PI/180,h,h,d,f):p=new El(u,c,n,r,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"CylinderGeometry"}})}};function Va(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function r2(i){return new B(i.y,-i.x)}var jf=class extends Ae{constructor(t,e,n,r,s,o,a,l,u,c,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,n=n||1,r=Math.floor(r)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let p=[],m=[],g=[],y=[],v=0,x=n/2,b=new A,w=new A;f&&t==0&&(t=u),f&&e==0&&(e=c);let E=new B(t,x),_=new B(e,-x),S=null,T=null,M=null,C=null,D=E.clone().sub(_),P=0,I=0,L=0;d>0&&(P=Math.min(t,e)*(1-d),I=t-P,L=e-P);let H=E.clone();H.x-=P;let U=Math.PI-D.angle(),G=D.angle(),z=Math.tan(G/2),V=Math.tan(U/2),$=z+V,F=d?$:V,j=d?$:z;if(u=Math.min(u,(t-I)/F,D.length()/$),c=Math.min(c,(e-L)/j,D.length()/$),u>0){let K=u/z;S=E.clone().sub(new B(K,u)),d&&(M=S.clone(),M.x-=P-$*u),E.sub(D.clone().setLength(K))}if(c>0){let K=c/V;T=_.clone().sub(new B(K,-c)),_.add(D.clone().setLength(K)),d&&(C=T.clone(),C.x-=P-$*c,H.sub(D.clone().setLength(K)))}D=E.clone().sub(_);let X=D.length()<.5,q=[];for(let K=0;K<=r;K++){let W=[],ye=K/r,fe=ye*l+a,ie=new B(Math.sin(fe),Math.cos(fe));C&&T?(k(W,ye,ie,U,c,C,-1,!0),k(W,ye,ie,G,c,T,-1,!1)):T?(Z(W,ie,T.x,0,-1),k(W,ye,ie,G,c,T,-1,!1)):o||Z(W,ie,e,L,-1);let we=r2(D).normalize();if(Va(we,ie,b),!X)for(let xe=0;xe<=s;xe++){let Oe=xe/s,Ie=D.clone().multiplyScalar(Oe).add(_);Va(Ie,ie,w),m.push(w.x,w.y,w.z),g.push(b.x,b.y,b.z),y.push(ye,.5+w.y/n),W.push(v++)}if(M&&S?(k(W,ye,ie,U,u,S,1,!1),k(W,ye,ie,G,u,M,1,!0)):S?(k(W,ye,ie,U,u,S,1,!1),Z(W,ie,S.x,0,1)):o||Z(W,ie,t,I,1),d&&!X){let xe=r2(D).multiplyScalar(-1).normalize();Va(xe,ie,b);for(let Oe=0;Oe<=s;Oe++){let Ie=Oe/s,Pe=D.clone().multiplyScalar(-Ie).add(H);Va(Pe,ie,w),m.push(w.x,w.y,w.z),g.push(b.x,b.y,b.z),y.push(ye,.5+w.y/n),W.push(v++)}}d&&!o&&W.push(W[0]),q.push(W)}for(let K=0;K<q.length-1;K++)for(let W=0;W<q[0].length-1;W++){if(o&&d&&W==s)continue;let ye=q[K][W],fe=q[K+1][W],ie=q[K+1][W+1],we=q[K][W+1],xe=m[ie*3+0],Oe=m[ie*3+2];p.push(ye,fe,we),(xe!=0||Oe!=0)&&p.push(fe,ie,we)}l<Math.PI*2&&(Q(-1,q[0],a),Q(1,q[q.length-1],a+l)),this.setIndex(p),this.setAttribute("position",new be(m,3)),this.setAttribute("normal",new be(g,3)),this.setAttribute("uv",new be(y,2));function k(K,W,ye,fe,ie,we,xe,Oe){for(let Ie=0;Ie<h+1;Ie++){let Pe=Ie/h,_e=xe<0?Pe:1-Pe;Oe&&(_e-=1),_e*=fe;let Ve=new B(Math.sin(_e),Math.cos(_e)*xe),ze=Ve.clone().multiplyScalar(ie).add(we);Va(ze,ye,w),m.push(w.x,w.y,w.z),Va(Ve,ye,b),g.push(b.x,b.y,b.z),y.push(W,.5+w.y/n),K.push(v++)}}function Z(K,W,ye,fe,ie){let we=new A,xe=new B,Oe=[ye,fe];ie<0&&Oe.reverse();for(let Ie of Oe)xe.set(Ie,x*ie),Va(xe,W,we),m.push(we.x,we.y,we.z),g.push(0,ie,0),y.push(.5,.5),K.push(v++)}function Q(K,W,ye){let fe=new B(Math.sin(ye),Math.cos(ye)),ie=new B(-Math.cos(ye),Math.sin(ye)),we=new A,xe=K<0?(Pe,_e,Ve)=>p.push(Pe,_e,Ve):(Pe,_e,Ve)=>p.push(Pe,Ve,_e),Oe=new B((t+e+I+L)/4,0);Va(Oe,fe,we),m.push(we.x,we.y,we.z),g.push(ie.x,0,ie.y),y.push(.5,.5);let Ie=v++;for(let Pe of W){let _e=m.slice(Pe*3,Pe*3+3);m.push(..._e),g.push(ie.x,0,ie.y);let Ve=y.slice(Pe*2,Pe*2+2);y.push(...Ve),v++}for(let Pe=Ie+1;Pe<v-1;Pe++)xe(Ie,Pe,Pe+1);xe(Ie,v-1,Ie+1)}}};var i2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return e.thetaLength=Te.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:h}=i.parameters,d;return l===0?(d=new Ae,d.setAttribute("position",new be([],3))):u>0||c>0||l<360?d=new jf(0,t/2,n,r,s,o,a,l*Math.PI/180,u,c,h,0,!0):d=new Uc(t/2,n,r,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...i,type:"ConeGeometry"}})}};var s2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,widthSegments:r,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=i.parameters,u;return a==0?u=new sr(t,e,n,r,s,o):u=new KS(t,e,n,r,s,o,a,l),Object.assign(u,{userData:{...i,type:"CubeGeometry"}})}},XS=Math.PI/2,KS=class extends Ae{constructor(t=1,e=1,n=1,r=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,n/2);let c=[],h=[],d=[],f=[],p=0,m=0;g("z","y","x",-1,-1,n,e,t,o,s,0),g("z","y","x",1,-1,n,e,-t,o,s,1),g("x","z","y",1,1,t,n,e,r,o,2),g("x","z","y",1,-1,t,n,-e,r,o,3),g("x","y","z",1,-1,t,e,n,r,s,4),g("x","y","z",-1,-1,t,e,-n,r,s,5),a>0&&(y("z","y","x",-1,-1,1,n,e,t,o,0),y("z","y","x",1,-1,-1,n,e,t,o,1),y("z","y","x",-1,1,-1,n,e,t,o,1),y("z","y","x",1,1,1,n,e,t,o,0),y("x","y","z",-1,-1,-1,t,e,n,r,0),y("x","y","z",1,-1,1,t,e,n,r,1),y("x","y","z",-1,1,1,t,e,n,r,0),y("x","y","z",1,1,-1,t,e,n,r,1),y("y","x","z",-1,-1,1,e,t,n,s,0),y("y","x","z",1,-1,-1,e,t,n,s,1),y("y","x","z",1,1,1,e,t,n,s,1),y("y","x","z",-1,1,-1,e,t,n,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new be(h,3)),this.setAttribute("normal",new be(d,3)),this.setAttribute("uv",new be(f,2));function g(x,b,w,E,_,S,T,M,C,D,P){let I=(S-2*a)/C,L=(T-2*a)/D,H=S/2-a,U=T/2-a,G=M/2,z=C+1,V=D+1,$=0,F=0,j=new A;for(let X=0;X<V;X++){let q=X*L-U;for(let k=0;k<z;k++){let Z=k*I-H;j[x]=Z*E,j[b]=q*_,j[w]=G,h.push(j.x,j.y,j.z),j[x]=0,j[b]=0,j[w]=M>0?1:-1,d.push(j.x,j.y,j.z),f.push(k/C),f.push(1-X/D),$+=1}}for(let X=0;X<D;X++)for(let q=0;q<C;q++){let k=p+q+z*X,Z=p+q+z*(X+1),Q=p+(q+1)+z*(X+1),K=p+(q+1)+z*X;c.push(k,Z,K),c.push(Z,Q,K),F+=6}u.addGroup(m,F,P),m+=F,p+=$}function y(x,b,w,E,_,S,T,M,C,D,P){let I=(T-2*a)/D,L=T/2-a,H=M/2-a,U=C/2,G=D+1,z=0,V=0,$=new A,F=new A;for(let j=0;j<l+1;j++){let X=j/l*XS,q=Math.sin(X)*a,k=(1-Math.cos(X))*a,Z=Math.sin(X),Q=Math.cos(X);$[b]=(H+q)*_,$[w]=(U-k)*S,F[x]=0,F[b]=Z*Math.sign($[b]),F[w]=Q*Math.sign($[w]);for(let K=0;K<G;K++){let W=K*I-L;$[x]=W*E,h.push($.x,$.y,$.z),d.push(F.x,F.y,F.z),f.push(K/D),f.push(0),z+=1}}for(let j=0;j<l;j++)for(let X=0;X<D;X++){let q=p+X+G*j,k=p+X+G*(j+1),Z=p+(X+1)+G*(j+1),Q=p+(X+1)+G*j;c.push(q,k,Q),c.push(k,Z,Q),V+=6}u.addGroup(m,V,P),m+=V,p+=z}function v(x,b,w){let E=new A,_=new A(t/2,e/2,n/2);_.subScalar(a);let S=[],T=x*b*w>0?(C,D,P)=>c.push(C,D,P):(C,D,P)=>c.push(C,P,D);for(let C=0;C<=l;C++){let D=[],P=XS*(1-C/l),I=Math.cos(P),L=Math.sin(P),H=0;for(let U=0;U<=C;U++){let G=Math.cos(H),z=Math.sin(H);E.x=I*G,E.y=L,E.z=I*z;let V=_.clone().addScaledVector(E,a);h.push(x*V.x,b*V.y,w*V.z),d.push(x*E.x,b*E.y,w*E.z),f.push(0,0),D.push(p++),H+=XS/C}S.push(D)}let M=S.length-1;for(let C=0;C<M;C++){let D=S[C],P=S[C+1],I=D.length-1;T(D[0],P[1],P[0]);for(let L=1;L<=I;L++)T(D[L-1],D[L],P[L]),T(D[L],P[L+1],P[L])}}}};var za=class extends Ae{constructor(t=[],e=[],n="",r=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),h(),this.setAttribute("position",new be(a,3)),this.setAttribute("normal",new be(u,3)),this.setAttribute("uv",new be(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],p=new A,m=p.clone(),g=new an,y=s*r,v=r-y,x=o+1,b=new A,w=(z,V)=>b.subVectors(z,V).normalize(),E=(z,V)=>Array(z).fill(void 0).map(V),_=E(t.length/3,(z,V)=>new A().fromArray(t,V*3).setLength(r)),S=[],T=1e6;for(let z=0;z<_.length;z++){let V=_[z],$=[],F,j,X,q=1e10,k=-1;for(;(k=e.indexOf(z,k+1))!=-1;){let W=k-k%3;F=e[W+(k+1)%3],j=e[W+(k+2)%3],X=V.distanceToSquared(_[F]),q=Math.min(q,X),$.push([F,j,X])}q+=1e-6;let Z=[],Q=0,K=$.length;for(let W=0;W<K;W++){[F,j,X]=$[Q];let ye=S[F]?.includes(z)==!0;X<=q&&Z.push(F+ +ye*T),Q=$.findIndex(fe=>fe[0]==j)}S.push(Z)}let M=[];{let z=0,V=0,$,F,j=f==3;for(let X=0;X<=o;X++){$=X*(X+1)/2,F=(X+1)*(X+2)/2;for(let q=0;q<o-X;q++)[z,V]=[$+q+X+2,F+q+X+3],M.push($,F,...j?[V,$]:[z,F],V,z),[$,F]=[z,V];M.push($,F,$+o+2)}}let C=p.clone(),D=p.clone(),P=p.clone(),I=p.clone(),L=p.clone(),H=[],U=E(_.length,()=>E(f,()=>p.clone()));for(let z=0;z<_.length;z++){p.copy(_[z]).normalize(),C.copy(p).multiplyScalar(v);let V=S[z];for(let Z=0;Z<V.length;Z++){let Q=V[Z],K=V[(Z+1)%f];g.setFromPointsAndIndices(_,z,Q%T,K%T),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,U[z][Z])}let $=[],F=[],j=[],X=new A;o==0&&[...U[z]].reduce((Z,Q)=>Z.add(Q),X).multiplyScalar(1/f);for(let Z=0;Z<f;Z++){let Q=[],K=(Z-1+f)%f,W=U[z][K],ye=U[z][Z];p.copy(W).sub(C),m.copy(ye).sub(C);let fe=C.angleTo(p),ie=p.angleTo(m),we=Math.cos(fe)*y;o==0?D.copy(X):D.copy(C).setLength(v+we),F.push(we);let xe=[D,W,ye];for(let Oe=0;Oe<2;Oe++){let Ie=xe[Oe],Pe=xe[Oe+1];I.subVectors(Ie,C),L.subVectors(Pe,C),P.crossVectors(I,L).normalize();for(let _e=0;_e<x;_e++){let Ve=[fe,ie][Oe]*_e/x;p.copy(I).applyAxisAngle(P,Ve).add(C),$.push(p.clone()),Oe&&(w(p,C),Q.push([_e==0?Ie:p.clone(),b.clone()]))}Oe&&(w(Pe,C),Q.push([Pe,b.clone()]))}j.push(Q)}H.push(j);let q=2*x,k=2;for(let Z=0;Z<f;Z++){let Q=q*Z,K=q*((Z+1)%f),W=[$[Q]];for(let fe=1;fe<x;fe++){I=$[Q+fe],L=$[K+fe],W.push(I);for(let ie=1,we=fe-k+1;ie<=we;ie++)p.lerpVectors(I,L,ie/(we+1)),p.sub(C).setLength(F[Z]).add(C),W.push(p.clone());W.push(L)}for(let fe=0;fe<x;fe++)W.push($[fe+x+Q]);W.push($[K+x]);let ye=M.map(fe=>W[fe]);a.push(...ye.map(fe=>[fe.x,fe.y,fe.z]).flat()),u.push(...ye.map(fe=>(w(fe,C),[b.x,b.y,b.z])).flat())}}let G=[];for(let z=0;z<S.length;z++)for(let V=0;V<f;V++){let $=S[z][V];if($<T){let F=S[$].findIndex(q=>q%T==z),j=H[z][V],X=H[$][F];for(let q=0;q<x;q++){let k=j[q],Z=X[x-q],Q=j[q+1],K=X[x-(q+1)];[k,Z,Q,Q,Z,K].forEach(W=>{a.push(W[0].x,W[0].y,W[0].z),u.push(W[1].x,W[1].y,W[1].z)})}G.push(j[0][0],X[x][0],j[x][0],X[0][0])}}for(;G.length;){let z,V,$,F;[z,V]=G.splice(0,2);let j=[z];for(;z!=V;)j.push(V),$=G.indexOf(V),F=$%2,V=G.splice($-F,2)[1-F];b.subVectors(j[0],j[1]).cross(p.subVectors(j[0],j[2])).normalize();let X=b.dot(j[0])<0;X&&b.negate();for(let q=1;q<=j.length-2;q++)[j[q+ +X],j[q+1-+X],j[0]].forEach(k=>{a.push(k.x,k.y,k.z),u.push(b.x,b.y,b.z)})}}function h(){let d=new A;for(let _=0;_<a.length;_+=3){d.x=a[_+0],d.y=a[_+1],d.z=a[_+2];let S=w(d)/2/Math.PI+.5,T=E(d)/Math.PI+.5;l.push(S,1-T)}let f=new A,p=new A,m=new A,g=new A,y=new B,v=new B,x=new B,b=(_,S,T,M)=>{M<0&&_.x===1&&(l[S]=_.x-1),T.x===0&&T.z===0&&(l[S]=M/2/Math.PI+.5)};for(let _=0,S=0;_<a.length;_+=9,S+=6){f.set(a[_+0],a[_+1],a[_+2]),p.set(a[_+3],a[_+4],a[_+5]),m.set(a[_+6],a[_+7],a[_+8]),y.set(l[S+0],l[S+1]),v.set(l[S+2],l[S+3]),x.set(l[S+4],l[S+5]),g.copy(f).add(p).add(m).divideScalar(3);let T=w(g);b(y,S+0,f,T),b(v,S+2,p,T),b(x,S+4,m,T)}for(let _=0;_<l.length;_+=6){let S=l[_+0],T=l[_+2],M=l[_+4],C=Math.max(S,T,M),D=Math.min(S,T,M);C>.9&&D<.1&&(S<.2&&(l[_+0]+=1),T<.2&&(l[_+2]+=1),M<.2&&(l[_+4]+=1))}function w(_){return Math.atan2(_.z,-_.x)}function E(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(t){return new za(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var o2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,detail:r,corner:s,cornerSides:o}=i.parameters,a=r===0&&s!==0?new Wf(t*.5,s,o):new zc(t*.5,r);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},Wf=class extends za{constructor(t=1,e=.2,n=4){let r=(1+Math.sqrt(5))/2,s=1/r,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,n),this.type=l}static fromJSON(t){return new Wf(t.radius,t.corner,t.cornerSides)}};var qf=1e-12,ph=class{constructor(t){this.position=new B;this.startPosition=new B;this.uuid=Te.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new ph(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},mh=class extends ph{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new mh(this.parent).copy(this)}},os=class extends ph{constructor(e,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new mh(this),new mh(this))}static create(e,n){let r=new os(e,new B(...n.position));return r.controls[0].position.set(...n.controlPrevious.position),r.controls[1].position.set(...n.controlNext.position),r.roundness=n.roundness,r.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,r}getOppositeControl(e){let n=this.controls.indexOf(e);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(e,n=1){for(let r=0,s=this.controls.length;r<s;r++){let o=this.controls[r];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new os(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),n=this.curveAfter?.getTangentAt(0);return[e,n]}computeNormals(e=new B,n=new B){let[r,s]=this.computeTangents();return r&&s&&(a2(r,e),a2(s,n)),[e,n]}computeTangent(e=new B){let[n,r]=this.computeTangents();return n&&r&&e.copy(n).add(r).normalize(),e}computeNormal(e=new B){let[n,r]=this.computeNormals();return e.copy(n).add(r).normalize(),e}};function a2(i,t=new B){let e=i.length();return t.set(-i.y/e,i.x/e)}var ZS=i=>i,gh=new B,zy=new B,JW=new B,$W=new B,e6=new B,t6=new B,c2=new A,u2=new A;function h2(i){let t=new B;t.addVectors(i.v0,gh.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new B;return e.addVectors(i.v2,zy.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Dr(i.v0,t,e,i.v2)}function Yf(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function n6(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function r6(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function JS(i,t,e){let n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((r*r+n*n-s*s)/(2*r*n))}function d2(i,t,e){return l2(i,t)&&l2(t,e)&&QS(i.position,t.position,e.position)}function QS(i,t,e){return gh.copy(t).sub(i).cross(zy.copy(e).sub(i))===0}function f2(i,t,e,n,r){let s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=(i.y+t.y)/2,a=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(i.y-t.y)/s,u=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-i.x)/s;return n.set(a+l,o+u),r.set(a-l,o-u),[n,r]}function p2(i,t,e){let n=i.distanceTo(e),r=t.distanceTo(e);return n<r?t:i}function m2(i,t,e,n,r,s){let o=t.x-i.x,a=t.y-i.y,l=e.x-i.x,u=e.y-i.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),h;return JS(t,i,e)>Math.PI&&(c*=-1),Yf(u,a)?h=(a+u)*(n/c-.5)*8/3/(o-l):h=(o+l)*(n/c-.5)*8/3/(u-a),r.set(t.x-h*a,t.y+h*o),s.set(e.x+h*u,e.y-h*l),[r,s]}function $S(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function l2(i,t){return QS(i.position,i.controls[1].position,t.position)&&QS(i.position,t.controls[0].position,t.position)}function g2(i,t,e,n,r=.5){let s=gh.subVectors(t,i).multiplyScalar(r).add(i),o=zy.subVectors(e,t).multiplyScalar(r).add(t),a=JW.subVectors(n,e).multiplyScalar(r).add(e),l=s,u=$W.subVectors(o,s).multiplyScalar(r).add(s),c=e6.subVectors(a,o).multiplyScalar(r).add(o),h=a,d=t6.subVectors(c,u).multiplyScalar(r).add(u);return[i.x,i.y,l.x,l.y,u.x,u.y,d.x,d.y,c.x,c.y,h.x,h.y,n.x,n.y]}function y2(i,t,e=12,n=!0){let r=u2.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=ZS(t[l]),c=gh,h=Ga(u,e);a.push(h);for(let d=0;d<=h;d++)if(u instanceof Dr||u instanceof mi||u instanceof Ir){if(u.getPoint(d/h,c),r.set(c.x,c.y,0),s!==void 0&&r6(s,r))continue;s===void 0&&(s=c2),s.copy(r),i.setXYZ(o,r.x,r.y,r.z),o++}}return n&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),i}function v2(i,t,e,n=12,r=!0){let s=u2.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=ZS(t[l]),h=gh,d=Ga(c,n);a.push(d);for(let f=0;f<=d;f++)if(c instanceof Dr||c instanceof mi||c instanceof Ir){if(c.getPoint(f/d,h),s.set(h.x,h.y,0),u?.equals(s))continue;u===void 0?u=c2:(i.setXYZ(o,u.x,u.y,u.z),o++,i.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return r&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),a}function ew(i,t=12,e=!1){let n=[];for(let r=0,s=i.length;r<s;r++){let o=i[r],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=Ga(o.roundedCurveCorner,t)*.5;r>0&&(n[r-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Ga(o.curveAfter,t)),n.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(n[i.length-1]+=Ga(i[0].roundedCurveCorner,t)*.5),n}function Ga(i,t=12){return i&&i instanceof Sl?t*2:i&&(i instanceof Ir||i instanceof sf)?1:i&&i instanceof Fc?t*i.points.length:t}function x2(i,t,e=12,n=!0){let r,s=0;for(let o=0;o<t.length;o++){let a=ZS(t[o]),l=Ga(a,e),u=gh;for(let c=0;c<=l;c++)if(a instanceof Dr||a instanceof mi||a instanceof Ir){if(a.getPoint(c/l,u),r!==void 0&&n6(r,u,qf))continue;r===void 0&&(r=zy),r.copy(u),i.push(u.x,u.y),s++}}return Yf(i[0],i[i.length-2],qf)&&Yf(i[1],i[i.length-1],qf)&&(i.pop(),i.pop()),n&&s>1&&!(Yf(i[s-1],i[1],qf)&&Yf(i[s-2],i[0],qf))&&(i.push(i[0],i[1]),s++),i}var tw=new B,i6=new B,s6=new B,o6=new B,a6=new B,l6=new B,Pt=class extends _o{constructor(e=100,n=100){super();this.points=[];this.shapeHoles=[];this.plane=new En(new A(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Te.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=n}static createFromState(e,n,r){let s=new Pt;return s.isClosed=e.isClosed,s.points=e.points.map(o=>os.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Pt.createFromState(o)),n!==void 0&&r!==void 0&&s.applySize(n,r),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let n=0,r=this.points.length;n<r;n++)this.points[n].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(e){let n=this.points.length,r=this.points.findIndex(s=>s.uuid===e);if(r<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(e);if(c<0)s+=u;else return c+s}}return r}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let n=this.points.length;for(let r=0,s=this.shapeHoles.length;r<s;r++){let o=this.shapeHoles[r],a=e-n;if(a<=o.points.length-1)return o.points[a];n+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let n=this.points.indexOf(e);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let r=0,s=this.shapeHoles.length;r<s;r++){let o=this.shapeHoles[r],a=o.points.indexOf(e);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...e]}applySize(e,n){e===0&&(e=.001),n===0&&(n=.001),this._width=e,this._height=n}applyScale(e,n){let r=tw.set(e,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(r),a.controls[0].position.multiply(r),a.controls[1].position.multiply(r)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,n);this._update()}createPoint(e,n=0,r=Te.generateUUID()){let s;e instanceof B?s=e:s=new B(e,n);let o=new os(r,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,n){this.points.splice(n,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let n=0,r=this.points.length;n<r;n++){let s=this.points[n];if(s.uuid===e)return s}for(let n=0,r=this.shapeHoles.length;n<r;n++){let o=this.shapeHoles[n].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let n=this.points.indexOf(e);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(e){let n=this.points.find(r=>r.uuid===e);n&&this.removePoint(n)}update(){for(let e=0,n=this.shapeHoles.length;e<n;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,n=12,r=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=r?this.roundedCurveDivisions:this.curveDivisions;return y2(e,r?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=ew(this.points,e,!1),this.roundedCurveDivisions=ew(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,n,r=12){return v2(e,this.curves,n,r,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),x2(e,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(e,n=!1){let r=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=Ga(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l<u;l++){let c=s[l];if(a<r+c)return[l,(a-r+1)/c];r+=c}return[0,1]}getCurveT(e,n,r){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if($S(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(tw.set(r.x,r.y))/h}let u=0;for(let h=0;h<e;h++)u+=a[h];return(n-u)/l}dispose(){}_applyCurveForPoint(e,n){$S(n,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let r=this.curves[this.curves.length-1];e.curveBefore=r,n.curveAfter=r;let s=r.clone();e.roundedCurveBefore=s,n.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let n=0,r=this.points.length;n<r;n++){let s=this.points[n];if(n===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[n-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let n=this.points[0],r=this.points[this.points.length-1];this._applyCurveForPoint(n,r)}if(this.points.length>2){let n=0;for(let r=0,s=this.points.length;r<s;r++){let o=this.points[r],a=this.points[r-1]??this.points[this.points.length-1],l=this.points[r+1]??this.points[0],u=o.roundness,c=a&&l&&d2(a,o,l);if(!o.controlsMoved()&&u>0&&!c){let h=o.curveBefore,d=o.curveAfter;if(h===void 0||d===void 0)continue;let f=o.roundedCurveBefore,p=o.roundedCurveAfter,m=h.getLength(),g=d.getLength(),y=Math.min(u,m*.499),v=Math.min(u,g*.499),x=Math.min(y,v),b=1-x/m,w=x/g,E=h.getPointAt(b,tw),_=d.getPointAt(w,i6);this._subSplitCurve(h,f,b,E,void 0),this._subSplitCurve(d,p,w,void 0,_);let S;if(this.useCubicForRoundedCorners){let T=JS(E,o.position,_)/2,M=Math.tan(T)*E.distanceTo(o.position),[C,D]=f2(E,_,M,s6,o6),P=p2(C,D,o.position),[I,L]=m2(P,E,_,M,a6,l6);S=new Dr(E.clone(),I.clone(),L.clone(),_.clone())}else S=new mi(E.clone(),o.position.clone(),_.clone());o.roundedCurveCorner=S,this.roundedCurves.splice(r+n,0,S),n++}}}}_subSplitCurve(e,n,r,s,o){if(e instanceof Ir)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=e,l=n,u=a.getUtoTmapping(r,0),c=g2(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return n}clone(){let e=new Pt(this._width,this._height);return e.points=this.points.map(n=>n.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(n=>n.clone()),e}toJSON(){return{points:this.points.reduce((e,n)=>e.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let n=e.points.length/7;for(let r=0;r<n;r++){let s=r*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],u=e.points[s+3],c=e.points[s+4],h=e.points[s+5],d=e.points[s+6],f=new os(Te.generateUUID(),new B(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,h),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(r=>{let s=new Pt;return s.fromJSON(r),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let n=(s,o)=>{o instanceof Dr&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},r=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof mi&&(s[a]=h2(s[a]));for(a=0,l=s.length;a<l;a++){let h=s[a],d=a>0?s[a-1]:null,f;h instanceof Dr?(f=this.createPoint(h.v0),f.controls[1].position.copy(h.v1)):h instanceof Ir&&(f=this.createPoint(h.v1)),f!==void 0&&(d!==null&&n(f,d),o.push(f))}let u=s[s.length-1],c=!1;return u instanceof Dr?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof Ir&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=r(e.curves),e instanceof _o&&(this.shapeHoles=e.holes.map(s=>{let o=new Pt;return o.fromShape(s),o})),this.update(),this}updatePoint(e,n){let r=this.getPointByUuid(e);r&&(n.position!==void 0&&r.position.fromArray(n.position),n.roundness!==void 0&&(r.roundness=n.roundness),n.areControlsDirectionsMirrored!==void 0&&(r.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,n){let s=this.getPointByUuid(e)?.controls[0];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}updateNextControl(e,n){let s=this.getPointByUuid(e)?.controls[1];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}};var rw=Math.PI*2;function nw({x:i,y:t},e,n,r,s){return{x:i*e+r,y:t*n+s}}function c6(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),n=Math.cos(i),r=Math.sin(i),s=Math.cos(i+t),o=Math.sin(i+t);return[{x:n-r*e,y:r+n*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function b2(i,t,e,n){let r=i*n-t*e<0?-1:1,s=Math.min(1,Math.max(-1,i*e+t*n));return r*Math.acos(s)}function u6(i,t,e,n,r,s,o,a,l,u){let c=Math.pow(r,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),p=c*h-c*f-h*d;p<0&&(p=0),p/=c*f+h*d,p=Math.sqrt(p)*(l===u?-1:1);let m=p*r/s*a,g=p*-s/r*o,y=m+(i+e)/2,v=g+(t+n)/2,x=(o-m)/r,b=(a-g)/s,w=(-o-m)/r,E=(-a-g)/s,_=b2(1,0,x,b),S=b2(x,b,w,E);return!u&&S>0&&(S-=rw),u&&S<0&&(S+=rw),{centerx:y,centery:v,ang1:_,ang2:S}}function S2({px:i,py:t,cx:e,cy:n,rx:r,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(r===0||s===0)return[];let u=(i-e)/2,c=(t-n)/2;if(u===0&&c===0)return[];r=Math.abs(r),s=Math.abs(s);let h=Math.pow(u,2)/Math.pow(r,2)+Math.pow(c,2)/Math.pow(s,2);h>1&&(r*=Math.sqrt(h),s*=Math.sqrt(h));let d=u6(i,t,e,n,r,s,u,c,o,a),{ang1:f,ang2:p}=d,{centerx:m,centery:g}=d,y=Math.abs(p)/(rw/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);p/=v;for(let x=0;x<v;x++)l.push(c6(f,p)),f+=p;return l.map(x=>{let{x:b,y:w}=nw(x[0],r,s,m,g),{x:E,y:_}=nw(x[1],r,s,m,g),{x:S,y:T}=nw(x[2],r,s,m,g);return{x1:b,y1:w,x2:E,y2:_,x:S,y:T}})}var xt;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(xt||(xt={}));var pn;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(pn||(pn={}));function nt(i,t){if(!i)throw t||"Assertion Failed!"}var Qe=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,n){nt(i.vertLeq(t,e)&&i.vertLeq(e,n));var r=e.s-t.s,s=n.s-e.s;return r+s>0?r<s?e.t-t.t+(t.t-n.t)*(r/(r+s)):e.t-n.t+(n.t-t.t)*(s/(r+s)):0},i.edgeSign=function(t,e,n){nt(i.vertLeq(t,e)&&i.vertLeq(e,n));var r=e.s-t.s,s=n.s-e.s;return r+s>0?(e.t-n.t)*r+(e.t-t.t)*s:0},i.transEval=function(t,e,n){nt(i.transLeq(t,e)&&i.transLeq(e,n));var r=e.t-t.t,s=n.t-e.t;return r+s>0?r<s?e.s-t.s+(t.s-n.s)*(r/(r+s)):e.s-n.s+(n.s-t.s)*(s/(r+s)):0},i.transSign=function(t,e,n){nt(i.transLeq(t,e)&&i.transLeq(e,n));var r=e.t-t.t,s=n.t-e.t;return r+s>0?(e.s-n.s)*r+(e.s-t.s)*s:0},i.vertCCW=function(t,e,n){return t.s*(e.t-n.t)+e.s*(n.t-t.t)+n.s*(t.t-e.t)>=0},i.interpolate=function(t,e,n,r){return t=t<0?0:t,n=n<0?0:n,t<=n?n===0?(e+r)/2:e+(r-e)*(t/(t+n)):r+(e-r)*(n/(t+n))},i.intersect=function(t,e,n,r,s){var o,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(n,r)||(l=n,n=r,r=l),i.vertLeq(t,n)||(l=t,t=n,n=l,l=e,e=r,r=l),i.vertLeq(n,e)?i.vertLeq(e,r)?(o=i.edgeEval(t,n,e),a=i.edgeEval(n,e,r),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,n.s,a,e.s)):(o=i.edgeSign(t,n,e),a=-i.edgeSign(t,r,e),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,n.s,a,r.s)):s.s=(n.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(n,r)||(l=n,n=r,r=l),i.transLeq(t,n)||(l=t,t=n,n=l,l=e,e=r,r=l),i.transLeq(n,e)?i.transLeq(e,r)?(o=i.transEval(t,n,e),a=i.transEval(n,e,r),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,n.t,a,e.t)):(o=i.transSign(t,n,e),a=-i.transSign(t,r,e),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,n.t,a,r.t)):s.t=(n.t+e.t)/2},i}(),Xf=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),Gy=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),yh=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),w2=function(){function i(){var t=new yh,e=new Xf,n=new Gy(0),r=new Gy(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,n.next=n,n.Sym=r,r.next=r,r.Sym=n,this.vHead=t,this.fHead=e,this.eHead=n,this.eHeadSym=r}return i.prototype.makeEdge_=function(t){var e=new Gy(0),n=new Gy(1);t.Sym.side<t.side&&(t=t.Sym);var r=t.Sym.next;return n.next=r,r.Sym.next=e,e.next=t,t.Sym.next=n,e.Sym=n,e.Onext=e,e.Lnext=n,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,n.Sym=e,n.Onext=n,n.Lnext=e,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,e},i.prototype.splice_=function(t,e){var n=t.Onext,r=e.Onext;n.Sym.Lnext=e,r.Sym.Lnext=t,t.Onext=r,e.Onext=n},i.prototype.makeVertex_=function(t,e,n){var r=t;nt(r,"Vertex can't be null!");var s=n.prev;r.prev=s,s.next=r,r.next=n,n.prev=r,r.anEdge=e;var o=e;do o.Org=r,o=o.Onext;while(o!==e)},i.prototype.makeFace_=function(t,e,n){var r=t;nt(r,"Face can't be null");var s=n.prev;r.prev=s,s.next=r,r.next=n,n.prev=r,r.anEdge=e,r.trail=null,r.marked=!1,r.inside=n.inside;var o=e;do o.Lface=r,o=o.Lnext;while(o!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,n=t.Sym.next;e.Sym.next=n,n.Sym.next=e},i.prototype.killVertex_=function(t,e){var n=t.anEdge,r=n;do r.Org=e,r=r.Onext;while(r!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.killFace_=function(t,e){var n=t.anEdge,r=n;do r.Lface=e,r=r.Lnext;while(r!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.makeEdge=function(){var t=new yh,e=new yh,n=new Xf,r=this.makeEdge_(this.eHead);return this.makeVertex_(t,r,this.vHead),this.makeVertex_(e,r.Sym,this.vHead),this.makeFace_(n,r,this.fHead),r},i.prototype.splice=function(t,e){var n=!1,r=!1;if(t!==e){if(e.Org!==t.Org&&(r=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!r){var s=new yh;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!n){var o=new Xf;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,n=!1;if(t.Lface!==t.Rface&&(n=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!n){var r=new Xf;this.makeFace_(r,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),n=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var r=new yh;return this.makeVertex_(r,n,e.Org),e.Lface=n.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),n=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,n),t.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=t.Rface,n.winding=t.winding,n.Sym.winding=t.Sym.winding,n.idx=t.idx,n.Sym.idx=t.Sym.idx,n},i.prototype.connect=function(t,e){var n=!1,r=this.makeEdge_(t),s=r.Sym;if(e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(r,t.Lnext),this.splice_(s,e),r.Org=t.Dst,s.Org=e.Org,r.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!n){var o=new Xf;this.makeFace_(o,r,t.Lface)}return r},i.prototype.zapFace=function(t){var e=t.anEdge,n,r,s,o,a;r=e.Lnext;do n=r,r=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,n=0;do n++,e=e.Lnext;while(e!==t.anEdge);return n},i.prototype.mergeConvexFaces=function(t){var e,n,r,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(n=e.anEdge,o=n.Org;r=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&Qe.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&Qe.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(r=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=r;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,n=this.eHead,r,s,o,a,l,u;for(s=t,s=t;(r=s.next)!==t;s=r){nt(r.prev===s),l=r.anEdge;do nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l),nt(l.Lface===r),l=l.Lnext;while(l!==r.anEdge)}for(nt(r.prev===s&&r.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){nt(o.prev===a),l=o.anEdge;do nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l),nt(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(nt(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)nt(l.Sym.next===u.Sym),nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Org!==null),nt(l.Dst!==null),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l);nt(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),A2=function(){function i(){this.handle=null}return i}(),E2=function(){function i(){this.key=null,this.node=0}return i}(),h6=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var n=0;n<t+1;n++)this.nodes[n]=new A2,this.handles[n]=new E2;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,n=this.handles,r,s,o;for(r=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(n[e[o+1].handle].key,n[e[o].handle].key)&&++o,nt(o<=this.max),s=e[o].handle,o>this.size||this.leq(n[r].key,n[s].key)){e[t].handle=r,n[r].node=t;break}e[t].handle=s,n[s].node=t,t=o}},i.prototype.floatUp_=function(t){var e=this.nodes,n=this.handles,r,s,o;for(r=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(n[s].key,n[r].key)){e[t].handle=r,n[r].node=t;break}e[t].handle=s,n[s].node=t,t=o}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,n;if(e=++this.size,e*2>this.max){this.max*=2;var r,s;for(s=this.nodes.length,this.nodes.length=this.max+1,r=s;r<this.nodes.length;r++)this.nodes[r]=new A2;for(s=this.handles.length,this.handles.length=this.max+1,r=s;r<this.handles.length;r++)this.handles[r]=new E2}return this.freeList===0?n=e:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[e].handle=n,this.handles[n].node=e,this.handles[n].key=t,this.initialized&&this.floatUp_(e),n},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,n=t[1].handle,r=e[n].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[n].key=null,e[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),r},i.prototype.delete=function(t){var e=this.nodes,n=this.handles,r;nt(t>=1&&t<=this.max&&n[t].key!==null),r=n[t].node,e[r].handle=e[this.size].handle,n[e[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(n[e[r>>1].handle].key,n[e[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),n[t].key=null,n[t].node=this.freeList,this.freeList=t},i}(),iw=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),_2=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),d6=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new _2,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var n=new _2;return n.key=e,n.next=t.next,t.next.prev=n,n.prev=t,t.next=n,n},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),f6=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,n){var r=t.event,s=e.eUp,o=n.eUp;if(s.Dst===r)return o.Dst===r?Qe.vertLeq(s.Org,o.Org)?Qe.edgeSign(o.Dst,s.Org,o.Org)<=0:Qe.edgeSign(s.Dst,o.Org,s.Org)>=0:Qe.edgeSign(o.Dst,r,o.Org)<=0;if(o.Dst===r)return Qe.edgeSign(s.Dst,r,s.Org)>=0;var a=Qe.edgeEval(s.Dst,r,s.Org),l=Qe.edgeEval(o.Dst,r,o.Org);return a>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&nt(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,n){nt(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=n,n.activeRegion=e},i.topLeftRegion=function(t,e){var n=e.eUp.Org,r;do e=i.regionAbove(e);while(e.eUp.Org===n);if(e.fixUpperEdge){if(r=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),r===null)return null;i.fixUpperEdge(t,e,r),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,n){var r=new iw;return r.eUp=n,r.nodeUp=t.dict.insertBefore(e.nodeUp,r),r.fixUpperEdge=!1,r.sentinel=!1,r.dirty=!1,n.activeRegion=r,r},i.isWindingInside=function(t,e){switch(t.windingRule){case xt.ODD:return(e&1)!==0;case xt.NONZERO:return e!==0;case xt.POSITIVE:return e>0;case xt.NEGATIVE:return e<0;case xt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var n=e.eUp,r=n.Lface;r.inside=e.inside,r.anEdge=n,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,n){for(var r,s=null,o=e,a=e.eUp;o!==n;){if(o.fixUpperEdge=!1,s=i.regionBelow(o),r=s.eUp,r.Org!=a.Org){if(!s.fixUpperEdge){i.finishRegion(t,o);break}r=t.mesh.connect(a.Lprev,r.Sym),i.fixUpperEdge(t,s,r)}a.Onext!==r&&(t.mesh.splice(r.Oprev,r),t.mesh.splice(a,r)),i.finishRegion(t,o),a=s.eUp,o=s}return a},i.addRightEdges=function(t,e,n,r,s,o){var a,l,u,c,h=!0;u=n;do nt(Qe.vertLeq(u.Org,u.Dst)),i.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==r);for(s===null&&(s=i.regionBelow(e).eUp.Rprev),l=e,c=s;a=i.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=i.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&i.checkForRightSplice(t,l)&&(i.addWinding(u,c),i.deleteRegion(t,l),t.mesh.delete(c)),h=!1,l=a,c=u;l.dirty=!0,nt(l.windingNumber-u.winding===a.windingNumber),o&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,n){t.mesh.splice(e,n)},i.vertexWeights=function(t,e,n){var r=Qe.vertL1dist(e,t),s=Qe.vertL1dist(n,t),o=.5*s/(r+s),a=.5*r/(r+s);t.coords[0]+=o*e.coords[0]+a*n.coords[0],t.coords[1]+=o*e.coords[1]+a*n.coords[1],t.coords[2]+=o*e.coords[2]+a*n.coords[2]},i.getIntersectData=function(t,e,n,r,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,n,r),i.vertexWeights(e,s,o)},i.checkForRightSplice=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp;if(Qe.vertLeq(r.Org,s.Org)){if(Qe.edgeSign(s.Dst,r.Org,s.Org)>0)return!1;Qe.vertEq(r.Org,s.Org)?r.Org!==s.Org&&(t.pq.delete(r.Org.pqHandle),i.spliceMergeVertices(t,s.Oprev,r)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(r,s.Oprev),e.dirty=n.dirty=!0)}else{if(Qe.edgeSign(r.Dst,s.Org,r.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(r.Sym),t.mesh.splice(s.Oprev,r)}return!0},i.checkForLeftSplice=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp,o;if(nt(!Qe.vertEq(r.Dst,s.Dst)),Qe.vertLeq(r.Dst,s.Dst)){if(Qe.edgeSign(r.Dst,s.Dst,r.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(r),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(Qe.edgeSign(s.Dst,r.Dst,s.Org)>0)return!1;e.dirty=n.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(r.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp,o=r.Org,a=s.Org,l=r.Dst,u=s.Dst,c,h,d=new yh,f,p;if(nt(!Qe.vertEq(u,l)),nt(Qe.edgeSign(l,t.event,o)<=0),nt(Qe.edgeSign(u,t.event,a)>=0),nt(o!==t.event&&a!==t.event),nt(!e.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),h=Math.max(a.t,u.t),c>h))return!1;if(Qe.vertLeq(o,a)){if(Qe.edgeSign(u,o,a)>0)return!1}else if(Qe.edgeSign(l,a,o)<0)return!1;return i.debugEvent(t),Qe.intersect(l,o,u,a,d),nt(Math.min(o.t,l.t)<=d.t),nt(d.t<=Math.max(a.t,u.t)),nt(Math.min(u.s,l.s)<=d.s),nt(d.s<=Math.max(a.s,o.s)),Qe.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=Qe.vertLeq(o,a)?o:a,Qe.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),Qe.vertEq(d,o)||Qe.vertEq(d,a)?(i.checkForRightSplice(t,e),!1):!Qe.vertEq(l,t.event)&&Qe.edgeSign(l,t.event,d)>=0||!Qe.vertEq(u,t.event)&&Qe.edgeSign(u,t.event,d)<=0?u===t.event?(t.mesh.splitEdge(r.Sym),t.mesh.splice(s.Sym,r),e=i.topLeftRegion(t,e),r=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),n),i.addRightEdges(t,e,r.Oprev,r,r,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(r.Lnext,s.Oprev),n=e,e=i.topRightRegion(e),p=i.regionBelow(e).eUp.Rprev,n.eUp=s.Oprev,s=i.finishLeftRegions(t,n,null),i.addRightEdges(t,e,s.Onext,r.Rprev,p,!0),!0):(Qe.edgeSign(l,t.event,d)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(r.Sym),r.Org.s=t.event.s,r.Org.t=t.event.t),Qe.edgeSign(u,t.event,d)<=0&&(e.dirty=n.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(r.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,r),r.Org.s=d.s,r.Org.t=d.t,r.Org.pqHandle=t.pq.insert(r.Org),i.getIntersectData(t,r.Org,o,l,a,u),i.regionAbove(e).dirty=e.dirty=n.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var n=i.regionBelow(e),r,s;;){for(;n.dirty;)e=n,n=i.regionBelow(n);if(!e.dirty&&(n=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,r=e.eUp,s=n.eUp,r.Dst!==s.Dst&&i.checkForLeftSplice(t,e)&&(n.fixUpperEdge?(i.deleteRegion(t,n),t.mesh.delete(s),n=i.regionBelow(e),s=n.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(r),e=i.regionAbove(n),r=e.eUp)),r.Org!==s.Org)if(r.Dst!==s.Dst&&!e.fixUpperEdge&&!n.fixUpperEdge&&(r.Dst===t.event||s.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);r.Org===s.Org&&r.Dst===s.Dst&&(i.addWinding(s,r),i.deleteRegion(t,e),t.mesh.delete(r),e=i.regionAbove(n))}},i.connectRightVertex=function(t,e,n){var r,s=n.Onext,o=i.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),Qe.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=i.topLeftRegion(t,e),s=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),o),u=!0),Qe.vertEq(l.Org,t.event)&&(t.mesh.splice(n,l.Oprev),n=i.finishLeftRegions(t,o,null),u=!0),u){i.addRightEdges(t,e,n.Onext,s,s,!0);return}Qe.vertLeq(l.Org,a.Org)?r=l.Oprev:r=a,r=t.mesh.connect(n.Lprev,r),i.addRightEdges(t,e,r,r.Onext,r.Onext,!1),r.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,n){var r,s,o,a,l;if(r=e.eUp,Qe.vertEq(r.Org,n)){nt(!1),i.spliceMergeVertices(t,r,n.anEdge);return}if(!Qe.vertEq(r.Dst,n)){t.mesh.splitEdge(r.Sym),e.fixUpperEdge&&(t.mesh.delete(r.Onext),e.fixUpperEdge=!1),t.mesh.splice(n.anEdge,r),i.sweepEvent(t,n);return}nt(!1),e=i.topRightRegion(e),l=i.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(nt(s!==o),i.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(n.anEdge,o),Qe.edgeGoesLeft(s)||(s=null),i.addRightEdges(t,e,o.Onext,a,s,!0)},i.connectLeftVertex=function(t,e){var n,r,s,o,a,l,u=new iw;if(u.eUp=e.anEdge.Sym,n=t.dict.search(u).key,r=i.regionBelow(n),!!r){if(o=n.eUp,a=r.eUp,Qe.edgeSign(o.Dst,e,o.Org)===0){i.connectLeftDegenerate(t,n,e);return}if(s=Qe.vertLeq(a.Dst,o.Dst)?n:r,n.inside||s.fixUpperEdge){if(s===n)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var c=t.mesh.connect(a.Dnext,e.anEdge);l=c.Sym}s.fixUpperEdge?i.fixUpperEdge(t,s,l):i.computeWinding(t,i.addRegionBelow(t,n,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,n,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var n=e.anEdge;n.activeRegion===null;)if(n=n.Onext,n===e.anEdge){i.connectLeftVertex(t,e);return}var r=i.topLeftRegion(t,n.activeRegion);nt(r!==null);var s=i.regionBelow(r),o=s.eUp,a=i.finishLeftRegions(t,s,null);a.Onext===o?i.connectRightVertex(t,r,a):i.addRightEdges(t,r,a.Onext,o,o,!0)},i.addSentinel=function(t,e,n,r){var s=new iw,o=t.mesh.makeEdge();o.Org.s=n,o.Org.t=r,o.Dst.s=e,o.Dst.t=r,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},i.initEdgeDict=function(t){t.dict=new d6(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],n=t.bmax[1]-t.bmin[1],r=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-n,a=t.bmax[1]+n;i.addSentinel(t,r,s,o),i.addSentinel(t,r,s,a)},i.doneEdgeDict=function(t){for(var e,n=0;(e=t.dict.min().key)!==null;)e.sentinel||(nt(e.fixUpperEdge),nt(++n===1)),nt(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,n,r,s=t.mesh.eHead;for(e=s.next;e!==s;e=n)n=e.next,r=e.Lnext,Qe.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,r,e),t.mesh.delete(e),e=r,r=e.Lnext),r.Lnext===e&&(r!==e&&((r===n||r===n.Sym)&&(n=n.next),t.mesh.delete(r)),(e===n||e===n.Sym)&&(n=n.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,n,r,s=0;for(r=t.mesh.vHead,n=r.next;n!==r;n=n.next)s++;for(s+=8,e=t.pq=new h6(s,Qe.vertLeq),r=t.mesh.vHead,n=r.next;n!==r;n=n.next)n.pqHandle=e.insert(n);return n!==r?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var n,r,s;for(n=e.fHead.next;n!==e.fHead;n=r)r=n.next,s=n.anEdge,nt(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),t.mesh.delete(s));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var n,r;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(n=t.pq.extractMin())!==null;){for(;r=t.pq.min(),!(r===null||!Qe.vertEq(r,n));)r=t.pq.extractMin(),i.spliceMergeVertices(t,n.anEdge,r.anEdge);i.sweepEvent(t,n)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),p6=function(){function i(){this.mesh=new w2,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=xt.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,n,r,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],p=[null,null,null],m=this.mesh.vHead;e=m.next;for(var g=0;g<3;++g)s=e.coords[g],u[g]=s,p[g]=e,l[g]=s,f[g]=e;for(e=m.next;e!==m;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<u[y]&&(u[y]=s,p[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-u[1]>l[0]-u[0]&&(v=1),l[2]-u[2]>l[v]-u[v]&&(v=2),u[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,n=p[v],r=f[v],c[0]=n.coords[0]-r.coords[0],c[1]=n.coords[1]-r.coords[1],c[2]=n.coords[2]-r.coords[2],e=m.next;e!==m;e=e.next)h[0]=e.coords[0]-r.coords[0],h[1]=e.coords[1]-r.coords[1],h[2]=e.coords[2]-r.coords[2],d[0]=c[1]*h[2]-c[2]*h[1],d[1]=c[2]*h[0]-c[0]*h[2],d[2]=c[0]*h[1]-c[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,t[0]=d[0],t[1]=d[1],t[2]=d[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,n=this.mesh.vHead,r,s=0,o=t.next;o!==t;o=o.next)if(r=o.anEdge,!(r.winding<=0))do s+=(r.Org.s-r.Dst.s)*(r.Org.t+r.Dst.t),r=r.Lnext;while(r!==o.anEdge);if(s<0){for(e=n.next;e!==n;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],n,r,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),n=this.sUnit,r=this.tUnit;var o=this.longAxis_(e);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,r[o]=0,r[(o+1)%3]=0,r[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,r);s&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var n,r;if(n=e.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;Qe.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;Qe.vertLeq(n.Org,n.Dst);n=n.Lnext);r=n.Lprev;for(var s=void 0;n.Lnext!==r;)if(Qe.vertLeq(n.Dst,r.Org)){for(;r.Lnext!==n&&(Qe.edgeGoesLeft(r.Lnext)||Qe.edgeSign(r.Org,r.Dst,r.Lnext.Dst)<=0);)s=t.connect(r.Lnext,r),r=s.Sym;r=r.Lprev}else{for(;r.Lnext!==n&&(Qe.edgeGoesRight(n.Lprev)||Qe.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=t.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(r.Lnext===n)throw"Mono region invalid";for(;r.Lnext.Lnext!==n;)s=t.connect(r.Lnext,r),r=s.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)if(e=n.next,n.inside&&!this.tessellateMonoRegion_(t,n))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)e=n.next,n.inside||t.zapFace(n)},i.prototype.setWindingNumber_=function(t,e,n){for(var r,s=t.eHead.next;s!==t.eHead;s=r)r=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:n?t.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,n,r){var s,o=0,a=0,l;n>3&&t.mergeConvexFaces(n);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>n)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,e===pn.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*r,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var h=u.n*r;this.vertices[h+0]=u.coords[0],this.vertices[h+1]=u.coords[1],r>2&&(this.vertices[h+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var d=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[d++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[d++]=-1;if(e===pn.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var p=l;p<n;++p)this.elements[d++]=-1}}},i.prototype.outputContours_=function(t,e){var n,r,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){r=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==r);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,r=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],e>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==r);this.elements[c++]=s,this.elements[c++]=o,s+=o}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new w2),t<2&&(t=2),t>3&&(t=3);for(var n=null,r=0;r<e.length;r+=t)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=e[r+0],n.Org.coords[1]=e[r+1],t>2?n.Org.coords[2]=e[r+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},i.prototype.tesselate=function(t,e,n,r,s,o){if(t===void 0&&(t=xt.ODD),e===void 0&&(e=pn.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,r<2&&(r=2),r>3&&(r=3),!this.mesh)return!1;this.projectPolygon_(),f6.computeInterior(this,o);var a=this.mesh;return e===pn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===pn.BOUNDARY_CONTOURS?this.outputContours_(a,r):this.outputPolymesh_(a,e,n,r),!0},i}();function as(i){var t=i.windingRule,e=t===void 0?xt.ODD:t,n=i.elementType,r=n===void 0?pn.POLYGONS:n,s=i.polySize,o=s===void 0?3:s,a=i.vertexSize,l=a===void 0?2:a,u=i.normal,c=u===void 0?[0,0,1]:u,h=i.contours,d=h===void 0?[]:h,f=i.strict,p=f===void 0?!0:f,m=i.debug,g=m===void 0?!1:m;if(!d&&p)throw new Error("Contours can't be empty");if(!!d){var y=new p6;i.edgeCreateCallback&&(y.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(y.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<d.length;v++)y.addContour(l||2,d[v]);return y.tesselate(e,r,o,l,c,p),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var Phe=xt.ODD,Dhe=xt.NONZERO,Ihe=xt.POSITIVE,Ohe=xt.NEGATIVE,Rhe=xt.ABS_GEQ_TWO,Lhe=pn.POLYGONS,Nhe=pn.CONNECTED_POLYGONS,Bhe=pn.BOUNDARY_CONTOURS;var Hy=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let n=t*Hy.eSize;this.buffer=new ArrayBuffer(n);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*r,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*r,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let n=t*Hy.eSize,r=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(r,o*s,3*t);o+=3*t;let l=new Float32Array(r,o*s,3*t);o+=3*t;let u=new Float32Array(r,o*s,2*t);e?(a.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),u.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),l.set(this.normals),u.set(this.uvs)),this.buffer=r,this.positions=a,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let r=this.capacity;for(;e>r;)r*=2;this.realloc(r)}let n=this.size;return this.size=e,n}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Kf=Hy;Kf.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var P2=$o(C2()),Qf={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},cw={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},uw={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},lw=(i,t)=>([e,n])=>(n<e&&(n+=t),(i>=e?i:i+t)<=n),ja=class extends Ae{constructor(e,n,r=0,s=12,o=3,a=xt.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=n,this._curveSegments=s,this._bevelSegmentsInput=o;let u=this._shape.extractShapePointsToFlatArray([],s),c=this._shape.shapeHoles.map(C=>{let D=C.extractShapePointsToFlatArray([],s),P=[];for(let I=D.length-1;I>=1;I-=2){let L=D[I-1],H=D[I-0];P.push(L,H)}return P}),h=[],d=[];for(let C=0;C<u.length;C+=2)d.push([u[C],u[C+1]]);h.push(d);for(let C=0;C<c.length;C++){let D=c[C],P=[];for(let I=0;I<D.length;I+=2)P.push([D[I],D[I+1]]);h.push(P)}let f=h[0].length?(0,P2.default)(h).distance:r;r<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(r,f,n/2),this._bevelSegments=Math.floor(o));let p;try{p=as({windingRule:a,elementType:pn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{p=Qf}let m;try{m=as({windingRule:xt.ODD,elementType:pn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=cw}if(!p)throw new Error("error generating geometry");let g=p.elementCount;if(m){p.elementCount+=m.elementCount;for(let C=0;C<m.elements.length;C++){let D=m.elements[C],P=C%2===0?p.vertexCount:0;p.elements.push(D+P)}for(let C=0;C<m.vertexIndices.length;C++){let D=m.vertexIndices[C],P=p.vertexCount;p.vertexIndices.push(D+P)}for(let C=0;C<m.vertices.length;C++){let D=m.vertices[C];p.vertices.push(D)}}let y=1/0,v=-1/0,x=1/0,b=-1/0;for(let C=0,D=p.vertexCount;C<D;C++){let P=C*2,I=p.vertices[P+0],L=p.vertices[P+1];I<y&&(y=I),I>v&&(v=I),L<x&&(x=L),L>b&&(b=L)}this._minX=y,this._minY=x,this._width=v-y,this._height=b-x,this._buffer=new Kf(this._computeBufferEstimatedSize(p));let w=[],E=[];for(let C=p.elementCount-1;C>=0;C--){let D=C>=g,P=C*2,I=p.elements[P+0],L=p.elements[P+1],H=I+L,U={start:I,count:L,normals:[],continuous:[],concave:[]},G=I,z=H-1,V=I+1,$=this._shape.roundedCurves.length;do{let k=G-I,Z=p.vertices[z*2+0],Q=p.vertices[z*2+1],K=p.vertices[G*2+0],W=p.vertices[G*2+1],ye=p.vertices[V*2+0],fe=p.vertices[V*2+1],ie=K-Z,we=W-Q,xe=Math.sqrt(ie*ie+we*we);ie/=xe,we/=xe;let Oe=K-ye,Ie=W-fe,Pe=Math.sqrt(Oe*Oe+Ie*Ie);Oe/=Pe,Ie/=Pe,U.normals[k*2+0]=-Ie,U.normals[k*2+1]=Oe,U.concave[k]=ie*Ie-we*Oe>0;let _e=p.vertexIndices[G];if(Array.isArray(_e))U.continuous[k]=!1;else{let[Ve,ze]=this._shape.getCurveIndexFromVertexId(_e-1,!0);if(ze>0&&ze<1)U.continuous[k]=!0;else{let R=ze===1?Ve+1:Ve-1;R=(R+$)%$;let O=ze===1?0:1,ne=this._shape.roundedCurves[Ve].getTangent(ze),ue=this._shape.roundedCurves[R].getTangent(O);U.continuous[k]=ne.dot(ue)>.95}}D&&(U.normals[k*2+0]*=-1,U.normals[k*2+1]*=-1),[z,G,V]=[G,V,V+1],V>=H&&(V-=L)}while(V!==I+1);let F=[];F.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(I*2,H*2),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((k,Z)=>[Z,Z]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(I*2,H*2)});let j=0;for(let k=1;k<=this._bevelSegments;k++){let Z=k/this._bevelSegments*Math.PI/2,Q=(1-Math.cos(Z))*this._bevel,K=[],W=[],ye=[],fe=[],ie=0;for(let xe=0;xe<L;xe++){let Oe=xe*2,Ie=(xe-1+L)%L*2,Pe=p.vertices[U.start*2+Oe+0],_e=p.vertices[U.start*2+Oe+1],Ve=-U.normals[Ie+0]*Q,ze=-U.normals[Ie+1]*Q,R=-U.normals[Oe+0]*Q,O=-U.normals[Oe+1]*Q;if(U.concave[xe]||!U.concave[xe]&&D){let ne=Math.atan2(ze,Ve),ue=Math.atan2(O,R);ue>ne&&(ue-=Math.PI*2);let me=ue-ne;if(U.continuous[xe]||D){let De=ne+me/2,Me=Math.cos(De)*Q,Ee=Math.sin(De)*Q;K[2*ie+0]=Pe+Me*(D?-1:1),K[2*ie+1]=_e+Ee*(D?-1:1),fe[ie]=xe,ie++}else{let De=Math.max(1,Math.floor(s/4*Math.abs(me)/Math.PI));for(let Me=0;Me<=De;Me++){let Ee=ne+me*(Me/De),le=Math.cos(Ee)*Q,Ke=Math.sin(Ee)*Q;K[2*ie+0]=Pe+le,K[2*ie+1]=_e+Ke,fe[ie]=xe,ie++}}}else K[2*ie+0]=Pe+Ve,K[2*ie+1]=_e+ze,fe[ie]=xe,W[xe]=ie,ie++,K[2*ie+0]=Pe,K[2*ie+1]=_e,fe[ie]=xe,ie++,K[2*ie+0]=Pe+R,K[2*ie+1]=_e+O,fe[ie]=xe,ye[xe]=ie,ie++}let we=as({windingRule:xt.POSITIVE,elementType:pn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[K],edgeCreateCallback:xe=>{let Ie=xe.Org.idx,Pe=fe[Ie],_e=fe[(Ie+1)%fe.length];xe.idx=[Pe,_e],xe.Sym.idx=[_e,Pe]},vertexIdCallback:xe=>{let Oe=xe.Lprev.idx;return[Oe?Oe[1]:0,xe.idx?xe.idx[0]:0]}});if(!we)throw console.log("Error"),new Error(`error generating bevel geometry for ${k}'th loop`);if(!we.vertexCount){let xe=(k-1)/this._bevelSegments*Math.PI/2;j=(1-Math.sin(xe))*this._bevel;break}for(let xe=0;xe<we.vertexIndices.length;xe++){let[Oe,Ie]=we.vertexIndices[xe];if(Oe===Ie)continue;let Pe=Ie;Ie<Oe&&(Pe+=L);for(let _e=Oe;_e<Pe;_e++){let Ve=_e%L,ze=(_e+1)%L;if(!U.continuous[Ve]||!U.continuous[ze]){we.vertexIndices[xe]=[Oe,Ve],we.vertexIndices.splice(xe+1,0,[ze,Ie]),we.vertices.splice((xe+1)*2,0,we.vertices[xe*2],we.vertices[xe*2+1]);break}}}F.push({bevelI:k,angle:Z,size:Q,boundary:we,reverseMap:fe,insetPoints:K})}let X=(k,Z,Q)=>{let K=0,W=k.boundary.vertexIndices.length;for(;K<W&&Q(k.boundary.vertexIndices[Z]);)Z=(Z+1)%W,K++;return K},q=w.length;for(let k=1;k<F.length;k++){let Z=F[k-1],Q=F[k],K=Z.boundary.vertexIndices.length,W=Q.boundary.vertexIndices.length;if(!K||!W)break;let ye=U.concave.length,fe=0,ie=lw(fe,L);for(;!Z.boundary.vertexIndices.filter(ie).length||!Q.boundary.vertexIndices.filter(ie).length;)fe++,ie=lw(fe,L);let we=Z.boundary.vertexIndices.findIndex(ie),xe=Q.boundary.vertexIndices.findIndex(ie);do we=(we+1)%K;while(ie(Z.boundary.vertexIndices[we]));do xe=(xe+1)%W;while(ie(Q.boundary.vertexIndices[xe]));fe=(fe+1)%L;let Oe=fe,Ie=0,Pe=this._buildBevelVert(U,Z,(we-1+K)%K,void 0,Ie),_e=this._buildBevelVert(U,Q,(xe-1+W)%W,void 0,Ie),Ve=Pe,ze=_e,R,O,ne=!1;do{Ie=(fe||ye)/ye,ie=lw(fe,L);let ue=X(Z,we,ie),me=X(Q,xe,ie),De=ne;if(ne=!1,ue&&!me){for(let Me=0;Me<ue;Me++)R=this._buildBevelVert(U,Z,(we+Me)%K,Me/(ue-1),Ie),w.push(Ve.topN,R.topP,ze.topN),l===!1&&w.push(R.bottomP,Ve.bottomN,ze.bottomN),Ve=R;ne=!0}else if(!ue&&me)for(let Me=0;Me<me;Me++)O=this._buildBevelVert(U,Q,(xe+Me)%W,Me/(me-1),Ie),w.push(ze.topN,Ve.topP,O.topP),l===!1&&w.push(Ve.bottomP,ze.bottomN,O.bottomP),ze=O;else if(ue&&me)if(R=this._buildBevelVert(U,Z,we,0,Ie),O=this._buildBevelVert(U,Q,xe,0,Ie),De?(w.push(Ve.topN,O.topP,ze.topN),w.push(Ve.topN,R.topP,O.topP),l===!1&&(w.push(O.bottomP,Ve.bottomN,ze.bottomN),w.push(O.bottomP,R.bottomP,Ve.bottomN))):(w.push(ze.topN,Ve.topN,R.topP),w.push(ze.topN,R.topP,O.topP),l===!1&&(w.push(R.bottomP,Ve.bottomN,ze.bottomN),w.push(R.bottomP,ze.bottomN,O.bottomP))),Ve=R,ze=O,ue===me)for(let Me=1;Me<ue;Me++)R=this._buildBevelVert(U,Z,(we+Me)%K,Me/(ue-1),Ie),O=this._buildBevelVert(U,Q,(xe+Me)%W,Me/(me-1),Ie),w.push(Ve.topN,R.topP,ze.topN),w.push(ze.topN,R.topP,O.topP),l===!1&&(w.push(R.bottomP,Ve.bottomN,ze.bottomN),w.push(R.bottomP,ze.bottomN,O.bottomP)),Ve=R,ze=O;else if(ue>me){let Me=ue/me,Ee=0;for(let le=1;le<ue;le++)R=this._buildBevelVert(U,Z,(we+le)%K,le/(ue-1),Ie),w.push(Ve.topN,R.topP,ze.topN),l===!1&&w.push(R.bottomP,Ve.bottomN,ze.bottomN),Ve=R,le>(Ee+1)*Me&&(Ee++,O=this._buildBevelVert(U,Q,(xe+Ee)%W,Ee/(me-1),Ie),w.push(ze.topN,R.topP,O.topP),l===!1&&w.push(R.bottomP,ze.bottomN,O.bottomP),ze=O)}else{let Me=me/ue,Ee=0;for(let le=1;le<me;le++)O=this._buildBevelVert(U,Q,(xe+le)%W,le/(me-1),Ie),w.push(ze.topN,R.topP,O.topP),l===!1&&w.push(R.bottomP,ze.bottomN,O.bottomP),ze=O,le>(Ee+1)*Me&&(Ee++,R=this._buildBevelVert(U,Z,(we+Ee)%K,Ee/(ue-1),Ie),w.push(Ve.topN,R.topP,ze.topN),l===!1&&w.push(R.bottomP,Ve.bottomN,ze.bottomN),Ve=R)}we=(we+ue)%K,xe=(xe+me)%W,fe=(fe+1)%ye}while(fe!==Oe)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(F,U,w),D){let k=[];for(let Z=w.length-1;Z>=q+2;Z-=3){let Q=w[Z-2],K=w[Z-1],W=w[Z-0];k.push(W,K,Q)}w.splice(q,w.length-q,...k)}if(D){let k=[];for(let Z=F[F.length-1].boundary.vertices.length-1;Z>=1;Z-=2){let Q=F[F.length-1].boundary.vertices[Z-1],K=F[F.length-1].boundary.vertices[Z-0];k.push(Q,K)}E.push(k)}if(!D){let k=F[F.length-1],Z;try{Z=as({windingRule:F.length>1?xt.POSITIVE:xt.ODD,elementType:pn.POLYGONS,vertexSize:2,strict:!0,contours:[k.insetPoints,...E]})}catch{Z=uw}if(!Z)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let Q=0;Q<Z.elementCount*3;Q+=3){let K=this._buildSurfaceVert(Z,Z.elements[Q+0],j),W=this._buildSurfaceVert(Z,Z.elements[Q+1],j),ye=this._buildSurfaceVert(Z,Z.elements[Q+2],j);w.push(K.top,W.top,ye.top),l===!1&&w.push(ye.bottom,W.bottom,K.bottom)}}this.vertexCache={}}this._buffer.shrink();let _=new Ge(Uint32Array.from(w),1),S=new Ge(this._buffer.positions,3),T=new Ge(this._buffer.normals,3),M=new Ge(this._buffer.uvs,2);S.needsUpdate=!0,T.needsUpdate=!0,M.needsUpdate=!0,_.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",T),this.setAttribute("uv",M),this.setIndex(_)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,r){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);r.push(u.topP,l.topN,l.bottomN),r.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,n,r){let s=n.toString();if(s in this.vertexCache)return this.vertexCache[s];let o=e.vertices[n*2+0],a=e.vertices[n*2+1],l=(o-this._minX)/this._width,u=(a-this._minY)/this._height;this.forPathBevel&&(u=1);let c=this._buffer.get(this.forPathBevel?1:2),h=c*3,d=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[h+0]=o,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-r,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=u,this.forPathBevel===!1&&(this._buffer.positions[h+3]=o,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=r,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=u),this.vertexCache[s]=f,f}_buildBevelVert(e,n,r,s=1,o){let a=`${n.bevelI}:${r}`;if(a in this.vertexCache&&o!==0&&o!==1&&(!o||o===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[l,u]=n.boundary.vertexIndices[r],c,h,d,f;l!==u?(h=l,c=u,f=!1,d=e.continuous[h]&&e.continuous[c]):(c=l,h=(c-1+e.count)%e.count,f=e.concave[c]&&n.bevelI>0,d=e.continuous[c]||f);let p=Math.cos(n.angle),m=Math.sin(n.angle),g=r*2,y=c*2,v=h*2,x=n.boundary.vertices[g+0],b=n.boundary.vertices[g+1],w=(1-m)*this._bevel,E=(x-this._minX)/this._width,_=(b-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(E=o),_=1);let S=e.normals[y+0],T=e.normals[y+1],M=e.normals[v+0],C=e.normals[v+1];if(f){let H=M-S,U=C-T;S=S+H*(1-s),T=T+U*(1-s);let G=Math.sqrt(S*S+T*T);S/=G,T/=G}let D=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),P=D*3,I=D*2,L={i:r,fi:c,topP:D+0,topN:D+0,bottomP:D+1,bottomN:D+1,pathBevelUCoord:o};return this._buffer.positions[P+0]=x,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[P+0]=S*p,this._buffer.normals[P+1]=T*p,this._buffer.normals[P+2]=m,this._buffer.uvs[I+0]=E,this._buffer.uvs[I+1]=_,this.forPathBevel===!1&&(this._buffer.positions[P+3]=x,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=S*p,this._buffer.normals[P+4]=T*p,this._buffer.normals[P+5]=-m,this._buffer.uvs[I+2]=_,this._buffer.uvs[I+3]=E),d||(this.forPathBevel?(D+=1,P+=3,I+=2):(D+=2,P+=6,I+=4),L.topP=D+0,L.bottomP=D+1,this._buffer.positions[P+0]=x,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[P+0]=M*p,this._buffer.normals[P+1]=C*p,this._buffer.normals[P+2]=m,this._buffer.uvs[I+0]=E,this._buffer.uvs[I+1]=_,this.forPathBevel===!1&&(this._buffer.positions[P+3]=x,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=M*p,this._buffer.normals[P+4]=C*p,this._buffer.normals[P+5]=-m,this._buffer.uvs[I+2]=_,this._buffer.uvs[I+3]=E)),this.vertexCache[a]=L,L}clone(){let e=new ja(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Io(this.userData),e}};var vh=class extends Ae{constructor(e,n=12,r={}){super();this.type="ShapeGeometry";this.windingRule=xt.ODD;this.elementType=pn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:xt.ODD,elementType:pn.POLYGONS,polySize:3,vertexSize:2,strict:!0},r);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,h;for(let p=0,m=s.length/2;p<m;p++){let g=p*2,y=s[g+0],v=s[g+1];if(c!==void 0&&y!==c&&(l=!1),h!==void 0&&v!==h&&(u=!1),c=y,h=v,!l&&!u)break}if(!l&&!u)try{a=as({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=Qf}let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Ge(new Float32Array(d*3),3),this._normalAttribute=new Ge(new Float32Array(d*3),3),this._uvAttribute=new Ge(new Float32Array(d*2),2),this._indexAttribute=new Ge(new Uint32Array(f*3),1),a){let p=1/0,m=-1/0,g=1/0,y=-1/0;for(let b=0,w=d;b<w;b++){let E=b*2,_=a.vertices[E+0],S=a.vertices[E+1];_<p&&(p=_),_>m&&(m=_),S<g&&(g=S),S>y&&(y=S)}let v=m-p,x=y-g;for(let b=0,w=d;b<w;b++){let E=b*2,_=a.vertices[E+0],S=a.vertices[E+1],T=(_-p)/v,M=(S-g)/x;this._positionAttribute.setXYZ(b,_,S,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,T,M)}for(let b=0,w=f;b<w;b++){let E=b*3,_=a.elements[E+0],S=a.elements[E+1],T=a.elements[E+2];this._indexAttribute.setX(E+0,_),this._indexAttribute.setX(E+1,S),this._indexAttribute.setX(E+2,T)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new vh(this._shape,this._curveSegments);return e.userData=Io(this.userData),e}};var xh=class extends ja{constructor(e,n,r=0,s=12,o=3,a=xt.ODD){super(e,n,r,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,r){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);r.push(u.topP,l.topN,l.bottomN),r.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new xh(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Io(this.userData),e}};var ti=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:xt.ODD},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=i.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof Pt?(o.width!==n||o.height!==r)&&o.applySize(n,r):o=new Pt(n,r).fromJSON(o),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&o.update());let l=o??new Pt(n,r);return{parameters:Object.assign(e,{width:n,height:r,depth:s,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:n,subdivisions:r,roundness:s,windingRule:o}=i.parameters;i.shape.roundness=s;let a;return t<=0?a=new vh(i.shape,r,{windingRule:o}):a=new xh(i.shape,t,e,r,n,o),Object.assign(a,{userData:{...i,type:"VectorGeometry"}})}};var I2=Math.PI*2,Sh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=Te.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:n,angle:r,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u=i.shape,c=t*.5,h=e*.5,d=x6(u,c,h,r*Math.PI/180,n,s);u.isClosed=!0,u.update();let f;return r===0?(f=new Ae,f.setAttribute("position",new be([],3))):f=ti.create({shape:u,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function x6(i,t,e,n,r,s){if(n>=I2)return r>30||r%4===0?(S6(i,t,e,s),Math.round(r/4)):D2(i,n,r,t,e,s);n=Math.max(n,.001);let o={x:0,y:e},a=n+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},u=S2({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:n>Math.PI,sweepFlag:!0});return r>30||r%u.length===0?b6(i,o.x,o.y,u,r,t,e,s):D2(i,n,r,t,e,s)}function b6(i,t,e,n,r,s,o,a){let l=Math.round(r/n.length);i.addPoint(bh(t,e));for(let u=0,c=n.length;u<c;u++){let h=n[u],d=i.points[u],f=bh(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),f.controls[0].position.set(h.x2,h.y2),i.addPoint(f)}return a>0?O2(i,s,o,a):i.addPoint(bh(0,0)),l}function D2(i,t,e,n,r,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,u=Math.sin(l)*n,c=Math.cos(l)*r;i.addPoint(bh(u,c))}return t<I2?s>0?O2(i,n,r,s):i.addPoint(bh(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&R2(i,n,r,s)),1}function S6(i,t,e,n=0,r=0,s=0){let o=.5522847498,a=t*o,l=e*o;i.addPoint(Wy(r-t,s,r-t,s-l,r-t,s+l)),i.addPoint(Wy(r,s+e,r-a,s+e,r+a,s+e)),i.addPoint(Wy(r+t,s,r+t,s+l,r+t,s-l)),i.addPoint(Wy(r,s-e,r+a,s-e,r-a,s-e)),n>0&&R2(i,t,e,n)}function bh(i,t){return new os(Te.generateUUID(),new B(i,t))}function Wy(i,t,e,n,r,s){let o=bh(i,t);return o.controls[0].position.set(e,n),o.controls[1].position.set(r,s),o}function O2(i,t,e,n){L2(i,t,e,n).forEach(s=>i.addPoint(s))}function R2(i,t,e,n){let r=L2(i,t,e,n),s=new Pt;r.forEach(o=>s.addPoint(o)),s.isClosed=!0,i.shapeHoles.push(s)}function L2(i,t,e,n){let r=n*t/100,s=r*(Math.abs(e)/Math.abs(t)),o=new B(r/t,s/e),a=i.points.map(l=>{let u=l.clone();return u.uuid=Te.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var N2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??n),s=Math.abs(e.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(e,{width:n,height:r,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:n,radius:r,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:h}=i.parameters,d=new Zf(!1,t,e,n,r,s,o,a,l,u,c,h);return Object.assign(d,{userData:{...i,type:"HelixGeometry"}})}},hw=new Ms([0,0,0],1),Zf=class extends Ae{constructor(t=!0,e=1,n=1,r=1,s=1,o=1,a=1,l=1,u=1,c=1,h=1,d=1){if(super(),o===0)return;let f=t&&o===1;f&&(d=0),h>100&&(h=100),h===0&&(d=0);let p=()=>new A,m=new A,g=p(),y=p(),v=p(),x,b,w,E,_,S,T,M,C=p(),D=p(),P=p(),I=p(),L=p(),H=p(),U=p(),G=p(),z=n-2*l+.001,V=z/o,$=Math.ceil(a*o),F=$+1,j=z/$,X=-z/2,q=c+1,k=2*Math.PI/c,Z=Math.PI/2/d,Q=.01,K=Math.min((1-h/100)*l,l-Q),W=l-K,ye=0,fe=2,ie=d*fe+fe,we=q*ie/fe,xe=we+q*F,Oe=Math.max(0,q*(F+ie)),[Ie,Pe,_e]=[3,3,2].map(ke=>Array(Oe*ke).fill(0)),Ve=[],ze=s-l;function R(ke,Le){let je=Math.PI/2;S=Le*j,M=2*Math.PI*(S%V)/V+je,S+=X,T=Math.sin(M)*ze,_=Math.cos(M)*ze,t?ke.set(_,T,S):ke.set(_,S,T)}R(m,-1e-10),R(g,0),C.copy(m),R(m,1);let O=m.distanceTo(g),ne=f?0:W+K,ue=O*$+2*ne,me=K,De=ue-ne;for(let ke=0;ke<=$;ke++){R(y,ke),G.subVectors(y,C).normalize(),C.copy(y),H.copy(y).setComponent(+t+1,0).normalize(),U.crossVectors(G,H).normalize();let Le=ke===0,je=ke===$,Je=Le?3*Math.PI/2:Z,St=Le?me:De,Zt=Le?q:xe,On=Le?0:Oe-q,Y=G.clone().multiplyScalar(Le?-W:W).add(y),ce=G.clone().multiplyScalar(Le?-1:1).normalize();for(let ve=0;ve<q;ve++){let Ue=ve*k;if(D.addVectors(m.copy(H).multiplyScalar(l*Math.cos(Ue)),g.copy(U).multiplyScalar(l*Math.sin(Ue))),P.copy(D).normalize(),Le||je){f||(ye=On+ve,[0,1,2].forEach(Be=>{Ie[ye*3+Be]=Y.getComponent(Be),Pe[ye*3+Be]=ce.getComponent(Be)}),_e[ye*2]=+je,_e[ye*2+1]=ve/c),g.copy(P).multiplyScalar(K),v.addVectors(y,g);for(let Be=0;Be<d;Be++){let wt=Be*Z+Je;I.addVectors(m.copy(G).multiplyScalar(W*Math.sin(wt)),g.copy(P).multiplyScalar(W*Math.cos(wt))),L.copy(I).normalize(),g.addVectors(v,I),I.normalize(),ye=Zt+Be*q+ve,[0,1,2].forEach(Sn=>{Ie[ye*3+Sn]=g.getComponent(Sn),Pe[ye*3+Sn]=L.getComponent(Sn)});let Rn=+Le+Math.sin(wt);_e[ye*2]=(St+W*Rn)/ue,_e[ye*2+1]=ve/c}}g.addVectors(y,D),ye=we+ke*q+ve,[0,1,2].forEach(Be=>{Ie[ye*3+Be]=g.getComponent(Be),Pe[ye*3+Be]=P.getComponent(Be)}),_e[ye*2]=(ne+ke*O)/ue,_e[ye*2+1]=ve/c}}let Me=F+2*d+fe,Ee=1,[le,Ke]=[+f,Me-1];for(let ke=le;ke<=Ke-1;ke++){let Le=f&&ke===Ke-1;for(let je=0;je<q-1;je++)x=ke*q+je,b=x+1,w=(Le?je:x)+q,E=(Le?je+1:b)+q,ke===0?Ve.push(b,E,w):ke===Me-2?Ve.push(x,b,w):Ve.push(x,b,w,b,E,w)}this.setIndex(Ve),this.setAttribute("position",new be(Ie,3)),this.setAttribute("normal",new be(Pe,3)),this.setAttribute("uv",new be(_e,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),n=t.radialSegments+1,r=Array.from(this.getIndex().array),s,o,a,l,u=6*(e-1)*t.radialSegments,c=e,h=c===e;for(let d=0;d<t.radialSegments;d++)s=c*n+d,o=s+1,a=(h?d:s)+n,l=(h?d+1:o)+n,r[u++]=s,r[u++]=o,r[u++]=a,r[u++]=o,r[u++]=l,r[u++]=a;return r.length=u,hw.array=r,hw.count=r.length,hw}};var B2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,detail:r,corner:s,cornerSides:o}=i.parameters,a=r===0&&s!==0?new Jf(t*.5,s,o):new Hc(t*.5,r);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...i,type:"IcosahedronGeometry"}})}},Jf=class extends za{constructor(t=1,e=.2,n=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,n),this.type=a}static fromJSON(t){return new Jf(t.radius,t.corner,t.cornerSides)}};var F2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:n}=i.parameters,r=new _o;r.moveTo(t[0].x,t[0].y),r.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new kc(r.extractPoints(n).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...i,type:"LatheGeometry"}})}};var Hs=new se,dw=new mt,qy=new A,Wa=class extends Ht{constructor(){super(),this.uuid=Te.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new $t().getNormalMatrix(t);for(let n=0,r=this.vertices.length;n<r;n++)this.vertices[n].applyMatrix4(t);for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return Hs.makeRotationX(t),this.applyMatrix4(Hs),this}rotateY(t){return Hs.makeRotationY(t),this.applyMatrix4(Hs),this}rotateZ(t){return Hs.makeRotationZ(t),this.applyMatrix4(Hs),this}translate(t,e,n){return Hs.makeTranslation(t,e,n),this.applyMatrix4(Hs),this}scale(t,e,n){return Hs.makeScale(t,e,n),this.applyMatrix4(Hs),this}lookAt(t){return dw.lookAt(t),dw.updateMatrix(),this.applyMatrix4(dw.matrix),this}fromBufferGeometry(t){let e=this,n=t.index!==null?t.index:void 0,r=t.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,o=r.normal,a=r.color,l=r.uv,u=r.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)e.vertices.push(new A().fromBufferAttribute(s,d)),a!==void 0&&e.colors.push(new Fe().fromBufferAttribute(a,d));function c(d,f,p,m){let g=a===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[p].clone()],y=o===void 0?[]:[new A().fromBufferAttribute(o,d),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,p)],v=new wh(d,f,p,y,g,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new B().fromBufferAttribute(l,d),new B().fromBufferAttribute(l,f),new B().fromBufferAttribute(l,p)]),u!==void 0&&e.faceVertexUvs[1].push([new B().fromBufferAttribute(u,d),new B().fromBufferAttribute(u,f),new B().fromBufferAttribute(u,p)])}let h=t.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],p=f.start,m=f.count;for(let g=p,y=p+m;g<y;g+=3)n!==void 0?c(n.getX(g),n.getX(g+1),n.getX(g+2),f.materialIndex):c(g,g+1,g+2,f.materialIndex)}else if(n!==void 0)for(let d=0;d<n.count;d+=3)c(n.getX(d),n.getX(d+1),n.getX(d+2));else for(let d=0;d<s.count;d+=3)c(d,d+1,d+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(qy).negate(),this.translate(qy.x,qy.y,qy.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,n=e===0?1:1/e,r=new se;return r.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let t=new A,e=new A;for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let n=0,r=this.vertices.length;n<r;n++)e[n]=new A;if(t){let n=new A,r=new A;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];n.subVectors(c,u),r.subVectors(l,u),n.cross(r),e[a.a].add(n),e[a.b].add(n),e[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let n=0,r=this.vertices.length;n<r;n++)e[n].normalize();for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let n=this.faces[t],r=n.vertexNormals;r.length===3?(r[0].copy(n.normal),r[1].copy(n.normal),r[2].copy(n.normal)):(r[0]=n.normal.clone(),r[1]=n.normal.clone(),r[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,o=r.vertexNormals.length;s<o;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let t=new Wa;t.faces=this.faces;for(let e=0,n=this.morphTargets.length;e<n;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new A,c={a:new A,b:new A,c:new A};s.push(u),o.push(c)}}let r=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=r.faceNormals[s],u=r.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Tt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ln),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,n=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let r,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,h=t.colors;e!==void 0&&(r=new $t().getNormalMatrix(e));for(let d=0,f=a.length;d<f;d++){let m=a[d].clone();e!==void 0&&m.applyMatrix4(e),o.push(m)}for(let d=0,f=h.length;d<f;d++)c.push(h[d].clone());for(let d=0,f=u.length;d<f;d++){let p=u[d],m,g,y=p.vertexNormals,v=p.vertexColors,x=new wh(p.a+s,p.b+s,p.c+s);x.normal.copy(p.normal),r!==void 0&&x.normal.applyMatrix3(r).normalize();for(let b=0,w=y.length;b<w;b++)m=y[b].clone(),r!==void 0&&m.applyMatrix3(r).normalize(),x.vertexNormals.push(m);x.color.copy(p.color);for(let b=0,w=v.length;b<w;b++)g=v[b],x.vertexColors.push(g.clone());x.materialIndex=p.materialIndex+n,l.push(x)}for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,b=y.length;x<b;x++)v.push(y[x].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},n=[],r=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],h=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[h]===void 0?(e[h]=l,n.push(this.vertices[l]),r[l]=n.length-1):r[l]=r[e[h]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=r[c.a],c.b=r[c.b],c.c=r[c.c];let h=[c.a,c.b,c.c];for(let d=0;d<3;d++)if(h[d]===h[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,h=this.faceVertexUvs.length;c<h;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(t){this.vertices=[];for(let e=0,n=t.length;e<n;e++){let r=t[e];this.vertices.push(new A(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}t.sort(n);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;r&&r.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(r[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let m in p)p[m]!==void 0&&(t[m]=p[m]);return t}let e=[];for(let p=0;p<this.vertices.length;p++){let m=this.vertices[p];e.push(m.x,m.y,m.z)}let n=[],r=[],s={},o=[],a={},l=[],u={};for(let p=0;p<this.faces.length;p++){let m=this.faces[p],g=!0,y=!1,v=this.faceVertexUvs[0][p]!==void 0,x=m.normal.length()>0,b=m.vertexNormals.length>0,w=m.color.r!==1||m.color.g!==1||m.color.b!==1,E=m.vertexColors.length>0,_=0;if(_=c(_,0,0),_=c(_,1,g),_=c(_,2,y),_=c(_,3,v),_=c(_,4,x),_=c(_,5,b),_=c(_,6,w),_=c(_,7,E),n.push(_),n.push(m.a,m.b,m.c),n.push(m.materialIndex),v){let S=this.faceVertexUvs[0][p];n.push(f(S[0]),f(S[1]),f(S[2]))}if(x&&n.push(h(m.normal)),b){let S=m.vertexNormals;n.push(h(S[0]),h(S[1]),h(S[2]))}if(w&&n.push(d(m.color)),E){let S=m.vertexColors;n.push(d(S[0]),d(S[1]),d(S[2]))}}function c(p,m,g){return g?p|1<<m:p&~(1<<m)}function h(p){let m=p.x.toString()+p.y.toString()+p.z.toString();return s[m]!==void 0||(s[m]=r.length/3,r.push(p.x,p.y,p.z)),s[m]}function d(p){let m=p.r.toString()+p.g.toString()+p.b.toString();return a[m]!==void 0||(a[m]=o.length,o.push(p.getHex())),a[m]}function f(p){let m=p.x.toString()+p.y.toString();return u[m]!==void 0||(u[m]=l.length/2,l.push(p.x,p.y)),u[m]}return t.data={},t.data.vertices=e,t.data.normals=r,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=n,t}clone(){return new Wa().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let d=0,f=e.length;d<f;d++)this.vertices.push(e[d].clone());let n=t.colors;for(let d=0,f=n.length;d<f;d++)this.colors.push(n[d].clone());let r=t.faces;for(let d=0,f=r.length;d<f;d++)this.faces.push(r[d].clone());for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,b=y.length;x<b;x++){let w=y[x];v.push(w.clone())}this.faceVertexUvs[d].push(v)}}let s=t.morphTargets;for(let d=0,f=s.length;d<f;d++){let p={};if(p.name=s[d].name,s[d].vertices!==void 0){p.vertices=[];for(let m=0,g=s[d].vertices.length;m<g;m++)p.vertices.push(s[d].vertices[m].clone())}if(s[d].normals!==void 0){p.normals=[];for(let m=0,g=s[d].normals.length;m<g;m++)p.normals.push(s[d].normals[m].clone())}this.morphTargets.push(p)}let o=t.morphNormals;for(let d=0,f=o.length;d<f;d++){let p={};if(o[d].vertexNormals!==void 0){p.vertexNormals=[];for(let m=0,g=o[d].vertexNormals.length;m<g;m++){let y=o[d].vertexNormals[m],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),p.vertexNormals.push(v)}}if(o[d].faceNormals!==void 0){p.faceNormals=[];for(let m=0,g=o[d].faceNormals.length;m<g;m++)p.faceNormals.push(o[d].faceNormals[m].clone())}this.morphNormals.push(p)}let a=t.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=t.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let u=t.lineDistances;for(let d=0,f=u.length;d<f;d++)this.lineDistances.push(u[d]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let h=t.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new fw().fromGeometry(this),e=new Ae,n=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Yy.call(new Ge(n,3),t.vertices)),t.normals.length>0){let r=new Float32Array(t.normals.length*3);e.setAttribute("normal",Yy.call(new Ge(r,3),t.normals))}if(t.colors.length>0){let r=new Float32Array(t.colors.length*3);e.setAttribute("color",k2.call(new Ge(r,3),t.colors))}if(t.uvs.length>0){let r=new Float32Array(t.uvs.length*2);e.setAttribute("uv",U2.call(new Ge(r,2),t.uvs))}if(t.uvs2.length>0){let r=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",U2.call(new Ge(r,2),t.uvs2))}e.groups=t.groups;for(let r in t.morphTargets){let s=[],o=t.morphTargets[r];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new be(u.data.length*3,3);c.name=u.name,s.push(Yy.call(c,u.data))}e.morphAttributes[r]=s}if(t.skinIndices.length>0){let r=new be(t.skinIndices.length*4,4);e.setAttribute("skinIndex",V2.call(r,t.skinIndices))}if(t.skinWeights.length>0){let r=new be(t.skinWeights.length*4,4);e.setAttribute("skinWeight",V2.call(r,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Ae,n=t.geometry;if(t.isPoints||t.isLine){let r=new be(n.vertices.length*3,3),s=new be(n.colors.length*3,3);if(e.setAttribute("position",Yy.call(r,n.vertices)),e.setAttribute("color",k2.call(s,n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new be(n.lineDistances.length,1);e.setAttribute("lineDistance",w6.call(o,n.lineDistances))}n.boundingSphere!==null&&(e.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(e.boundingBox=n.boundingBox.clone())}else t.isMesh&&(e=n.toBufferGeometry());return e}};Wa.prototype.isGeometry=!0;var fw=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],n,r,s,o=t.faces;for(r=0;r<o.length;r++){let a=o[r];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=r*3-n.start,e.push(n)),n={start:r*3,materialIndex:s})}n!==void 0&&(n.count=r*3-n.start,e.push(n)),this.groups=e}fromGeometry(t){let e=t.faces,n=t.vertices,r=t.faceVertexUvs,s=r[0]&&r[0].length>0,o=r[1]&&r[1].length>0,a=t.morphTargets,l=a.length,u;if(l>0){u=[];for(let y=0;y<l;y++)u[y]={name:a[y].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,h=c.length,d;if(h>0){d=[];for(let y=0;y<h;y++)d[y]={name:c[y].name,data:[]};this.morphTargets.normal=d}let f=t.skinIndices,p=t.skinWeights,m=f.length===n.length,g=p.length===n.length;n.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<e.length;y++){let v=e[y];this.vertices.push(n[v.a],n[v.b],n[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let w=v.normal;this.normals.push(w,w,w)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let w=v.color;this.colors.push(w,w,w)}if(s===!0){let w=r[0][y];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new B,new B,new B))}if(o===!0){let w=r[1][y];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new B,new B,new B))}for(let w=0;w<l;w++){let E=a[w].vertices;u[w].data.push(E[v.a],E[v.b],E[v.c])}for(let w=0;w<h;w++){let E=c[w].vertexNormals[y];d[w].data.push(E.a,E.b,E.c)}m&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},wh=class{constructor(t,e,n,r,s,o=0){this.a=t,this.b=e,this.c=n,this.normal=r&&r.isVector3?r:new A,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new Fe,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,n=t.vertexNormals.length;e<n;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,n=t.vertexColors.length;e<n;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function w6(i){return this.array.set(i),this}function k2(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),s=new Fe),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function U2(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),s=new B),t[e++]=s.x,t[e++]=s.y}return this}function Yy(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),s=new A),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function V2(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),s=new Xe),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var A6=["a","b","c"];function E6(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function pw(i,t,e){let n=Math.min(i,t),r=Math.max(i,t),s=n+"_"+r;return e.get(s)}function mw(i,t,e,n,r,s){let o=Math.min(i,t),a=Math.max(i,t),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=e[o],h=e[a];u={a:c,b:h,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(r),s[i].edges.push(u),s[t].edges.push(u)}function _6(i,t,e,n){let r,s,o;for(r=0,s=i.length;r<s;r++)e[r]={edges:[]};for(r=0,s=t.length;r<s;r++)o=t[r],mw(o.a,o.b,i,n,o,e),mw(o.b,o.c,i,n,o,e),mw(o.c,o.a,i,n,o,e)}function Xy(i,t,e,n,r){i.push(new wh(t,e,n,void 0,void 0,r))}function Ah(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function Ky(i,t,e,n){i.push([t.clone(),e.clone(),n.clone()])}var Qy=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Ae?t=new Wa().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new A,n,r,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],h=c!==void 0&&c.length>0,d=[],f=new Map;_6(l,u,d,f);let p=[],m,g,y,v,x,b,w;for(let Q of Array.from(f.keys())){for(g=f.get(Q),y=new A,x=3/8,b=1/8,w=g.faces.length,w!=2&&(x=.5,b=0,w!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<w;o++){for(v=g.faces[o],a=0;a<3&&(m=l[E6(v,A6[a])],!(m!==g.a&&m!==g.b));a++);m&&e.add(m)}e.multiplyScalar(b),y.add(e),g.newEdge=p.length,p.push(y)}let E,_,S,T,M,C,D,P=[];for(r=0,s=l.length;r<s;r++){for(C=l[r],M=d[r].edges,n=M.length,n==3?E=3/16:n>3&&(E=3/(8*n)),_=1-n*Number(E),S=E,n<=2&&(n==2?(_=3/4,S=1/8):n==1||n==0),D=C.clone().multiplyScalar(_),e.set(0,0,0),o=0;o<n;o++)T=M[o],m=T.a!==C?T.a:T.b,e.add(m);e.multiplyScalar(Number(S)),D.add(e),P.push(D)}let I=P.concat(p),L=P.length,H,U,G,z=[],V=[],$,F,j,X,q=new B,k=new B,Z=new B;for(r=0,s=u.length;r<s;r++)v=u[r],H=Number(pw(v.a,v.b,f).newEdge)+L,U=Number(pw(v.b,v.c,f).newEdge)+L,G=Number(pw(v.c,v.a,f).newEdge)+L,Xy(z,H,U,G,v.materialIndex),Xy(z,v.a,H,G,v.materialIndex),Xy(z,v.b,U,H,v.materialIndex),Xy(z,v.c,G,U,v.materialIndex),h&&($=c[r],F=$[0],j=$[1],X=$[2],q.set(Ah(F.x,j.x),Ah(F.y,j.y)),k.set(Ah(j.x,X.x),Ah(j.y,X.y)),Z.set(Ah(F.x,X.x),Ah(F.y,X.y)),Ky(V,q,k,Z),Ky(V,F,q,Z),Ky(V,j,k,q),Ky(V,X,Z,k));t.vertices=I,t.faces=z,h&&(t.faceVertexUvs[0]=V)}};var Jn=new A,z2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ae().copy(new sr(100,100,100)),n;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Jn),n={width:Jn.x,height:Jn.y,depth:Jn.z,subdivisions:0}):n=t.parameters;let r={...n,...i.parameters};return{parameters:{width:Math.abs(r.width),height:Math.abs(r.height),depth:Math.abs(r.depth),subdivisions:Math.abs(r.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:n,subdivisions:r}=i.parameters,s=i.geometry??new Ae().copy(new sr(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Jn)):Jn.set(o.width,o.height,o.depth),(t!==Jn.x||e!==Jn.y||n!==Jn.z)&&s.scale(Jn.x===0?1:t/Jn.x,Jn.y===0?1:e/Jn.y,Jn.z===0?1:n/Jn.z);let a=s.originalGeometry;try{r>0?(a===void 0||o?.subdivisions!==r)&&(a===void 0&&(a=s),s=new Qy(r).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete i.geometry,Object.assign(s,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Zc(e).load(i,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(Jn);let o=100/Jn.x;Object.assign(s.parameters,{width:100,height:Jn.y*o,depth:Jn.z*o}),t(this.build(s))})}};var Zy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:n,cornerRadius:r,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5,h=0,d=0,f=2*Math.PI/n;for(let m=0;m<n;m++){let g=f*m,y=h+Math.sin(g)*u,v=d+Math.cos(g)*c;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=r;l.roundness=r,l.update();let p=ti.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...i,type:"PolygonGeometry"}})}};var G2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,radialSegments:r,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=new yw(t*.5,e,r,s,o,a,l);return u.scale(1,1,n/t),Object.assign(u,{userData:{...i,type:"PyramidGeometry"}})}};function $f(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function gw(i,t,e,n,r,s){let o=t.clone().sub(i),a=e.clone().sub(i),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===r){let u=o.add(a).normalize();s.copy(i).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(i),s.addScaledVector(o,r/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function T6(i,t,e){let n=i.clone().sub(t),r=e.clone().sub(t);return n.projectOnVector(r),n.add(t)}var yw=class extends Ae{constructor(t=.5,e=1,n=4,r=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),r=Math.floor(r),a=Math.floor(a);let l=[],u=[],c=[],h=[],d=0,f=e/2,p=Math.PI/n,m=t*Math.cos(Math.PI/n),g=2*Math.PI/n,y=(n-2)*Math.PI/n,v=Math.PI-y,x=new A(0,-f,0),b=new A(0,f,0),w=new B(t,-f),E=new B(m,-f),_=new B(0,b.y).sub(E),S=new B(0,b.y).sub(w),T=new B(_.y,-_.x).normalize(),M=new B(S.y,-S.x).normalize(),D=t*Math.cos(Math.PI/n)*Math.tan((Math.PI-_.angle())/2)-1e-8;o=Math.min(o,D);let P;{let V=new A(T.x,T.y,0),$=new A(Math.cos(g)*V.x,V.y,Math.sin(g)*V.x);P=V.angleTo($)}let I=o/Math.tan((Math.PI-_.angle())/2),L=o/Math.tan((Math.PI-P)/2),H=new A;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),h.push(0,0);let V=d++,$=[],F=w.clone(),j=I/Math.cos(Math.PI/n);F.x-=j;for(let X=0;X<n;X++){let q=X/n*Math.PI*2+p,k=new B(Math.sin(q),Math.cos(q));$f(F,k,H),u.push(H.x,H.y,H.z),c.push(0,-1,0),h.push(0,0),$.push(d++)}for(let X=0;X<$.length;X++)l.push($[X],V,$[(X+1)%$.length])}let U=[];{let V=new A,$=new A,F=new A,j=new A,X=new A,q=new A;for(let k=0;k<n;k++){let Z=k/n*Math.PI*2+p,Q=(k+.5)/n*Math.PI*2+p,K=(k+1)/n*Math.PI*2+p,W=new B(Math.sin(Z),Math.cos(Z)),ye=new B(Math.sin(Q),Math.cos(Q)),fe=new B(Math.sin(K),Math.cos(K));$f(w,W,$),$f(w,fe,F),$f(T,ye,V),gw(b,$,F,L,L,j),u.push(j.x,j.y,j.z),gw($,b,F,L,I,X),u.push(X.x,X.y,X.z),gw(F,$,b,I,L,q),u.push(q.x,q.y,q.z),c.push(V.x,V.y,V.z),c.push(V.x,V.y,V.z),c.push(V.x,V.y,V.z),h.push(0,0),h.push(0,0),h.push(0,0);let ie=d++,we=d++,xe=d++;if(l.push(ie,we,xe),o>0){{let Pe=$.clone().add(F).multiplyScalar(.5),_e=b.clone().sub(Pe).normalize(),ze=x.clone().sub(Pe).normalize().add(_e).normalize().multiplyScalar(-1),R=q.clone().sub(X);G(Pe,R,ze,_.angle())}let Oe,Ie;{let Pe=new A;$f(M,fe,Pe);let _e=q.clone().add(j).multiplyScalar(.5);_e=T6(_e,F,b);let Ve=q.clone().sub(j);[Oe,Ie]=G(_e,Ve,Pe,P,j.y)}{let Pe=Oe,_e=Pe.clone().setY(0).normalize(),Ve=new A(0,-1,0),ze=_e.clone().cross(Ve);z(Pe,_e,Ve,ze)}U.concat(Ie);{let Pe=_.angle(),_e=Math.PI-Pe,Ve=b.clone();Ve.y-=o/Math.sin(Pe-Math.PI/2);let ze=new A,R=[];for(let ne=0;ne<a;ne++){let ue=[],me=Math.PI/2-_e*ne/a,De=Math.cos(me),Me=Math.sin(me),Ee=Q;for(let le=0;le<=ne;le++){let Ke=Math.cos(Ee),ke=Math.sin(Ee);V.x=De*ke,V.y=Me,V.z=De*Ke,ze.copy(Ve).addScaledVector(V,o),u.push(ze.x,ze.y,ze.z),c.push(V.x,V.y,V.z),h.push(0,0),ue.push(d++),Ee+=Math.PI*2/ne/n}R.push(ue)}Ie.reverse(),R.push(Ie);let O=R.length-1;for(let ne=0;ne<O;ne++){let ue=R[ne],me=R[ne+1],De=ue.length-1;l.push(me[1],ue[0],me[0]);for(let Me=1;Me<=De;Me++)l.push(ue[Me],ue[Me-1],me[Me]),l.push(me[Me+1],ue[Me],me[Me])}}}}}this.setIndex(l),this.setAttribute("position",new be(u,3)),this.setAttribute("normal",new be(c,3)),this.setAttribute("uv",new be(h,2));function G(V,$,F,j,X){let q=-j/2,k=(Math.PI-j)/2,Z=$.clone().normalize().cross(F);V.addScaledVector(F,-o/Math.sin(k));let Q=new A,K=new A,W=1,ye=d,fe=[];for(let ie=0;ie<=a;ie++){let we=q+ie/a*j;K.set(0,0,0),K.addScaledVector(Z,Math.sin(we)),K.addScaledVector(F,Math.cos(we));for(let xe=0;xe<=W;xe++){let Oe=xe/W-.5;if(Q.copy(V),Q.addScaledVector($,Oe),Q.addScaledVector(K,o),X!=null){let Ie=Math.max(0,Q.y-X);Q.addScaledVector($,-Ie/$.y)}u.push(Q.x,Q.y,Q.z),c.push(K.x,K.y,K.z),h.push(0,0),xe===0&&fe.push(d),d++}}for(let ie=0;ie<a;ie++)for(let we=0;we<W;we++){let xe=ye+we+(W+1)*ie,Oe=xe+(W+1),Ie=Oe+1,Pe=xe+1;l.push(xe,Oe,Pe),l.push(Oe,Ie,Pe)}return[V.clone().addScaledVector($,.5),fe]}function z(V,$,F,j){let X=Math.PI/2,q=S.angle()-X,k=[],Z=new A,Q=new A;for(let W=0;W<=a;W++){let ye=[],fe=W/a;for(let ie=0;ie<=W;ie++){let xe=((W?ie/W:0)-.5)*v,Oe=Math.cos(xe),Ie=Math.sin(xe),Pe=Math.atan(Math.tan(q)*Oe),_e=(X+Pe)*fe,Ve=Math.cos(_e),ze=Math.sin(_e);Z.set(0,0,0),Z.addScaledVector($,ze*Oe),Z.addScaledVector(F,Ve),Z.addScaledVector(j,ze*Ie),Q.copy(V).addScaledVector(Z,o),u.push(Q.x,Q.y,Q.z),c.push(Z.x,Z.y,Z.z),h.push(0,0),ye.push(d++)}k.push(ye)}let K=k.length-1;for(let W=0;W<K;W++){let ye=k[W],fe=k[W+1],ie=ye.length-1;l.push(ye[0],fe[1],fe[0]);for(let we=1;we<=ie;we++)l.push(ye[we-1],ye[we],fe[we]),l.push(ye[we],fe[we+1],fe[we])}}}};var Jy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),n=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:n}}static build(i){let t=i.shape,{width:e,height:n,cornerRadius:r,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u={x:e*.5,y:n*.5},c={x:-u.x,y:-u.y},h={x:u.x,y:u.y};function d(b,w,E){return w>e&&E>n?Math.min(b*e/w,b*n/E):w>e?b*e/w:E>n?b*n/E:b}let f=[];f[0]=r[0]===0?0:d(r[0],r[0]+r[3],r[0]+r[1]),f[1]=r[1]===0?0:d(r[1],r[1]+r[2],r[1]+r[0]),f[2]=r[2]===0?0:d(r[2],r[2]+r[1],r[2]+r[3]),f[3]=r[3]===0?0:d(r[3],r[3]+r[0],r[3]+r[2]);let p=c.x,m=h.x,g=h.y,y=c.y;t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(p,y)),t.isClosed=!0;let v=!0;for(let b=0,w=t.points.length;b<w;b++)t.points[b].roundness=f[b],b>0&&f[b]!==f[b-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=ti.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...i,type:"RectangleGeometry"}})}};var H2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=Te.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:n=t,widthSegments:r=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=i.parameters,c;return u===0?(c=new Ae,c.setAttribute("position",new be([],3))):c=new Tl(.5*t,r,s,o,a,l,u*Te.DEG2RAD),c.scale(1,e/t,n/t),Object.assign(c,{userData:{...i,type:"SphereGeometry"}})}};var j2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:n=8,heightSegments:r=8}=i.parameters,s=new Ao(t,e,n,r);return s.scale(1,1,1),Object.assign(s,{userData:{...i,type:"PlaneGeometry"}})}};var W2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,angle:r,cornerRadius:s,cornerSegments:o}=i.parameters,a=new vw(t,e,n,r,s,o);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},vw=class extends Ae{constructor(t=1,e=1,n=1,r=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),r=Math.min(180-c,r),r*=Math.PI/180;let h=[],d=Math.PI/2,f=(Q=0,K=0,W=0)=>new A(Q,K,W),p=f(),m=f(),[g,y,v]=[e/2,t/2,n/2],x=-y,b=+y,[w,E,_]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],S=(Q,K=!1)=>Math.sin(Q-Math.PI/(1+ +K)),T=(Q,K=!1)=>Math.cos(Q-Math.PI/(1+ +K));_.y=Math.sin(r)*e-g;let M=Math.cos(r)*e-v,C=w.z-c;r<=d?(_.z=Math.min(M,C),_.z==C&&(_.y-=(M-C)/Math.tan(d-r))):E.z=Math.min(E.z-M-v,w.z-c),p.subVectors(w,E),m.subVectors(_,E);let D=Math.min(p.length(),m.length())*s/100,P=D*Math.tan(r/2),I=D/Math.cos(r/2),L=p.clone().normalize().add(m.normalize()).setLength(I).add(E);p.set(0,S(r,!0),T(r,!0)),h.push([_,p.clone()]);let H=(Math.PI-r)/o;for(let Q=0;Q<=o;Q++){let K=d+r+Q*H;p.set(0,Math.sin(K)*P,Math.cos(K)*P),p.add(L),m.set(0,S(K),T(K)),h.push([p.clone(),m.clone()])}h.push([w,f(0,1,0)]);let U=Math.sin(H/2)*P*2,G=h.length-1,z=h[0][0].distanceTo(h[1][0]),V=h[G-1][0].distanceTo(h[G][0]),$=z+U*o+V;h[0].push(1);for(let Q=0;Q<=o;Q++)h[Q+1].push(1-(z+Q*U)/$);h[G].push(0);let[F,j,X]=h[0],q,k,Z;for(let Q=1;Q<h.length;Q++)[q,k,Z]=h[Q],a.push(x,F.y,F.z,x,q.y,q.z,b,F.y,F.z,b,F.y,F.z,x,q.y,q.z,b,q.y,q.z),l.push(0,j.y,j.z,0,k.y,k.z,0,j.y,j.z,0,j.y,j.z,0,k.y,k.z,0,k.y,k.z),u.push(0,X,0,Z,1,X,1,X,0,Z,1,Z),[F,j,X]=[q,k,Z];this.setAttribute("position",new be(a,3)),this.setAttribute("normal",new be(l,3)),this.setAttribute("uv",new be(u,2))}};var $y=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:n,spikes:r,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=i.parameters,c=i.shape,h=t*.5,d=e*.5,f=0,p=0,m=o*Math.PI/360/r,g=Math.PI/2*3*-1,y=h*n/100,v=d*n/100;if(r===3&&n===50){m=2*Math.PI/r;for(let b=0;b<r;b++){let w=m*b,E=f+Math.sin(w)*h,_=p+Math.cos(w)*d;c.addPoint(c.createPoint(E,_))}}else for(let b=0;b<r;b++){let w=f+Math.cos(g)*h,E=p+Math.sin(g)*d;c.addPoint(c.createPoint(w,E)),g+=m,w=f+Math.cos(g)*y,E=p+Math.sin(g)*v,b<=r,c.addPoint(c.createPoint(w,E)),g+=m}c.isClosed=!0;for(let b=0,w=c.points.length;b<w;b++)c.points[b].roundness=s;c.roundness=s,c.update();let x=ti.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...i,type:"StarGeometry"}})}};var q2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,n=new Ao(t,e);return Object.assign(n,{userData:{...i,type:"TextFrameGeometry"}})}};var Y2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:n,height:r,depth:s})}}static build(i){let{width:t,height:e,depth:n,radialSegments:r,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=M6(t,e,n,t*.5,o,s,0,0,r,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...i,type:"TorusGeometry"}})}};function M6(i,t,e,n,r,s,o,a,l,u,c){[t,e]=[e,t],o=t/2;let h=Te.clamp(r/360,0,1);if(h===0){let d=new Ae;return d.setAttribute("position",new be([],3)),d}return h===1&&(u=0),new Zf(!0,i,t,e,n,h,s,o,a,l,u,c)}var X2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:n,radialSegments:r,p:s,q:o}=i.parameters,a=t*.5;a!==e&&(a-=e);let l=new jc(a,e,n,r,s,o);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var K2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:n,depth:r,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5;a?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=n;l.roundness=n,l.update();let h=ti.create({shape:l,parameters:{roundness:n,depth:r,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...i,type:"TriangleGeometry"}})}};function Q2(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}var xw=class{add(t,e,n){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(r){this[r]=this[r]||[],e&&this[r][n?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(n){n.call(e&&e.context?e.context:e,e)})}},bw=class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(e=>{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}},ae=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+ae.version}static addUnaryOp(t){return ae.max_unop_len=Math.max(t.length,ae.max_unop_len),ae.unary_ops[t]=1,ae}static addBinaryOp(t,e,n){return ae.max_binop_len=Math.max(t.length,ae.max_binop_len),ae.binary_ops[t]=e,n?ae.right_associative.add(t):ae.right_associative.delete(t),ae}static addIdentifierChar(t){return ae.additional_identifier_chars.add(t),ae}static addLiteral(t,e){return ae.literals[t]=e,ae}static removeUnaryOp(t){return delete ae.unary_ops[t],t.length===ae.max_unop_len&&(ae.max_unop_len=ae.getMaxKeyLen(ae.unary_ops)),ae}static removeAllUnaryOps(){return ae.unary_ops={},ae.max_unop_len=0,ae}static removeIdentifierChar(t){return ae.additional_identifier_chars.delete(t),ae}static removeBinaryOp(t){return delete ae.binary_ops[t],t.length===ae.max_binop_len&&(ae.max_binop_len=ae.getMaxKeyLen(ae.binary_ops)),ae.right_associative.delete(t),ae}static removeAllBinaryOps(){return ae.binary_ops={},ae.max_binop_len=0,ae}static removeLiteral(t){return delete ae.literals[t],ae}static removeAllLiterals(){return ae.literals={},ae}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new ae(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(e=>e.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return ae.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!ae.binary_ops[String.fromCharCode(t)]||ae.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return ae.isIdentifierStart(t)||ae.isDecimalDigit(t)}throwError(t){let e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(ae.hooks[t]){let n={context:this,node:e};return ae.hooks.run(t,n),n.node}return e}searchHook(t){if(ae.hooks[t]){let e={context:this};return ae.hooks[t].find(function(n){return n.call(e.context,e),e.node}),e.node}}gobbleSpaces(){let t=this.code;for(;t===ae.SPACE_CODE||t===ae.TAB_CODE||t===ae.LF_CODE||t===ae.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),e=t.length===1?t[0]:{type:ae.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e=[],n,r;for(;this.index<this.expr.length;)if(n=this.code,n===ae.SEMCOL_CODE||n===ae.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())e.push(r);else if(this.index<this.expr.length){if(n===t)break;this.throwError('Unexpected "'+this.char+'"')}return e}gobbleExpression(){let t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,ae.max_binop_len),e=t.length;for(;e>0;){if(ae.binary_ops.hasOwnProperty(t)&&(!ae.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!ae.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=e,t;t=t.substr(0,--e)}return!1}gobbleBinaryExpression(){let t,e,n,r,s,o,a,l,u;if(o=this.gobbleToken(),!o||(e=this.gobbleBinaryOp(),!e))return o;for(s={value:e,prec:ae.binaryPrecedence(e),right_a:ae.right_associative.has(e)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+e),r=[o,s,a];e=this.gobbleBinaryOp();){if(n=ae.binaryPrecedence(e),n===0){this.index-=e.length;break}s={value:e,prec:n,right_a:ae.right_associative.has(e)},u=e;let c=h=>s.right_a&&h.right_a?n>h.prec:n<=h.prec;for(;r.length>2&&c(r[r.length-2]);)a=r.pop(),e=r.pop().value,o=r.pop(),t={type:ae.BINARY_EXP,operator:e,left:o,right:a},r.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+u),r.push(s,t)}for(l=r.length-1,t=r[l];l>1;)t={type:ae.BINARY_EXP,operator:r[l-1].value,left:r[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,n,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(t=this.code,ae.isDecimalDigit(t)||t===ae.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===ae.SQUOTE_CODE||t===ae.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(t===ae.OBRACK_CODE)r=this.gobbleArray();else{for(e=this.expr.substr(this.index,ae.max_unop_len),n=e.length;n>0;){if(ae.unary_ops.hasOwnProperty(e)&&(!ae.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!ae.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=n;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:ae.UNARY_EXP,operator:e,argument:s,prefix:!0})}e=e.substr(0,--n)}ae.isIdentifierStart(t)?(r=this.gobbleIdentifier(),ae.literals.hasOwnProperty(r.name)?r={type:ae.LITERAL,value:ae.literals[r.name],raw:r.name}:r.name===ae.this_str&&(r={type:ae.THIS_EXP})):t===ae.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let e=this.code;for(;e===ae.PERIOD_CODE||e===ae.OBRACK_CODE||e===ae.OPAREN_CODE||e===ae.QUMARK_CODE;){let n;if(e===ae.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==ae.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),e=this.code}this.index++,e===ae.OBRACK_CODE?(t={type:ae.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},this.gobbleSpaces(),e=this.code,e!==ae.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):e===ae.OPAREN_CODE?t={type:ae.CALL_EXP,arguments:this.gobbleArguments(ae.CPAREN_CODE),callee:t}:(e===ae.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:ae.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t="",e,n;for(;ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(this.code===ae.PERIOD_CODE)for(t+=this.expr.charAt(this.index++);ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(e=this.char,e==="e"||e==="E"){for(t+=this.expr.charAt(this.index++),e=this.char,(e==="+"||e==="-")&&(t+=this.expr.charAt(this.index++));ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);ae.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+t+this.char+")")}return n=this.code,ae.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(n===ae.PERIOD_CODE||t.length===1&&t.charCodeAt(0)===ae.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:ae.LITERAL,value:parseFloat(t),raw:t}}gobbleStringLiteral(){let t="",e=this.index,n=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===n){r=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":t+=`
|
|
3139
|
-
`;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=s}else t+=s}return r||this.throwError('Unclosed quote after "'+t+'"'),{type:ae.LITERAL,value:t,raw:this.expr.substring(e,this.index)}}gobbleIdentifier(){let t=this.code,e=this.index;for(ae.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,ae.isIdentifierPart(t));)this.index++;return{type:ae.IDENTIFIER,name:this.expr.slice(e,this.index)}}gobbleArguments(t){let e=[],n=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===t){n=!0,this.index++,t===ae.CPAREN_CODE&&r&&r>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(s===ae.COMMA_CODE){if(this.index++,r++,r!==e.length){if(t===ae.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===ae.CBRACK_CODE)for(let o=e.length;o<r;o++)e.push(null)}}else if(e.length!==r&&r!==0)this.throwError("Expected comma");else{let o=this.gobbleExpression();(!o||o.type===ae.COMPOUND)&&this.throwError("Expected comma"),e.push(o)}}return n||this.throwError("Expected "+String.fromCharCode(t)),e}gobbleGroup(){this.index++;let t=this.gobbleExpressions(ae.CPAREN_CODE);if(this.code===ae.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:ae.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:ae.ARRAY_EXP,elements:this.gobbleArguments(ae.CBRACK_CODE)}}},C6=new xw;Object.assign(ae,{hooks:C6,plugins:new bw(ae),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});ae.max_unop_len=ae.getMaxKeyLen(ae.unary_ops);ae.max_binop_len=ae.getMaxKeyLen(ae.binary_ops);var Wl=i=>new ae(i).parse(),P6=Object.getOwnPropertyNames(ae);P6.forEach(i=>{Wl[i]===void 0&&i!=="prototype"&&(Wl[i]=ae[i])});Wl.Jsep=ae;var D6="ConditionalExpression",I6={name:"ternary",init(i){i.hooks.add("after-expression",function(e){if(e.node&&this.code===i.QUMARK_CODE){this.index++;let n=e.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===i.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),e.node={type:D6,test:n,consequent:r,alternate:s},n.operator&&i.binary_ops[n.operator]<=.9){let o=n;for(;o.right.operator&&i.binary_ops[o.right.operator]<=.9;)o=o.right;e.node.test=o.right,o.right=e.node,e.node=n}}else this.throwError("Expected :")}})}};Wl.plugins.register(I6);var O6=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],R6=["0","1","2","3","4","5","6","7","8","9","."],L6=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function N6(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}Wl.addBinaryOp("^",11,!0);function ev(i,t,e="number"){let n="";for(let o=0;o<i.length;o++){let a=i[o];if("id"in a){let l=i[o-1];if(o>0&&"id"in l){console.error("Two variables in a row",i);return}let u=t.getVariable(a.id),c=Hr.getDisplayedValue(u);e==="number"&&Hr.isTextValue(u)&&Array.isArray(u.textValue)&&u.textValue.length===1?c=parseFloat(c).toString():e==="boolean"&&Hr.isBoolean(u)?c=u?"true":"false":e==="boolean"&&Hr.isTextValue(u)&&!Array.isArray(u.textValue)&&(c='"'+c+'"'),n+=c;continue}else if(e==="string"){a.name!=='"'&&a.name!=="+"&&(n+=a.name),a.name==="+"&&n[n.length-1]==="\\"&&(n=n.slice(0,-1)+a.name);continue}if(a.name==="and"){n+="&&";continue}if(a.name==="or"){n+="||";continue}if(a.name==="True"){n+="true";continue}if(a.name==="False"){n+="false";continue}if(e==="boolean"&&!N6(a.name)&&!R6.includes(a.name)&&!O6.includes(a.name)&&!L6.includes(a.name.replace(/\($/g,""))){n+='"'+a.name+'"';continue}n+=a.name}if(e==="string")return n;if(i.length===0){if(e==="number")return 0;if(e==="boolean")return!1}let r;try{r=Wl(n)}catch(o){console.error(n,o);return}let s;try{s=Mt(r)}catch(o){console.error(n,r,o)}return s}function Mt(i){switch(i.type){case"BinaryExpression":switch(i.operator){case"==":return Number(Mt(i.left)===Mt(i.right));case"!=":return Number(Mt(i.left)!==Mt(i.right));case">":return Number(Mt(i.left)>Mt(i.right));case">=":return Number(Mt(i.left)>=Mt(i.right));case"<":return Number(Mt(i.left)<Mt(i.right));case"<=":return Number(Mt(i.left)<=Mt(i.right));case"+":return Mt(i.left)+Mt(i.right);case"-":return Mt(i.left)-Mt(i.right);case"*":return Mt(i.left)*Mt(i.right);case"/":return Mt(i.left)/Mt(i.right);case"%":return Mt(i.left)%Mt(i.right);case"&&":return Mt(i.left)&&Mt(i.right);case"||":return Mt(i.left)||Mt(i.right);case"^":return Math.pow(Mt(i.left),Mt(i.right));default:throw new Error("Unknown operator: "+i.operator)}case"UnaryExpression":switch(i.operator){case"-":return-Mt(i.argument);case"!":return Number(!Mt(i.argument));default:throw new Error("Unknown operator: "+i.operator)}case"Identifier":throw new Error("Unknown identifier: "+i.name);case"Literal":return i.value;case"CallExpression":if(i.callee.type==="Identifier"){if(i.callee.name==="random"){let t=0,e=1;if(i.arguments.length>=1)try{t=Mt(i.arguments[0])}catch(n){console.warn(n)}if(i.arguments.length>=2)try{e=Mt(i.arguments[1])}catch(n){console.warn(n)}return t=Math.min(e,t),e=Math.max(e,t),t+Math.random()*(e-t)}return Math[i.callee.name].apply(null,i.arguments.map(Mt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+i.type)}}var B6=new se,F6=new se;function k6(i,t,e){let n=[new A,new A,new A],r=[new A,new A,new A];return i.extractBasis(n[0],n[1],n[2]),t.extractBasis(r[0],r[1],r[2]),n.forEach((s,o)=>{let a=r[o],l=Te.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new se().makeBasis(n[0],n[1],n[2])}var Z2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??Sh.create({parameters:gS}).userData.shape;return{path:i.path??Uu.defaultData(),parameters:Object.assign(e,{width:n,height:r,depth:s,extrusion:{...gy,...e.extrusion}}),shapeData:o}}static build(i){if(i.path.points.length>=2){let e=new Sw(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ae,{userData:{...i,type:"PathGeometry"}})}},Sw=class extends Ae{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)||!Q2(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let n=this._computeBasisMatrices(e),{depth:r,offset:s}=this.inputs.parameters.extrusion,o=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(s*o),l=this.inputs.path.isClosed?Math.ceil((r+s)*o):Math.ceil(Math.min(1,r+s)*o),u=Math.min(Math.max(2,l-a+1),o+2),c=[],h=[];for(let z=0;z<u;z++){let V=this.inputs.path.isClosed?(z+a)%e.length:Math.min(z+a,e.length-1);c.push(e[V].clone()),h.push(n[V].clone())}let d=(z,V,$)=>{c[z]=c[z].clone().lerp(c[V],$),h[z]=k6(h[z],h[V],$)},f=0,p=s*o%1;(!this.inputs.path.isClosed||r<=1)&&(p||s===0)&&(f=p,d(0,1,f));let m=0,g=(s+r)*o%1;if((this.inputs.path.isClosed&&r<=1||!this.inputs.path.isClosed&&s+r<1)&&g&&(m=g,d(c.length-1,c.length-2,1-m)),r===0){let z=c.length-1;c[z].copy(c[0]),h[z].copy(h[0])}this._applyPathModifiers(h,f,m);let{bevel:y,bevelSides:v}=this.inputs.parameters.extrusion,x=y>0?this.inputs.parameters.extrusion.capType:"flat",b=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(b=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:w,infos:E,vertices:_}=this._computeShapePoints(b),S=0,T;x==="round"&&(T=new ja(this.inputs.shapeData,2*y,y,b,v,void 0,!0),S=T.getAttribute("position").count);let M=0,C=0;E.sort((z,V)=>z.start-V.start),E.forEach(z=>{z.verticesStart=M,z.verticesCount=z.continuous.reduce((V,$,F)=>V+(F===0||!$?2:1),0),C+=z.verticesCount,M=C});let D=C*u,P,I=0;if(this._isOpenEnded()&&x==="flat"){try{P=as({windingRule:xt.ODD,elementType:pn.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:w})}catch{P=uw}I=P.vertexCount}let L=D+2*I+S*2,H=D+2*I,U={positions:new Float32Array(L*3),normals:new Float32Array(L*3),uvs:new Float32Array(L*2)},G=[];if(E.forEach(z=>{this._extrudeRegion(z,_,h,c,U,G,this._isGeometryClosed()&&!this._isOpenEnded())}),P&&(this._closeEnd(P,D,G,U,h[0],c[0],!1),this._closeEnd(P,D+I,G,U,h[h.length-1],c[c.length-1],!0)),T){U.positions.set(T.getAttribute("position").array,H*3),U.normals.set(T.getAttribute("normal").array,H*3),U.uvs.set(T.getAttribute("uv").array,H*2);let z=G.length;G.push(...T.getIndex().array.map(F=>F+H)),H+=S,U.positions.set(T.getAttribute("position").array,H*3),U.normals.set(T.getAttribute("normal").array,H*3),U.uvs.set(T.getAttribute("uv").array,H*2);let V=G.length;G.push(...T.getIndex().array.map(F=>F+H)),this.setAttribute("position",new Ge(U.positions,3)),this.setAttribute("normal",new Ge(U.normals,3)),this.setAttribute("uv",new Ge(U.uvs,2)),this.setIndex(G);let $=B6;$.copy(h[h.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange($,H,L),$.copy(h[0]).setPosition(c[0]).multiply(F6.makeScale(1,1,-1)),this.applyMatrix4OnRange($,H-S,H),this.reverseIndicesOnRange(z,V)}else this.setAttribute("position",new Ge(U.positions,3)),this.setAttribute("normal",new Ge(U.normals,3)),this.setAttribute("uv",new Ge(U.uvs,2)),this.setIndex(G)}_extractPathPoints(){let n=Uy(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(n.length<2)return[];let r=[n[0]];return n.forEach(o=>{r[r.length-1].distanceToSquared(o)>.001&&r.push(o)}),this.inputs.path.isClosed&&r[r.length-1].distanceTo(r[0])<.001&&r.pop(),r}_computeBasisMatrices(e){let n=[],r=e.length,s=this.inputs.path.isClosed,o=new A,a=new A,l=new A,u=new A,c=new A(0,1,0);for(let g=0;g<r;g++){let y=e[g],v;g===0?v=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):v=e[g-1];let x;g===r-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[g-1]):x=e[g+1];let b=y.clone().sub(v).normalize(),w=x.clone().sub(y).normalize(),E=b.clone().add(w).normalize();l.copy(E),g===0&&(E.equals(c)||E.clone().negate().equals(c))&&c.set(0,0,1);let _=c.clone().cross(E).normalize(),S=E.clone().cross(_).normalize();c.copy(S),u.copy(_),g===0&&(o.copy(S),a.copy(E));let T=new se().makeBasis(_,S,E);n.push(T)}let h=s?a:l,d=s?o:new A(0,1,0),f=h.clone().cross(u).normalize(),p=Math.acos(d.dot(f));if(isNaN(p))return n;let m=d.clone().cross(f);h.dot(m)>0&&(p*=-1);for(let g=1;g<n.length;g++){let y=new se().makeRotationZ(p*g/n.length);n[g].multiply(y)}return n}_applyPathModifiers(e,n,r){let s=e.length,{angle:o,twist:a,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new se,h=new se;return e.forEach((d,f)=>{let p=f===0?0:f===s-1?1:(f-n)/(s-(r===0?0:1)-(n+(1-r)));c.makeRotationZ(Te.lerp(o,o+a,p)*Te.DEG2RAD);let m=Te.lerp(l,u,p);h.makeScale(m,m,m),d.multiply(c).multiply(h)}),e}_computeShapePoints(e=12,n=xt.ODD){let r=this.inputs.shapeData,s=r.extractShapePointsToFlatArray([],e),o=r.shapeHoles.map(m=>{let g=m.extractShapePointsToFlatArray([],e),y=[];for(let v=g.length-1;v>=1;v-=2){let x=g[v-1],b=g[v-0];y.push(x,b)}return y}),a;try{a=as({windingRule:n,elementType:pn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=Qf}let l;try{l=as({windingRule:xt.ODD,elementType:pn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=cw}if(!a)throw new Error("error generating geometry");let u=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let g=l.elements[m],y=m%2===0?a.vertexCount:0;a.elements.push(g+y)}for(let m=0;m<l.vertexIndices.length;m++){let g=l.vertexIndices[m],y=a.vertexCount;a.vertexIndices.push(g+y)}for(let m=0;m<l.vertices.length;m++){let g=l.vertices[m];a.vertices.push(g)}}let c=1/0,h=-1/0,d=1/0,f=-1/0;for(let m=0,g=a.vertexCount;m<g;m++){let y=m*2,v=a.vertices[y+0],x=a.vertices[y+1];v<c&&(c=v),v>h&&(h=v),x<d&&(d=x),x>f&&(f=x)}let p=[];for(let m=a.elementCount-1;m>=0;m--){let g=m>=u,y=m*2,v=a.elements[y+0],x=a.elements[y+1],b=v+x,w={start:v,count:x,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};p.push(w);let E=v,_=b-1,S=v+1,T=r.roundedCurves.length;do{let M=E-v,C=a.vertices[_*2+0],D=a.vertices[_*2+1],P=a.vertices[E*2+0],I=a.vertices[E*2+1],L=a.vertices[S*2+0],H=a.vertices[S*2+1],U=P-C,G=I-D,z=Math.sqrt(U*U+G*G);U/=z,G/=z;let V=P-L,$=I-H,F=Math.sqrt(V*V+$*$);V/=F,$/=F,w.normals[M*2+0]=-$,w.normals[M*2+1]=V;let j=a.vertexIndices[E];if(Array.isArray(j))w.continuous[M]=!1;else{let[X,q]=r.getCurveIndexFromVertexId(j-1,!0);if(q>0&&q<1)w.continuous[M]=!0;else{let k=q===1?X+1:X-1;k=(k+T)%T;let Z=q===1?0:1,Q=r.roundedCurves[X].getTangent(q),K=r.roundedCurves[k].getTangent(Z);w.continuous[M]=Q.dot(K)>.95}}g&&(w.normals[M*2+0]*=-1,w.normals[M*2+1]*=-1),[_,E,S]=[E,S,S+1],S>=b&&(S-=x)}while(S!==v+1)}return{regions:[s,...o],infos:p,vertices:a.vertices}}_insertVertex(e,n,r,s,o){let a=n*2,l=n*3;e.positions[l+0]=r.x,e.positions[l+1]=r.y,e.positions[l+2]=r.z,e.normals[l+0]=s.x,e.normals[l+1]=s.y,e.normals[l+2]=s.z,e.uvs[a+0]=o.x,e.uvs[a+1]=o.y}_extrudeRegion(e,n,r,s,o,a,l){let u=new A,c=new A,h=new A,d=new A,f=new B;r.forEach((m,g)=>{let y=s[g],v=e.verticesStart*r.length+e.verticesCount*g;for(let x=0;x<e.count;x++){let b=(e.start+x)*2;if(u.set(n[b+0],n[b+1],0),h.copy(u).applyMatrix4(m).add(y),e.continuous[x])d.set(e.normals[x*2+0],e.normals[x*2+1],0);else{let w=x===0?(e.start+e.count-1)*2:b-2;c.set(n[w+0],n[w+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(m).normalize(),f.set(x===0?1:x/e.count,g/(r.length-1)),this._insertVertex(o,v,h,d,f),v++,!e.continuous[x]||x===0){if(x===0)d.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,g/(r.length-1));else{let w=x===e.count-1?e.start*2:b+2;c.set(n[w+0],n[w+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(m).normalize(),this._insertVertex(o,v,h,d,f),v++}}});let p=r.length-1;for(let m=0;m<p;m++){let g=e.verticesStart*r.length+e.verticesCount*m,y=e.verticesStart*r.length+e.verticesCount*(m+1),v=0;for(let x=0;x<e.count;x++){(!e.continuous[x]||x===0)&&v++;let b=x===e.count-1?0:v+1,w=g+v,E=g+b,_=y+b,S=y+v;e.isHole?a.push(w,_,E,w,S,_):a.push(w,E,_,w,_,S),v++}}}_closeEnd(e,n,r,s,o,a,l){let u=e.vertexCount,c=new A(0,0,l?-1:1).applyMatrix4(o),h=new A,d=new B;for(let p=0;p<u;p++){let m=2*p;h.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(o).add(a),this._insertVertex(s,n+p,h,c,d)}let f=e.elements;for(let p=0;p<e.elementCount;p++){let m=3*p,g=f[m+0]+n,y=f[m+(l?1:2)]+n,v=f[m+(l?2:1)]+n;r.push(g,y,v)}}applyMatrix4OnRange(e,n,r){let s=e.elements,o=new $t().getNormalMatrix(e).elements,a,l,u,c,h=this.attributes.position,d=this.attributes.normal;if(!h||!d)return;let f=h.array,p=d.array,m=h.itemSize;for(let g=n*m,y=r*m;g<y;g+=m){if(g===n)debugger;a=f[g+0],l=f[g+1],u=f[g+2],c=1/(s[3]*a+s[7]*l+s[11]*u+s[15]),f[g+0]=(s[0]*a+s[4]*l+s[8]*u+s[12])*c,f[g+1]=(s[1]*a+s[5]*l+s[9]*u+s[13])*c,f[g+2]=(s[2]*a+s[6]*l+s[10]*u+s[14])*c,a=p[g+0],l=p[g+1],u=p[g+2],p[g+0]=o[0]*a+o[3]*l+o[6]*u,p[g+1]=o[1]*a+o[4]*l+o[7]*u,p[g+2]=o[2]*a+o[5]*l+o[8]*u}h.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,n){let r=this.index;if(r){for(let s=e;s<n;s+=3){let o=r.getX(s),a=r.getX(s+1),l=r.getX(s+2);r.setXYZ(s,l,a,o)}r.needsUpdate=!0}}};function J2(){let i=new Ae;return i.setAttribute("position",new Ge(new Float32Array([]),3)),i.setIndex(new Ge(new Uint16Array([]),1)),i}var U6=J2().attributes,V6=12,z6=1,Eh=class extends Ae{constructor(e,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,U6),this.userData={parameters:e,type:"TextGeometry"};let r=n.getFont(e.font);r?.isLoaded?(this.font=r,this.update(e)):this.updateFont(e.font,n).then(()=>{this.update(e),n?.requestRender()})}async updateFont(e,n){let r=n.getFont(e);r&&(this.font=r,await r.loadingPromise)}update(e){let n=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!n?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:r,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=e,h=Hr.getDisplayedValue(u),d=c===2?h.toUpperCase():c===3?h.toLowerCase():h,f=G6(e,n,d),{shapes:p,charWidths:m,charCoords:g}=n.generateShapes(f,e),y=(typeof r=="number"?r:1)*.5,v=(typeof s=="number"?s:1)*.5,x=p.map(E=>new Pt().fromShape(E));this.vectorShapes=x;let b=x.map(E=>ti.create({shape:E,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?xt.NONZERO:xt.ODD,subdivisions:this.isLowResolution&&o>0?z6:V6}})),w=b.length?rs(b):J2();w.translate(-y,v,0),this.dispose(),this.wrappedText=f,this.charCoords=g,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([E,_])=>{this.setAttribute(E,_)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=Qr(new Ae,Eh.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([n,r])=>{this.setAttribute(n,r)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function G6(i,t,e){let n=[""],r="";for(let s of e)r+=s,s===" "||s===`
|
|
3138
|
+
}`;function Wk(i,t,e){let n=new tf,r=new B,s=new B,o=new Xe,a=new nf({depthPacking:gb}),l=new Wx,u={},c=e.maxTextureSize,h={[fi]:kn,[kn]:fi,[Ur]:Ur},d=new ot({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new B},radius:{value:4}},vertexShader:Hk,fragmentShader:jk}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let p=new Ae;p.setAttribute("position",new Ge(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new Fn(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ng,this.render=function(b,w,E){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let _=i.getRenderTarget(),S=i.getActiveCubeFace(),T=i.getActiveMipmapLevel(),M=i.state;M.setBlending(Nt),M.buffers.color.setClear(1,1,1,1),M.buffers.depth.setTest(!0),M.setScissorTest(!1);for(let C=0,D=b.length;C<D;C++){let P=b[C],I=P.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;r.copy(I.mapSize);let L=I.getFrameExtents();if(r.multiply(L),s.copy(I.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/L.x),r.x=s.x*L.x,I.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/L.y),r.y=s.y*L.y,I.mapSize.y=s.y)),I.map===null){let U=this.type!==Wd?{minFilter:Lt,magFilter:Lt}:{};I.map=new ut(r.x,r.y,U),I.map.texture.name=P.name+".shadowMap",I.camera.updateProjectionMatrix()}i.setRenderTarget(I.map),i.clear();let H=I.getViewportCount();for(let U=0;U<H;U++){let G=I.getViewport(U);o.set(s.x*G.x,s.y*G.y,s.x*G.z,s.y*G.w),M.viewport(o),I.updateMatrices(P,U),n=I.getFrustum(),x(w,E,I.camera,P,this.type)}I.isPointLightShadow!==!0&&this.type===Wd&&y(I,E),I.needsUpdate=!1}g.needsUpdate=!1,i.setRenderTarget(_,S,T)};function y(b,w){let E=t.update(m);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new ut(r.x,r.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(w,null,E,d,m,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,i.setRenderTarget(b.map),i.clear(),i.renderBufferDirect(w,null,E,f,m,null)}function v(b,w,E,_,S,T){let M=null,C=E.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)M=C;else if(M=E.isPointLight===!0?l:a,i.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){let D=M.uuid,P=w.uuid,I=u[D];I===void 0&&(I={},u[D]=I);let L=I[P];L===void 0&&(L=M.clone(),I[P]=L),M=L}return M.visible=w.visible,M.wireframe=w.wireframe,T===Wd?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:h[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,E.isPointLight===!0&&M.isMeshDistanceMaterial===!0&&(M.referencePosition.setFromMatrixPosition(E.matrixWorld),M.nearDistance=_,M.farDistance=S),M}function x(b,w,E,_,S){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&S===Wd)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,b.matrixWorld);let C=t.update(b),D=b.material;if(Array.isArray(D)){let P=C.groups;for(let I=0,L=P.length;I<L;I++){let H=P[I],U=D[H.materialIndex];if(U&&U.visible){let G=v(b,U,_,E.near,E.far,S);i.renderBufferDirect(E,null,C,G,b,H)}}}else if(D.visible){let P=v(b,D,_,E.near,E.far,S);i.renderBufferDirect(E,null,C,P,b,null)}}let M=b.children;for(let C=0,D=M.length;C<D;C++)x(M[C],w,E,_,S)}}function qk(i,t,e){let n=e.isWebGL2;function r(){let Y=!1,ce=new Xe,ve=null,Ue=new Xe(0,0,0,0);return{setMask:function(Be){ve!==Be&&!Y&&(i.colorMask(Be,Be,Be,Be),ve=Be)},setLocked:function(Be){Y=Be},setClear:function(Be,wt,Rn,Sn,sl){sl===!0&&(Be*=Sn,wt*=Sn,Rn*=Sn),ce.set(Be,wt,Rn,Sn),Ue.equals(ce)===!1&&(i.clearColor(Be,wt,Rn,Sn),Ue.copy(ce))},reset:function(){Y=!1,ve=null,Ue.set(-1,0,0,0)}}}function s(){let Y=!1,ce=null,ve=null,Ue=null;return{setTest:function(Be){Be?Z(2929):Q(2929)},setMask:function(Be){ce!==Be&&!Y&&(i.depthMask(Be),ce=Be)},setFunc:function(Be){if(ve!==Be){switch(Be){case wL:i.depthFunc(512);break;case AL:i.depthFunc(519);break;case EL:i.depthFunc(513);break;case Dx:i.depthFunc(515);break;case _L:i.depthFunc(514);break;case TL:i.depthFunc(518);break;case ML:i.depthFunc(516);break;case CL:i.depthFunc(517);break;default:i.depthFunc(515)}ve=Be}},setLocked:function(Be){Y=Be},setClear:function(Be){Ue!==Be&&(i.clearDepth(Be),Ue=Be)},reset:function(){Y=!1,ce=null,ve=null,Ue=null}}}function o(){let Y=!1,ce=null,ve=null,Ue=null,Be=null,wt=null,Rn=null,Sn=null,sl=null;return{setTest:function(on){Y||(on?Z(2960):Q(2960))},setMask:function(on){ce!==on&&!Y&&(i.stencilMask(on),ce=on)},setFunc:function(on,uo,_i){(ve!==on||Ue!==uo||Be!==_i)&&(i.stencilFunc(on,uo,_i),ve=on,Ue=uo,Be=_i)},setOp:function(on,uo,_i){(wt!==on||Rn!==uo||Sn!==_i)&&(i.stencilOp(on,uo,_i),wt=on,Rn=uo,Sn=_i)},setLocked:function(on){Y=on},setClear:function(on){sl!==on&&(i.clearStencil(on),sl=on)},reset:function(){Y=!1,ce=null,ve=null,Ue=null,Be=null,wt=null,Rn=null,Sn=null,sl=null}}}let a=new r,l=new s,u=new o,c=new WeakMap,h=new WeakMap,d={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,b=null,w=null,E=null,_=null,S=null,T=!1,M=null,C=null,D=null,P=null,I=null,L=i.getParameter(35661),H=!1,U=0,G=i.getParameter(7938);G.indexOf("WebGL")!==-1?(U=parseFloat(/^WebGL (\d)/.exec(G)[1]),H=U>=1):G.indexOf("OpenGL ES")!==-1&&(U=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),H=U>=2);let z=null,V={},$=i.getParameter(3088),F=i.getParameter(2978),j=new Xe().fromArray($),X=new Xe().fromArray(F);function q(Y,ce,ve){let Ue=new Uint8Array(4),Be=i.createTexture();i.bindTexture(Y,Be),i.texParameteri(Y,10241,9728),i.texParameteri(Y,10240,9728);for(let wt=0;wt<ve;wt++)i.texImage2D(ce+wt,0,6408,1,1,0,6408,5121,Ue);return Be}let k={};k[3553]=q(3553,3553,1),k[34067]=q(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),Z(2929),l.setFunc(Dx),Oe(!1),Ie(L1),Z(2884),we(Nt);function Z(Y){d[Y]!==!0&&(i.enable(Y),d[Y]=!0)}function Q(Y){d[Y]!==!1&&(i.disable(Y),d[Y]=!1)}function K(Y,ce){return f[Y]!==ce?(i.bindFramebuffer(Y,ce),f[Y]=ce,n&&(Y===36009&&(f[36160]=ce),Y===36160&&(f[36009]=ce)),!0):!1}function W(Y,ce){let ve=m,Ue=!1;if(Y)if(ve=p.get(ce),ve===void 0&&(ve=[],p.set(ce,ve)),Y.isWebGLMultipleRenderTargets){let Be=Y.texture;if(ve.length!==Be.length||ve[0]!==36064){for(let wt=0,Rn=Be.length;wt<Rn;wt++)ve[wt]=36064+wt;ve.length=Be.length,Ue=!0}}else ve[0]!==36064&&(ve[0]=36064,Ue=!0);else ve[0]!==1029&&(ve[0]=1029,Ue=!0);Ue&&(e.isWebGL2?i.drawBuffers(ve):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ve))}function ye(Y){return g!==Y?(i.useProgram(Y),g=Y,!0):!1}let fe={[Tc]:32774,[hL]:32778,[dL]:32779};if(n)fe[k1]=32775,fe[U1]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(fe[k1]=Y.MIN_EXT,fe[U1]=Y.MAX_EXT)}let ie={[fL]:0,[pL]:1,[mL]:768,[h_]:770,[SL]:776,[xL]:774,[yL]:772,[gL]:769,[d_]:771,[bL]:775,[vL]:773};function we(Y,ce,ve,Ue,Be,wt,Rn,Sn){if(Y===Nt){y===!0&&(Q(3042),y=!1);return}if(y===!1&&(Z(3042),y=!0),Y!==uL){if(Y!==v||Sn!==T){if((x!==Tc||E!==Tc)&&(i.blendEquation(32774),x=Tc,E=Tc),Sn)switch(Y){case Ic:i.blendFuncSeparate(1,771,1,771);break;case N1:i.blendFunc(1,1);break;case B1:i.blendFuncSeparate(0,769,0,1);break;case F1:i.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case Ic:i.blendFuncSeparate(770,771,1,771);break;case N1:i.blendFunc(770,1);break;case B1:i.blendFuncSeparate(0,769,0,1);break;case F1:i.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}b=null,w=null,_=null,S=null,v=Y,T=Sn}return}Be=Be||ce,wt=wt||ve,Rn=Rn||Ue,(ce!==x||Be!==E)&&(i.blendEquationSeparate(fe[ce],fe[Be]),x=ce,E=Be),(ve!==b||Ue!==w||wt!==_||Rn!==S)&&(i.blendFuncSeparate(ie[ve],ie[Ue],ie[wt],ie[Rn]),b=ve,w=Ue,_=wt,S=Rn),v=Y,T=!1}function xe(Y,ce){Y.side===Ur?Q(2884):Z(2884);let ve=Y.side===kn;ce&&(ve=!ve),Oe(ve),Y.blending===Ic&&Y.transparent===!1?we(Nt):we(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.premultipliedAlpha),l.setFunc(Y.depthFunc),l.setTest(Y.depthTest),l.setMask(Y.depthWrite),a.setMask(Y.colorWrite);let Ue=Y.stencilWrite;u.setTest(Ue),Ue&&(u.setMask(Y.stencilWriteMask),u.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),u.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),_e(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?Z(32926):Q(32926)}function Oe(Y){M!==Y&&(Y?i.frontFace(2304):i.frontFace(2305),M=Y)}function Ie(Y){Y!==aL?(Z(2884),Y!==C&&(Y===L1?i.cullFace(1029):Y===lL?i.cullFace(1028):i.cullFace(1032))):Q(2884),C=Y}function Pe(Y){Y!==D&&(H&&i.lineWidth(Y),D=Y)}function _e(Y,ce,ve){Y?(Z(32823),(P!==ce||I!==ve)&&(i.polygonOffset(ce,ve),P=ce,I=ve)):Q(32823)}function Ve(Y){Y?Z(3089):Q(3089)}function ze(Y){Y===void 0&&(Y=33984+L-1),z!==Y&&(i.activeTexture(Y),z=Y)}function R(Y,ce,ve){ve===void 0&&(z===null?ve=33984+L-1:ve=z);let Ue=V[ve];Ue===void 0&&(Ue={type:void 0,texture:void 0},V[ve]=Ue),(Ue.type!==Y||Ue.texture!==ce)&&(z!==ve&&(i.activeTexture(ve),z=ve),i.bindTexture(Y,ce||k[Y]),Ue.type=Y,Ue.texture=ce)}function O(){let Y=V[z];Y!==void 0&&Y.type!==void 0&&(i.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function ne(){try{i.compressedTexImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ue(){try{i.compressedTexImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function me(){try{i.texSubImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function De(){try{i.texSubImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Me(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ee(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function le(){try{i.texStorage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ke(){try{i.texStorage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ke(){try{i.texImage2D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Le(){try{i.texImage3D.apply(i,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function je(Y){j.equals(Y)===!1&&(i.scissor(Y.x,Y.y,Y.z,Y.w),j.copy(Y))}function Je(Y){X.equals(Y)===!1&&(i.viewport(Y.x,Y.y,Y.z,Y.w),X.copy(Y))}function St(Y,ce){let ve=h.get(ce);ve===void 0&&(ve=new WeakMap,h.set(ce,ve));let Ue=ve.get(Y);Ue===void 0&&(Ue=i.getUniformBlockIndex(ce,Y.name),ve.set(Y,Ue))}function Zt(Y,ce){let Ue=h.get(ce).get(Y);c.get(ce)!==Ue&&(i.uniformBlockBinding(ce,Ue,Y.__bindingPointIndex),c.set(ce,Ue))}function On(){i.disable(3042),i.disable(2884),i.disable(2929),i.disable(32823),i.disable(3089),i.disable(2960),i.disable(32926),i.blendEquation(32774),i.blendFunc(1,0),i.blendFuncSeparate(1,0,1,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(513),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(519,0,4294967295),i.stencilOp(7680,7680,7680),i.clearStencil(0),i.cullFace(1029),i.frontFace(2305),i.polygonOffset(0,0),i.activeTexture(33984),i.bindFramebuffer(36160,null),n===!0&&(i.bindFramebuffer(36009,null),i.bindFramebuffer(36008,null)),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),d={},z=null,V={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,b=null,w=null,E=null,_=null,S=null,T=!1,M=null,C=null,D=null,P=null,I=null,j.set(0,0,i.canvas.width,i.canvas.height),X.set(0,0,i.canvas.width,i.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:Z,disable:Q,bindFramebuffer:K,drawBuffers:W,useProgram:ye,setBlending:we,setMaterial:xe,setFlipSided:Oe,setCullFace:Ie,setLineWidth:Pe,setPolygonOffset:_e,setScissorTest:Ve,activeTexture:ze,bindTexture:R,unbindTexture:O,compressedTexImage2D:ne,compressedTexImage3D:ue,texImage2D:ke,texImage3D:Le,updateUBOMapping:St,uniformBlockBinding:Zt,texStorage2D:le,texStorage3D:Ke,texSubImage2D:me,texSubImage3D:De,compressedTexSubImage2D:Me,compressedTexSubImage3D:Ee,scissor:je,viewport:Je,reset:On}}function Yk(i,t,e,n,r,s,o){let a=r.isWebGL2,l=r.maxTextures,u=r.maxCubemapSize,c=r.maxTextureSize,h=r.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap,m,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(R,O){return y?new OffscreenCanvas(R,O):Om("canvas")}function x(R,O,ne,ue){let me=1;if((R.width>ue||R.height>ue)&&(me=ue/Math.max(R.width,R.height)),me<1||O===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let De=O?Im:Math.floor,Me=De(me*R.width),Ee=De(me*R.height);m===void 0&&(m=v(Me,Ee));let le=ne?v(Me,Ee):m;return le.width=Me,le.height=Ee,le.getContext("2d").drawImage(R,0,0,Me,Ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Me+"x"+Ee+")."),le}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function b(R){return Bx(R.width)&&Bx(R.height)}function w(R){return a?!1:R.wrapS!==Jt||R.wrapT!==Jt||R.minFilter!==Lt&&R.minFilter!==Ze}function E(R,O){return R.generateMipmaps&&O&&R.minFilter!==Lt&&R.minFilter!==Ze}function _(R){i.generateMipmap(R)}function S(R,O,ne,ue,me=!1){if(a===!1)return O;if(R!==null){if(i[R]!==void 0)return i[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let De=O;return O===6403&&(ne===5126&&(De=33326),ne===5131&&(De=33325),ne===5121&&(De=33321)),O===33319&&(ne===5126&&(De=33328),ne===5131&&(De=33327),ne===5121&&(De=33323)),O===6408&&(ne===5126&&(De=34836),ne===5131&&(De=34842),ne===5121&&(De=ue===$e&&me===!1?35907:32856),ne===32819&&(De=32854),ne===32820&&(De=32855)),(De===33325||De===33326||De===33327||De===33328||De===34842||De===34836)&&t.get("EXT_color_buffer_float"),De}function T(R,O,ne){return E(R,ne)===!0||R.isFramebufferTexture&&R.minFilter!==Lt&&R.minFilter!==Ze?Math.log2(Math.max(O.width,O.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?O.mipmaps.length:1}function M(R){return R===Lt||R===V1||R===Y0?9728:9729}function C(R){let O=R.target;O.removeEventListener("dispose",C),P(O),O.isVideoTexture&&p.delete(O)}function D(R){let O=R.target;O.removeEventListener("dispose",D),L(O)}function P(R){let O=n.get(R);if(O.__webglInit===void 0)return;let ne=R.source,ue=g.get(ne);if(ue){let me=ue[O.__cacheKey];me.usedTimes--,me.usedTimes===0&&I(R),Object.keys(ue).length===0&&g.delete(ne)}n.remove(R)}function I(R){let O=n.get(R);i.deleteTexture(O.__webglTexture);let ne=R.source,ue=g.get(ne);delete ue[O.__cacheKey],o.memory.textures--}function L(R){let O=R.texture,ne=n.get(R),ue=n.get(O);if(ue.__webglTexture!==void 0&&(i.deleteTexture(ue.__webglTexture),o.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)i.deleteFramebuffer(ne.__webglFramebuffer[me]),ne.__webglDepthbuffer&&i.deleteRenderbuffer(ne.__webglDepthbuffer[me]);else{if(i.deleteFramebuffer(ne.__webglFramebuffer),ne.__webglDepthbuffer&&i.deleteRenderbuffer(ne.__webglDepthbuffer),ne.__webglMultisampledFramebuffer&&i.deleteFramebuffer(ne.__webglMultisampledFramebuffer),ne.__webglColorRenderbuffer)for(let me=0;me<ne.__webglColorRenderbuffer.length;me++)ne.__webglColorRenderbuffer[me]&&i.deleteRenderbuffer(ne.__webglColorRenderbuffer[me]);ne.__webglDepthRenderbuffer&&i.deleteRenderbuffer(ne.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let me=0,De=O.length;me<De;me++){let Me=n.get(O[me]);Me.__webglTexture&&(i.deleteTexture(Me.__webglTexture),o.memory.textures--),n.remove(O[me])}n.remove(O),n.remove(R)}let H=0;function U(){H=0}function G(){let R=H;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),H+=1,R}function z(R){let O=[];return O.push(R.wrapS),O.push(R.wrapT),O.push(R.wrapR||0),O.push(R.magFilter),O.push(R.minFilter),O.push(R.anisotropy),O.push(R.internalFormat),O.push(R.format),O.push(R.type),O.push(R.generateMipmaps),O.push(R.premultiplyAlpha),O.push(R.flipY),O.push(R.unpackAlignment),O.push(R.encoding),O.join()}function V(R,O){let ne=n.get(R);if(R.isVideoTexture&&Ve(R),R.isRenderTargetTexture===!1&&R.version>0&&ne.__version!==R.version){let ue=R.image;if(ue===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ue.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q(ne,R,O);return}}e.bindTexture(3553,ne.__webglTexture,33984+O)}function $(R,O){let ne=n.get(R);if(R.version>0&&ne.__version!==R.version){Q(ne,R,O);return}e.bindTexture(35866,ne.__webglTexture,33984+O)}function F(R,O){let ne=n.get(R);if(R.version>0&&ne.__version!==R.version){Q(ne,R,O);return}e.bindTexture(32879,ne.__webglTexture,33984+O)}function j(R,O){let ne=n.get(R);if(R.version>0&&ne.__version!==R.version){K(ne,R,O);return}e.bindTexture(34067,ne.__webglTexture,33984+O)}let X={[Zi]:10497,[Jt]:33071,[Rx]:33648},q={[Lt]:9728,[V1]:9984,[Y0]:9986,[Ze]:9729,[BL]:9985,[gl]:9987};function k(R,O,ne){if(ne?(i.texParameteri(R,10242,X[O.wrapS]),i.texParameteri(R,10243,X[O.wrapT]),(R===32879||R===35866)&&i.texParameteri(R,32882,X[O.wrapR]),i.texParameteri(R,10240,q[O.magFilter]),i.texParameteri(R,10241,q[O.minFilter])):(i.texParameteri(R,10242,33071),i.texParameteri(R,10243,33071),(R===32879||R===35866)&&i.texParameteri(R,32882,33071),(O.wrapS!==Jt||O.wrapT!==Jt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(R,10240,M(O.magFilter)),i.texParameteri(R,10241,M(O.minFilter)),O.minFilter!==Lt&&O.minFilter!==Ze&&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 ue=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===Lt||O.minFilter!==Y0&&O.minFilter!==gl||O.type===Sr&&t.has("OES_texture_float_linear")===!1||a===!1&&O.type===yl&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||n.get(O).__currentAnisotropy)&&(i.texParameterf(R,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,r.getMaxAnisotropy())),n.get(O).__currentAnisotropy=O.anisotropy)}}function Z(R,O){let ne=!1;R.__webglInit===void 0&&(R.__webglInit=!0,O.addEventListener("dispose",C));let ue=O.source,me=g.get(ue);me===void 0&&(me={},g.set(ue,me));let De=z(O);if(De!==R.__cacheKey){me[De]===void 0&&(me[De]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,ne=!0),me[De].usedTimes++;let Me=me[R.__cacheKey];Me!==void 0&&(me[R.__cacheKey].usedTimes--,Me.usedTimes===0&&I(O)),R.__cacheKey=De,R.__webglTexture=me[De].texture}return ne}function Q(R,O,ne){let ue=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(ue=35866),O.isData3DTexture&&(ue=32879);let me=Z(R,O),De=O.source;e.bindTexture(ue,R.__webglTexture,33984+ne);let Me=n.get(De);if(De.version!==Me.__version||me===!0){e.activeTexture(33984+ne),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let Ee=w(O)&&b(O.image)===!1,le=x(O.image,Ee,!1,c);le=ze(O,le);let Ke=b(le)||a,ke=s.convert(O.format,O.encoding),Le=s.convert(O.type),je=S(O.internalFormat,ke,Le,O.encoding,O.isVideoTexture);k(ue,O,Ke);let Je,St=O.mipmaps,Zt=a&&O.isVideoTexture!==!0,On=Me.__version===void 0||me===!0,Y=T(O,le,Ke);if(O.isDepthTexture)je=6402,a?O.type===Sr?je=36012:O.type===xo?je=33190:O.type===sa?je=35056:je=33189:O.type===Sr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===pl&&je===6402&&O.type!==m_&&O.type!==xo&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=xo,Le=s.convert(O.type)),O.format===la&&je===6402&&(je=34041,O.type!==sa&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=sa,Le=s.convert(O.type))),On&&(Zt?e.texStorage2D(3553,1,je,le.width,le.height):e.texImage2D(3553,0,je,le.width,le.height,0,ke,Le,null));else if(O.isDataTexture)if(St.length>0&&Ke){Zt&&On&&e.texStorage2D(3553,Y,je,St[0].width,St[0].height);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],Zt?e.texSubImage2D(3553,ce,0,0,Je.width,Je.height,ke,Le,Je.data):e.texImage2D(3553,ce,je,Je.width,Je.height,0,ke,Le,Je.data);O.generateMipmaps=!1}else Zt?(On&&e.texStorage2D(3553,Y,je,le.width,le.height),e.texSubImage2D(3553,0,0,0,le.width,le.height,ke,Le,le.data)):e.texImage2D(3553,0,je,le.width,le.height,0,ke,Le,le.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Zt&&On&&e.texStorage3D(35866,Y,je,St[0].width,St[0].height,le.depth);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],O.format!==di?ke!==null?Zt?e.compressedTexSubImage3D(35866,ce,0,0,0,Je.width,Je.height,le.depth,ke,Je.data,0,0):e.compressedTexImage3D(35866,ce,je,Je.width,Je.height,le.depth,0,Je.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Zt?e.texSubImage3D(35866,ce,0,0,0,Je.width,Je.height,le.depth,ke,Le,Je.data):e.texImage3D(35866,ce,je,Je.width,Je.height,le.depth,0,ke,Le,Je.data)}else{Zt&&On&&e.texStorage2D(3553,Y,je,St[0].width,St[0].height);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],O.format!==di?ke!==null?Zt?e.compressedTexSubImage2D(3553,ce,0,0,Je.width,Je.height,ke,Je.data):e.compressedTexImage2D(3553,ce,je,Je.width,Je.height,0,Je.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Zt?e.texSubImage2D(3553,ce,0,0,Je.width,Je.height,ke,Le,Je.data):e.texImage2D(3553,ce,je,Je.width,Je.height,0,ke,Le,Je.data)}else if(O.isDataArrayTexture)Zt?(On&&e.texStorage3D(35866,Y,je,le.width,le.height,le.depth),e.texSubImage3D(35866,0,0,0,0,le.width,le.height,le.depth,ke,Le,le.data)):e.texImage3D(35866,0,je,le.width,le.height,le.depth,0,ke,Le,le.data);else if(O.isData3DTexture)Zt?(On&&e.texStorage3D(32879,Y,je,le.width,le.height,le.depth),e.texSubImage3D(32879,0,0,0,0,le.width,le.height,le.depth,ke,Le,le.data)):e.texImage3D(32879,0,je,le.width,le.height,le.depth,0,ke,Le,le.data);else if(O.isFramebufferTexture){if(On)if(Zt)e.texStorage2D(3553,Y,je,le.width,le.height);else{let ce=le.width,ve=le.height;for(let Ue=0;Ue<Y;Ue++)e.texImage2D(3553,Ue,je,ce,ve,0,ke,Le,null),ce>>=1,ve>>=1}}else if(St.length>0&&Ke){Zt&&On&&e.texStorage2D(3553,Y,je,St[0].width,St[0].height);for(let ce=0,ve=St.length;ce<ve;ce++)Je=St[ce],Zt?e.texSubImage2D(3553,ce,0,0,ke,Le,Je):e.texImage2D(3553,ce,je,ke,Le,Je);O.generateMipmaps=!1}else Zt?(On&&e.texStorage2D(3553,Y,je,le.width,le.height),e.texSubImage2D(3553,0,0,0,ke,Le,le)):e.texImage2D(3553,0,je,ke,Le,le);E(O,Ke)&&_(ue),Me.__version=De.version,O.onUpdate&&O.onUpdate(O)}R.__version=O.version}function K(R,O,ne){if(O.image.length!==6)return;let ue=Z(R,O),me=O.source;e.bindTexture(34067,R.__webglTexture,33984+ne);let De=n.get(me);if(me.version!==De.__version||ue===!0){e.activeTexture(33984+ne),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let Me=O.isCompressedTexture||O.image[0].isCompressedTexture,Ee=O.image[0]&&O.image[0].isDataTexture,le=[];for(let ce=0;ce<6;ce++)!Me&&!Ee?le[ce]=x(O.image[ce],!1,!0,u):le[ce]=Ee?O.image[ce].image:O.image[ce],le[ce]=ze(O,le[ce]);let Ke=le[0],ke=b(Ke)||a,Le=s.convert(O.format,O.encoding),je=s.convert(O.type),Je=S(O.internalFormat,Le,je,O.encoding),St=a&&O.isVideoTexture!==!0,Zt=De.__version===void 0||ue===!0,On=T(O,Ke,ke);k(34067,O,ke);let Y;if(Me){St&&Zt&&e.texStorage2D(34067,On,Je,Ke.width,Ke.height);for(let ce=0;ce<6;ce++){Y=le[ce].mipmaps;for(let ve=0;ve<Y.length;ve++){let Ue=Y[ve];O.format!==di?Le!==null?St?e.compressedTexSubImage2D(34069+ce,ve,0,0,Ue.width,Ue.height,Le,Ue.data):e.compressedTexImage2D(34069+ce,ve,Je,Ue.width,Ue.height,0,Ue.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):St?e.texSubImage2D(34069+ce,ve,0,0,Ue.width,Ue.height,Le,je,Ue.data):e.texImage2D(34069+ce,ve,Je,Ue.width,Ue.height,0,Le,je,Ue.data)}}}else{Y=O.mipmaps,St&&Zt&&(Y.length>0&&On++,e.texStorage2D(34067,On,Je,le[0].width,le[0].height));for(let ce=0;ce<6;ce++)if(Ee){St?e.texSubImage2D(34069+ce,0,0,0,le[ce].width,le[ce].height,Le,je,le[ce].data):e.texImage2D(34069+ce,0,Je,le[ce].width,le[ce].height,0,Le,je,le[ce].data);for(let ve=0;ve<Y.length;ve++){let Be=Y[ve].image[ce].image;St?e.texSubImage2D(34069+ce,ve+1,0,0,Be.width,Be.height,Le,je,Be.data):e.texImage2D(34069+ce,ve+1,Je,Be.width,Be.height,0,Le,je,Be.data)}}else{St?e.texSubImage2D(34069+ce,0,0,0,Le,je,le[ce]):e.texImage2D(34069+ce,0,Je,Le,je,le[ce]);for(let ve=0;ve<Y.length;ve++){let Ue=Y[ve];St?e.texSubImage2D(34069+ce,ve+1,0,0,Le,je,Ue.image[ce]):e.texImage2D(34069+ce,ve+1,Je,Le,je,Ue.image[ce])}}}E(O,ke)&&_(34067),De.__version=me.version,O.onUpdate&&O.onUpdate(O)}R.__version=O.version}function W(R,O,ne,ue,me){let De=s.convert(ne.format,ne.encoding),Me=s.convert(ne.type),Ee=S(ne.internalFormat,De,Me,ne.encoding);n.get(O).__hasExternalTextures||(me===32879||me===35866?e.texImage3D(me,0,Ee,O.width,O.height,O.depth,0,De,Me,null):e.texImage2D(me,0,Ee,O.width,O.height,0,De,Me,null)),e.bindFramebuffer(36160,R),_e(O)?d.framebufferTexture2DMultisampleEXT(36160,ue,me,n.get(ne).__webglTexture,0,Pe(O)):(me===3553||me>=34069&&me<=34074)&&i.framebufferTexture2D(36160,ue,me,n.get(ne).__webglTexture,0),e.bindFramebuffer(36160,null)}function ye(R,O,ne){if(i.bindRenderbuffer(36161,R),O.depthBuffer&&!O.stencilBuffer){let ue=33189;if(ne||_e(O)){let me=O.depthTexture;me&&me.isDepthTexture&&(me.type===Sr?ue=36012:me.type===xo&&(ue=33190));let De=Pe(O);_e(O)?d.renderbufferStorageMultisampleEXT(36161,De,ue,O.width,O.height):i.renderbufferStorageMultisample(36161,De,ue,O.width,O.height)}else i.renderbufferStorage(36161,ue,O.width,O.height);i.framebufferRenderbuffer(36160,36096,36161,R)}else if(O.depthBuffer&&O.stencilBuffer){let ue=Pe(O);ne&&_e(O)===!1?i.renderbufferStorageMultisample(36161,ue,35056,O.width,O.height):_e(O)?d.renderbufferStorageMultisampleEXT(36161,ue,35056,O.width,O.height):i.renderbufferStorage(36161,34041,O.width,O.height),i.framebufferRenderbuffer(36160,33306,36161,R)}else{let ue=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let me=0;me<ue.length;me++){let De=ue[me],Me=s.convert(De.format,De.encoding),Ee=s.convert(De.type),le=S(De.internalFormat,Me,Ee,De.encoding),Ke=Pe(O);ne&&_e(O)===!1?i.renderbufferStorageMultisample(36161,Ke,le,O.width,O.height):_e(O)?d.renderbufferStorageMultisampleEXT(36161,Ke,le,O.width,O.height):i.renderbufferStorage(36161,le,O.width,O.height)}}i.bindRenderbuffer(36161,null)}function fe(R,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,R),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),V(O.depthTexture,0);let ue=n.get(O.depthTexture).__webglTexture,me=Pe(O);if(O.depthTexture.format===pl)_e(O)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ue,0,me):i.framebufferTexture2D(36160,36096,3553,ue,0);else if(O.depthTexture.format===la)_e(O)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ue,0,me):i.framebufferTexture2D(36160,33306,3553,ue,0);else throw new Error("Unknown depthTexture format")}function ie(R){let O=n.get(R),ne=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!O.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");fe(O.__webglFramebuffer,R)}else if(ne){O.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)e.bindFramebuffer(36160,O.__webglFramebuffer[ue]),O.__webglDepthbuffer[ue]=i.createRenderbuffer(),ye(O.__webglDepthbuffer[ue],R,!1)}else e.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=i.createRenderbuffer(),ye(O.__webglDepthbuffer,R,!1);e.bindFramebuffer(36160,null)}function we(R,O,ne){let ue=n.get(R);O!==void 0&&W(ue.__webglFramebuffer,R,R.texture,36064,3553),ne!==void 0&&ie(R)}function xe(R){let O=R.texture,ne=n.get(R),ue=n.get(O);R.addEventListener("dispose",D),R.isWebGLMultipleRenderTargets!==!0&&(ue.__webglTexture===void 0&&(ue.__webglTexture=i.createTexture()),ue.__version=O.version,o.memory.textures++);let me=R.isWebGLCubeRenderTarget===!0,De=R.isWebGLMultipleRenderTargets===!0,Me=b(R)||a;if(me){ne.__webglFramebuffer=[];for(let Ee=0;Ee<6;Ee++)ne.__webglFramebuffer[Ee]=i.createFramebuffer()}else{if(ne.__webglFramebuffer=i.createFramebuffer(),De)if(r.drawBuffers){let Ee=R.texture;for(let le=0,Ke=Ee.length;le<Ke;le++){let ke=n.get(Ee[le]);ke.__webglTexture===void 0&&(ke.__webglTexture=i.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&R.samples>0&&_e(R)===!1){let Ee=De?O:[O];ne.__webglMultisampledFramebuffer=i.createFramebuffer(),ne.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ne.__webglMultisampledFramebuffer);for(let le=0;le<Ee.length;le++){let Ke=Ee[le];ne.__webglColorRenderbuffer[le]=i.createRenderbuffer(),i.bindRenderbuffer(36161,ne.__webglColorRenderbuffer[le]);let ke=s.convert(Ke.format,Ke.encoding),Le=s.convert(Ke.type),je=S(Ke.internalFormat,ke,Le,Ke.encoding,R.isXRRenderTarget===!0),Je=Pe(R);i.renderbufferStorageMultisample(36161,Je,je,R.width,R.height),i.framebufferRenderbuffer(36160,36064+le,36161,ne.__webglColorRenderbuffer[le])}i.bindRenderbuffer(36161,null),R.depthBuffer&&(ne.__webglDepthRenderbuffer=i.createRenderbuffer(),ye(ne.__webglDepthRenderbuffer,R,!0)),e.bindFramebuffer(36160,null)}}if(me){e.bindTexture(34067,ue.__webglTexture),k(34067,O,Me);for(let Ee=0;Ee<6;Ee++)W(ne.__webglFramebuffer[Ee],R,O,36064,34069+Ee);E(O,Me)&&_(34067),e.unbindTexture()}else if(De){let Ee=R.texture;for(let le=0,Ke=Ee.length;le<Ke;le++){let ke=Ee[le],Le=n.get(ke);e.bindTexture(3553,Le.__webglTexture),k(3553,ke,Me),W(ne.__webglFramebuffer,R,ke,36064+le,3553),E(ke,Me)&&_(3553)}e.unbindTexture()}else{let Ee=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(a?Ee=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Ee,ue.__webglTexture),k(Ee,O,Me),W(ne.__webglFramebuffer,R,O,36064,Ee),E(O,Me)&&_(Ee),e.unbindTexture()}R.depthBuffer&&ie(R)}function Oe(R){let O=b(R)||a,ne=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let ue=0,me=ne.length;ue<me;ue++){let De=ne[ue];if(E(De,O)){let Me=R.isWebGLCubeRenderTarget?34067:3553,Ee=n.get(De).__webglTexture;e.bindTexture(Me,Ee),_(Me),e.unbindTexture()}}}function Ie(R){if(a&&R.samples>0&&_e(R)===!1){let O=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],ne=R.width,ue=R.height,me=16384,De=[],Me=R.stencilBuffer?33306:36096,Ee=n.get(R),le=R.isWebGLMultipleRenderTargets===!0;if(le)for(let Ke=0;Ke<O.length;Ke++)e.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,null),e.bindFramebuffer(36160,Ee.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,null,0);e.bindFramebuffer(36008,Ee.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Ee.__webglFramebuffer);for(let Ke=0;Ke<O.length;Ke++){De.push(36064+Ke),R.depthBuffer&&De.push(Me);let ke=Ee.__ignoreDepthValues!==void 0?Ee.__ignoreDepthValues:!1;if(ke===!1&&(R.depthBuffer&&(me|=256),R.stencilBuffer&&(me|=1024)),le&&i.framebufferRenderbuffer(36008,36064,36161,Ee.__webglColorRenderbuffer[Ke]),ke===!0&&(i.invalidateFramebuffer(36008,[Me]),i.invalidateFramebuffer(36009,[Me])),le){let Le=n.get(O[Ke]).__webglTexture;i.framebufferTexture2D(36009,36064,3553,Le,0)}i.blitFramebuffer(0,0,ne,ue,0,0,ne,ue,me,9728),f&&i.invalidateFramebuffer(36008,De)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),le)for(let Ke=0;Ke<O.length;Ke++){e.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,Ee.__webglColorRenderbuffer[Ke]);let ke=n.get(O[Ke]).__webglTexture;e.bindFramebuffer(36160,Ee.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,ke,0)}e.bindFramebuffer(36009,Ee.__webglMultisampledFramebuffer)}}function Pe(R){return Math.min(h,R.samples)}function _e(R){let O=n.get(R);return a&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Ve(R){let O=o.render.frame;p.get(R)!==O&&(p.set(R,O),R.update())}function ze(R,O){let ne=R.encoding,ue=R.format,me=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===Nx||ne!==pi&&(ne===$e?a===!1?t.has("EXT_sRGB")===!0&&ue===di?(R.format=Nx,R.minFilter=Ze,R.generateMipmaps=!1):O=Rm.sRGBToLinear(O):(ue!==di||me!==nn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ne)),O}this.allocateTextureUnit=G,this.resetTextureUnits=U,this.setTexture2D=V,this.setTexture2DArray=$,this.setTexture3D=F,this.setTextureCube=j,this.rebindTextures=we,this.setupRenderTarget=xe,this.updateRenderTargetMipmap=Oe,this.updateMultisampleRenderTarget=Ie,this.setupDepthRenderbuffer=ie,this.setupFrameBufferTexture=W,this.useMultisampledRTT=_e}function Xk(i,t,e){let n=e.isWebGL2;function r(s,o=null){let a;if(s===nn)return 5121;if(s===VL)return 32819;if(s===zL)return 32820;if(s===FL)return 5120;if(s===kL)return 5122;if(s===m_)return 5123;if(s===UL)return 5124;if(s===xo)return 5125;if(s===Sr)return 5126;if(s===yl)return n?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===GL)return 6406;if(s===di)return 6408;if(s===HL)return 6409;if(s===jL)return 6410;if(s===pl)return 6402;if(s===la)return 34041;if(s===Nx)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===WL)return 6403;if(s===qL)return 36244;if(s===db)return 33319;if(s===YL)return 33320;if(s===XL)return 36249;if(s===X0||s===K0||s===Q0||s===Z0)if(o===$e)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===X0)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===K0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Q0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Z0)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===X0)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===K0)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Q0)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Z0)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===z1||s===G1||s===H1||s===j1)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===z1)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===G1)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===H1)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===j1)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===KL)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===W1||s===q1)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===W1)return o===$e?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===q1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Y1||s===X1||s===K1||s===Q1||s===Z1||s===J1||s===$1||s===eE||s===tE||s===nE||s===rE||s===iE||s===sE||s===oE)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Y1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===X1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===K1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Q1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Z1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===J1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===$1)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===eE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===tE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===nE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===rE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===iE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===sE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===oE)return o===$e?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===J0)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===J0)return o===$e?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===QL||s===aE||s===lE||s===cE)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===J0)return a.COMPRESSED_RED_RGTC1_EXT;if(s===aE)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===lE)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===cE)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===sa?n?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):i[s]!==void 0?i[s]:null}return{convert:r}}var qx=class extends An{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},Ts=class extends mt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Kk={type:"move"},Kd=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ts,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 Ts,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ts,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let r=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(u&&t.hand){o=!0;for(let m of t.hand.values()){let g=e.getJointPose(m,n),y=this._getHandJoint(u,m);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=g.radius),y.visible=g!==null}let c=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],d=c.position.distanceTo(h.position),f=.02,p=.005;u.inputState.pinching&&d>f+p?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&d<=f-p&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(r=e.getPose(t.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Kk)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new Ts;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},Ci=class extends en{constructor(t,e,n,r,s,o,a,l,u,c){if(c=c!==void 0?c:pl,c!==pl&&c!==la)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===pl&&(n=xo),n===void 0&&c===la&&(n=sa),super(null,r,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Lt,this.minFilter=l!==void 0?l:Lt,this.flipY=!1,this.generateMipmaps=!1}},Yx=class extends Ht{constructor(t,e){super();let n=this,r=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,h=null,d=null,f=null,p=null,m=e.getContextAttributes(),g=null,y=null,v=[],x=[],b=new Set,w=new Map,E=new An;E.layers.enable(1),E.viewport=new Xe;let _=new An;_.layers.enable(2),_.viewport=new Xe;let S=[E,_],T=new qx;T.layers.enable(1),T.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(F){let j=v[F];return j===void 0&&(j=new Kd,v[F]=j),j.getTargetRaySpace()},this.getControllerGrip=function(F){let j=v[F];return j===void 0&&(j=new Kd,v[F]=j),j.getGripSpace()},this.getHand=function(F){let j=v[F];return j===void 0&&(j=new Kd,v[F]=j),j.getHandSpace()};function D(F){let j=x.indexOf(F.inputSource);if(j===-1)return;let X=v[j];X!==void 0&&X.dispatchEvent({type:F.type,data:F.inputSource})}function P(){r.removeEventListener("select",D),r.removeEventListener("selectstart",D),r.removeEventListener("selectend",D),r.removeEventListener("squeeze",D),r.removeEventListener("squeezestart",D),r.removeEventListener("squeezeend",D),r.removeEventListener("end",P),r.removeEventListener("inputsourceschange",I);for(let F=0;F<v.length;F++){let j=x[F];j!==null&&(x[F]=null,v[F].disconnect(j))}M=null,C=null,t.setRenderTarget(g),f=null,d=null,h=null,r=null,y=null,$.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(F){s=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(F){a=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(F){u=F},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(F){if(r=F,r!==null){if(g=t.getRenderTarget(),r.addEventListener("select",D),r.addEventListener("selectstart",D),r.addEventListener("selectend",D),r.addEventListener("squeeze",D),r.addEventListener("squeezestart",D),r.addEventListener("squeezeend",D),r.addEventListener("end",P),r.addEventListener("inputsourceschange",I),m.xrCompatible!==!0&&await e.makeXRCompatible(),r.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let j={antialias:r.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,e,j),r.updateRenderState({baseLayer:f}),y=new ut(f.framebufferWidth,f.framebufferHeight,{format:di,type:nn,encoding:t.outputEncoding,stencilBuffer:m.stencil})}else{let j=null,X=null,q=null;m.depth&&(q=m.stencil?35056:33190,j=m.stencil?la:pl,X=m.stencil?sa:xo);let k={colorFormat:32856,depthFormat:q,scaleFactor:s};h=new XRWebGLBinding(r,e),d=h.createProjectionLayer(k),r.updateRenderState({layers:[d]}),y=new ut(d.textureWidth,d.textureHeight,{format:di,type:nn,depthTexture:new Ci(d.textureWidth,d.textureHeight,X,void 0,void 0,void 0,void 0,void 0,void 0,j),stencilBuffer:m.stencil,encoding:t.outputEncoding,samples:m.antialias?4:0});let Z=t.properties.get(y);Z.__ignoreDepthValues=d.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await r.requestReferenceSpace(a),$.setContext(r),$.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function I(F){for(let j=0;j<F.removed.length;j++){let X=F.removed[j],q=x.indexOf(X);q>=0&&(x[q]=null,v[q].disconnect(X))}for(let j=0;j<F.added.length;j++){let X=F.added[j],q=x.indexOf(X);if(q===-1){for(let Z=0;Z<v.length;Z++)if(Z>=x.length){x.push(X),q=Z;break}else if(x[Z]===null){x[Z]=X,q=Z;break}if(q===-1)break}let k=v[q];k&&k.connect(X)}}let L=new A,H=new A;function U(F,j,X){L.setFromMatrixPosition(j.matrixWorld),H.setFromMatrixPosition(X.matrixWorld);let q=L.distanceTo(H),k=j.projectionMatrix.elements,Z=X.projectionMatrix.elements,Q=k[14]/(k[10]-1),K=k[14]/(k[10]+1),W=(k[9]+1)/k[5],ye=(k[9]-1)/k[5],fe=(k[8]-1)/k[0],ie=(Z[8]+1)/Z[0],we=Q*fe,xe=Q*ie,Oe=q/(-fe+ie),Ie=Oe*-fe;j.matrixWorld.decompose(F.position,F.quaternion,F.scale),F.translateX(Ie),F.translateZ(Oe),F.matrixWorld.compose(F.position,F.quaternion,F.scale),F.matrixWorldInverse.copy(F.matrixWorld).invert();let Pe=Q+Oe,_e=K+Oe,Ve=we-Ie,ze=xe+(q-Ie),R=W*K/_e*Pe,O=ye*K/_e*Pe;F.projectionMatrix.makePerspective(Ve,ze,R,O,Pe,_e)}function G(F,j){j===null?F.matrixWorld.copy(F.matrix):F.matrixWorld.multiplyMatrices(j.matrixWorld,F.matrix),F.matrixWorldInverse.copy(F.matrixWorld).invert()}this.updateCamera=function(F){if(r===null)return;T.near=_.near=E.near=F.near,T.far=_.far=E.far=F.far,(M!==T.near||C!==T.far)&&(r.updateRenderState({depthNear:T.near,depthFar:T.far}),M=T.near,C=T.far);let j=F.parent,X=T.cameras;G(T,j);for(let k=0;k<X.length;k++)G(X[k],j);T.matrixWorld.decompose(T.position,T.quaternion,T.scale),F.matrix.copy(T.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale);let q=F.children;for(let k=0,Z=q.length;k<Z;k++)q[k].updateMatrixWorld(!0);X.length===2?U(T,E,_):T.projectionMatrix.copy(E.projectionMatrix)},this.getCamera=function(){return T},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(F){l=F,d!==null&&(d.fixedFoveation=F),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=F)},this.getPlanes=function(){return b};let z=null;function V(F,j){if(c=j.getViewerPose(u||o),p=j,c!==null){let X=c.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let q=!1;X.length!==T.cameras.length&&(T.cameras.length=0,q=!0);for(let k=0;k<X.length;k++){let Z=X[k],Q=null;if(f!==null)Q=f.getViewport(Z);else{let W=h.getViewSubImage(d,Z);Q=W.viewport,k===0&&(t.setRenderTargetTextures(y,W.colorTexture,d.ignoreDepthValues?void 0:W.depthStencilTexture),t.setRenderTarget(y))}let K=S[k];K===void 0&&(K=new An,K.layers.enable(k),K.viewport=new Xe,S[k]=K),K.matrix.fromArray(Z.transform.matrix),K.projectionMatrix.fromArray(Z.projectionMatrix),K.viewport.set(Q.x,Q.y,Q.width,Q.height),k===0&&T.matrix.copy(K.matrix),q===!0&&T.cameras.push(K)}}for(let X=0;X<v.length;X++){let q=x[X],k=v[X];q!==null&&k!==void 0&&k.update(q,j,u||o)}if(z&&z(F,j),j.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:j.detectedPlanes});let X=null;for(let q of b)j.detectedPlanes.has(q)||(X===null&&(X=[]),X.push(q));if(X!==null)for(let q of X)b.delete(q),w.delete(q),n.dispatchEvent({type:"planeremoved",data:q});for(let q of j.detectedPlanes)if(!b.has(q))b.add(q),w.set(q,j.lastChangedTime),n.dispatchEvent({type:"planeadded",data:q});else{let k=w.get(q);q.lastChangedTime>k&&(w.set(q,q.lastChangedTime),n.dispatchEvent({type:"planechanged",data:q}))}}p=null}let $=new b_;$.setAnimationLoop(V),this.setAnimationLoop=function(F){z=F},this.dispose=function(){}}};function Qk(i,t){function e(m,g){g.color.getRGB(m.fogColor.value,x_(i)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?r(m,g):g.isMeshToonMaterial?(r(m,g),c(m,g)):g.isMeshPhongMaterial?(r(m,g),u(m,g)):g.isMeshStandardMaterial?(r(m,g),h(m,g),g.isMeshPhysicalMaterial&&d(m,g,x)):g.isMeshMatcapMaterial?(r(m,g),f(m,g)):g.isMeshDepthMaterial?r(m,g):g.isMeshDistanceMaterial?(r(m,g),p(m,g)):g.isMeshNormalMaterial?r(m,g):g.isLineBasicMaterial?(s(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?a(m,g,y,v):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.bumpMap&&(m.bumpMap.value=g.bumpMap,m.bumpScale.value=g.bumpScale,g.side===kn&&(m.bumpScale.value*=-1)),g.displacementMap&&(m.displacementMap.value=g.displacementMap,m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap),g.normalMap&&(m.normalMap.value=g.normalMap,m.normalScale.value.copy(g.normalScale),g.side===kn&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(m.envMap.value=y,m.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;let b=i.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*b}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uv2Transform.value.copy(x.matrix))}function s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function a(m,g,y,v){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=v*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix))}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function c(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function d(m,g,y){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===kn&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function f(m,g){g.matcap&&(m.matcap.value=g.matcap)}function p(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:n}}function Zk(i,t,e,n){let r={},s={},o=[],a=e.isWebGL2?i.getParameter(35375):0;function l(v,x){let b=x.program;n.uniformBlockBinding(v,b)}function u(v,x){let b=r[v.id];b===void 0&&(p(v),b=c(v),r[v.id]=b,v.addEventListener("dispose",g));let w=x.program;n.updateUBOMapping(v,w);let E=t.render.frame;s[v.id]!==E&&(d(v),s[v.id]=E)}function c(v){let x=h();v.__bindingPointIndex=x;let b=i.createBuffer(),w=v.__size,E=v.usage;return i.bindBuffer(35345,b),i.bufferData(35345,w,E),i.bindBuffer(35345,null),i.bindBufferBase(35345,x,b),b}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let x=r[v.id],b=v.uniforms,w=v.__cache;i.bindBuffer(35345,x);for(let E=0,_=b.length;E<_;E++){let S=b[E];if(f(S,E,w)===!0){let T=S.__offset,M=Array.isArray(S.value)?S.value:[S.value],C=0;for(let D=0;D<M.length;D++){let P=M[D],I=m(P);typeof P=="number"?(S.__data[0]=P,i.bufferSubData(35345,T+C,S.__data)):P.isMatrix3?(S.__data[0]=P.elements[0],S.__data[1]=P.elements[1],S.__data[2]=P.elements[2],S.__data[3]=P.elements[0],S.__data[4]=P.elements[3],S.__data[5]=P.elements[4],S.__data[6]=P.elements[5],S.__data[7]=P.elements[0],S.__data[8]=P.elements[6],S.__data[9]=P.elements[7],S.__data[10]=P.elements[8],S.__data[11]=P.elements[0]):(P.toArray(S.__data,C),C+=I.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(35345,T,S.__data)}}i.bindBuffer(35345,null)}function f(v,x,b){let w=v.value;if(b[x]===void 0){if(typeof w=="number")b[x]=w;else{let E=Array.isArray(w)?w:[w],_=[];for(let S=0;S<E.length;S++)_.push(E[S].clone());b[x]=_}return!0}else if(typeof w=="number"){if(b[x]!==w)return b[x]=w,!0}else{let E=Array.isArray(b[x])?b[x]:[b[x]],_=Array.isArray(w)?w:[w];for(let S=0;S<E.length;S++){let T=E[S];if(T.equals(_[S])===!1)return T.copy(_[S]),!0}}return!1}function p(v){let x=v.uniforms,b=0,w=16,E=0;for(let _=0,S=x.length;_<S;_++){let T=x[_],M={boundary:0,storage:0},C=Array.isArray(T.value)?T.value:[T.value];for(let D=0,P=C.length;D<P;D++){let I=C[D],L=m(I);M.boundary+=L.boundary,M.storage+=L.storage}if(T.__data=new Float32Array(M.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=b,_>0){E=b%w;let D=w-E;E!==0&&D-M.boundary<0&&(b+=w-E,T.__offset=b)}b+=M.storage}return E=b%w,E>0&&(b+=w-E),v.__size=b,v.__cache={},this}function m(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let b=o.indexOf(x.__bindingPointIndex);o.splice(b,1),i.deleteBuffer(r[x.id]),delete r[x.id],delete s[x.id]}function y(){for(let v in r)i.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:l,update:u,dispose:y}}function Jk(){let i=Om("canvas");return i.style.display="block",i}function xb(i={}){this.isWebGLRenderer=!0;let t=i.canvas!==void 0?i.canvas:Jk(),e=i.context!==void 0?i.context:null,n=i.depth!==void 0?i.depth:!0,r=i.stencil!==void 0?i.stencil:!0,s=i.antialias!==void 0?i.antialias:!1,o=i.premultipliedAlpha!==void 0?i.premultipliedAlpha:!0,a=i.preserveDrawingBuffer!==void 0?i.preserveDrawingBuffer:!1,l=i.powerPreference!==void 0?i.powerPreference:"default",u=i.failIfMajorPerformanceCaveat!==void 0?i.failIfMajorPerformanceCaveat:!1,c;e!==null?c=e.getContextAttributes().alpha:c=i.alpha!==void 0?i.alpha:!1;let h=null,d=null,f=[],p=[];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=pi,this.physicallyCorrectLights=!1,this.toneMapping=So,this.toneMappingExposure=1;let m=this,g=!1,y=0,v=0,x=null,b=-1,w=null,E=new Xe,_=new Xe,S=null,T=t.width,M=t.height,C=1,D=null,P=null,I=new Xe(0,0,T,M),L=new Xe(0,0,T,M),H=!1,U=new tf,G=!1,z=!1,V=null,$=new se,F=new B,j=new A,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return x===null?C:1}let k=e;function Z(N,te){for(let he=0;he<N.length;he++){let ee=N[he],pe=t.getContext(ee,te);if(pe!==null)return pe}return null}try{let N={alpha:!0,depth:n,stencil:r,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${To}`),t.addEventListener("webglcontextlost",je,!1),t.addEventListener("webglcontextrestored",Je,!1),t.addEventListener("webglcontextcreationerror",St,!1),k===null){let te=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&te.shift(),k=Z(te,N),k===null)throw Z(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}k.getShaderPrecisionFormat===void 0&&(k.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let Q,K,W,ye,fe,ie,we,xe,Oe,Ie,Pe,_e,Ve,ze,R,O,ne,ue,me,De,Me,Ee,le,Ke;function ke(){Q=new xF(k),K=new fF(k,Q,i),Q.init(K),Ee=new Xk(k,Q,K),W=new qk(k,Q,K),ye=new wF,fe=new Lk,ie=new Yk(k,Q,W,fe,K,Ee,ye),we=new mF(m),xe=new vF(m),Oe=new I3(k,K),le=new hF(k,Q,Oe,K),Ie=new bF(k,Oe,ye,le),Pe=new TF(k,Ie,Oe,ye),me=new _F(k,K,ie),O=new pF(fe),_e=new Rk(m,we,xe,Q,K,le,O),Ve=new Qk(m,fe),ze=new Bk,R=new Gk(Q,K),ue=new uF(m,we,xe,W,Pe,c,o),ne=new Wk(m,Pe,K),Ke=new Zk(k,ye,K,W),De=new dF(k,Q,ye,K),Me=new SF(k,Q,ye,K),ye.programs=_e.programs,m.capabilities=K,m.extensions=Q,m.properties=fe,m.renderLists=ze,m.shadowMap=ne,m.state=W,m.info=ye}ke();let Le=new Yx(m,k);this.xr=Le,this.getContext=function(){return k},this.getContextAttributes=function(){return k.getContextAttributes()},this.forceContextLoss=function(){let N=Q.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){let N=Q.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(N){N!==void 0&&(C=N,this.setSize(T,M,!1))},this.getSize=function(N){return N.set(T,M)},this.setSize=function(N,te,he){if(Le.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=N,M=te,t.width=Math.floor(N*C),t.height=Math.floor(te*C),he!==!1&&(t.style.width=N+"px",t.style.height=te+"px"),this.setViewport(0,0,N,te)},this.getDrawingBufferSize=function(N){return N.set(T*C,M*C).floor()},this.setDrawingBufferSize=function(N,te,he){T=N,M=te,C=he,t.width=Math.floor(N*he),t.height=Math.floor(te*he),this.setViewport(0,0,N,te)},this.getCurrentViewport=function(N){return N.copy(E)},this.getViewport=function(N){return N.copy(I)},this.setViewport=function(N,te,he,ee){N.isVector4?I.set(N.x,N.y,N.z,N.w):I.set(N,te,he,ee),W.viewport(E.copy(I).multiplyScalar(C).floor())},this.getScissor=function(N){return N.copy(L)},this.setScissor=function(N,te,he,ee){N.isVector4?L.set(N.x,N.y,N.z,N.w):L.set(N,te,he,ee),W.scissor(_.copy(L).multiplyScalar(C).floor())},this.getScissorTest=function(){return H},this.setScissorTest=function(N){W.setScissorTest(H=N)},this.setOpaqueSort=function(N){D=N},this.setTransparentSort=function(N){P=N},this.getClearColor=function(N){return N.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(N=!0,te=!0,he=!0){let ee=0;N&&(ee|=16384),te&&(ee|=256),he&&(ee|=1024),k.clear(ee)},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",je,!1),t.removeEventListener("webglcontextrestored",Je,!1),t.removeEventListener("webglcontextcreationerror",St,!1),ze.dispose(),R.dispose(),fe.dispose(),we.dispose(),xe.dispose(),Pe.dispose(),le.dispose(),Ke.dispose(),_e.dispose(),Le.dispose(),Le.removeEventListener("sessionstart",Ue),Le.removeEventListener("sessionend",Be),V&&(V.dispose(),V=null),wt.stop()};function je(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function Je(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let N=ye.autoReset,te=ne.enabled,he=ne.autoUpdate,ee=ne.needsUpdate,pe=ne.type;ke(),ye.autoReset=N,ne.enabled=te,ne.autoUpdate=he,ne.needsUpdate=ee,ne.type=pe}function St(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function Zt(N){let te=N.target;te.removeEventListener("dispose",Zt),On(te)}function On(N){Y(N),fe.remove(N)}function Y(N){let te=fe.get(N).programs;te!==void 0&&(te.forEach(function(he){_e.releaseProgram(he)}),N.isShaderMaterial&&_e.releaseShaderCache(N))}this.renderBufferDirect=function(N,te,he,ee,pe,it){te===null&&(te=X);let ht=pe.isMesh&&pe.matrixWorld.determinant()<0,pt=ZR(N,te,he,ee,pe);W.setMaterial(ee,ht);let vt=he.index,It=1;ee.wireframe===!0&&(vt=Ie.getWireframeAttribute(he),It=2);let At=he.drawRange,Et=he.attributes.position,Ln=At.start*It,li=(At.start+At.count)*It;it!==null&&(Ln=Math.max(Ln,it.start*It),li=Math.min(li,(it.start+it.count)*It)),vt!==null?(Ln=Math.max(Ln,0),li=Math.min(li,vt.count)):Et!=null&&(Ln=Math.max(Ln,0),li=Math.min(li,Et.count));let ho=li-Ln;if(ho<0||ho===1/0)return;le.setup(pe,ee,pt,he,vt);let ol,Nn=De;if(vt!==null&&(ol=Oe.get(vt),Nn=Me,Nn.setIndex(ol)),pe.isMesh)ee.wireframe===!0?(W.setLineWidth(ee.wireframeLinewidth*q()),Nn.setMode(1)):Nn.setMode(4);else if(pe.isLine){let _t=ee.linewidth;_t===void 0&&(_t=1),W.setLineWidth(_t*q()),pe.isLineSegments?Nn.setMode(1):pe.isLineLoop?Nn.setMode(2):Nn.setMode(3)}else pe.isPoints?Nn.setMode(0):pe.isSprite&&Nn.setMode(4);if(pe.isInstancedMesh)Nn.renderInstances(Ln,ho,pe.count);else if(he.isInstancedBufferGeometry){let _t=he._maxInstanceCount!==void 0?he._maxInstanceCount:1/0,H0=Math.min(he.instanceCount,_t);Nn.renderInstances(Ln,ho,H0)}else Nn.render(Ln,ho)},this.compile=function(N,te){function he(ee,pe,it){ee.transparent===!0&&ee.side===Ur&&ee.forceSinglePass===!1?(ee.side=kn,ee.needsUpdate=!0,_i(ee,pe,it),ee.side=fi,ee.needsUpdate=!0,_i(ee,pe,it),ee.side=Ur):_i(ee,pe,it)}d=R.get(N),d.init(),p.push(d),N.traverseVisible(function(ee){ee.isLight&&ee.layers.test(te.layers)&&(d.pushLight(ee),ee.castShadow&&d.pushShadow(ee))}),d.setupLights(m.physicallyCorrectLights),N.traverse(function(ee){let pe=ee.material;if(pe)if(Array.isArray(pe))for(let it=0;it<pe.length;it++){let ht=pe[it];he(ht,N,ee)}else he(pe,N,ee)}),p.pop(),d=null};let ce=null;function ve(N){ce&&ce(N)}function Ue(){wt.stop()}function Be(){wt.start()}let wt=new b_;wt.setAnimationLoop(ve),typeof self<"u"&&wt.setContext(self),this.setAnimationLoop=function(N){ce=N,Le.setAnimationLoop(N),N===null?wt.stop():wt.start()},Le.addEventListener("sessionstart",Ue),Le.addEventListener("sessionend",Be),this.render=function(N,te){if(te!==void 0&&te.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),Le.enabled===!0&&Le.isPresenting===!0&&(Le.cameraAutoUpdate===!0&&Le.updateCamera(te),te=Le.getCamera()),N.isScene===!0&&N.onBeforeRender(m,N,te,x),d=R.get(N,p.length),d.init(),p.push(d),$.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),U.setFromProjectionMatrix($),z=this.localClippingEnabled,G=O.init(this.clippingPlanes,z),h=ze.get(N,f.length),h.init(),f.push(h),Rn(N,te,0,m.sortObjects),h.finish(),m.sortObjects===!0&&h.sort(D,P),G===!0&&O.beginShadows();let he=d.state.shadowsArray;if(ne.render(he,N,te),G===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(h,N),d.setupLights(m.physicallyCorrectLights),te.isArrayCamera){let ee=te.cameras;for(let pe=0,it=ee.length;pe<it;pe++){let ht=ee[pe];Sn(h,N,ht,ht.viewport)}}else Sn(h,N,te);x!==null&&(ie.updateMultisampleRenderTarget(x),ie.updateRenderTargetMipmap(x)),N.isScene===!0&&N.onAfterRender(m,N,te),le.resetDefaultState(),b=-1,w=null,p.pop(),p.length>0?d=p[p.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function Rn(N,te,he,ee){if(N.visible===!1)return;if(N.layers.test(te.layers)){if(N.isGroup)he=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(te);else if(N.isLight)d.pushLight(N),N.castShadow&&d.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||U.intersectsSprite(N)){ee&&j.setFromMatrixPosition(N.matrixWorld).applyMatrix4($);let ht=Pe.update(N),pt=N.material;pt.visible&&h.push(N,ht,pt,he,j.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==ye.render.frame&&(N.skeleton.update(),N.skeleton.frame=ye.render.frame),!N.frustumCulled||U.intersectsObject(N))){ee&&j.setFromMatrixPosition(N.matrixWorld).applyMatrix4($);let ht=Pe.update(N),pt=N.material;if(Array.isArray(pt)){let vt=ht.groups;for(let It=0,At=vt.length;It<At;It++){let Et=vt[It],Ln=pt[Et.materialIndex];Ln&&Ln.visible&&h.push(N,ht,Ln,he,j.z,Et)}}else pt.visible&&h.push(N,ht,pt,he,j.z,null)}}let it=N.children;for(let ht=0,pt=it.length;ht<pt;ht++)Rn(it[ht],te,he,ee)}function Sn(N,te,he,ee){let pe=N.opaque,it=N.transmissive,ht=N.transparent;d.setupLightsView(he),G===!0&&O.setGlobalState(m.clippingPlanes,he),it.length>0&&sl(pe,te,he),ee&&W.viewport(E.copy(ee)),pe.length>0&&on(pe,te,he),it.length>0&&on(it,te,he),ht.length>0&&on(ht,te,he),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function sl(N,te,he){let ee=K.isWebGL2;V===null&&(V=new ut(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?yl:nn,minFilter:gl,samples:ee&&s===!0?4:0})),m.getDrawingBufferSize(F),ee?V.setSize(F.x,F.y):V.setSize(Im(F.x),Im(F.y));let pe=m.getRenderTarget();m.setRenderTarget(V),m.clear();let it=m.toneMapping;m.toneMapping=So,on(N,te,he),m.toneMapping=it,ie.updateMultisampleRenderTarget(V),ie.updateRenderTargetMipmap(V),m.setRenderTarget(pe)}function on(N,te,he){let ee=te.isScene===!0?te.overrideMaterial:null;for(let pe=0,it=N.length;pe<it;pe++){let ht=N[pe],pt=ht.object,vt=ht.geometry,It=ee===null?ht.material:ee,At=ht.group;pt.layers.test(he.layers)&&uo(pt,te,he,vt,It,At)}}function uo(N,te,he,ee,pe,it){N.onBeforeRender(m,te,he,ee,pe,it),N.modelViewMatrix.multiplyMatrices(he.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),pe.onBeforeRender(m,te,he,ee,N,it),pe.transparent===!0&&pe.side===Ur&&pe.forceSinglePass===!1?(pe.side=kn,pe.needsUpdate=!0,m.renderBufferDirect(he,te,ee,pe,N,it),pe.side=fi,pe.needsUpdate=!0,m.renderBufferDirect(he,te,ee,pe,N,it),pe.side=Ur):m.renderBufferDirect(he,te,ee,pe,N,it),N.onAfterRender(m,te,he,ee,pe,it)}function _i(N,te,he){te.isScene!==!0&&(te=X);let ee=fe.get(N),pe=d.state.lights,it=d.state.shadowsArray,ht=pe.state.version,pt=_e.getParameters(N,pe.state,it,te,he),vt=_e.getProgramCacheKey(pt),It=ee.programs;ee.environment=N.isMeshStandardMaterial?te.environment:null,ee.fog=te.fog,ee.envMap=(N.isMeshStandardMaterial?xe:we).get(N.envMap||ee.environment),It===void 0&&(N.addEventListener("dispose",Zt),It=new Map,ee.programs=It);let At=It.get(vt);if(At!==void 0){if(ee.currentProgram===At&&ee.lightsStateVersion===ht)return P1(N,pt),At}else pt.uniforms=_e.getUniforms(N),N.onBuild(he,pt,m),N.onBeforeCompile(pt,m),At=_e.acquireProgram(pt,vt),It.set(vt,At),ee.uniforms=pt.uniforms;let Et=ee.uniforms;(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(Et.clippingPlanes=O.uniform),P1(N,pt),ee.needsLights=$R(N),ee.lightsStateVersion=ht,ee.needsLights&&(Et.ambientLightColor.value=pe.state.ambient,Et.lightProbe.value=pe.state.probe,Et.directionalLights.value=pe.state.directional,Et.directionalLightShadows.value=pe.state.directionalShadow,Et.spotLights.value=pe.state.spot,Et.spotLightShadows.value=pe.state.spotShadow,Et.rectAreaLights.value=pe.state.rectArea,Et.ltc_1.value=pe.state.rectAreaLTC1,Et.ltc_2.value=pe.state.rectAreaLTC2,Et.pointLights.value=pe.state.point,Et.pointLightShadows.value=pe.state.pointShadow,Et.hemisphereLights.value=pe.state.hemi,Et.directionalShadowMap.value=pe.state.directionalShadowMap,Et.directionalShadowMatrix.value=pe.state.directionalShadowMatrix,Et.spotShadowMap.value=pe.state.spotShadowMap,Et.spotLightMatrix.value=pe.state.spotLightMatrix,Et.spotLightMap.value=pe.state.spotLightMap,Et.pointShadowMap.value=pe.state.pointShadowMap,Et.pointShadowMatrix.value=pe.state.pointShadowMatrix);let Ln=At.getUniforms(),li=Oc.seqWithValue(Ln.seq,Et);return ee.currentProgram=At,ee.uniformsList=li,At}function P1(N,te){let he=fe.get(N);he.outputEncoding=te.outputEncoding,he.instancing=te.instancing,he.skinning=te.skinning,he.morphTargets=te.morphTargets,he.morphNormals=te.morphNormals,he.morphColors=te.morphColors,he.morphTargetsCount=te.morphTargetsCount,he.numClippingPlanes=te.numClippingPlanes,he.numIntersection=te.numClipIntersection,he.vertexAlphas=te.vertexAlphas,he.vertexTangents=te.vertexTangents,he.toneMapping=te.toneMapping}function ZR(N,te,he,ee,pe){te.isScene!==!0&&(te=X),ie.resetTextureUnits();let it=te.fog,ht=ee.isMeshStandardMaterial?te.environment:null,pt=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:pi,vt=(ee.isMeshStandardMaterial?xe:we).get(ee.envMap||ht),It=ee.vertexColors===!0&&!!he.attributes.color&&he.attributes.color.itemSize===4,At=!!ee.normalMap&&!!he.attributes.tangent,Et=!!he.morphAttributes.position,Ln=!!he.morphAttributes.normal,li=!!he.morphAttributes.color,ho=ee.toneMapped?m.toneMapping:So,ol=he.morphAttributes.position||he.morphAttributes.normal||he.morphAttributes.color,Nn=ol!==void 0?ol.length:0,_t=fe.get(ee),H0=d.state.lights;if(G===!0&&(z===!0||N!==w)){let ci=N===w&&ee.id===b;O.setState(ee,N,ci)}let rr=!1;ee.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==H0.state.version||_t.outputEncoding!==pt||pe.isInstancedMesh&&_t.instancing===!1||!pe.isInstancedMesh&&_t.instancing===!0||pe.isSkinnedMesh&&_t.skinning===!1||!pe.isSkinnedMesh&&_t.skinning===!0||_t.envMap!==vt||ee.fog===!0&&_t.fog!==it||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==O.numPlanes||_t.numIntersection!==O.numIntersection)||_t.vertexAlphas!==It||_t.vertexTangents!==At||_t.morphTargets!==Et||_t.morphNormals!==Ln||_t.morphColors!==li||_t.toneMapping!==ho||K.isWebGL2===!0&&_t.morphTargetsCount!==Nn)&&(rr=!0):(rr=!0,_t.__version=ee.version);let al=_t.currentProgram;rr===!0&&(al=_i(ee,te,pe));let D1=!1,Bd=!1,j0=!1,br=al.getUniforms(),ll=_t.uniforms;if(W.useProgram(al.program)&&(D1=!0,Bd=!0,j0=!0),ee.id!==b&&(b=ee.id,Bd=!0),D1||w!==N){if(br.setValue(k,"projectionMatrix",N.projectionMatrix),K.logarithmicDepthBuffer&&br.setValue(k,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),w!==N&&(w=N,Bd=!0,j0=!0),ee.isShaderMaterial||ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshStandardMaterial||ee.envMap){let ci=br.map.cameraPosition;ci!==void 0&&ci.setValue(k,j.setFromMatrixPosition(N.matrixWorld))}(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial)&&br.setValue(k,"isOrthographic",N.isOrthographicCamera===!0),(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial||ee.isShadowMaterial||pe.isSkinnedMesh)&&br.setValue(k,"viewMatrix",N.matrixWorldInverse)}if(pe.isSkinnedMesh){br.setOptional(k,pe,"bindMatrix"),br.setOptional(k,pe,"bindMatrixInverse");let ci=pe.skeleton;ci&&(K.floatVertexTextures?(ci.boneTexture===null&&ci.computeBoneTexture(),br.setValue(k,"boneTexture",ci.boneTexture,ie),br.setValue(k,"boneTextureSize",ci.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 W0=he.morphAttributes;if((W0.position!==void 0||W0.normal!==void 0||W0.color!==void 0&&K.isWebGL2===!0)&&me.update(pe,he,ee,al),(Bd||_t.receiveShadow!==pe.receiveShadow)&&(_t.receiveShadow=pe.receiveShadow,br.setValue(k,"receiveShadow",pe.receiveShadow)),ee.isMeshGouraudMaterial&&ee.envMap!==null&&(ll.envMap.value=vt,ll.flipEnvMap.value=vt.isCubeTexture&&vt.isRenderTargetTexture===!1?-1:1),Bd&&(br.setValue(k,"toneMappingExposure",m.toneMappingExposure),_t.needsLights&&JR(ll,j0),it&&ee.fog===!0&&Ve.refreshFogUniforms(ll,it),Ve.refreshMaterialUniforms(ll,ee,C,M,V),Oc.upload(k,_t.uniformsList,ll,ie)),ee.isShaderMaterial&&ee.uniformsNeedUpdate===!0&&(Oc.upload(k,_t.uniformsList,ll,ie),ee.uniformsNeedUpdate=!1),ee.isSpriteMaterial&&br.setValue(k,"center",pe.center),br.setValue(k,"modelViewMatrix",pe.modelViewMatrix),br.setValue(k,"normalMatrix",pe.normalMatrix),br.setValue(k,"modelMatrix",pe.matrixWorld),pe.previousModelViewMatrix&&br.setValue(k,"previousModelViewMatrix",pe.previousModelViewMatrix),N.previousProjectionMatrix&&br.setValue(k,"previousProjectionMatrix",N.previousProjectionMatrix),ee.isShaderMaterial||ee.isRawShaderMaterial){let ci=ee.uniformsGroups;for(let q0=0,eL=ci.length;q0<eL;q0++)if(K.isWebGL2){let I1=ci[q0];Ke.update(I1,al),Ke.bind(I1,al)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return al}function JR(N,te){N.ambientLightColor.needsUpdate=te,N.lightProbe.needsUpdate=te,N.directionalLights.needsUpdate=te,N.directionalLightShadows.needsUpdate=te,N.pointLights.needsUpdate=te,N.pointLightShadows.needsUpdate=te,N.spotLights.needsUpdate=te,N.spotLightShadows.needsUpdate=te,N.rectAreaLights.needsUpdate=te,N.hemisphereLights.needsUpdate=te}function $R(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(N,te,he){fe.get(N.texture).__webglTexture=te,fe.get(N.depthTexture).__webglTexture=he;let ee=fe.get(N);ee.__hasExternalTextures=!0,ee.__hasExternalTextures&&(ee.__autoAllocateDepthBuffer=he===void 0,ee.__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"),ee.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(N,te){let he=fe.get(N);he.__webglFramebuffer=te,he.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(N,te=0,he=0){x=N,y=te,v=he;let ee=!0,pe=null,it=!1,ht=!1;if(N){let vt=fe.get(N);vt.__useDefaultFramebuffer!==void 0?(W.bindFramebuffer(36160,null),ee=!1):vt.__webglFramebuffer===void 0?ie.setupRenderTarget(N):vt.__hasExternalTextures&&ie.rebindTextures(N,fe.get(N.texture).__webglTexture,fe.get(N.depthTexture).__webglTexture);let It=N.texture;(It.isData3DTexture||It.isDataArrayTexture||It.isCompressedArrayTexture)&&(ht=!0);let At=fe.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(pe=At[te],it=!0):K.isWebGL2&&N.samples>0&&ie.useMultisampledRTT(N)===!1?pe=fe.get(N).__webglMultisampledFramebuffer:pe=At,E.copy(N.viewport),_.copy(N.scissor),S=N.scissorTest}else E.copy(I).multiplyScalar(C).floor(),_.copy(L).multiplyScalar(C).floor(),S=H;if(W.bindFramebuffer(36160,pe)&&K.drawBuffers&&ee&&W.drawBuffers(N,pe),W.viewport(E),W.scissor(_),W.setScissorTest(S),it){let vt=fe.get(N.texture);k.framebufferTexture2D(36160,36064,34069+te,vt.__webglTexture,he)}else if(ht){let vt=fe.get(N.texture),It=te||0;k.framebufferTextureLayer(36160,36064,vt.__webglTexture,he||0,It)}b=-1},this.readRenderTargetPixels=function(N,te,he,ee,pe,it,ht){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let pt=fe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&ht!==void 0&&(pt=pt[ht]),pt){W.bindFramebuffer(36160,pt);try{let vt=N.texture,It=vt.format,At=vt.type;if(It!==di&&Ee.convert(It)!==k.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Et=At===yl&&(Q.has("EXT_color_buffer_half_float")||K.isWebGL2&&Q.has("EXT_color_buffer_float"));if(At!==nn&&Ee.convert(At)!==k.getParameter(35738)&&!(At===Sr&&(K.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!Et){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=N.width-ee&&he>=0&&he<=N.height-pe&&k.readPixels(te,he,ee,pe,Ee.convert(It),Ee.convert(At),it)}finally{let vt=x!==null?fe.get(x).__webglFramebuffer:null;W.bindFramebuffer(36160,vt)}}},this.copyFramebufferToTexture=function(N,te,he=0){let ee=Math.pow(2,-he),pe=Math.floor(te.image.width*ee),it=Math.floor(te.image.height*ee);ie.setTexture2D(te,0),k.copyTexSubImage2D(3553,he,0,0,N.x,N.y,pe,it),W.unbindTexture()},this.copyTextureToTexture=function(N,te,he,ee=0){let pe=te.image.width,it=te.image.height,ht=Ee.convert(he.format),pt=Ee.convert(he.type);ie.setTexture2D(he,0),k.pixelStorei(37440,he.flipY),k.pixelStorei(37441,he.premultiplyAlpha),k.pixelStorei(3317,he.unpackAlignment),te.isDataTexture?k.texSubImage2D(3553,ee,N.x,N.y,pe,it,ht,pt,te.image.data):te.isCompressedTexture?k.compressedTexSubImage2D(3553,ee,N.x,N.y,te.mipmaps[0].width,te.mipmaps[0].height,ht,te.mipmaps[0].data):k.texSubImage2D(3553,ee,N.x,N.y,ht,pt,te.image),ee===0&&he.generateMipmaps&&k.generateMipmap(3553),W.unbindTexture()},this.copyTextureToTexture3D=function(N,te,he,ee,pe=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let it=N.max.x-N.min.x+1,ht=N.max.y-N.min.y+1,pt=N.max.z-N.min.z+1,vt=Ee.convert(ee.format),It=Ee.convert(ee.type),At;if(ee.isData3DTexture)ie.setTexture3D(ee,0),At=32879;else if(ee.isDataArrayTexture)ie.setTexture2DArray(ee,0),At=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}k.pixelStorei(37440,ee.flipY),k.pixelStorei(37441,ee.premultiplyAlpha),k.pixelStorei(3317,ee.unpackAlignment);let Et=k.getParameter(3314),Ln=k.getParameter(32878),li=k.getParameter(3316),ho=k.getParameter(3315),ol=k.getParameter(32877),Nn=he.isCompressedTexture?he.mipmaps[0]:he.image;k.pixelStorei(3314,Nn.width),k.pixelStorei(32878,Nn.height),k.pixelStorei(3316,N.min.x),k.pixelStorei(3315,N.min.y),k.pixelStorei(32877,N.min.z),he.isDataTexture||he.isData3DTexture?k.texSubImage3D(At,pe,te.x,te.y,te.z,it,ht,pt,vt,It,Nn.data):he.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),k.compressedTexSubImage3D(At,pe,te.x,te.y,te.z,it,ht,pt,vt,Nn.data)):k.texSubImage3D(At,pe,te.x,te.y,te.z,it,ht,pt,vt,It,Nn),k.pixelStorei(3314,Et),k.pixelStorei(32878,Ln),k.pixelStorei(3316,li),k.pixelStorei(3315,ho),k.pixelStorei(32877,ol),pe===0&&ee.generateMipmaps&&k.generateMipmap(At),W.unbindTexture()},this.initTexture=function(N){N.isCubeTexture?ie.setTextureCube(N,0):N.isData3DTexture?ie.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?ie.setTexture2DArray(N,0):ie.setTexture2D(N,0),W.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,W.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var Xx=class extends xb{};Xx.prototype.isWebGL1Renderer=!0;var Bc=class{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Fe(t),this.near=e,this.far=n}clone(){return new Bc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},wr=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(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},Vm=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Lx,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Mi()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let r=0,s=this.stride;r<s;r++)this.array[t+r]=e.array[n+r];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mi()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mi()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Fr=new A,xl=class{constructor(t,e,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Fr.fromBufferAttribute(this,e),Fr.applyMatrix4(t),this.setXYZ(e,Fr.x,Fr.y,Fr.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Fr.fromBufferAttribute(this,e),Fr.applyNormalMatrix(t),this.setXYZ(e,Fr.x,Fr.y,Fr.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Fr.fromBufferAttribute(this,e),Fr.transformDirection(t),this.setXYZ(e,Fr.x,Fr.y,Fr.z);return this}setX(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=bo(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=bo(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=bo(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=bo(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array),r=Wt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array),r=Wt(r,this.array),s=Wt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}return new Ge(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new xl(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var rf=class extends mt{constructor(){super(),this.isBone=!0,this.type="Bone"}},Eo=class extends en{constructor(t=null,e=1,n=1,r,s,o,a,l,u=Lt,c=Lt,h,d){super(null,o,a,l,u,c,r,s,h,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},HE=new se,$k=new se,ca=class{constructor(t=[],e=[]){this.uuid=Mi(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new se)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let n=new se;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let t=this.bones,e=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:$k;HE.multiplyMatrices(a,e[s]),HE.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new ca(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=g_(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let n=new Eo(e,t,t,di,Sr);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){let r=this.bones[e];if(r.name===t)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,r=t.bones.length;n<r;n++){let s=t.bones[n],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new rf),this.bones.push(o),this.boneInverses.push(new se().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){let t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,n=this.boneInverses;for(let r=0,s=e.length;r<s;r++){let o=e[r];t.bones.push(o.uuid);let a=n[r];t.boneInverses.push(a.toArray())}return t}},zm=class extends Ge{constructor(t,e,n,r=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};var Pi=class extends vl{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Fe(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},jE=new A,WE=new A,qE=new se,Ex=new Ji,xm=new ln,bl=class extends mt{constructor(t=new Ae,e=new Pi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let r=1,s=e.count;r<s;r++)jE.fromBufferAttribute(e,r-1),WE.fromBufferAttribute(e,r),n[r]=n[r-1],n[r]+=jE.distanceTo(WE);t.setAttribute("lineDistance",new be(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,r=this.matrixWorld,s=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),xm.copy(n.boundingSphere),xm.applyMatrix4(r),xm.radius+=s,t.ray.intersectsSphere(xm)===!1)return;qE.copy(r).invert(),Ex.copy(t.ray).applyMatrix4(qE);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new A,c=new A,h=new A,d=new A,f=this.isLineSegments?2:1,p=n.index,g=n.attributes.position;if(p!==null){let y=Math.max(0,o.start),v=Math.min(p.count,o.start+o.count);for(let x=y,b=v-1;x<b;x+=f){let w=p.getX(x),E=p.getX(x+1);if(u.fromBufferAttribute(g,w),c.fromBufferAttribute(g,E),Ex.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let S=t.ray.origin.distanceTo(d);S<t.near||S>t.far||e.push({distance:S,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,b=v-1;x<b;x+=f){if(u.fromBufferAttribute(g,x),c.fromBufferAttribute(g,x+1),Ex.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let E=t.ray.origin.distanceTo(d);E<t.near||E>t.far||e.push({distance:E,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},YE=new A,XE=new A,ua=class extends bl{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let r=0,s=e.count;r<s;r+=2)YE.fromBufferAttribute(e,r),XE.fromBufferAttribute(e,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+YE.distanceTo(XE);t.setAttribute("lineDistance",new be(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Gm=class extends en{constructor(t,e,n,r,s,o,a,l,u){super(t,e,n,r,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Ze,this.magFilter=s!==void 0?s:Ze,this.generateMipmaps=!1;let c=this;function h(){c.needsUpdate=!0,t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var Di=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,r=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(r),e.push(s),r=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),r=0,s=n.length,o;e?o=e:o=t*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(r=Math.floor(a+(l-a)/2),u=n[r]-o,u<0)a=r+1;else if(u>0)l=r-1;else{l=r;break}if(r=l,n[r]===o)return r/(s-1);let c=n[r],d=n[r+1]-c,f=(o-c)/d;return(r+f)/(s-1)}getTangent(t,e){let r=t-1e-4,s=t+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),l=e||(o.isVector2?new B:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new A,r=[],s=[],o=[],a=new A,l=new se;for(let f=0;f<=t;f++){let p=f/t;r[f]=this.getTangentAt(p,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(r[0].x),h=Math.abs(r[0].y),d=Math.abs(r[0].z);c<=u&&(u=c,n.set(1,0,0)),h<=u&&(u=h,n.set(0,1,0)),d<=u&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(r[f-1],r[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(Wn(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(r[f],s[f])}if(e===!0){let f=Math.acos(Wn(s[0].dot(s[t]),-1,1));f/=t,r[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(r[p],f*p)),o[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},Sl=class extends Di{constructor(t=0,e=0,n=1,r=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let n=e||new B,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),u=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let c=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=u-this.aY;l=d*c-f*h+this.aX,u=d*h+f*c+this.aY}return n.set(l,u)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},Kx=class extends Sl{constructor(t,e,n,r,s,o){super(t,e,n,n,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function bb(){let i=0,t=0,e=0,n=0;function r(s,o,a,l){i=s,t=a,e=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){r(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,h){let d=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+h)+(l-a)/h;d*=c,f*=c,r(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return i+t*s+e*o+n*a}}}var bm=new A,_x=new bb,Tx=new bb,Mx=new bb,Qx=class extends Di{constructor(t=[],e=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=r}getPoint(t,e=new A){let n=e,r=this.points,s=r.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=r[(a-1)%s]:(bm.subVectors(r[0],r[1]).add(r[0]),u=bm);let h=r[a%s],d=r[(a+1)%s];if(this.closed||a+2<s?c=r[(a+2)%s]:(bm.subVectors(r[s-1],r[s-2]).add(r[s-1]),c=bm),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(u.distanceToSquared(h),f),m=Math.pow(h.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(c),f);m<1e-4&&(m=1),p<1e-4&&(p=m),g<1e-4&&(g=m),_x.initNonuniformCatmullRom(u.x,h.x,d.x,c.x,p,m,g),Tx.initNonuniformCatmullRom(u.y,h.y,d.y,c.y,p,m,g),Mx.initNonuniformCatmullRom(u.z,h.z,d.z,c.z,p,m,g)}else this.curveType==="catmullrom"&&(_x.initCatmullRom(u.x,h.x,d.x,c.x,this.tension),Tx.initCatmullRom(u.y,h.y,d.y,c.y,this.tension),Mx.initCatmullRom(u.z,h.z,d.z,c.z,this.tension));return n.set(_x.calc(l),Tx.calc(l),Mx.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new A().fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function KE(i,t,e,n,r){let s=(n-t)*.5,o=(r-e)*.5,a=i*i,l=i*a;return(2*e-2*n+s+o)*l+(-3*e+3*n-2*s-o)*a+s*i+e}function eU(i,t){let e=1-i;return e*e*t}function tU(i,t){return 2*(1-i)*i*t}function nU(i,t){return i*i*t}function Qd(i,t,e,n){return eU(i,t)+tU(i,e)+nU(i,n)}function rU(i,t){let e=1-i;return e*e*e*t}function iU(i,t){let e=1-i;return 3*e*e*i*t}function sU(i,t){return 3*(1-i)*i*i*t}function oU(i,t){return i*i*i*t}function Zd(i,t,e,n,r){return rU(i,t)+iU(i,e)+sU(i,n)+oU(i,r)}var Dr=class extends Di{constructor(t=new B,e=new B,n=new B,r=new B){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new B){let n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Zd(t,r.x,s.x,o.x,a.x),Zd(t,r.y,s.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},wl=class extends Di{constructor(t=new A,e=new A,n=new A,r=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new A){let n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Zd(t,r.x,s.x,o.x,a.x),Zd(t,r.y,s.y,o.y,a.y),Zd(t,r.z,s.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Ir=class extends Di{constructor(t=new B,e=new B){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new B){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let n=e||new B;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},sf=class extends Di{constructor(t=new A,e=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new A){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},mi=class extends Di{constructor(t=new B,e=new B,n=new B){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new B){let n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(Qd(t,r.x,s.x,o.x),Qd(t,r.y,s.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Zx=class extends Di{constructor(t=new A,e=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new A){let n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(Qd(t,r.x,s.x,o.x),Qd(t,r.y,s.y,o.y),Qd(t,r.z,s.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Fc=class extends Di{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new B){let n=e,r=this.points,s=(r.length-1)*t,o=Math.floor(s),a=s-o,l=r[o===0?o:o-1],u=r[o],c=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return n.set(KE(a,l.x,u.x,c.x,h.x),KE(a,l.y,u.y,c.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(r.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let r=this.points[e];t.points.push(r.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let r=t.points[e];this.points.push(new B().fromArray(r))}return this}},aU=Object.freeze({__proto__:null,ArcCurve:Kx,CatmullRomCurve3:Qx,CubicBezierCurve:Dr,CubicBezierCurve3:wl,EllipseCurve:Sl,LineCurve:Ir,LineCurve3:sf,QuadraticBezierCurve:mi,QuadraticBezierCurve3:Zx,SplineCurve:Fc}),of=class extends Di{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Ir(e,t))}getPoint(t,e){let n=t*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=n){let o=r[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,r=this.curves.length;n<r;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];n&&n.equals(c)||(e.push(c),n=c)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(r.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let r=this.curves[e];t.curves.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let r=t.curves[e];this.curves.push(new aU[r.type]().fromJSON(r))}return this}},Al=class extends of{constructor(t){super(),this.type="Path",this.currentPoint=new B,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let n=new Ir(this.currentPoint.clone(),new B(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,r){let s=new mi(this.currentPoint.clone(),new B(t,e),new B(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(t,e,n,r,s,o){let a=new Dr(this.currentPoint.clone(),new B(t,e),new B(n,r),new B(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new Fc(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,r,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,n,r,s,o),this}absarc(t,e,n,r,s,o){return this.absellipse(t,e,n,n,r,s,o),this}ellipse(t,e,n,r,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,n,r,s,o,a,l),this}absellipse(t,e,n,r,s,o,a,l){let u=new Sl(t,e,n,r,s,o,a,l);if(this.curves.length>0){let h=u.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},kc=class extends Ae{constructor(t=[new B(0,-.5),new B(.5,0),new B(0,.5)],e=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:r},e=Math.floor(e),r=Wn(r,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,h=new A,d=new B,f=new A,p=new A,m=new A,g=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(m.x,m.y,m.z);break;default:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),l.push(f.x,f.y,f.z),m.copy(p)}for(let v=0;v<=e;v++){let x=n+v*c*r,b=Math.sin(x),w=Math.cos(x);for(let E=0;E<=t.length-1;E++){h.x=t[E].x*b,h.y=t[E].y,h.z=t[E].x*w,o.push(h.x,h.y,h.z),d.x=v/e,d.y=E/(t.length-1),a.push(d.x,d.y);let _=l[3*E+0]*b,S=l[3*E+1],T=l[3*E+0]*w;u.push(_,S,T)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let b=x+v*t.length,w=b,E=b+t.length,_=b+t.length+1,S=b+1;s.push(w,E,S),s.push(_,S,E)}this.setIndex(s),this.setAttribute("position",new be(o,3)),this.setAttribute("uv",new be(a,2)),this.setAttribute("normal",new be(u,3))}static fromJSON(t){return new kc(t.points,t.segments,t.phiStart,t.phiLength)}};var El=class extends Ae{constructor(t=1,e=1,n=1,r=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;r=Math.floor(r),s=Math.floor(s);let c=[],h=[],d=[],f=[],p=0,m=[],g=n/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new be(h,3)),this.setAttribute("normal",new be(d,3)),this.setAttribute("uv",new be(f,2));function v(){let b=new A,w=new A,E=0,_=(e-t)/n;for(let S=0;S<=s;S++){let T=[],M=S/s,C=M*(e-t)+t;for(let D=0;D<=r;D++){let P=D/r,I=P*l+a,L=Math.sin(I),H=Math.cos(I);w.x=C*L,w.y=-M*n+g,w.z=C*H,h.push(w.x,w.y,w.z),b.set(L,_,H).normalize(),d.push(b.x,b.y,b.z),f.push(P,1-M),T.push(p++)}m.push(T)}for(let S=0;S<r;S++)for(let T=0;T<s;T++){let M=m[T][S],C=m[T+1][S],D=m[T+1][S+1],P=m[T][S+1];c.push(M,C,P),c.push(C,D,P),E+=6}u.addGroup(y,E,0),y+=E}function x(b){let w=p,E=new B,_=new A,S=0,T=b===!0?t:e,M=b===!0?1:-1;for(let D=1;D<=r;D++)h.push(0,g*M,0),d.push(0,M,0),f.push(.5,.5),p++;let C=p;for(let D=0;D<=r;D++){let I=D/r*l+a,L=Math.cos(I),H=Math.sin(I);_.x=T*H,_.y=g*M,_.z=T*L,h.push(_.x,_.y,_.z),d.push(0,M,0),E.x=L*.5+.5,E.y=H*.5*M+.5,f.push(E.x,E.y),p++}for(let D=0;D<r;D++){let P=w+D,I=C+D;b===!0?c.push(I,I+1,P):c.push(I+1,I,P),S+=3}u.addGroup(y,S,b===!0?1:2),y+=S}}static fromJSON(t){return new El(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Uc=class extends El{constructor(t=1,e=1,n=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,n,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new Uc(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Vc=class extends Ae{constructor(t=[],e=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:r};let s=[],o=[];a(r),u(n),c(),this.setAttribute("position",new be(s,3)),this.setAttribute("normal",new be(s.slice(),3)),this.setAttribute("uv",new be(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new A,b=new A,w=new A;for(let E=0;E<e.length;E+=3)f(e[E+0],x),f(e[E+1],b),f(e[E+2],w),l(x,b,w,v)}function l(v,x,b,w){let E=w+1,_=[];for(let S=0;S<=E;S++){_[S]=[];let T=v.clone().lerp(b,S/E),M=x.clone().lerp(b,S/E),C=E-S;for(let D=0;D<=C;D++)D===0&&S===E?_[S][D]=T:_[S][D]=T.clone().lerp(M,D/C)}for(let S=0;S<E;S++)for(let T=0;T<2*(E-S)-1;T++){let M=Math.floor(T/2);T%2===0?(d(_[S][M+1]),d(_[S+1][M]),d(_[S][M])):(d(_[S][M+1]),d(_[S+1][M+1]),d(_[S+1][M]))}}function u(v){let x=new A;for(let b=0;b<s.length;b+=3)x.x=s[b+0],x.y=s[b+1],x.z=s[b+2],x.normalize().multiplyScalar(v),s[b+0]=x.x,s[b+1]=x.y,s[b+2]=x.z}function c(){let v=new A;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let b=g(v)/2/Math.PI+.5,w=y(v)/Math.PI+.5;o.push(b,1-w)}p(),h()}function h(){for(let v=0;v<o.length;v+=6){let x=o[v+0],b=o[v+2],w=o[v+4],E=Math.max(x,b,w),_=Math.min(x,b,w);E>.9&&_<.1&&(x<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),w<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){let b=v*3;x.x=t[b+0],x.y=t[b+1],x.z=t[b+2]}function p(){let v=new A,x=new A,b=new A,w=new A,E=new B,_=new B,S=new B;for(let T=0,M=0;T<s.length;T+=9,M+=6){v.set(s[T+0],s[T+1],s[T+2]),x.set(s[T+3],s[T+4],s[T+5]),b.set(s[T+6],s[T+7],s[T+8]),E.set(o[M+0],o[M+1]),_.set(o[M+2],o[M+3]),S.set(o[M+4],o[M+5]),w.copy(v).add(x).add(b).divideScalar(3);let C=g(w);m(E,M+0,v,C),m(_,M+2,x,C),m(S,M+4,b,C)}}function m(v,x,b,w){w<0&&v.x===1&&(o[x]=v.x-1),b.x===0&&b.z===0&&(o[x]=w/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function y(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(t){return new Vc(t.vertices,t.indices,t.radius,t.details)}},zc=class extends Vc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,r=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new zc(t.radius,t.detail)}};var _o=class extends Al{constructor(t){super(t),this.uuid=Mi(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,r=this.holes.length;n<r;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(r.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let r=this.holes[e];t.holes.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let r=t.holes[e];this.holes.push(new Al().fromJSON(r))}return this}},lU={triangulate:function(i,t,e=2){let n=t&&t.length,r=n?t[0]*e:i.length,s=__(i,0,r,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,h,d,f;if(n&&(s=fU(i,t,s,e)),i.length>80*e){a=u=i[0],l=c=i[1];for(let p=e;p<r;p+=e)h=i[p],d=i[p+1],h<a&&(a=h),d<l&&(l=d),h>u&&(u=h),d>c&&(c=d);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return af(s,o,e,a,l,f,0),o}};function __(i,t,e,n,r){let s,o;if(r===EU(i,t,e,n)>0)for(s=t;s<e;s+=n)o=QE(s,i[s],i[s+1],o);else for(s=e-n;s>=t;s-=n)o=QE(s,i[s],i[s+1],o);return o&&ig(o,o.next)&&(cf(o),o=o.next),o}function _l(i,t){if(!i)return i;t||(t=i);let e=i,n;do if(n=!1,!e.steiner&&(ig(e,e.next)||fn(e.prev,e,e.next)===0)){if(cf(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function af(i,t,e,n,r,s,o){if(!i)return;!o&&s&&vU(i,n,r,s);let a=i,l,u;for(;i.prev!==i.next;){if(l=i.prev,u=i.next,s?uU(i,n,r,s):cU(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(u.i/e|0),cf(i),i=u.next,a=u.next;continue}if(i=u,i===a){o?o===1?(i=hU(_l(i),t,e),af(i,t,e,n,r,s,2)):o===2&&dU(i,t,e,n,r,s):af(_l(i),t,e,n,r,s,1);break}}}function cU(i){let t=i.prev,e=i,n=i.next;if(fn(t,e,n)>=0)return!1;let r=t.x,s=e.x,o=n.x,a=t.y,l=e.y,u=n.y,c=r<s?r<o?r:o:s<o?s:o,h=a<l?a<u?a:u:l<u?l:u,d=r>s?r>o?r:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,p=n.next;for(;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=h&&p.y<=f&&Dc(r,a,s,l,o,u,p.x,p.y)&&fn(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function uU(i,t,e,n){let r=i.prev,s=i,o=i.next;if(fn(r,s,o)>=0)return!1;let a=r.x,l=s.x,u=o.x,c=r.y,h=s.y,d=o.y,f=a<l?a<u?a:u:l<u?l:u,p=c<h?c<d?c:d:h<d?h:d,m=a>l?a>u?a:u:l>u?l:u,g=c>h?c>d?c:d:h>d?h:d,y=Jx(f,p,t,e,n),v=Jx(m,g,t,e,n),x=i.prevZ,b=i.nextZ;for(;x&&x.z>=y&&b&&b.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Dc(a,c,l,h,u,d,x.x,x.y)&&fn(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Dc(a,c,l,h,u,d,b.x,b.y)&&fn(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==r&&x!==o&&Dc(a,c,l,h,u,d,x.x,x.y)&&fn(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==o&&Dc(a,c,l,h,u,d,b.x,b.y)&&fn(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function hU(i,t,e){let n=i;do{let r=n.prev,s=n.next.next;!ig(r,s)&&T_(r,n,n.next,s)&&lf(r,s)&&lf(s,r)&&(t.push(r.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),cf(n),cf(n.next),n=i=s),n=n.next}while(n!==i);return _l(n)}function dU(i,t,e,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&SU(o,a)){let l=M_(o,a);o=_l(o,o.next),l=_l(l,l.next),af(o,t,e,n,r,s,0),af(l,t,e,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function fU(i,t,e,n){let r=[],s,o,a,l,u;for(s=0,o=t.length;s<o;s++)a=t[s]*n,l=s<o-1?t[s+1]*n:i.length,u=__(i,a,l,n,!1),u===u.next&&(u.steiner=!0),r.push(bU(u));for(r.sort(pU),s=0;s<r.length;s++)e=mU(r[s],e);return e}function pU(i,t){return i.x-t.x}function mU(i,t){let e=gU(i,t);if(!e)return t;let n=M_(e,i);return _l(n,n.next),_l(e,e.next)}function gU(i,t){let e=t,n=-1/0,r,s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>n&&(n=d,r=e.x<e.next.x?e:e.next,d===s))return r}e=e.next}while(e!==t);if(!r)return null;let a=r,l=r.x,u=r.y,c=1/0,h;e=r;do s>=e.x&&e.x>=l&&s!==e.x&&Dc(o<u?s:n,o,l,u,o<u?n:s,o,e.x,e.y)&&(h=Math.abs(o-e.y)/(s-e.x),lf(e,i)&&(h<c||h===c&&(e.x>r.x||e.x===r.x&&yU(r,e)))&&(r=e,c=h)),e=e.next;while(e!==a);return r}function yU(i,t){return fn(i.prev,i,t.prev)<0&&fn(t.next,i,i.next)<0}function vU(i,t,e,n){let r=i;do r.z===0&&(r.z=Jx(r.x,r.y,t,e,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,xU(r)}function xU(i){let t,e,n,r,s,o,a,l,u=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,n=e,a=0,t=0;t<u&&(a++,n=n.nextZ,!!n);t++);for(l=u;a>0||l>0&&n;)a!==0&&(l===0||!n||e.z<=n.z)?(r=e,e=e.nextZ,a--):(r=n,n=n.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;e=n}s.nextZ=null,u*=2}while(o>1);return i}function Jx(i,t,e,n,r){return i=(i-e)*r|0,t=(t-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function bU(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function Dc(i,t,e,n,r,s,o,a){return(r-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(r-o)*(n-a)}function SU(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!wU(i,t)&&(lf(i,t)&&lf(t,i)&&AU(i,t)&&(fn(i.prev,i,t.prev)||fn(i,t.prev,t))||ig(i,t)&&fn(i.prev,i,i.next)>0&&fn(t.prev,t,t.next)>0)}function fn(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function ig(i,t){return i.x===t.x&&i.y===t.y}function T_(i,t,e,n){let r=wm(fn(i,t,e)),s=wm(fn(i,t,n)),o=wm(fn(e,n,i)),a=wm(fn(e,n,t));return!!(r!==s&&o!==a||r===0&&Sm(i,e,t)||s===0&&Sm(i,n,t)||o===0&&Sm(e,i,n)||a===0&&Sm(e,t,n))}function Sm(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function wm(i){return i>0?1:i<0?-1:0}function wU(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&T_(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function lf(i,t){return fn(i.prev,i,i.next)<0?fn(i,t,i.next)>=0&&fn(i,i.prev,t)>=0:fn(i,t,i.prev)<0||fn(i,i.next,t)<0}function AU(i,t){let e=i,n=!1,r=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&r<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==i);return n}function M_(i,t){let e=new $x(i.i,i.x,i.y),n=new $x(t.i,t.x,t.y),r=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function QE(i,t,e,n){let r=new $x(i,t,e);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function cf(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function $x(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function EU(i,t,e,n){let r=0;for(let s=t,o=e-n;s<e;s+=n)r+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return r}var Gc=class{static area(t){let e=t.length,n=0;for(let r=e-1,s=0;s<e;r=s++)n+=t[r].x*t[s].y-t[s].x*t[r].y;return n*.5}static isClockWise(t){return Gc.area(t)<0}static triangulateShape(t,e){let n=[],r=[],s=[];ZE(t),JE(n,t);let o=t.length;e.forEach(ZE);for(let l=0;l<e.length;l++)r.push(o),o+=e[l].length,JE(n,e[l]);let a=lU.triangulate(n,r);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function ZE(i){let t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function JE(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}var Hc=class extends Vc{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Hc(t.radius,t.detail)}};var Tl=class extends Ae{constructor(t=1,e=32,n=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),u=0,c=[],h=new A,d=new A,f=[],p=[],m=[],g=[];for(let y=0;y<=n;y++){let v=[],x=y/n,b=0;y==0&&o==0?b=.5/e:y==n&&l==Math.PI&&(b=-.5/e);for(let w=0;w<=e;w++){let E=w/e;h.x=-t*Math.cos(r+E*s)*Math.sin(o+x*a),h.y=t*Math.cos(o+x*a),h.z=t*Math.sin(r+E*s)*Math.sin(o+x*a),p.push(h.x,h.y,h.z),d.copy(h).normalize(),m.push(d.x,d.y,d.z),g.push(E+b,1-x),v.push(u++)}c.push(v)}for(let y=0;y<n;y++)for(let v=0;v<e;v++){let x=c[y][v+1],b=c[y][v],w=c[y+1][v],E=c[y+1][v+1];(y!==0||o>0)&&f.push(x,b,E),(y!==n-1||l<Math.PI)&&f.push(b,w,E)}this.setIndex(f),this.setAttribute("position",new be(p,3)),this.setAttribute("normal",new be(m,3)),this.setAttribute("uv",new be(g,2))}static fromJSON(t){return new Tl(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var jc=class extends Ae{constructor(t=1,e=.4,n=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:r,p:s,q:o},n=Math.floor(n),r=Math.floor(r);let a=[],l=[],u=[],c=[],h=new A,d=new A,f=new A,p=new A,m=new A,g=new A,y=new A;for(let x=0;x<=n;++x){let b=x/n*s*Math.PI*2;v(b,s,o,t,f),v(b+.01,s,o,t,p),g.subVectors(p,f),y.addVectors(p,f),m.crossVectors(g,y),y.crossVectors(m,g),m.normalize(),y.normalize();for(let w=0;w<=r;++w){let E=w/r*Math.PI*2,_=-e*Math.cos(E),S=e*Math.sin(E);h.x=f.x+(_*y.x+S*m.x),h.y=f.y+(_*y.y+S*m.y),h.z=f.z+(_*y.z+S*m.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),u.push(d.x,d.y,d.z),c.push(x/n),c.push(w/r)}}for(let x=1;x<=n;x++)for(let b=1;b<=r;b++){let w=(r+1)*(x-1)+(b-1),E=(r+1)*x+(b-1),_=(r+1)*x+b,S=(r+1)*(x-1)+b;a.push(w,E,S),a.push(E,_,S)}this.setIndex(a),this.setAttribute("position",new be(l,3)),this.setAttribute("normal",new be(u,3)),this.setAttribute("uv",new be(c,2));function v(x,b,w,E,_){let S=Math.cos(x),T=Math.sin(x),M=w/b*x,C=Math.cos(M);_.x=E*(2+C)*.5*S,_.y=E*(2+C)*T*.5,_.z=E*Math.sin(M)*.5}}static fromJSON(t){return new jc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function ia(i,t,e){return C_(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function Am(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function C_(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function _U(i){function t(r,s){return i[r]-i[s]}let e=i.length,n=new Array(e);for(let r=0;r!==e;++r)n[r]=r;return n.sort(t),n}function $E(i,t,e){let n=i.length,r=new i.constructor(n);for(let s=0,o=0;o!==n;++s){let a=e[s]*t;for(let l=0;l!==t;++l)r[o++]=i[a+l]}return r}function P_(i,t,e,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=i[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=i[r++];while(s!==void 0);else do o=s[n],o!==void 0&&(t.push(s.time),e.push(o)),s=i[r++];while(s!==void 0)}var Wc=class{constructor(t,e,n,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,r=e[n],s=e[n-1];e:{t:{let o;n:{r:if(!(t<r)){for(let a=n+2;;){if(r===void 0){if(t<s)break r;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=r,r=e[++n],t<r)break t}o=e.length;break n}if(!(t>=s)){let a=e[1];t<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(r=s,s=e[--n-1],t>=s)break t}o=n,n=0;break n}break e}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(r=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,t,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=t*r;for(let o=0;o!==r;++o)e[o]=n[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},eb=class extends Wc{constructor(t,e,n,r){super(t,e,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Mc,endingEnd:Mc}}intervalChanged_(t,e,n){let r=this.parameterPositions,s=t-2,o=t+1,a=r[s],l=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case Cc:s=t,a=2*e-n;break;case Dm:s=r.length-2,a=e+r[s]-r[s+1];break;default:s=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Cc:o=t,l=2*n-e;break;case Dm:o=1,l=n+r[1]-r[0];break;default:o=t-1,l=e}let u=(n-e)*.5,c=this.valueSize;this._weightPrev=u/(e-a),this._weightNext=u/(l-n),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-e)/(r-e),m=p*p,g=m*p,y=-d*g+2*d*m-d*p,v=(1+d)*g+(-1.5-2*d)*m+(-.5+d)*p+1,x=(-1-f)*g+(1.5+f)*m+.5*p,b=f*g-f*m;for(let w=0;w!==a;++w)s[w]=y*o[c+w]+v*o[u+w]+x*o[l+w]+b*o[h+w];return s}},Hm=class extends Wc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(n-e)/(r-e),h=1-c;for(let d=0;d!==a;++d)s[d]=o[u+d]*h+o[l+d]*c;return s}},tb=class extends Wc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t){return this.copySampleValue_(t-1)}},Ii=class{constructor(t,e,n,r){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Am(e,this.TimeBufferType),this.values=Am(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Am(t.times,Array),values:Am(t.values,Array)};let r=t.getInterpolation();r!==t.DefaultInterpolation&&(n.interpolation=r)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new tb(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Hm(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new eb(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Cm:e=this.InterpolantFactoryMethodDiscrete;break;case Pm:e=this.InterpolantFactoryMethodLinear;break;case $0:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Cm;case this.InterpolantFactoryMethodLinear:return Pm;case this.InterpolantFactoryMethodSmooth:return $0}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]*=t}return this}trim(t,e){let n=this.times,r=n.length,s=0,o=r-1;for(;s!==r&&n[s]<t;)++s;for(;o!==-1&&n[o]>e;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=ia(n,s,o),this.values=ia(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(r!==void 0&&C_(r))for(let a=0,l=r.length;a!==l;++a){let u=r[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}return t}optimize(){let t=ia(this.times),e=ia(this.values),n=this.getValueSize(),r=this.getInterpolation()===$0,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=t[a],c=t[a+1];if(u!==c&&(a!==1||u!==t[0]))if(r)l=!0;else{let h=a*n,d=h-n,f=h+n;for(let p=0;p!==n;++p){let m=e[h+p];if(m!==e[d+p]||m!==e[f+p]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let h=a*n,d=o*n;for(let f=0;f!==n;++f)e[d+f]=e[h+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*n,l=o*n,u=0;u!==n;++u)e[l+u]=e[a+u];++o}return o!==t.length?(this.times=ia(t,0,o),this.values=ia(e,0,o*n)):(this.times=t,this.values=e),this}clone(){let t=ia(this.times,0),e=ia(this.values,0),n=this.constructor,r=new n(this.name,t,e);return r.createInterpolant=this.createInterpolant,r}};Ii.prototype.TimeBufferType=Float32Array;Ii.prototype.ValueBufferType=Float32Array;Ii.prototype.DefaultInterpolation=Pm;var ha=class extends Ii{};ha.prototype.ValueTypeName="bool";ha.prototype.ValueBufferType=Array;ha.prototype.DefaultInterpolation=Cm;ha.prototype.InterpolantFactoryMethodLinear=void 0;ha.prototype.InterpolantFactoryMethodSmooth=void 0;var jm=class extends Ii{};jm.prototype.ValueTypeName="color";var qc=class extends Ii{};qc.prototype.ValueTypeName="number";var nb=class extends Wc{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(r-e),u=t*a;for(let c=u+a;u!==c;u+=4)Ye.slerpFlat(s,0,o,u-a,o,u,l);return s}},Ml=class extends Ii{InterpolantFactoryMethodLinear(t){return new nb(this.times,this.values,this.getValueSize(),t)}};Ml.prototype.ValueTypeName="quaternion";Ml.prototype.DefaultInterpolation=Pm;Ml.prototype.InterpolantFactoryMethodSmooth=void 0;var da=class extends Ii{};da.prototype.ValueTypeName="string";da.prototype.ValueBufferType=Array;da.prototype.DefaultInterpolation=Cm;da.prototype.InterpolantFactoryMethodLinear=void 0;da.prototype.InterpolantFactoryMethodSmooth=void 0;var Yc=class extends Ii{};Yc.prototype.ValueTypeName="vector";var Xc=class{constructor(t,e=-1,n,r=mb){this.name=t,this.tracks=n,this.duration=e,this.blendMode=r,this.uuid=Mi(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],n=t.tracks,r=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(MU(n[o]).scale(r));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=n.length;s!==o;++s)e.push(Ii.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(t,e,n,r){let s=e.length,o=[];for(let a=0;a<s;a++){let l=[],u=[];l.push((a+s-1)%s,a,(a+1)%s),u.push(0,1,0);let c=_U(l);l=$E(l,1,c),u=$E(u,1,c),!r&&l[0]===0&&(l.push(s),u.push(u[0])),o.push(new qc(".morphTargetInfluences["+e[a].name+"]",l,u).scale(1/n))}return new this(t,-1,o)}static findByName(t,e){let n=t;if(!Array.isArray(t)){let r=t;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===e)return n[r];return null}static CreateClipsFromMorphTargetSequences(t,e,n){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){let u=t[a],c=u.name.match(s);if(c&&c.length>1){let h=c[1],d=r[h];d||(r[h]=d=[]),d.push(u)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],e,n));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(h,d,f,p,m){if(f.length!==0){let g=[],y=[];P_(f,g,y,p),g.length!==0&&m.push(new h(d,g,y))}},r=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,u=t.hierarchy||[];for(let h=0;h<u.length;h++){let d=u[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let f={},p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let m=0;m<d[p].morphTargets.length;m++)f[d[p].morphTargets[m]]=-1;for(let m in f){let g=[],y=[];for(let v=0;v!==d[p].morphTargets.length;++v){let x=d[p];g.push(x.time),y.push(x.morphTarget===m?1:0)}r.push(new qc(".morphTargetInfluence["+m+"]",g,y))}l=f.length*o}else{let f=".bones["+e[h].name+"]";n(Yc,f+".position",d,"pos",r),n(Ml,f+".quaternion",d,"rot",r),n(Yc,f+".scale",d,"scl",r)}}return r.length===0?null:new this(s,l,r,a)}resetDuration(){let t=this.tracks,e=0;for(let n=0,r=t.length;n!==r;++n){let s=this.tracks[n];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function TU(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return qc;case"vector":case"vector2":case"vector3":case"vector4":return Yc;case"color":return jm;case"quaternion":return Ml;case"bool":case"boolean":return ha;case"string":return da}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function MU(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=TU(i.type);if(i.times===void 0){let e=[],n=[];P_(i.keys,e,n,"value"),i.times=e,i.values=n}return t.parse!==void 0?t.parse(i):new t(i.name,i.times,i.values,i.interpolation)}var e_={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(this.files[i]=t)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}},uf=class{constructor(t,e,n){let r=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(c){a++,s===!1&&r.onStart!==void 0&&r.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,r.onProgress!==void 0&&r.onProgress(c,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(c){r.onError!==void 0&&r.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,h){return u.push(c,h),this},this.removeHandler=function(c){let h=u.indexOf(c);return h!==-1&&u.splice(h,2),this},this.getHandler=function(c){for(let h=0,d=u.length;h<d;h+=2){let f=u[h],p=u[h+1];if(f.global&&(f.lastIndex=0),f.test(c))return p}return null}}},CU=new uf,Kc=class{constructor(t){this.manager=t!==void 0?t:CU,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(r,s){n.load(t,r,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}},vo={},rb=class extends Error{constructor(t,e){super(t),this.response=e}},Qc=class extends Kc{constructor(t){super(t)}load(t,e,n,r){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=e_.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(vo[t]!==void 0){vo[t].push({onLoad:e,onProgress:n,onError:r});return}vo[t]=[],vo[t].push({onLoad:e,onProgress:n,onError:r});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=vo[t],h=u.body.getReader(),d=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=d?parseInt(d):0,p=f!==0,m=0,g=new ReadableStream({start(y){v();function v(){h.read().then(({done:x,value:b})=>{if(x)y.close();else{m+=b.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let E=0,_=c.length;E<_;E++){let S=c[E];S.onProgress&&S.onProgress(w)}y.enqueue(b),v()}})}}});return new Response(g)}else throw new rb(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return u.arrayBuffer().then(p=>f.decode(p))}}}).then(u=>{e_.add(t,u);let c=vo[t];delete vo[t];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=vo[t];if(c===void 0)throw this.manager.itemError(t),u;delete vo[t];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onError&&f.onError(u)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var fa=class extends mt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Fe(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},Wm=class extends fa{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Fe(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},Cx=new se,t_=new A,n_=new A,hf=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new B(512,512),this.map=null,this.mapPass=null,this.matrix=new se,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new tf,this._frameExtents=new B(1,1),this._viewportCount=1,this._viewports=[new Xe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;t_.setFromMatrixPosition(t.matrixWorld),e.position.copy(t_),n_.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(n_),e.updateMatrixWorld(),Cx.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Cx),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Cx)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},ib=class extends hf{constructor(){super(new An(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,n=$d*2*t.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(n!==e.fov||r!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=r,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},qm=class extends fa{constructor(t,e,n=0,r=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.target=new mt,this.distance=n,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new ib}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},r_=new se,jd=new A,Px=new A,sb=class extends hf{constructor(){super(new An(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new B(4,2),this._viewportCount=6,this._viewports=[new Xe(2,1,1,1),new Xe(0,1,1,1),new Xe(3,1,1,1),new Xe(1,1,1,1),new Xe(3,0,1,1),new Xe(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,r=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),jd.setFromMatrixPosition(t.matrixWorld),n.position.copy(jd),Px.copy(n.position),Px.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Px),n.updateMatrixWorld(),r.makeTranslation(-jd.x,-jd.y,-jd.z),r_.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(r_)}},Ym=class extends fa{constructor(t,e,n=0,r=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new sb}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},ob=class extends hf{constructor(){super(new Nc(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Xm=class extends fa{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(mt.DEFAULT_UP),this.updateMatrix(),this.target=new mt,this.shadow=new ob}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var ab=class extends Ae{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Zc=class extends Kc{constructor(t){super(t)}load(t,e,n,r){let s=this,o=new Qc(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){r?r(l):console.error(l),s.manager.itemError(t)}},n,r)}parse(t){let e={},n={};function r(f,p){if(e[p]!==void 0)return e[p];let g=f.interleavedBuffers[p],y=s(f,g.buffer),v=em(g.type,y),x=new Vm(v,g.stride);return x.uuid=g.uuid,e[p]=x,x}function s(f,p){if(n[p]!==void 0)return n[p];let g=f.arrayBuffers[p],y=new Uint32Array(g).buffer;return n[p]=y,y}let o=t.isInstancedBufferGeometry?new ab:new Ae,a=t.data.index;if(a!==void 0){let f=em(a.type,a.array);o.setIndex(new Ge(f,1))}let l=t.data.attributes;for(let f in l){let p=l[f],m;if(p.isInterleavedBufferAttribute){let g=r(t.data,p.data);m=new xl(g,p.itemSize,p.offset,p.normalized)}else{let g=em(p.type,p.array),y=p.isInstancedBufferAttribute?zm:Ge;m=new y(g,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),p.updateRange!==void 0&&(m.updateRange.offset=p.updateRange.offset,m.updateRange.count=p.updateRange.count),o.setAttribute(f,m)}let u=t.data.morphAttributes;if(u)for(let f in u){let p=u[f],m=[];for(let g=0,y=p.length;g<y;g++){let v=p[g],x;if(v.isInterleavedBufferAttribute){let b=r(t.data,v.data);x=new xl(b,v.itemSize,v.offset,v.normalized)}else{let b=em(v.type,v.array);x=new Ge(b,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),m.push(x)}o.morphAttributes[f]=m}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=t.data.groups||t.data.drawcalls||t.data.offsets;if(h!==void 0)for(let f=0,p=h.length;f!==p;++f){let m=h[f];o.addGroup(m.start,m.count,m.materialIndex)}let d=t.data.boundingSphere;if(d!==void 0){let f=new A;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new ln(f,d.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var Km=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=i_(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=i_();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function i_(){return(typeof performance>"u"?Date:performance).now()}var lb=class{constructor(t,e,n){this.binding=t,this.valueSize=n;let r,s,o;switch(e){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let n=this.buffer,r=this.valueSize,s=t*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)n[s+a]=n[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(n,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,r,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,n=this.buffer,r=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=e*this._origIndex;this._mixBufferRegion(n,r,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*e,1,e);for(let l=e,u=e+e;l!==u;++l)if(n[l]!==n[l+e]){a.setValue(n,r);break}}saveOriginalState(){let t=this.binding,e=this.buffer,n=this.valueSize,r=n*this._origIndex;t.getValue(e,r);for(let s=n,o=r;s!==o;++s)e[s]=e[r+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,r,s){if(r>=.5)for(let o=0;o!==s;++o)t[e+o]=t[n+o]}_slerp(t,e,n,r){Ye.slerpFlat(t,e,t,e,t,n,r)}_slerpAdditive(t,e,n,r,s){let o=this._workIndex*s;Ye.multiplyQuaternionsFlat(t,o,t,e,t,n),Ye.slerpFlat(t,e,t,e,t,o,r)}_lerp(t,e,n,r,s){let o=1-r;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[n+a]*r}}_lerpAdditive(t,e,n,r,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[n+o]*r}}},Sb="\\[\\]\\.:\\/",PU=new RegExp("["+Sb+"]","g"),wb="[^"+Sb+"]",DU="[^"+Sb.replace("\\.","")+"]",IU=/((?:WC+[\/:])*)/.source.replace("WC",wb),OU=/(WCOD+)?/.source.replace("WCOD",DU),RU=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",wb),LU=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",wb),NU=new RegExp("^"+IU+OU+RU+LU+"$"),BU=["material","materials","bones","map"],cb=class{constructor(t,e,n){let r=n||Rt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},Rt=class{constructor(t,e,n){this.path=e,this.parsedPath=n||Rt.parseTrackName(e),this.node=Rt.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Rt.Composite(t,e,n):new Rt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(PU,"")}static parseTrackName(t){let e=NU.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=n.nodeName.substring(r+1);BU.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=n(a.children);if(l)return l}return null},r=n(t.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)t[e++]=n[r]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,r=e.propertyName,s=e.propertyIndex;if(t||(t=Rt.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let u=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===u){u=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(u!==void 0){if(t[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[u]}}let o=t[r];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+r+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Rt.Composite=cb;Rt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Rt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Rt.prototype.GetterByBindingType=[Rt.prototype._getValue_direct,Rt.prototype._getValue_array,Rt.prototype._getValue_arrayElement,Rt.prototype._getValue_toArray];Rt.prototype.SetterByBindingTypeAndVersioning=[[Rt.prototype._setValue_direct,Rt.prototype._setValue_direct_setNeedsUpdate,Rt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Rt.prototype._setValue_array,Rt.prototype._setValue_array_setNeedsUpdate,Rt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Rt.prototype._setValue_arrayElement,Rt.prototype._setValue_arrayElement_setNeedsUpdate,Rt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Rt.prototype._setValue_fromArray,Rt.prototype._setValue_fromArray_setNeedsUpdate,Rt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var ub=class{constructor(t,e,n=null,r=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=r;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:Mc,endingEnd:Mc};for(let u=0;u!==o;++u){let c=s[u].createInterpolant(null);a[u]=c,c.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=pb,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){let r=this._clip.duration,s=t._clip.duration,o=s/r,a=r/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,u=a.sampleValues;return l[0]=s,l[1]=s+n,u[0]=t/o,u[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,r){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*n;l<0||n===0?e=0:(this._startTime=null,e=n*l)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let l=this._interpolants,u=this._propertyBindings;switch(this.blendMode){case ZL:for(let c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulateAdditive(a);break;case mb:default:for(let c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulate(r,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,n=this.loop,r=this.time+t,s=this._loopCount,o=n===ff;if(t===0)return s===-1?r:o&&(s&1)===1?e-r:r;if(n===fb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=e)r=e;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=e||r<0){let a=Math.floor(r/e);r-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?e:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let u=t<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return e-r}return r}_setEndings(t,e,n){let r=this._interpolantSettings;n?(r.endingStart=Cc,r.endingEnd=Cc):(t?r.endingStart=this.zeroSlopeAtStart?Cc:Mc:r.endingStart=Dm,e?r.endingEnd=this.zeroSlopeAtEnd?Cc:Mc:r.endingEnd=Dm)}_scheduleFading(t,e,n){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=n,this}},FU=new Float32Array(1),Qm=class extends Ht{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let n=t._localRoot||this._root,r=t._clip.tracks,s=r.length,o=t._propertyBindings,a=t._interpolants,l=n.uuid,u=this._bindingsByRootAndName,c=u[l];c===void 0&&(c={},u[l]=c);for(let h=0;h!==s;++h){let d=r[h],f=d.name,p=c[f];if(p!==void 0)++p.referenceCount,o[h]=p;else{if(p=o[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let m=e&&e._propertyBindings[h].binding.parsedPath;p=new lb(Rt.create(n,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[h]=p}a[h].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let n=(t._localRoot||this._root).uuid,r=t._clip.uuid,s=this._actionsByClip[r];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,r,n)}let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,n){let r=this._actions,s=this._actionsByClip,o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=r.length,r.push(t),o.actionByRoot[n]=t}_removeInactiveAction(t){let e=this._actions,n=e[e.length-1],r=t._cacheIndex;n._cacheIndex=r,e[r]=n,e.pop(),t._cacheIndex=null;let s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,u=l[l.length-1],c=t._byClipCacheIndex;u._byClipCacheIndex=c,l[c]=u,l.pop(),t._byClipCacheIndex=null;let h=a.actionByRoot,d=(t._localRoot||this._root).uuid;delete h[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let n=0,r=e.length;n!==r;++n){let s=e[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,n=t._cacheIndex,r=this._nActiveActions++,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_takeBackAction(t){let e=this._actions,n=t._cacheIndex,r=--this._nActiveActions,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_addInactiveBinding(t,e,n){let r=this._bindingsByRootAndName,s=this._bindings,o=r[e];o===void 0&&(o={},r[e]=o),o[n]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,n=t.binding,r=n.rootNode.uuid,s=n.path,o=this._bindingsByRootAndName,a=o[r],l=e[e.length-1],u=t._cacheIndex;l._cacheIndex=u,e[u]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(t){let e=this._bindings,n=t._cacheIndex,r=this._nActiveBindings++,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_takeBackBinding(t){let e=this._bindings,n=t._cacheIndex,r=--this._nActiveBindings,s=e[r];t._cacheIndex=r,e[r]=t,s._cacheIndex=n,e[n]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,n=t[e];return n===void 0&&(n=new Hm(new Float32Array(2),new Float32Array(2),1,FU),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){let e=this._controlInterpolants,n=t.__cacheIndex,r=--this._nActiveControlInterpolants,s=e[r];t.__cacheIndex=r,e[r]=t,s.__cacheIndex=n,e[n]=s}clipAction(t,e,n){let r=e||this._root,s=r.uuid,o=typeof t=="string"?Xc.findByName(r,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],u=null;if(n===void 0&&(o!==null?n=o.blendMode:n=mb),l!==void 0){let h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===n)return h;u=l.knownActions[0],o===null&&(o=u._clip)}if(o===null)return null;let c=new ub(this,o,e,n);return this._bindAction(c,u),this._addInactiveAction(c,a,s),c}existingAction(t,e){let n=e||this._root,r=n.uuid,s=typeof t=="string"?Xc.findByName(n,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let n=e-1;n>=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;let e=this._actions,n=this._nActiveActions,r=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let u=0;u!==n;++u)e[u]._update(r,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let u=0;u!==l;++u)a[u].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,n=t.uuid,r=this._actionsByClip,s=r[n];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let u=o[a];this._deactivateAction(u);let c=u._cacheIndex,h=e[e.length-1];u._cacheIndex=null,u._byClipCacheIndex=null,h._cacheIndex=c,e[c]=h,e.pop(),this._removeInactiveBindingsForAction(u)}delete r[n]}}uncacheRoot(t){let e=t.uuid,n=this._actionsByClip;for(let o in n){let a=n[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let r=this._bindingsByRootAndName,s=r[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let n=this.existingAction(t,e);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},oe=class{constructor(t){this.value=t}clone(){return new oe(this.value.clone===void 0?this.value:this.value.clone())}};var Jc=class{constructor(t,e,n=0,r=1/0){this.ray=new Ji(t,e),this.near=n,this.far=r,this.camera=null,this.layers=new ef,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,n=[]){return hb(t,this,n,e),n.sort(s_),n}intersectObjects(t,e=!0,n=[]){for(let r=0,s=t.length;r<s;r++)hb(t[r],this,n,e);return n.sort(s_),n}};function s_(i,t){return i.distance-t.distance}function hb(i,t,e,n){if(i.layers.test(t.layers)&&i.raycast(t,e),n===!0){let r=i.children;for(let s=0,o=r.length;s<o;s++)hb(r[s],t,e,!0)}}var df=class{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Wn(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var o_=new B,Zm=class{constructor(t=new B(1/0,1/0),e=new B(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=o_.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return o_.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},a_=new A,Em=new A,Xn=class{constructor(t=new A,e=new A){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){a_.subVectors(t,this.start),Em.subVectors(this.end,this.start);let n=Em.dot(Em),s=Em.dot(a_)/n;return e&&(s=Wn(s,0,1)),s}closestPointToPoint(t,e,n){let r=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},l_=new A,Jm=class extends mt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Ae,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;r.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new be(r,3));let s=new Pi({fog:!1,toneMapped:!1});this.cone=new ua(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),l_.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(l_),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var $m=class extends Fn{constructor(t,e,n){let r=new Tl(e,4,2),s=new wo({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=t,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var c_=new A,_m=new A,u_=new A,eg=class extends mt{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let r=new Ae;r.setAttribute("position",new be([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new Pi({fog:!1,toneMapped:!1});this.lightPlane=new bl(r,s),this.add(this.lightPlane),r=new Ae,r.setAttribute("position",new be([0,0,0,0,0,1],3)),this.targetLine=new bl(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),c_.setFromMatrixPosition(this.light.matrixWorld),_m.setFromMatrixPosition(this.light.target.matrixWorld),u_.subVectors(_m,c_),this.lightPlane.lookAt(_m),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(_m),this.targetLine.scale.z=u_.length()}},Tm=new A,yn=new $i,pa=class extends ua{constructor(t){let e=new Ae,n=new Pi({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,m){l(p),l(m)}function l(p){r.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(r.length/3-1)}e.setAttribute("position",new be(r,3)),e.setAttribute("color",new be(s,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Fe(16755200),c=new Fe(16711680),h=new Fe(43775),d=new Fe(16777215),f=new Fe(3355443);this.setColors(u,c,h,d,f)}setColors(t,e,n,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,n=1,r=1;yn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),wn("c",e,t,yn,0,0,-1),wn("t",e,t,yn,0,0,1),wn("n1",e,t,yn,-n,-r,-1),wn("n2",e,t,yn,n,-r,-1),wn("n3",e,t,yn,-n,r,-1),wn("n4",e,t,yn,n,r,-1),wn("f1",e,t,yn,-n,-r,1),wn("f2",e,t,yn,n,-r,1),wn("f3",e,t,yn,-n,r,1),wn("f4",e,t,yn,n,r,1),wn("u1",e,t,yn,n*.7,r*1.1,-1),wn("u2",e,t,yn,-n*.7,r*1.1,-1),wn("u3",e,t,yn,0,r*2,-1),wn("cf1",e,t,yn,-n,0,1),wn("cf2",e,t,yn,n,0,1),wn("cf3",e,t,yn,0,-r,1),wn("cf4",e,t,yn,0,r,1),wn("cn1",e,t,yn,-n,0,-1),wn("cn2",e,t,yn,n,0,-1),wn("cn3",e,t,yn,0,-r,-1),wn("cn4",e,t,yn,0,r,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function wn(i,t,e,n,r,s,o){Tm.set(r,s,o).unproject(n);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],Tm.x,Tm.y,Tm.z)}}var ma=class extends ua{constructor(t,e=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ae;s.setIndex(new Ge(n,1)),s.setAttribute("position",new be(r,3)),super(s,new Pi({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var tg=class extends ua{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ae;r.setAttribute("position",new be(e,3)),r.setAttribute("color",new be(n,3));let s=new Pi({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(t,e,n){let r=new Fe,s=this.geometry.attributes.color.array;return r.set(t),r.toArray(s,0),r.toArray(s,3),r.set(e),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:To}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=To);var tu=".",pf=Symbol("target"),Ab=Symbol("unsubscribe");function mf(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function D_(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var yi=Array.isArray;function Cl(i){return typeof i=="symbol"}var kU={after:(i,t)=>yi(i)?i.slice(t.length):t===""?i:i.slice(t.length+1),concat:(i,t)=>yi(i)?(i=[...i],t&&i.push(t),i):t&&t.toString!==void 0?(i!==""&&(i+=tu),Cl(t)?i+t.toString():i+t):i,initial:i=>{if(yi(i))return i.slice(0,-1);if(i==="")return i;let t=i.lastIndexOf(tu);return t===-1?"":i.slice(0,t)},last:i=>{if(yi(i))return i[i.length-1]||"";if(i==="")return i;let t=i.lastIndexOf(tu);return t===-1?i:i.slice(t+1)},walk:(i,t)=>{if(yi(i))for(let e of i)t(e);else if(i!==""){let e=0,n=i.indexOf(tu);if(n===-1)t(i);else for(;e<i.length;)n===-1&&(n=i.length),t(i.slice(e,n)),e=n+1,n=i.indexOf(tu,e)}},get(i,t){return this.walk(t,e=>{i&&(i=i[e])}),i}},Vr=kU;function Eb(i){return typeof i=="object"&&typeof i.next=="function"}function _b(i,t,e,n,r){let s=i.next;if(t.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=r(o.value[0],t,o.value[0],n),o.value[1]=r(o.value[1],t,o.value[0],n)),o};else if(t.name==="values"){let o=e[pf].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=r(a.value,t,o.next().value,n)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=r(o.value,t,o.value,n)),o};return i}function sg(i,t,e){return i.isUnsubscribed||t.ignoreSymbols&&Cl(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var gf=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let n=this._getProperties(t),r=n[e];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(t,e),n[e]=r),r}getProxy(t,e,n,r){if(this.isUnsubscribed)return t;let s=t[r],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,n):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,Vr.get(e,this.getPath(t)))}defineProperty(t,e,n){return Reflect.defineProperty(t,e,n)?(this.isUnsubscribed||(this._getProperties(t)[e]=n),!0):!1}setProperty(t,e,n,r,s){if(!this._equals(s,n)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,n,r):Reflect.set(t,e,n)}return!0}deleteProperty(t,e,n){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(t);r&&(delete r[e],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(t,e,n){let r=this._getOwnPropertyDescriptor(e,n);return t!==void 0&&r!==void 0&&Object.is(t.value,r.value)&&(t.writable||!1)===(r.writable||!1)&&(t.enumerable||!1)===(r.enumerable||!1)&&(t.configurable||!1)===(r.configurable||!1)&&t.get===r.get&&t.set===r.set}isGetInvariant(t,e){let n=this._getOwnPropertyDescriptor(t,e);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function nu(i){return toString.call(i)==="[object Object]"}function ru(){return!0}function ga(i,t){return i.length!==t.length||i.some((e,n)=>t[n]!==e)}var og=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var UU=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Tb={push:ru,pop:ru,shift:ru,unshift:ru,copyWithin:ga,reverse:ga,sort:ga,splice:ga,flat:ga,fill:ga},I_=new Set([...og,...UU,...Object.keys(Tb)]);function iu(i,t){if(i.size!==t.size)return!0;for(let e of i)if(!t.has(e))return!0;return!1}var Mb=["keys","values","entries"],Cb=new Set(["has","toString"]),Pb={add:iu,clear:iu,delete:iu,forEach:iu},O_=new Set([...Cb,...Object.keys(Pb),...Mb]);function su(i,t){if(i.size!==t.size)return!0;let e;for(let[n,r]of i)if(e=t.get(n),e!==r||e===void 0&&!t.has(n))return!0;return!1}var VU=new Set([...Cb,"get"]),Db={set:su,clear:su,delete:su,forEach:su},R_=new Set([...VU,...Object.keys(Db),...Mb]);var ar=class{constructor(t,e,n,r){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return og.has(t)}_shallowClone(t){let e=t;if(nu(t))e={...t};else if(yi(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(n=>this._shallowClone(n)));else if(t instanceof Map){e=new Map;for(let[n,r]of t.entries())e.set(n,this._shallowClone(r))}return this._clonedCache.add(e),e}preferredThisArg(t,e,n,r){return t?(yi(r)?this._onIsChanged=Tb[e]:r instanceof Set?this._onIsChanged=Pb[e]:r instanceof Map&&(this._onIsChanged=Db[e]),r):n}update(t,e,n){let r=Vr.after(t,this._path);if(e!=="length"){let s=this.clone;Vr.walk(r,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:r,property:e,previous:n}),s&&s[e]&&(s[e]=n)}this._isChanged=!0}undo(t){let e;for(let n=this._changes.length-1;n!==-1;n--)e=this._changes[n],Vr.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var ou=class extends ar{static isHandledMethod(t){return I_.has(t)}};var yf=class extends ar{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var au=class extends ar{static isHandledMethod(t){return O_.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var lu=class extends ar{static isHandledMethod(t){return R_.has(t)}undo(t){for(let[e,n]of this.clone.entries())t.set(e,n);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var vf=class extends ar{constructor(t,e,n,r){super(void 0,e,n,r),this._arg1=n[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var xf=class extends ar{constructor(t,e,n,r){super(void 0,e,n,r),this._weakKey=n[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var ts=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return nu(t)||yi(t)||mf(t)}static isHandledMethod(t,e){return nu(t)?ar.isHandledMethod(e):yi(t)?ou.isHandledMethod(e):t instanceof Set?au.isHandledMethod(e):t instanceof Map?lu.isHandledMethod(e):mf(t)}get isCloning(){return this._stack.length>0}start(t,e,n){let r=ar;yi(t)?r=ou:t instanceof Date?r=yf:t instanceof Set?r=au:t instanceof Map?r=lu:t instanceof WeakSet?r=vf:t instanceof WeakMap&&(r=xf),this._stack.push(new r(t,e,n,this._hasOnValidate))}update(t,e,n){this._stack[this._stack.length-1].update(t,e,n)}preferredThisArg(t,e,n){let{name:r}=t,s=ts.isHandledMethod(n,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,e,n)}isChanged(t,e,n){return this._stack[this._stack.length-1].isChanged(t,e,n)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var zU={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Ib=(i,t,e={})=>{e={...zU,...e};let n=Symbol("ProxyTarget"),{equals:r,isShallow:s,ignoreDetached:o,details:a}=e,l=new gf(r),u=typeof e.onValidate=="function",c=new ts(u),h=(v,x,b,w,E)=>!u||c.isCloning||e.onValidate(Vr.concat(l.getPath(v),x),b,w,E)===!0,d=(v,x,b,w)=>{!sg(l,e,x)&&!(o&&l.isDetached(v,i))&&f(l.getPath(v),x,b,w)},f=(v,x,b,w,E)=>{c.isCloning?c.update(v,x,w):t(Vr.concat(v,x),b,w,E)},p=v=>v&&(v[n]||v),m=(v,x,b,w)=>D_(v)||b==="constructor"||s&&!ts.isHandledMethod(x,b)||sg(l,e,b)||l.isGetInvariant(x,b)||o&&l.isDetached(x,i)?v:(w===void 0&&(w=l.getPath(x)),l.getProxy(v,Vr.concat(w,b),g,n)),g={get(v,x,b){if(Cl(x)){if(x===n||x===pf)return v;if(x===Ab&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let w=mf(v)?Reflect.get(v,x):Reflect.get(v,x,b);return m(w,v,x)},set(v,x,b,w){b=p(b);let E=v[n]||v,_=E[x];if(r(_,b)&&x in v)return!0;let S=h(v,x,b,_);return S&&l.setProperty(E,x,b,w,_)?(d(v,x,v[x],_),!0):!S},defineProperty(v,x,b){if(!l.isSameDescriptor(b,v,x)){let w=v[x];h(v,x,b.value,w)&&l.defineProperty(v,x,b,w)&&d(v,x,b.value,w)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let b=Reflect.get(v,x),w=h(v,x,void 0,b);return w&&l.deleteProperty(v,x,b)?(d(v,x,void 0,b),!0):!w},apply(v,x,b){let w=x[n]||x;if(l.isUnsubscribed)return Reflect.apply(v,w,b);if((a===!1||a!==!0&&!a.includes(v.name))&&ts.isHandledType(w)){let E=Vr.initial(l.getPath(v)),_=ts.isHandledMethod(w,v.name);c.start(w,E,b);let S=Reflect.apply(v,c.preferredThisArg(v,x,w),_?b.map(C=>p(C)):b),T=c.isChanged(w,r),M=c.stop();if(ts.isHandledType(S)&&_&&(x instanceof Map&&v.name==="get"&&(E=Vr.concat(E,b[0])),S=l.getProxy(S,E,g)),T){let C={name:v.name,args:b,result:S},D=c.isCloning?Vr.initial(E):E,P=c.isCloning?Vr.last(E):"";h(Vr.get(i,D),P,w,M,C)?f(D,P,w,M,C):c.undo(w)}return(x instanceof Map||x instanceof Set)&&Eb(S)?_b(S,v,x,E,m):S}return Reflect.apply(v,x,b)}},y=l.getProxy(i,e.pathAsArray?[]:"",g);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};Ib.target=i=>i&&i[pf]||i;Ib.unsubscribe=i=>i[Ab]||i;var Ob=Ib;var GU=typeof global=="object"&&global&&global.Object===Object&&global,ag=GU;var HU=typeof self=="object"&&self&&self.Object===Object&&self,jU=ag||HU||Function("return this")(),vn=jU;var WU=vn.Symbol,lr=WU;var L_=Object.prototype,qU=L_.hasOwnProperty,YU=L_.toString,bf=lr?lr.toStringTag:void 0;function XU(i){var t=qU.call(i,bf),e=i[bf];try{i[bf]=void 0;var n=!0}catch{}var r=YU.call(i);return n&&(t?i[bf]=e:delete i[bf]),r}var N_=XU;var KU=Object.prototype,QU=KU.toString;function ZU(i){return QU.call(i)}var B_=ZU;var JU="[object Null]",$U="[object Undefined]",F_=lr?lr.toStringTag:void 0;function eV(i){return i==null?i===void 0?$U:JU:F_&&F_ in Object(i)?N_(i):B_(i)}var vi=eV;function tV(i){return i!=null&&typeof i=="object"}var Ar=tV;var nV="[object Symbol]";function rV(i){return typeof i=="symbol"||Ar(i)&&vi(i)==nV}var ya=rV;function iV(i,t){for(var e=-1,n=i==null?0:i.length,r=Array(n);++e<n;)r[e]=t(i[e],e,i);return r}var lg=iV;var sV=Array.isArray,Kn=sV;var oV=1/0,k_=lr?lr.prototype:void 0,U_=k_?k_.toString:void 0;function V_(i){if(typeof i=="string")return i;if(Kn(i))return lg(i,V_)+"";if(ya(i))return U_?U_.call(i):"";var t=i+"";return t=="0"&&1/i==-oV?"-0":t}var z_=V_;var aV=/\s/;function lV(i){for(var t=i.length;t--&&aV.test(i.charAt(t)););return t}var G_=lV;var cV=/^\s+/;function uV(i){return i&&i.slice(0,G_(i)+1).replace(cV,"")}var H_=uV;function hV(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var Un=hV;var j_=0/0,dV=/^[-+]0x[0-9a-f]+$/i,fV=/^0b[01]+$/i,pV=/^0o[0-7]+$/i,mV=parseInt;function gV(i){if(typeof i=="number")return i;if(ya(i))return j_;if(Un(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=Un(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=H_(i);var e=fV.test(i);return e||pV.test(i)?mV(i.slice(2),e?2:8):dV.test(i)?j_:+i}var Rb=gV;function yV(i){return i}var W_=yV;var vV="[object AsyncFunction]",xV="[object Function]",bV="[object GeneratorFunction]",SV="[object Proxy]";function wV(i){if(!Un(i))return!1;var t=vi(i);return t==xV||t==bV||t==vV||t==SV}var cg=wV;var AV=vn["__core-js_shared__"],ug=AV;var q_=function(){var i=/[^.]+$/.exec(ug&&ug.keys&&ug.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function EV(i){return!!q_&&q_ in i}var Y_=EV;var _V=Function.prototype,TV=_V.toString;function MV(i){if(i!=null){try{return TV.call(i)}catch{}try{return i+""}catch{}}return""}var Mo=MV;var CV=/[\\^$.*+?()[\]{}|]/g,PV=/^\[object .+?Constructor\]$/,DV=Function.prototype,IV=Object.prototype,OV=DV.toString,RV=IV.hasOwnProperty,LV=RegExp("^"+OV.call(RV).replace(CV,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function NV(i){if(!Un(i)||Y_(i))return!1;var t=cg(i)?LV:PV;return t.test(Mo(i))}var X_=NV;function BV(i,t){return i?.[t]}var K_=BV;function FV(i,t){var e=K_(i,t);return X_(e)?e:void 0}var Kr=FV;var kV=Kr(vn,"WeakMap"),hg=kV;var Q_=Object.create,UV=function(){function i(){}return function(t){if(!Un(t))return{};if(Q_)return Q_(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),Z_=UV;function VV(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var J_=VV;function zV(i,t){var e=-1,n=i.length;for(t||(t=Array(n));++e<n;)t[e]=i[e];return t}var $_=zV;var GV=800,HV=16,jV=Date.now;function WV(i){var t=0,e=0;return function(){var n=jV(),r=HV-(n-e);if(e=n,r>0){if(++t>=GV)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var eT=WV;function qV(i){return function(){return i}}var tT=qV;var YV=function(){try{var i=Kr(Object,"defineProperty");return i({},"",{}),i}catch{}}(),cu=YV;var XV=cu?function(i,t){return cu(i,"toString",{configurable:!0,enumerable:!1,value:tT(t),writable:!0})}:W_,nT=XV;var KV=eT(nT),rT=KV;function QV(i,t){for(var e=-1,n=i==null?0:i.length;++e<n&&t(i[e],e,i)!==!1;);return i}var iT=QV;var ZV=9007199254740991,JV=/^(?:0|[1-9]\d*)$/;function $V(i,t){var e=typeof i;return t=t??ZV,!!t&&(e=="number"||e!="symbol"&&JV.test(i))&&i>-1&&i%1==0&&i<t}var uu=$V;function ez(i,t,e){t=="__proto__"&&cu?cu(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var dg=ez;function tz(i,t){return i===t||i!==i&&t!==t}var hu=tz;var nz=Object.prototype,rz=nz.hasOwnProperty;function iz(i,t,e){var n=i[t];(!(rz.call(i,t)&&hu(n,e))||e===void 0&&!(t in i))&&dg(i,t,e)}var du=iz;function sz(i,t,e,n){var r=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=n?n(e[a],i[a],a,e,i):void 0;l===void 0&&(l=i[a]),r?dg(e,a,l):du(e,a,l)}return e}var Cs=sz;var sT=Math.max;function oz(i,t,e){return t=sT(t===void 0?i.length-1:t,0),function(){for(var n=arguments,r=-1,s=sT(n.length-t,0),o=Array(s);++r<s;)o[r]=n[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=n[r];return a[t]=e(o),J_(i,this,a)}}var oT=oz;var az=9007199254740991;function lz(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=az}var fu=lz;function cz(i){return i!=null&&fu(i.length)&&!cg(i)}var fg=cz;var uz=Object.prototype;function hz(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||uz;return i===e}var pu=hz;function dz(i,t){for(var e=-1,n=Array(i);++e<i;)n[e]=t(e);return n}var aT=dz;var fz="[object Arguments]";function pz(i){return Ar(i)&&vi(i)==fz}var Lb=pz;var lT=Object.prototype,mz=lT.hasOwnProperty,gz=lT.propertyIsEnumerable,yz=Lb(function(){return arguments}())?Lb:function(i){return Ar(i)&&mz.call(i,"callee")&&!gz.call(i,"callee")},mu=yz;function vz(){return!1}var cT=vz;var dT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,uT=dT&&typeof module=="object"&&module&&!module.nodeType&&module,xz=uT&&uT.exports===dT,hT=xz?vn.Buffer:void 0,bz=hT?hT.isBuffer:void 0,Sz=bz||cT,Pl=Sz;var wz="[object Arguments]",Az="[object Array]",Ez="[object Boolean]",_z="[object Date]",Tz="[object Error]",Mz="[object Function]",Cz="[object Map]",Pz="[object Number]",Dz="[object Object]",Iz="[object RegExp]",Oz="[object Set]",Rz="[object String]",Lz="[object WeakMap]",Nz="[object ArrayBuffer]",Bz="[object DataView]",Fz="[object Float32Array]",kz="[object Float64Array]",Uz="[object Int8Array]",Vz="[object Int16Array]",zz="[object Int32Array]",Gz="[object Uint8Array]",Hz="[object Uint8ClampedArray]",jz="[object Uint16Array]",Wz="[object Uint32Array]",rn={};rn[Fz]=rn[kz]=rn[Uz]=rn[Vz]=rn[zz]=rn[Gz]=rn[Hz]=rn[jz]=rn[Wz]=!0;rn[wz]=rn[Az]=rn[Nz]=rn[Ez]=rn[Bz]=rn[_z]=rn[Tz]=rn[Mz]=rn[Cz]=rn[Pz]=rn[Dz]=rn[Iz]=rn[Oz]=rn[Rz]=rn[Lz]=!1;function qz(i){return Ar(i)&&fu(i.length)&&!!rn[vi(i)]}var fT=qz;function Yz(i){return function(t){return i(t)}}var gu=Yz;var pT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sf=pT&&typeof module=="object"&&module&&!module.nodeType&&module,Xz=Sf&&Sf.exports===pT,Nb=Xz&&ag.process,Kz=function(){try{var i=Sf&&Sf.require&&Sf.require("util").types;return i||Nb&&Nb.binding&&Nb.binding("util")}catch{}}(),Co=Kz;var mT=Co&&Co.isTypedArray,Qz=mT?gu(mT):fT,pg=Qz;var Zz=Object.prototype,Jz=Zz.hasOwnProperty;function $z(i,t){var e=Kn(i),n=!e&&mu(i),r=!e&&!n&&Pl(i),s=!e&&!n&&!r&&pg(i),o=e||n||r||s,a=o?aT(i.length,String):[],l=a.length;for(var u in i)(t||Jz.call(i,u))&&!(o&&(u=="length"||r&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||uu(u,l)))&&a.push(u);return a}var mg=$z;function eG(i,t){return function(e){return i(t(e))}}var gg=eG;var tG=gg(Object.keys,Object),gT=tG;var nG=Object.prototype,rG=nG.hasOwnProperty;function iG(i){if(!pu(i))return gT(i);var t=[];for(var e in Object(i))rG.call(i,e)&&e!="constructor"&&t.push(e);return t}var yT=iG;function sG(i){return fg(i)?mg(i):yT(i)}var yu=sG;function oG(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var vT=oG;var aG=Object.prototype,lG=aG.hasOwnProperty;function cG(i){if(!Un(i))return vT(i);var t=pu(i),e=[];for(var n in i)n=="constructor"&&(t||!lG.call(i,n))||e.push(n);return e}var xT=cG;function uG(i){return fg(i)?mg(i,!0):xT(i)}var vu=uG;var hG=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,dG=/^\w*$/;function fG(i,t){if(Kn(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||ya(i)?!0:dG.test(i)||!hG.test(i)||t!=null&&i in Object(t)}var bT=fG;var pG=Kr(Object,"create"),Po=pG;function mG(){this.__data__=Po?Po(null):{},this.size=0}var ST=mG;function gG(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var wT=gG;var yG="__lodash_hash_undefined__",vG=Object.prototype,xG=vG.hasOwnProperty;function bG(i){var t=this.__data__;if(Po){var e=t[i];return e===yG?void 0:e}return xG.call(t,i)?t[i]:void 0}var AT=bG;var SG=Object.prototype,wG=SG.hasOwnProperty;function AG(i){var t=this.__data__;return Po?t[i]!==void 0:wG.call(t,i)}var ET=AG;var EG="__lodash_hash_undefined__";function _G(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Po&&t===void 0?EG:t,this}var _T=_G;function xu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}xu.prototype.clear=ST;xu.prototype.delete=wT;xu.prototype.get=AT;xu.prototype.has=ET;xu.prototype.set=_T;var Bb=xu;function TG(){this.__data__=[],this.size=0}var TT=TG;function MG(i,t){for(var e=i.length;e--;)if(hu(i[e][0],t))return e;return-1}var va=MG;var CG=Array.prototype,PG=CG.splice;function DG(i){var t=this.__data__,e=va(t,i);if(e<0)return!1;var n=t.length-1;return e==n?t.pop():PG.call(t,e,1),--this.size,!0}var MT=DG;function IG(i){var t=this.__data__,e=va(t,i);return e<0?void 0:t[e][1]}var CT=IG;function OG(i){return va(this.__data__,i)>-1}var PT=OG;function RG(i,t){var e=this.__data__,n=va(e,i);return n<0?(++this.size,e.push([i,t])):e[n][1]=t,this}var DT=RG;function bu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}bu.prototype.clear=TT;bu.prototype.delete=MT;bu.prototype.get=CT;bu.prototype.has=PT;bu.prototype.set=DT;var xa=bu;var LG=Kr(vn,"Map"),ba=LG;function NG(){this.size=0,this.__data__={hash:new Bb,map:new(ba||xa),string:new Bb}}var IT=NG;function BG(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var OT=BG;function FG(i,t){var e=i.__data__;return OT(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Sa=FG;function kG(i){var t=Sa(this,i).delete(i);return this.size-=t?1:0,t}var RT=kG;function UG(i){return Sa(this,i).get(i)}var LT=UG;function VG(i){return Sa(this,i).has(i)}var NT=VG;function zG(i,t){var e=Sa(this,i),n=e.size;return e.set(i,t),this.size+=e.size==n?0:1,this}var BT=zG;function Su(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var n=i[t];this.set(n[0],n[1])}}Su.prototype.clear=IT;Su.prototype.delete=RT;Su.prototype.get=LT;Su.prototype.has=NT;Su.prototype.set=BT;var Dl=Su;var GG="Expected a function";function Fb(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(GG);var e=function(){var n=arguments,r=t?t.apply(this,n):n[0],s=e.cache;if(s.has(r))return s.get(r);var o=i.apply(this,n);return e.cache=s.set(r,o)||s,o};return e.cache=new(Fb.Cache||Dl),e}Fb.Cache=Dl;var FT=Fb;var HG=500;function jG(i){var t=FT(i,function(n){return e.size===HG&&e.clear(),n}),e=t.cache;return t}var kT=jG;var WG=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,qG=/\\(\\)?/g,YG=kT(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(WG,function(e,n,r,s){t.push(r?s.replace(qG,"$1"):n||e)}),t}),UT=YG;function XG(i){return i==null?"":z_(i)}var VT=XG;function KG(i,t){return Kn(i)?i:bT(i,t)?[i]:UT(VT(i))}var Oi=KG;var QG=1/0;function ZG(i){if(typeof i=="string"||ya(i))return i;var t=i+"";return t=="0"&&1/i==-QG?"-0":t}var wa=ZG;function JG(i,t){t=Oi(t,i);for(var e=0,n=t.length;i!=null&&e<n;)i=i[wa(t[e++])];return e&&e==n?i:void 0}var yg=JG;function $G(i,t){for(var e=-1,n=t.length,r=i.length;++e<n;)i[r+e]=t[e];return i}var wu=$G;var zT=lr?lr.isConcatSpreadable:void 0;function e4(i){return Kn(i)||mu(i)||!!(zT&&i&&i[zT])}var GT=e4;function HT(i,t,e,n,r){var s=-1,o=i.length;for(e||(e=GT),r||(r=[]);++s<o;){var a=i[s];t>0&&e(a)?t>1?HT(a,t-1,e,n,r):wu(r,a):n||(r[r.length]=a)}return r}var jT=HT;function t4(i){var t=i==null?0:i.length;return t?jT(i,1):[]}var WT=t4;function n4(i){return rT(oT(i,void 0,WT),i+"")}var vg=n4;var r4=gg(Object.getPrototypeOf,Object),Au=r4;var i4="[object Object]",s4=Function.prototype,o4=Object.prototype,qT=s4.toString,a4=o4.hasOwnProperty,l4=qT.call(Object);function c4(i){if(!Ar(i)||vi(i)!=i4)return!1;var t=Au(i);if(t===null)return!0;var e=a4.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&qT.call(e)==l4}var YT=c4;function u4(i,t,e){var n=-1,r=i.length;t<0&&(t=-t>r?0:r+t),e=e>r?r:e,e<0&&(e+=r),r=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(r);++n<r;)s[n]=i[n+t];return s}var XT=u4;function h4(){this.__data__=new xa,this.size=0}var KT=h4;function d4(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var QT=d4;function f4(i){return this.__data__.get(i)}var ZT=f4;function p4(i){return this.__data__.has(i)}var JT=p4;var m4=200;function g4(i,t){var e=this.__data__;if(e instanceof xa){var n=e.__data__;if(!ba||n.length<m4-1)return n.push([i,t]),this.size=++e.size,this;e=this.__data__=new Dl(n)}return e.set(i,t),this.size=e.size,this}var $T=g4;function Eu(i){var t=this.__data__=new xa(i);this.size=t.size}Eu.prototype.clear=KT;Eu.prototype.delete=QT;Eu.prototype.get=ZT;Eu.prototype.has=JT;Eu.prototype.set=$T;var _u=Eu;function y4(i,t){return i&&Cs(t,yu(t),i)}var eM=y4;function v4(i,t){return i&&Cs(t,vu(t),i)}var tM=v4;var sM=typeof exports=="object"&&exports&&!exports.nodeType&&exports,nM=sM&&typeof module=="object"&&module&&!module.nodeType&&module,x4=nM&&nM.exports===sM,rM=x4?vn.Buffer:void 0,iM=rM?rM.allocUnsafe:void 0;function b4(i,t){if(t)return i.slice();var e=i.length,n=iM?iM(e):new i.constructor(e);return i.copy(n),n}var oM=b4;function S4(i,t){for(var e=-1,n=i==null?0:i.length,r=0,s=[];++e<n;){var o=i[e];t(o,e,i)&&(s[r++]=o)}return s}var aM=S4;function w4(){return[]}var xg=w4;var A4=Object.prototype,E4=A4.propertyIsEnumerable,lM=Object.getOwnPropertySymbols,_4=lM?function(i){return i==null?[]:(i=Object(i),aM(lM(i),function(t){return E4.call(i,t)}))}:xg,Tu=_4;function T4(i,t){return Cs(i,Tu(i),t)}var cM=T4;var M4=Object.getOwnPropertySymbols,C4=M4?function(i){for(var t=[];i;)wu(t,Tu(i)),i=Au(i);return t}:xg,bg=C4;function P4(i,t){return Cs(i,bg(i),t)}var uM=P4;function D4(i,t,e){var n=t(i);return Kn(i)?n:wu(n,e(i))}var Sg=D4;function I4(i){return Sg(i,yu,Tu)}var wf=I4;function O4(i){return Sg(i,vu,bg)}var wg=O4;var R4=Kr(vn,"DataView"),Ag=R4;var L4=Kr(vn,"Promise"),Eg=L4;var N4=Kr(vn,"Set"),_g=N4;var hM="[object Map]",B4="[object Object]",dM="[object Promise]",fM="[object Set]",pM="[object WeakMap]",mM="[object DataView]",F4=Mo(Ag),k4=Mo(ba),U4=Mo(Eg),V4=Mo(_g),z4=Mo(hg),Il=vi;(Ag&&Il(new Ag(new ArrayBuffer(1)))!=mM||ba&&Il(new ba)!=hM||Eg&&Il(Eg.resolve())!=dM||_g&&Il(new _g)!=fM||hg&&Il(new hg)!=pM)&&(Il=function(i){var t=vi(i),e=t==B4?i.constructor:void 0,n=e?Mo(e):"";if(n)switch(n){case F4:return mM;case k4:return hM;case U4:return dM;case V4:return fM;case z4:return pM}return t});var Do=Il;var G4=Object.prototype,H4=G4.hasOwnProperty;function j4(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&H4.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var gM=j4;var W4=vn.Uint8Array,Mu=W4;function q4(i){var t=new i.constructor(i.byteLength);return new Mu(t).set(new Mu(i)),t}var Cu=q4;function Y4(i,t){var e=t?Cu(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var yM=Y4;var X4=/\w*$/;function K4(i){var t=new i.constructor(i.source,X4.exec(i));return t.lastIndex=i.lastIndex,t}var vM=K4;var xM=lr?lr.prototype:void 0,bM=xM?xM.valueOf:void 0;function Q4(i){return bM?Object(bM.call(i)):{}}var SM=Q4;function Z4(i,t){var e=t?Cu(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var wM=Z4;var J4="[object Boolean]",$4="[object Date]",eH="[object Map]",tH="[object Number]",nH="[object RegExp]",rH="[object Set]",iH="[object String]",sH="[object Symbol]",oH="[object ArrayBuffer]",aH="[object DataView]",lH="[object Float32Array]",cH="[object Float64Array]",uH="[object Int8Array]",hH="[object Int16Array]",dH="[object Int32Array]",fH="[object Uint8Array]",pH="[object Uint8ClampedArray]",mH="[object Uint16Array]",gH="[object Uint32Array]";function yH(i,t,e){var n=i.constructor;switch(t){case oH:return Cu(i);case J4:case $4:return new n(+i);case aH:return yM(i,e);case lH:case cH:case uH:case hH:case dH:case fH:case pH:case mH:case gH:return wM(i,e);case eH:return new n;case tH:case iH:return new n(i);case nH:return vM(i);case rH:return new n;case sH:return SM(i)}}var AM=yH;function vH(i){return typeof i.constructor=="function"&&!pu(i)?Z_(Au(i)):{}}var EM=vH;var xH="[object Map]";function bH(i){return Ar(i)&&Do(i)==xH}var _M=bH;var TM=Co&&Co.isMap,SH=TM?gu(TM):_M,MM=SH;var wH="[object Set]";function AH(i){return Ar(i)&&Do(i)==wH}var CM=AH;var PM=Co&&Co.isSet,EH=PM?gu(PM):CM,DM=EH;var _H=1,TH=2,MH=4,IM="[object Arguments]",CH="[object Array]",PH="[object Boolean]",DH="[object Date]",IH="[object Error]",OM="[object Function]",OH="[object GeneratorFunction]",RH="[object Map]",LH="[object Number]",RM="[object Object]",NH="[object RegExp]",BH="[object Set]",FH="[object String]",kH="[object Symbol]",UH="[object WeakMap]",VH="[object ArrayBuffer]",zH="[object DataView]",GH="[object Float32Array]",HH="[object Float64Array]",jH="[object Int8Array]",WH="[object Int16Array]",qH="[object Int32Array]",YH="[object Uint8Array]",XH="[object Uint8ClampedArray]",KH="[object Uint16Array]",QH="[object Uint32Array]",tn={};tn[IM]=tn[CH]=tn[VH]=tn[zH]=tn[PH]=tn[DH]=tn[GH]=tn[HH]=tn[jH]=tn[WH]=tn[qH]=tn[RH]=tn[LH]=tn[RM]=tn[NH]=tn[BH]=tn[FH]=tn[kH]=tn[YH]=tn[XH]=tn[KH]=tn[QH]=!0;tn[IH]=tn[OM]=tn[UH]=!1;function Tg(i,t,e,n,r,s){var o,a=t&_H,l=t&TH,u=t&MH;if(e&&(o=r?e(i,n,r,s):e(i)),o!==void 0)return o;if(!Un(i))return i;var c=Kn(i);if(c){if(o=gM(i),!a)return $_(i,o)}else{var h=Do(i),d=h==OM||h==OH;if(Pl(i))return oM(i,a);if(h==RM||h==IM||d&&!r){if(o=l||d?{}:EM(i),!a)return l?uM(i,tM(o,i)):cM(i,eM(o,i))}else{if(!tn[h])return r?i:{};o=AM(i,h,a)}}s||(s=new _u);var f=s.get(i);if(f)return f;s.set(i,o),DM(i)?i.forEach(function(g){o.add(Tg(g,t,e,g,i,s))}):MM(i)&&i.forEach(function(g,y){o.set(y,Tg(g,t,e,y,i,s))});var p=u?l?wg:wf:l?vu:yu,m=c?void 0:p(i);return iT(m||i,function(g,y){m&&(y=g,g=i[y]),du(o,y,Tg(g,t,e,y,i,s))}),o}var Mg=Tg;var ZH=1,JH=4;function $H(i){return Mg(i,ZH|JH)}var Io=$H;var e5="__lodash_hash_undefined__";function t5(i){return this.__data__.set(i,e5),this}var LM=t5;function n5(i){return this.__data__.has(i)}var NM=n5;function Cg(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new Dl;++t<e;)this.add(i[t])}Cg.prototype.add=Cg.prototype.push=LM;Cg.prototype.has=NM;var BM=Cg;function r5(i,t){for(var e=-1,n=i==null?0:i.length;++e<n;)if(t(i[e],e,i))return!0;return!1}var FM=r5;function i5(i,t){return i.has(t)}var kM=i5;var s5=1,o5=2;function a5(i,t,e,n,r,s){var o=e&s5,a=i.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var u=s.get(i),c=s.get(t);if(u&&c)return u==t&&c==i;var h=-1,d=!0,f=e&o5?new BM:void 0;for(s.set(i,t),s.set(t,i);++h<a;){var p=i[h],m=t[h];if(n)var g=o?n(m,p,h,t,i,s):n(p,m,h,i,t,s);if(g!==void 0){if(g)continue;d=!1;break}if(f){if(!FM(t,function(y,v){if(!kM(f,v)&&(p===y||r(p,y,e,n,s)))return f.push(v)})){d=!1;break}}else if(!(p===m||r(p,m,e,n,s))){d=!1;break}}return s.delete(i),s.delete(t),d}var Pg=a5;function l5(i){var t=-1,e=Array(i.size);return i.forEach(function(n,r){e[++t]=[r,n]}),e}var UM=l5;function c5(i){var t=-1,e=Array(i.size);return i.forEach(function(n){e[++t]=n}),e}var VM=c5;var u5=1,h5=2,d5="[object Boolean]",f5="[object Date]",p5="[object Error]",m5="[object Map]",g5="[object Number]",y5="[object RegExp]",v5="[object Set]",x5="[object String]",b5="[object Symbol]",S5="[object ArrayBuffer]",w5="[object DataView]",zM=lr?lr.prototype:void 0,kb=zM?zM.valueOf:void 0;function A5(i,t,e,n,r,s,o){switch(e){case w5:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case S5:return!(i.byteLength!=t.byteLength||!s(new Mu(i),new Mu(t)));case d5:case f5:case g5:return hu(+i,+t);case p5:return i.name==t.name&&i.message==t.message;case y5:case x5:return i==t+"";case m5:var a=UM;case v5:var l=n&u5;if(a||(a=VM),i.size!=t.size&&!l)return!1;var u=o.get(i);if(u)return u==t;n|=h5,o.set(i,t);var c=Pg(a(i),a(t),n,r,s,o);return o.delete(i),c;case b5:if(kb)return kb.call(i)==kb.call(t)}return!1}var GM=A5;var E5=1,_5=Object.prototype,T5=_5.hasOwnProperty;function M5(i,t,e,n,r,s){var o=e&E5,a=wf(i),l=a.length,u=wf(t),c=u.length;if(l!=c&&!o)return!1;for(var h=l;h--;){var d=a[h];if(!(o?d in t:T5.call(t,d)))return!1}var f=s.get(i),p=s.get(t);if(f&&p)return f==t&&p==i;var m=!0;s.set(i,t),s.set(t,i);for(var g=o;++h<l;){d=a[h];var y=i[d],v=t[d];if(n)var x=o?n(v,y,d,t,i,s):n(y,v,d,i,t,s);if(!(x===void 0?y===v||r(y,v,e,n,s):x)){m=!1;break}g||(g=d=="constructor")}if(m&&!g){var b=i.constructor,w=t.constructor;b!=w&&"constructor"in i&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof w=="function"&&w instanceof w)&&(m=!1)}return s.delete(i),s.delete(t),m}var HM=M5;var C5=1,jM="[object Arguments]",WM="[object Array]",Dg="[object Object]",P5=Object.prototype,qM=P5.hasOwnProperty;function D5(i,t,e,n,r,s){var o=Kn(i),a=Kn(t),l=o?WM:Do(i),u=a?WM:Do(t);l=l==jM?Dg:l,u=u==jM?Dg:u;var c=l==Dg,h=u==Dg,d=l==u;if(d&&Pl(i)){if(!Pl(t))return!1;o=!0,c=!1}if(d&&!c)return s||(s=new _u),o||pg(i)?Pg(i,t,e,n,r,s):GM(i,t,l,e,n,r,s);if(!(e&C5)){var f=c&&qM.call(i,"__wrapped__"),p=h&&qM.call(t,"__wrapped__");if(f||p){var m=f?i.value():i,g=p?t.value():t;return s||(s=new _u),r(m,g,e,n,s)}}return d?(s||(s=new _u),HM(i,t,e,n,r,s)):!1}var YM=D5;function XM(i,t,e,n,r){return i===t?!0:i==null||t==null||!Ar(i)&&!Ar(t)?i!==i&&t!==t:YM(i,t,e,n,XM,r)}var KM=XM;function I5(i,t){return i!=null&&t in Object(i)}var QM=I5;function O5(i,t,e){t=Oi(t,i);for(var n=-1,r=t.length,s=!1;++n<r;){var o=wa(t[n]);if(!(s=i!=null&&e(i,o)))break;i=i[o]}return s||++n!=r?s:(r=i==null?0:i.length,!!r&&fu(r)&&uu(o,r)&&(Kn(i)||mu(i)))}var ZM=O5;function R5(i,t){return i!=null&&ZM(i,t,QM)}var JM=R5;var L5=function(){return vn.Date.now()},Ig=L5;var N5="Expected a function",B5=Math.max,F5=Math.min;function k5(i,t,e){var n,r,s,o,a,l,u=0,c=!1,h=!1,d=!0;if(typeof i!="function")throw new TypeError(N5);t=Rb(t)||0,Un(e)&&(c=!!e.leading,h="maxWait"in e,s=h?B5(Rb(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function f(E){var _=n,S=r;return n=r=void 0,u=E,o=i.apply(S,_),o}function p(E){return u=E,a=setTimeout(y,t),c?f(E):o}function m(E){var _=E-l,S=E-u,T=t-_;return h?F5(T,s-S):T}function g(E){var _=E-l,S=E-u;return l===void 0||_>=t||_<0||h&&S>=s}function y(){var E=Ig();if(g(E))return v(E);a=setTimeout(y,m(E))}function v(E){return a=void 0,d&&n?f(E):(n=r=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,n=l=r=a=void 0}function b(){return a===void 0?o:v(Ig())}function w(){var E=Ig(),_=g(E);if(n=arguments,r=this,l=E,_){if(a===void 0)return p(l);if(h)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return w.cancel=x,w.flush=b,w}var Ol=k5;function U5(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var $M=U5;function V5(i,t){return t.length<2?i:yg(i,XT(t,0,-1))}var eC=V5;function z5(i,t){return KM(i,t)}var Af=z5;function G5(i,t){return t=Oi(t,i),i=eC(i,t),i==null||delete i[wa($M(t))]}var tC=G5;function H5(i){return YT(i)?void 0:i}var nC=H5;var j5=1,W5=2,q5=4,Y5=vg(function(i,t){var e={};if(i==null)return e;var n=!1;t=lg(t,function(s){return s=Oi(s,i),n||(n=s.length>1),s}),Cs(i,wg(i),e),n&&(e=Mg(e,j5|W5|q5,nC));for(var r=t.length;r--;)tC(e,t[r]);return e}),Ub=Y5;function X5(i,t,e,n){if(!Un(i))return i;t=Oi(t,i);for(var r=-1,s=t.length,o=s-1,a=i;a!=null&&++r<s;){var l=wa(t[r]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(r!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=Un(c)?c:uu(t[r+1])?[]:{})}du(a,l,u),a=a[l]}return i}var rC=X5;function K5(i,t,e){for(var n=-1,r=t.length,s={};++n<r;){var o=t[n],a=yg(i,o);e(a,o)&&rC(s,Oi(o,i),a)}return s}var iC=K5;function Q5(i,t){return iC(i,t,function(e,n){return JM(i,n)})}var sC=Q5;var Z5=vg(function(i,t){return i==null?{}:sC(i,t)}),xi=Z5;var J5="Expected a function";function $5(i,t,e){var n=!0,r=!0;if(typeof i!="function")throw new TypeError(J5);return Un(e)&&(n="leading"in e?!!e.leading:n,r="trailing"in e?!!e.trailing:r),Ol(i,t,{leading:n,maxWait:t,trailing:r})}var Vb=$5;function oC(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function Qr(i,t){return Object.setPrototypeOf(i,t),i}var ej=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),tj=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),nj=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Rl&&"ontouchend"in document,rj=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,ij=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,sj=()=>{if(typeof window>"u")return!1;let i=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(i)&&/Apple Computer/.test(t)},oj=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},aj=()=>{if(typeof window>"u")return;let t=new URLSearchParams(window.location.search).get("desktop-app-version");return t?(window.localStorage.setItem("desktop-app-version",t),t):window.localStorage.getItem("desktop-app-version")??"0.0.6"},lj=ej(),Qre=lj?aj():void 0,Rl=tj(),Og=nj(),aC=rj(),Qn=ij(),zb=sj(),Gb=Number(oj());function Rg(i){return Array.isArray(i)?i:[i]}function lC(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}function Ef(i){return Rl?i.metaKey:i.ctrlKey}var We=[],Ng={},_f={},Lg={};function cC(i){We.includes(i)||We.push(i)}function Pu(i){delete Ng[i.pointerId];for(let t=0;t<We.length;t++)if(We[t].pointerId===i.pointerId){We.splice(t,1);break}}function uC(){We.splice(0,We.length)}function Bg(i){if(i.pointerType!=="touch")return;let t=Ng[i.pointerId];t===void 0&&(t={x:0,y:0},Ng[i.pointerId]=t),t.x=i.pageX,t.y=i.pageY}function Fg(i){let t=i.pointerId===We[0].pointerId?We[1]:We[0];return Ng[t.pointerId]}function hC(i){_f[i.key]=!0,Lg[i.key]=Lg[i.key]===void 0?1:Lg[i.key]+1}function dC(i){if(Rl&&_f.Meta)for(let t in _f)_f[t]=!1;else _f[i.key]=!1;Lg={}}function fC(i){i.addEventListener("pointerdown",cC,!0),i.addEventListener("pointerdown",Bg,!0),i.addEventListener("pointermove",Bg,!0),i.addEventListener("pointerup",Pu,!0),i.addEventListener("pointercancel",Pu,!0),i.addEventListener("pointerleave",Pu,!0),window.addEventListener("keydown",hC,!0),window.addEventListener("keyup",dC,!0)}function pC(i){i.removeEventListener("pointerdown",cC,!0),i.removeEventListener("pointerdown",Bg,!0),i.removeEventListener("pointermove",Bg,!0),i.removeEventListener("pointerup",Pu,!0),i.removeEventListener("pointercancel",Pu,!0),i.removeEventListener("pointerleave",Pu,!0),window.removeEventListener("keydown",hC,!0),window.removeEventListener("keyup",dC,!0)}var mC,gC=new Promise(i=>{mC=i});var kg;function yC(){if(kg)return kg;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@0.9.459/build",r=import("./navmesh.js"),[s,o]=await Promise.all([r,fetch(`${e}/navmesh.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});mC(l)}return kg=i(),kg}var vC,xC=new Promise(i=>{vC=i});var Ug;function bC(){if(Ug)return Ug;async function i(){let e=await import("./physics.js");await e.init(),vC(e)}return Ug=i(),Ug}var tt=class{modifyById(t,e){let n=this;if(n[t]===void 0)throw new Error("not expected");{let s={...n,[t]:e};return Object.setPrototypeOf(s,tt.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let n=e[t.id],r;n===void 0?r={type:2,id:t.id}:r={type:1,id:t.id,data:n};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,tt.prototype),{data:a,actual:t,reverse:r}}else if(t.type===2){let{id:n}=t,r=e[n];if(r===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,tt.prototype),delete s[n],{data:s,actual:t,reverse:{type:1,id:n,data:r}}}}return null}};function Tf(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let n=i[e];n&&typeof n=="object"&&Tf(n)}return Object.freeze(i)}function SC(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var Du=class extends Error{};function Vg(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function Ps(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let s=i;i=t,t=s}let n=[],r=1/(e+1);for(let s=0;s<e;s++){let o=i+(t-i)*(s+.75+Math.random()*.5)*r;n.push(o)}return n}function Iu(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function wC(){return typeof process<"u"}function AC(i,t){for(let e of i)t(e.id,e.data)!==!0&&AC(e.children,t)}function EC(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)EC(e,t)}var cn=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,cn.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Tf(this[e]),e++}fillCaches0(e,n){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,n);for(let r of e.children)this.fillCaches0(r,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,n){if(!this.has(e))return!0;for(;e;){let r=this.parent(e);if(r===n)return!0;e=r}return!1}rootAcestor(e){for(;e;){let n=this.parent(e);if(n)e=n;else return e}return e}isDescendantOf(e,n){for(;e;){let r=this.parent(e);if(r===n)return!0;e=r}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,n){if(e===null)this.traverse(n);else{let r=this.get(e);r&&EC(r,n)}}traverse(e){AC(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:n},this.modifyArrayBy(s,o)}}modifyArrayBy(e,n){let r=e,s=n;for(;r!==null;){let a=s,l=r;if(r=this.parent(r),r===void 0)throw new Error;s=this.childrenArray(r);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,cn.prototype);let o=s;return o.fillCaches(),o}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:n}){if(this.get(e)!==void 0)return!0;for(let r of n)if(this.checkDuplicatedIdRec(r))return!0;return!1}addOp(e){let{parent:n,fi:r,id:s,data:o,children:a}=e;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=n,u=this.childrenArray(l),c={fi:r,id:s,data:o,children:a};return u=[...u,c],u.sort((d,f)=>d.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:n}=e;if(this.get(n)===null)return null;{let r=this.parent(n);if(r===void 0)return null;let s=this.childrenArray(r),o=s.findIndex(u=>u.id===n);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(r,s),actual:e,reverse:{type:7,...a,parent:r}}}}moveOp(e){let{parent:n,fi:r,id:s}=e;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let f=n;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new Du("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],h=this.modifyArrayBy(o,l);o=n,l=h.childrenArray(o);let d=c.fi;return c={...c,fi:r},l=[...l,c],l.sort((f,p)=>f.fi-p.fi),e.localIndex=l.indexOf(c),h=h.modifyArrayBy(o,l),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,id:s}}}previous(e,n){if(n===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let r=null;for(let s of this.childrenArray(e)){if(s.id===n)return r;r=s.id}return null}traverseSortNext(e){let n=this.parent(e);if(n!==void 0){let r=this.childrenArray(n),s=r.findIndex(o=>o.id===e)+1;if(s<r.length)return r[s].id;if(n)return this.traverseSortNext(n)}}sortNext(e){let n=this.childrenArray(e);return n.length>0?n[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let n=this.childrenArray(e);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):e}sortPrevious(e){let n=this.parent(e);if(n!==void 0){let r=this.childrenArray(n),s=r.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(r[s].id):n}}getAllSorted(e){let n=[];for(let r of e){let s=this.getWithSortKey(r.id);s!==void 0&&n.push({...r,...s})}n.sort((r,s)=>SC(r.sortKey,s.sortKey));for(let r of n)delete r.sortKey;return n}getWithSortKey(e){var n=e;let r=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)r.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:r}}}insertBeforeHelper(e,n,r){return this.insertAfterHelper(e,this.previous(e,n),r)}insertAfterHelper(e,n,r){let s=this.childrenArray(e);if(n===null){if(s.length===0)return Ps(0,r,r);{let o=s[0].fi;return Ps(o-r,o,r)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return Ps(l,l+r,r)}else return Ps(o.fi,a.fi,r)}}};var Ou;(t=>{function i(e,n){if(n.type!==0)return null;if(Array.isArray(e)){let r=n.props,s={},o=[...e],a=!1;if(r)for(let l of Object.keys(r)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=r[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let r=n.props,s={},o={...e},a=!1;if(r)for(let l of Object.keys(r)){s[l]=o[l];let u=r[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}t.runOp=i})(Ou||(Ou={}));var Re=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Re.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Tf(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,n){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:n},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,Re.prototype);let n=e;return wC()||n.fillCaches(),n}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:n,id:r,data:s}=e,o=this,a={fi:n,id:r,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:r}}}deleteOp(e){let{id:n}=e,r=this,s=r.findIndex(l=>l.id===n);if(s===-1)return null;e.localIndex=s,r=[...r];let o=r.splice(s,1)[0];return{data:this.modifyArrayBy(r),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:n,id:r}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===r);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,h)=>c.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:r}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let r of this){if(r.id===e)return n;n=r.id}return null}insertBeforeHelper(e,n){return this.insertAfterHelper(this.previous(e),n)}insertAfterHelper(e,n){let r=this;if(e===null){if(r.length===0)return Ps(0,n,n);{let s=r[0].fi;return Ps(s-n,s,n)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=r.find(a=>a.fi>s.fi);if(o===void 0){let a=r[r.length-1].fi;return Ps(a,a+n,n)}else return Ps(s.fi,o.fi,n)}}};function Ru(i){return i&&typeof i=="object"&&i instanceof Yt}var Yt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],n=this,r=0,s={};for(;r<t.path.length;){if(e.push(n),n=n===void 0?void 0:n[t.path[r]],n!==void 0&&!Ru(n))return null;r+=1}n=n?Vg(n):new Yt;for(let[l,u]of Object.entries(t.props)){let c=n[l];s[l]=c,u===void 0?delete n[l]:n[l]=u}for(;r>0;){if(Object.keys(n).length===0){let l=e[r-1];l&&(n=Vg(l),delete n[t.path[r-1]])}else{let l=e[r-1];if(l){let u=Vg(l);u[t.path[r-1]]=n,n=u}else{let u=new Yt;u[t.path[r-1]]=n,n=u}}r-=1}let o=Object.setPrototypeOf(n,Yt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},Ds;(n=>{function i(r,s){return Mf(r,s)??r}n.apply=i;function t(r,s){return jb(r,s)}n.merge=t;function e(r,s){let o=0,a=s.path,l=r;for(;o<a.length&&l!==void 0;){if(l=Vn.zoomOnce(l,a[o]),l===void 0)return s;if(!Ru(l))return;o+=1}if(l===void 0)return s;if(!!Ru(l))if(s.type===0){let u={...s.props};for(let c of Object.keys(l))delete u[c];return{...s,props:u}}else if(s.type===1||s.type===4||s.type===7){let u=Hb([s],l);return u?(console.log(u),u):s}else return s}n.filterOp=e})(Ds||(Ds={}));function Hb(i,t){if(t===void 0)return;let e=!1,n=i.map(r=>{let s=r.id,o=Mf(r.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=r.data),r.children){let a=Hb(r.children,t);return a!==void 0?e=!0:a=r.children,{...r,id:s,data:o,children:a}}else return{...r,id:s,data:o}});if(e)return n}function cj(i,t){if(t===void 0)return;let e=!1,n=i.map(r=>{let s=r.id,o=Mf(r.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=r.data),{...r,id:s,data:o}});if(e)return Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}function Mf(i,t){if(!Ru(t))return t;if(i instanceof cn){let e=Hb(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof Re)return cj(i,t);if(Array.isArray(i)){let e=!1,n=i.map((r,s)=>{let o=Mf(r,t[s]);return e=e||o!==void 0,o===void 0&&(o=r),o});return e?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else{if(i instanceof Yt)return jb(i,t);if(i&&typeof i=="object"){let e={},n=!1;for(let[r,s]of Object.entries(i)){let o=Mf(s,t[r]);n=n||o!==void 0,o===void 0&&(o=s),e[r]=o}return n?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function jb(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!Ru(t))return t;if(!Ru(i))return Ds.apply(i,t);let e=new Set;for(let r of Object.keys(i))e.add(r);for(let r of Object.keys(t))e.add(r);let n=new Yt;for(let r of e){let s=jb(i===void 0?void 0:i[r],t===void 0?void 0:t[r]);n[r]=s}return n}function _C(i,t){let e={cur:[],result:[],len:0};return i=Cf(i,t,e)??i,[i,e.result]}function zg(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function Gg(i){i&&(i.len-=1)}function uj(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function TC(i,t,e){let n=!1,r=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Cf(s.data,t,zg(e,o));Gg(e),n=n||l!==void 0,l===void 0&&(l=s.data);let u=TC(s.children,t,e);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return r}function hj(i,t,e){let n=!1,r=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,e!==null))throw new Error("not supported");let l=Cf(s.data,t,zg(e,o));return Gg(e),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function Cf(i,t,e){if(i instanceof cn){let n=TC(i,t,e);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}else{if(i instanceof Re)return hj(i,t,e);if(Array.isArray(i)){let n=!1,r=i.map((s,o)=>{let a=Cf(s,t,zg(e,o));return Gg(e),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(i&&typeof i=="object"&&!Iu(i)){let n={},r=!1;for(let[s,o]of Object.entries(i))if(s!=="name"&&s!=="text"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");r=!0,s=a}let l=Cf(o,t,zg(e,s));Gg(e),r=r||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else if(typeof i=="string"){let n=t[i];return n!==void 0&&uj(e),n}else return}}var Hg;(t=>{function i(e,n){let r=Vn.zoom(n,e.path);if(typeof r=="object"){let s={};for(let o of Object.keys(e.props))s[o]=r[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=i})(Hg||(Hg={}));var zn;(a=>{function i(l,u){return{...l,path:l.path.slice(u)}}a.drop=i;function t(l,u){return e(l,u)?.data??l}a.applySimple=t;function e(l,u){let c=u.path;for(var h=[];;){let d;if(l instanceof Yt&&u.type===0&&(d=l.runOp({...u,path:c.slice(h.length)}),d===null&&(d=void 0)),d===void 0&&h.length===c.length&&(l instanceof cn||l instanceof Re||l instanceof tt?d=l.runOp(u):d=Ou.runOp(l,u)),d!==void 0)if(d!==null){let m=d.data;for(let g=h.length-1;g>=0;g--){let y=c[g],v=h[g];if(v instanceof cn){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Re){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof tt){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Yt){let x={...v,[y]:m};m=Object.setPrototypeOf(x,Yt.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=m;m=[...v],m[y]=x}else m={...v,[y]:m};else return null}return{data:m,actual:{...d.actual,path:c},reverse:{...d.reverse,path:c}}}else return null;let f=c[h.length],p;if(l instanceof cn){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof Re){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else l!==null&&(p=l[f]);if(p!==void 0)h.push(l),l=p;else return null}}a.apply=e;function n(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=n;function r(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=r;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&r(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(zn||(zn={}));var Pf;(l=>{function i(){return[]}l.empty=i;function t(u,c){let h=[];for(let d of u){let[f,...p]=d.path;f===c&&h.push({...d,path:p})}return h}l.removePrefix=t;function e(u,c){return u.map(h=>({...h,path:[c,...h.path]}))}l.addPrefix=e;function n(u,c){return[...u,...c]}l.concat=n;function r(u,c){return[...u.filter(d=>!c.some(f=>zn.subsumed(d,f))),...c]}l.compress=r;function s(u,c){return u.every(h=>c.every(d=>zn.commutative(h,d)))}l.commutative=s;function o(u,c){for(let h of c){let d=a(u,h);d!==null&&(u=d.data)}return u}l.applyAll=o;function a(u,c){var h=u;let d=[],f=[];for(let p of c)try{if(p.type===3){let m,g;p.path[p.path.length-1]==="variables"?m=Vn.zoom(h,[...p.path,p.id,"value"]):m=Vn.zoom(h,[...p.path,p.id]);let y=zn.apply(h,{...p,type:2});if(y!==null){h=y.data;let[v,x]=_C(h,{[p.id]:m});h=v;for(let b=0;b<x.length;b++){let w=x[b],E=w.pop();if(typeof E=="number"){let _=[E];for(let T=b+1;T<x.length;T++){let M=x[T],C=M[M.length-1];if(typeof C=="number"&&Vn.equal(w,M.slice(0,M.length-1)))_.push(C),x.splice(T,1);else break}let S=Vn.zoom(h,w);g=S.map((T,M)=>_.includes(M)?p.id:T),m=S,E=w.pop()}else g=p.id;d.push({type:0,path:w,props:{[E]:m}}),f.push({type:0,path:w,props:{[E]:g}})}f.push(y.reverse),d.push(y.actual)}}else{let m=zn.apply(h,p);m!==null&&(d.push(m.actual),h=m.data,f.push(m.reverse))}}catch(m){if(m instanceof Du)return null;throw m}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(Pf||(Pf={}));var MC=Symbol(),dj=Symbol(),Wg=Symbol(),Ll=class{reportOp(t,e,n=[]){let r=this;if(e===null)return;r._current=e.data;let s=n;for(;!(r instanceof jg);){let o=r._path,a=r._current;if(o!==""&&s.splice(0,0,o),r=r._parent,r===null)return;r.update(o,a)}r.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let n=e[Wg];n&&n(),delete this._children[t]}}}},qb=class extends Ll{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,Ou.runOp(this._current,t),t.path)}},Yb=class extends Ll{constructor(t,e,n){super(),this._parent=t,this._path=e,this._current=n}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,tt.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},CC={get(i,t){if(t===Wg)return()=>{i._parent=null};if(t===MC)return i._current;if(t===dj)return i;let{_current:e,_children:n}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e[t],o=qg(i,t,s);return o!==s?(n===void 0&&(n={},i._children=n),n[t]=o,o):s},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,n=Reflect.getOwnPropertyDescriptor(e,t);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:e[t]}}},fj={...CC,set(i,t,e){let n={type:0,props:{[t]:pn(e)??e}};return i.deleteChildren(t),i.runOp(n),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},pj={...CC,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},Lu=class extends Ll{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[Wg]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,n)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:n}=this,r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e.get(t)?.data,o=qg(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}add(t,e,n,r,s){this.runOp({type:7,parent:t,fi:e,id:n,data:r,children:s})}move(t,e,n){this.runOp({type:9,parent:t,fi:e,id:n})}insertAfter(t,e,n){let r=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,r[s],o.id,o.data,o.children)}}insertBefore(t,e,n){let r=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,r[s],o.id,o.data,o.children)}}moveAfter(t,e,n){let r=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,r[s],o)}}moveBefore(t,e,n){let r=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,r[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},Nu=class extends Ll{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[Wg]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let n=0;n<e;n++){let r=this._current[n].id,s=this._current[n].fi;t(this.data(this._current[n].id),r,s)}}find(t){let e=this.length;for(let n=0;n<e;n++){let r=this._current[n].id;if(t(this.data(r),r))return this.get(r)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:n}=this,r=n===void 0?void 0:n[t];if(r!==void 0)return r;let s=e.get(t)?.data,o=qg(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,n){this.runOp({type:4,fi:t,id:e,data:n})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(n[r],s.id,s.data)}}insertBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(n[r],s.id,s.data)}}moveAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(n[r],s)}}moveBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(n[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Wb(i,t,e){if(i.length>0){let n=i[i.length-1];if(n.type===0&&t.type===0&&Vn.equal(n.path,e)){Object.assign(n.props,t.props);return}}i.push({...t,path:e})}var jg=class extends Ll{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,n,r){Wb(this.ts,e,t),Wb(this.actual,n,t),Wb(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function qg(i,t,e){return e instanceof cn?new Lu(i,t,e):e instanceof Re?new Nu(i,t,e):e instanceof tt?new Proxy(new Yb(i,t,e),pj):e!==null&&typeof e=="object"?Iu(e)?e:new Proxy(new qb(i,t,e),fj):e}function Xb(i){let t=new jg(i);return[qg(t,"",i),t]}function Aa(i,t){let[e,n]=Xb(i);return t(e),n.result()}function pn(i){return i instanceof Lu||i instanceof Nu?i._current:i!==null&&typeof i=="object"?i[MC]:i}var Vn;(r=>{function i(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}r.equal=i;function t(s,o,a){let l=n(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...o};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return o}r.removeOverridden=t;function e(s,o){if((s instanceof cn||s instanceof Lu)&&typeof o=="string")return s.data(o);if((s instanceof Re||s instanceof Nu)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}r.zoomOnce=e;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}r.zoom=n})(Vn||(Vn={}));function PC(i,t){let e=[];if(t.length===i.length)for(var n=0;n<i.length;){if(t[n]==="*")e.push(i[n]);else if(i[n]!==t[n])return null;n+=1}else return null;return e}function Or(i,t){let e=[];if(t.length<=i.length)for(var n=0;n<t.length;){if(t[n]==="*")e.push(i[n]);else if(i[n]!==t[n])return null;n+=1}else return null;return e}var Yg=class{},Df=class extends Yg{constructor(e){super();this.id=e}},If=class extends Yg{constructor(e){super();this.data=e}};var Qb;try{Qb=new TextDecoder}catch{}var Ne,_a,J=0;var FC=[],Zb=FC,Jb=0,Zr={},Ot,Ea,Ri=0,Is=0,bi,Oo,zr=[],kt,DC={useRecords:!1,mapsAsObjects:!0},Of=class{},eS=new Of;eS.name="MessagePack 0xC1";var Bu=!1,Os=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(Ne)return GC(()=>(Kg(),this?this.unpack(t,e):Os.prototype.unpack.call(DC,t,e)));_a=e>-1?e:t.length,J=0,Jb=0,Is=0,Ea=null,Zb=FC,bi=null,Ne=t;try{kt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw Ne=null,t instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Os){if(Zr=this,this.structures)return Ot=this.structures,Xg();(!Ot||Ot.length>0)&&(Ot=[])}else Zr=DC,(!Ot||Ot.length>0)&&(Ot=[]);return Xg()}unpackMultiple(t,e){let n,r=0;try{Bu=!0;let s=t.length,o=this?this.unpack(t,s):Jg.unpack(t,s);if(e){for(e(o);J<s;)if(r=J,e(Xg())===!1)return}else{for(n=[o];J<s;)r=J,n.push(Xg());return n}}catch(s){throw s.lastPosition=r,s.values=n,s}finally{Bu=!1,Kg()}}_mergeStructures(t,e){t=t||[];for(let n=0,r=t.length;n<r;n++){let s=t[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}t.sharedLength=t.length;for(let n in e||[])if(n>=0){let r=t[n],s=e[n];s&&(r&&((t.restoreStructures||(t.restoreStructures=[]))[n]=r),t[n]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Xg(){try{if(!Zr.trusted&&!Bu){let t=Ot.sharedLength||0;t<Ot.length&&(Ot.length=t)}let i=xn();if(J==_a)Ot.restoreStructures&&IC(),Ot=null,Ne=null,Oo&&(Oo=null);else if(J>_a){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Bu)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Ot.restoreStructures&&IC(),Kg(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function IC(){for(let i in Ot.restoreStructures)Ot[i]=Ot.restoreStructures[i];Ot.restoreStructures=null}function xn(){let i=Ne[J++];if(i<160)if(i<128){if(i<64)return i;{let t=Ot[i&63]||Zr.getStructures&&kC()[i&63];return t?(t.read||(t.read=tS(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,Zr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[VC()]=xn();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(xn(),xn());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=xn();return t}else if(i<192){let t=i-160;if(Is>=J)return Ea.slice(J-Ri,(J+=t)-Ri);if(Is==0&&_a<140){let e=t<16?nS(t):UC(t);if(e!=null)return e}return $b(t)}else{let t;switch(i){case 192:return null;case 193:return bi?(t=xn(),t>0?bi[1].slice(bi.position1,bi.position1+=t):bi[0].slice(bi.position0,bi.position0-=t)):eS;case 194:return!1;case 195:return!0;case 196:return Kb(Ne[J++]);case 197:return t=kt.getUint16(J),J+=2,Kb(t);case 198:return t=kt.getUint32(J),J+=4,Kb(t);case 199:return Nl(Ne[J++]);case 200:return t=kt.getUint16(J),J+=2,Nl(t);case 201:return t=kt.getUint32(J),J+=4,Nl(t);case 202:if(t=kt.getFloat32(J),Zr.useFloat32>2){let e=Zg[(Ne[J]&127)<<1|Ne[J+1]>>7];return J+=4,(e*t+(t>0?.5:-.5)>>0)/e}return J+=4,t;case 203:return t=kt.getFloat64(J),J+=8,t;case 204:return Ne[J++];case 205:return t=kt.getUint16(J),J+=2,t;case 206:return t=kt.getUint32(J),J+=4,t;case 207:return Zr.int64AsNumber?(t=kt.getUint32(J)*4294967296,t+=kt.getUint32(J+4)):t=kt.getBigUint64(J),J+=8,t;case 208:return kt.getInt8(J++);case 209:return t=kt.getInt16(J),J+=2,t;case 210:return t=kt.getInt32(J),J+=4,t;case 211:return Zr.int64AsNumber?(t=kt.getInt32(J)*4294967296,t+=kt.getUint32(J+4)):t=kt.getBigInt64(J),J+=8,t;case 212:if(t=Ne[J++],t==114)return BC(Ne[J++]&63);{let e=zr[t];if(e)return e.read?(J++,e.read(xn())):e.noBuffer?(J++,e()):e(Ne.subarray(J,++J));throw new Error("Unknown extension "+t)}case 213:return t=Ne[J],t==114?(J++,BC(Ne[J++]&63,Ne[J++])):Nl(2);case 214:return Nl(4);case 215:return Nl(8);case 216:return Nl(16);case 217:return t=Ne[J++],Is>=J?Ea.slice(J-Ri,(J+=t)-Ri):gj(t);case 218:return t=kt.getUint16(J),J+=2,Is>=J?Ea.slice(J-Ri,(J+=t)-Ri):yj(t);case 219:return t=kt.getUint32(J),J+=4,Is>=J?Ea.slice(J-Ri,(J+=t)-Ri):vj(t);case 220:return t=kt.getUint16(J),J+=2,RC(t);case 221:return t=kt.getUint32(J),J+=4,RC(t);case 222:return t=kt.getUint16(J),J+=2,LC(t);case 223:return t=kt.getUint32(J),J+=4,LC(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var mj=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function tS(i,t){function e(){if(e.count++>2){let r=i.read=new Function("r","return function(){return {"+i.map(s=>mj.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(xn);return i.highByte===0&&(i.read=OC(t,i.read)),r()}let n={};for(let r=0,s=i.length;r<s;r++){let o=i[r];n[o]=xn()}return n}return e.count=0,i.highByte===0?OC(t,e):e}var OC=(i,t)=>function(){let e=Ne[J++];if(e===0)return t();let n=i<32?-(i+(e<<5)):i+(e<<5),r=Ot[n]||kC()[n];if(!r)throw new Error("Record id is not defined for "+n);return r.read||(r.read=tS(r,i)),r.read()};function kC(){let i=GC(()=>(Ne=null,Zr.getStructures()));return Ot=Zr._mergeStructures(i,Ot)}var $b=Qg,gj=Qg,yj=Qg,vj=Qg;function Qg(i){let t;if(i<16&&(t=nS(i)))return t;if(i>64&&Qb)return Qb.decode(Ne.subarray(J,J+=i));let e=J+i,n=[];for(t="";J<e;){let r=Ne[J++];if((r&128)===0)n.push(r);else if((r&224)===192){let s=Ne[J++]&63;n.push((r&31)<<6|s)}else if((r&240)===224){let s=Ne[J++]&63,o=Ne[J++]&63;n.push((r&31)<<12|s<<6|o)}else if((r&248)===240){let s=Ne[J++]&63,o=Ne[J++]&63,a=Ne[J++]&63,l=(r&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(r);n.length>=4096&&(t+=ur.apply(String,n),n.length=0)}return n.length>0&&(t+=ur.apply(String,n)),t}function RC(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=xn();return t}function LC(i){if(Zr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[VC()]=xn();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(xn(),xn());return t}}var ur=String.fromCharCode;function UC(i){let t=J,e=new Array(i);for(let n=0;n<i;n++){let r=Ne[J++];if((r&128)>0){J=t;return}e[n]=r}return ur.apply(String,e)}function nS(i){if(i<4)if(i<2){if(i===0)return"";{let t=Ne[J++];if((t&128)>1){J-=1;return}return ur(t)}}else{let t=Ne[J++],e=Ne[J++];if((t&128)>0||(e&128)>0){J-=2;return}if(i<3)return ur(t,e);let n=Ne[J++];if((n&128)>0){J-=3;return}return ur(t,e,n)}else{let t=Ne[J++],e=Ne[J++],n=Ne[J++],r=Ne[J++];if((t&128)>0||(e&128)>0||(n&128)>0||(r&128)>0){J-=4;return}if(i<6){if(i===4)return ur(t,e,n,r);{let s=Ne[J++];if((s&128)>0){J-=5;return}return ur(t,e,n,r,s)}}else if(i<8){let s=Ne[J++],o=Ne[J++];if((s&128)>0||(o&128)>0){J-=6;return}if(i<7)return ur(t,e,n,r,s,o);let a=Ne[J++];if((a&128)>0){J-=7;return}return ur(t,e,n,r,s,o,a)}else{let s=Ne[J++],o=Ne[J++],a=Ne[J++],l=Ne[J++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){J-=8;return}if(i<10){if(i===8)return ur(t,e,n,r,s,o,a,l);{let u=Ne[J++];if((u&128)>0){J-=9;return}return ur(t,e,n,r,s,o,a,l,u)}}else if(i<12){let u=Ne[J++],c=Ne[J++];if((u&128)>0||(c&128)>0){J-=10;return}if(i<11)return ur(t,e,n,r,s,o,a,l,u,c);let h=Ne[J++];if((h&128)>0){J-=11;return}return ur(t,e,n,r,s,o,a,l,u,c,h)}else{let u=Ne[J++],c=Ne[J++],h=Ne[J++],d=Ne[J++];if((u&128)>0||(c&128)>0||(h&128)>0||(d&128)>0){J-=12;return}if(i<14){if(i===12)return ur(t,e,n,r,s,o,a,l,u,c,h,d);{let f=Ne[J++];if((f&128)>0){J-=13;return}return ur(t,e,n,r,s,o,a,l,u,c,h,d,f)}}else{let f=Ne[J++],p=Ne[J++];if((f&128)>0||(p&128)>0){J-=14;return}if(i<15)return ur(t,e,n,r,s,o,a,l,u,c,h,d,f,p);let m=Ne[J++];if((m&128)>0){J-=15;return}return ur(t,e,n,r,s,o,a,l,u,c,h,d,f,p,m)}}}}}function Kb(i){return Zr.copyBuffers?Uint8Array.prototype.slice.call(Ne,J,J+=i):Ne.subarray(J,J+=i)}function Nl(i){let t=Ne[J++];if(zr[t])return zr[t](Ne.subarray(J,J+=i));throw new Error("Unknown extension type "+t)}var NC=new Array(4096);function VC(){let i=Ne[J++];if(i>=160&&i<192){if(i=i-160,Is>=J)return Ea.slice(J-Ri,(J+=i)-Ri);if(!(Is==0&&_a<180))return $b(i)}else return J--,xn();let t=(i<<5^(i>1?kt.getUint16(J):i>0?Ne[J]:0))&4095,e=NC[t],n=J,r=J+i-3,s,o=0;if(e&&e.bytes==i){for(;n<r;){if(s=kt.getUint32(n),s!=e[o++]){n=1879048192;break}n+=4}for(r+=3;n<r;)if(s=Ne[n++],s!=e[o++]){n=1879048192;break}if(n===r)return J=n,e.string;r-=3,n=J}for(e=[],NC[t]=e,e.bytes=i;n<r;)s=kt.getUint32(n),e.push(s),n+=4;for(r+=3;n<r;)s=Ne[n++],e.push(s);let a=i<16?nS(i):UC(i);return a!=null?e.string=a:e.string=$b(i)}var BC=(i,t)=>{var e=xn();let n=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let r=Ot[i];return r&&r.isShared&&((Ot.restoreStructures||(Ot.restoreStructures=[]))[i]=r),Ot[i]=e,e.read=tS(e,n),e.read()},zC=typeof self=="object"?self:global;zr[0]=()=>{};zr[0].noBuffer=!0;zr[101]=()=>{let i=xn();return(zC[i[0]]||Error)(i[1])};zr[105]=i=>{let t=kt.getUint32(J-4);Oo||(Oo=new Map);let e=Ne[J],n;e>=144&&e<160||e==220||e==221?n=[]:n={};let r={target:n};Oo.set(t,r);let s=xn();return r.used?Object.assign(n,s):(r.target=s,s)};zr[112]=i=>{let t=kt.getUint32(J-4),e=Oo.get(t);return e.used=!0,e.target};zr[115]=()=>new Set(xn());var rS=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");zr[116]=i=>{let t=i[0],e=rS[t];if(!e)throw new Error("Could not find typed array for code "+t);return new zC[e](Uint8Array.prototype.slice.call(i,1).buffer)};zr[120]=()=>{let i=xn();return new RegExp(i[0],i[1])};zr[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=J;J+=t-4,bi=[xn(),xn()],bi.position0=0,bi.position1=0;let n=J;J=e;try{return xn()}finally{J=n}};zr[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function GC(i){let t=_a,e=J,n=Jb,r=Ri,s=Is,o=Ea,a=Zb,l=Oo,u=bi,c=new Uint8Array(Ne.slice(0,_a)),h=Ot,d=Ot.slice(0,Ot.length),f=Zr,p=Bu,m=i();return _a=t,J=e,Jb=n,Ri=r,Is=s,Ea=o,Zb=a,Oo=l,bi=u,Ne=c,Bu=p,Ot=h,Ot.splice(0,Ot.length,...d),Zr=f,kt=new DataView(Ne.buffer,Ne.byteOffset,Ne.byteLength),m}function Kg(){Ne=null,Oo=null,Ot=null}function HC(i){i.unpack?zr[i.type]=i.unpack:zr[i.type]=i}var Zg=new Array(147);for(let i=0;i<256;i++)Zg[i]=+("1e"+Math.floor(45.15-i*.30103));var Jg=new Os({useRecords:!1}),xj=Jg.unpack,bj=Jg.unpackMultiple,Sj=Jg.unpack,$g={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},wj=new Float32Array(1),ase=new Uint8Array(wj.buffer,0,4);var ey;try{ey=new TextEncoder}catch{}var ty,sS,ny=typeof Buffer<"u",iS=ny?Buffer.allocUnsafeSlow:Uint8Array,YC=ny?Buffer:Uint8Array,jC=ny?4294967296:2144337920,de,_n,re=0,Rs,Ls=null,Aj=/[\u0080-\uFFFF]/,Rf=Symbol("record-id"),Bl=class extends Os{constructor(t){super(t),this.offset=0;let e,n,r,s,o,a,l=0,u=YC.prototype.utf8Write?function(S,T,M){return de.utf8Write(S,T,M)}:ey&&ey.encodeInto?function(S,T){return ey.encodeInto(S,de.subarray(T)).written}:!1,c=this;t||(t={});let h=t&&t.sequential,d=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=t.maxOwnStructures;p==null&&(p=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let m=f>32||p+f>64,g=f+64,y=f+p+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,b=0;this.pack=this.encode=function(S,T){if(de||(de=new iS(8192),_n=new DataView(de.buffer,0,8192),re=0),Rs=de.length-10,Rs-re<2048?(de=new iS(de.length),_n=new DataView(de.buffer,0,de.length),Rs=de.length-10,re=0):re=re+7&2147483640,n=re,a=c.structuredClone?new Map:null,c.bundleStrings?(Ls=["",""],de[re++]=214,de[re++]=98,Ls.position=re-n,re+=4):Ls=null,r=c.structures,r){r.uninitialized&&(r=c._mergeStructures(c.getStructures()));let M=r.sharedLength||0;if(M>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let C=0;C<M;C++){let D=r[C];if(!D)continue;let P,I=r.transitions;for(let L=0,H=D.length;L<H;L++){let U=D[L];P=I[U],P||(P=I[U]=Object.create(null)),I=P}I[Rf]=C+64}l=M}h||(r.nextId=M+64)}s&&(s=!1),o=r||[];try{if(w(S),Ls){_n.setUint32(Ls.position+n,re-Ls.position-n);let M=Ls;Ls=null,w(M[0]),w(M[1])}if(c.offset=re,a&&a.idsToInsert){re+=a.idsToInsert.length*6,re>Rs&&_(re),c.offset=re;let M=_j(de.subarray(n,re),a.idsToInsert);return a=null,M}return T&KC?(de.start=n,de.end=re,de):de.subarray(n,re)}finally{if(r){if(b<10&&b++,x>1e4)r.transitions=null,b=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!h){for(let M=0,C=v.length;M<C;M++)v[M][Rf]=0;v=[]}if(s&&c.saveStructures){let M=r.sharedLength||f;r.length>M&&(r=r.slice(0,M));let C=de.subarray(n,re);return c.saveStructures(r,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(S)):(l=M,C)}}T&Oj&&(re=n)}};let w=S=>{re>Rs&&(de=_(re));var T=typeof S,M;if(T==="string"){let C=S.length;if(Ls&&C>=8&&C<4096){let I=Aj.test(S);Ls[I?0:1]+=S,de[re++]=193,w(I?-C:C);return}let D;C<32?D=1:C<256?D=2:C<65536?D=3:D=5;let P=C*3;if(re+P>Rs&&(de=_(re+P)),C<64||!u){let I,L,H,U=re+D;for(I=0;I<C;I++)L=S.charCodeAt(I),L<128?de[U++]=L:L<2048?(de[U++]=L>>6|192,de[U++]=L&63|128):(L&64512)===55296&&((H=S.charCodeAt(I+1))&64512)===56320?(L=65536+((L&1023)<<10)+(H&1023),I++,de[U++]=L>>18|240,de[U++]=L>>12&63|128,de[U++]=L>>6&63|128,de[U++]=L&63|128):(de[U++]=L>>12|224,de[U++]=L>>6&63|128,de[U++]=L&63|128);M=U-re-D}else M=u(S,re+D,P);M<32?de[re++]=160|M:M<256?(D<2&&de.copyWithin(re+2,re+1,re+1+M),de[re++]=217,de[re++]=M):M<65536?(D<3&&de.copyWithin(re+3,re+2,re+2+M),de[re++]=218,de[re++]=M>>8,de[re++]=M&255):(D<5&&de.copyWithin(re+5,re+3,re+3+M),de[re++]=219,_n.setUint32(re,M),re+=4),re+=M}else if(T==="number")if(S>>>0===S)S<64?de[re++]=S:S<256?(de[re++]=204,de[re++]=S):S<65536?(de[re++]=205,de[re++]=S>>8,de[re++]=S&255):(de[re++]=206,_n.setUint32(re,S),re+=4);else if(S>>0===S)S>=-32?de[re++]=256+S:S>=-128?(de[re++]=208,de[re++]=S+256):S>=-32768?(de[re++]=209,_n.setInt16(re,S),re+=2):(de[re++]=210,_n.setInt32(re,S),re+=4);else{let C;if((C=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){de[re++]=202,_n.setFloat32(re,S);let D;if(C<4||(D=S*Zg[(de[re]&127)<<1|de[re+1]>>7])>>0===D){re+=4;return}else re--}de[re++]=203,_n.setFloat64(re,S),re+=8}else if(T==="object")if(!S)de[re++]=192;else{if(a){let D=a.get(S);if(D){if(!D.id){let P=a.idsToInsert||(a.idsToInsert=[]);D.id=P.push(D)}de[re++]=214,de[re++]=112,_n.setUint32(re,D.id),re+=4;return}else a.set(S,{offset:re-n})}let C=S.constructor;if(C===Object)E(S,!0);else if(C===Array){M=S.length,M<16?de[re++]=144|M:M<65536?(de[re++]=220,de[re++]=M>>8,de[re++]=M&255):(de[re++]=221,_n.setUint32(re,M),re+=4);for(let D=0;D<M;D++)w(S[D])}else if(C===Map){M=S.size,M<16?de[re++]=128|M:M<65536?(de[re++]=222,de[re++]=M>>8,de[re++]=M&255):(de[re++]=223,_n.setUint32(re,M),re+=4);for(let[D,P]of S)w(D),w(P)}else{for(let D=0,P=ty.length;D<P;D++){let I=sS[D];if(S instanceof I){let L=ty[D];if(L.write){L.type&&(de[re++]=212,de[re++]=L.type,de[re++]=0),w(L.write.call(this,S));return}let H=de,U=_n,G=re;de=null;let z;try{z=L.pack.call(this,S,V=>(de=H,H=null,re+=V,re>Rs&&_(re),{target:de,targetView:_n,position:re-V}),w)}finally{H&&(de=H,_n=U,re=G,Rs=de.length-10)}z&&(z.length+re>Rs&&_(z.length+re),re=Ej(z,de,re,L.type));return}}E(S,!S.hasOwnProperty)}}else if(T==="boolean")de[re++]=S?195:194;else if(T==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))de[re++]=211,_n.setBigInt64(re,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)de[re++]=207,_n.setBigUint64(re,S);else if(this.largeBigIntToFloat)de[re++]=203,_n.setFloat64(re,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");re+=8}else if(T==="undefined")this.encodeUndefinedAsNil?de[re++]=192:(de[re++]=212,de[re++]=0,de[re++]=0);else if(T==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},E=this.useRecords===!1?this.variableMapSize?S=>{let T=Object.keys(S),M=T.length;M<16?de[re++]=128|M:M<65536?(de[re++]=222,de[re++]=M>>8,de[re++]=M&255):(de[re++]=223,_n.setUint32(re,M),re+=4);let C;for(let D=0;D<M;D++)w(C=T[D]),w(S[C])}:(S,T)=>{de[re++]=222;let M=re-n;re+=2;let C=0;for(let D in S)(T||S.hasOwnProperty(D))&&(w(D),w(S[D]),C++);de[M+++n]=C>>8,de[M+n]=C&255}:S=>{let T=Object.keys(S),M,C=o.transitions||(o.transitions=Object.create(null)),D=0;for(let I=0,L=T.length;I<L;I++){let H=T[I];M=C[H],M||(M=C[H]=Object.create(null),D++),C=M}let P=C[Rf];if(P)P>=96&&m?(de[re++]=((P-=96)&31)+96,de[re++]=P>>5):de[re++]=P;else{P=o.nextId,P||(P=64),P<g&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(P=o.nextOwnId,P<y||(P=g),o.nextOwnId=P+1):(P>=y&&(P=g),o.nextId=P+1);let I=T.highByte=P>=96&&m?P-96>>5:-1;C[Rf]=P,o[P-64]=T,P<g?(T.isShared=!0,o.sharedLength=P-63,s=!0,I>=0?(de[re++]=(P&31)+96,de[re++]=I):de[re++]=P):(I>=0?(de[re++]=213,de[re++]=114,de[re++]=(P&31)+96,de[re++]=I):(de[re++]=212,de[re++]=114,de[re++]=P),D&&(x+=b*D),v.length>=p&&(v.shift()[Rf]=0),v.push(C),w(T))}for(let I=0,L=T.length;I<L;I++)w(S[T[I]])},_=S=>{let T;if(S>16777216){if(S-n>jC)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(jC,Math.round(Math.max((S-n)*(S>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(S-n<<2,de.length-1)>>12)+1<<12;let M=new iS(T);return _n=new DataView(M.buffer,0,T),de.copy?de.copy(M,0,n,S):M.set(de.slice(n,S)),re-=n,n=0,Rs=M.length-10,de=M}}useBuffer(t){de=t,_n=new DataView(de.buffer,de.byteOffset,de.byteLength),re=0}};sS=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Of];ty=[{pack(i,t,e){let n=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:r,targetView:s,position:o}=t(6);r[o++]=214,r[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:r,targetView:s,position:o}=t(10);r[o++]=215,r[o++]=255,s.setUint32(o,i.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:r,targetView:s,position:o}=t(3);r[o++]=212,r[o++]=255,r[o++]=255}else{let{target:r,targetView:s,position:o}=t(15);r[o++]=199,r[o++]=12,r[o++]=255,s.setUint32(o,i.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(i,t,e){let n=Array.from(i),{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=115,r[s++]=0),e(n)}},{pack(i,t,e){let{target:n,position:r}=t(this.structuredClone?3:0);this.structuredClone&&(n[r++]=212,n[r++]=101,n[r++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:n,position:r}=t(this.structuredClone?3:0);this.structuredClone&&(n[r++]=212,n[r++]=120,n[r++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?WC(i,16,t):qC(ny?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==YC&&this.structuredClone?WC(i,rS.indexOf(e.name),t):qC(i,t)}},{pack(i,t){let{target:e,position:n}=t(1);e[n]=193}}];function WC(i,t,e,n){let r=i.byteLength;if(r+1<256){var{target:s,position:o}=e(4+r);s[o++]=199,s[o++]=r+1}else if(r+1<65536){var{target:s,position:o}=e(5+r);s[o++]=200,s[o++]=r+1>>8,s[o++]=r+1&255}else{var{target:s,position:o,targetView:a}=e(7+r);s[o++]=201,a.setUint32(o,r+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),o)}function qC(i,t){let e=i.byteLength;var n,r;if(e<256){var{target:n,position:r}=t(e+2);n[r++]=196,n[r++]=e}else if(e<65536){var{target:n,position:r}=t(e+3);n[r++]=197,n[r++]=e>>8,n[r++]=e&255}else{var{target:n,position:r,targetView:s}=t(e+5);n[r++]=198,s.setUint32(r,e),r+=4}n.set(i,r)}function Ej(i,t,e,n){let r=i.length;switch(r){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:r<256?(t[e++]=199,t[e++]=r):r<65536?(t[e++]=200,t[e++]=r>>8,t[e++]=r&255):(t[e++]=201,t[e++]=r>>24,t[e++]=r>>16&255,t[e++]=r>>8&255,t[e++]=r&255)}return t[e++]=n,t.set(i,e),e+=r,e}function _j(i,t){let e,n=t.length*6,r=i.length-n;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;i.copyWithin(s+n,s,r),n-=6;let a=s+n;i[a++]=214,i[a++]=105,i[a++]=o>>24,i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=o&255,r=s}return i}function Ta(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");sS.unshift(i.Class),ty.unshift(i)}HC(i)}var XC=new Bl({useRecords:!1}),Tj=XC.pack,Mj=XC.pack;var{NEVER:Cj,ALWAYS:Pj,DECIMAL_ROUND:Dj,DECIMAL_FIT:Ij}=$g,KC=512,Oj=1024;var QC=new Bl({structuredClone:!0});Ta({Class:tt.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,tt.prototype),i}});Ta({Class:Re.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Re.prototype),i}});Ta({Class:cn.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,cn.prototype),i}});Ta({Class:Df.prototype.constructor,type:4,write(i){return i.id},read(i){return new Df(i)}});Ta({Class:If.prototype.constructor,type:5,write(i){return i.data},read(i){return new If(i)}});Ta({Class:Yt.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Yt.prototype),i}});function Rj(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let n=i[e];t=(t<<5)-t+n,t=t&t}return t}function oS(i){if(Iu(i))return i;if(Array.isArray(i))return i.map(oS);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=oS(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var ry;(n=>{function i(r){return QC.pack(r)}n.serialize=i;function t(r){return QC.unpack(r)}n.deserialize=t;function e(r){return Rj(i(oS(r))).toString()}n.checksum=e})(ry||(ry={}));var ZC;(e=>{function i(n){return n.type==="Conditional"?n.condition.type==="Distance"?"Distance":"StateChange":n.type}e.toEventUIType=i;function t(n){return n==="Distance"||n==="StateChange"?"Conditional":n}e.fromEventUIType=t})(ZC||(ZC={}));var Si={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Create","SetVariable","Conditional"],["MouseHover"]:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","Conditional"],["Scroll"]:["Transition","Animation","Create","SetVariable","Conditional"],["Start"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","Conditional"],["Conditional"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["MouseDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["MouseUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["MousePress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["KeyDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["KeyUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["KeyPress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset","SetVariable","Conditional"],["GameControl"]:["Transition","Animation","Audio","Create","Conditional"],["Collision"]:["Transition","Animation","Audio","Video","Create","Destroy","Reset","SetVariable","Conditional"],["Trigger"]:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["Resize"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"],["VariableChange"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","Conditional"]},JC;(e=>{function i(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"}e.is=i;function t(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,mode:"Object",disabled:!1,runMode:"Once",actions:new Re}:{type:n,disabled:!1,key:void 0,runMode:"Once",actions:new Re}}e.defaultData=t})(JC||(JC={}));var iy;(e=>{function i(n){return{type:"Property",value:[n??null,"position","x"]}}e.propertyDefaultData=i,e.valueDefaultData={type:"Literal",value:0}})(iy||(iy={}));var aS;(n=>{function i(r){return{type:"Comparison",operator:"==",lOperand:iy.propertyDefaultData(r),rOperand:{...iy.valueDefaultData}}}n.comparisonDefaultData=i;function t(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}}n.distanceDefaultData=t;function e(r,s){return{type:"State",object:r??null,state:s??null}}n.stateDefaultData=e})(aS||(aS={}));var $C;(e=>{function i(n){return n.type==="Conditional"}e.is=i;function t(n){return{type:"Conditional",disabled:!1,inActions:new Re,outActions:new Re,condition:aS.distanceDefaultData(n)}}e.defaultData=t})($C||($C={}));var eP;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new Re,drop:new Re}})(eP||(eP={}));var sy;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new Re})(sy||(sy={}));var oy;(t=>t.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(oy||(oy={}));var tP;(e=>{function i(n){return n.type==="MouseHover"}e.is=i;function t(){return{type:"MouseHover",disabled:!1,actions:new Re}}e.defaultData=t})(tP||(tP={}));var nP;(e=>{function i(n){return n.type==="Scroll"}e.is=i;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Re}}e.defaultData=t})(nP||(nP={}));var rP;(e=>{function i(n){return n.type==="Start"}e.is=i;function t(){return{type:"Start",disabled:!1,actions:new Re}}e.defaultData=t})(rP||(rP={}));var iP;(e=>{function i(n){return n.type==="Collision"}e.is=i;function t(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new Re}}e.defaultData=t})(iP||(iP={}));var sP;(e=>{function i(n){return n.type==="Trigger"}e.is=i;function t(n,r){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new Re,triggerZone:"box",position:r.toArray(),rotation:[0,0,0],size:n.toArray(),radius:n.length()/2,helperVisible:!0}}e.defaultData=t})(sP||(sP={}));var ay;(o=>{o.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(a){return a.type==="Resize"}o.is=t;function e(a){return typeof a=="string"?a:"custom"}o.sizeToDevice=e;function n(a){return typeof a=="string"?[...o.defaultSizes[a]]:[...a]}o.deviceToSize=n;function r(){let a={size:"mobile",operator:"<",actions:new Re},l={size:"tablet",operator:"<",actions:new Re},u={size:[...o.defaultSizes.custom],operator:"<>",actions:new Re},c=new Re;return c.push({id:Te.generateUUID(),fi:0,data:a},{id:Te.generateUUID(),fi:1,data:l},{id:Te.generateUUID(),fi:2,data:u}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:c}}o.defaultData=r;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new Re}}o.defaultBreakpointData=s})(ay||(ay={}));var ly;(n=>{n.propertyPaths={"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}n.is=t;function e(){return{disabled:!1,type:"VariableChange",actions:new Re,variableId:"",objectId:null,property:"Position X"}}n.defaultData=e})(ly||(ly={}));var Li="personal camera",Ca="a218fcc3-276b-49b9-b485-49037fd14f5f",lP=2960946,Zn=5526619;var Fl;(e=>{function i(n,r){return n[0]===r[0]&&n[1]===r[1]}e.isEqual=i;function t(n,r,s){return[n[0]+(r[0]-n[0])*s,n[1]+(r[1]-n[1])*s]}e.lerp=t})(Fl||(Fl={}));var Ns;(a=>{function i(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}a.isEqual=i;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}a.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}a.sub=e;function n(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}a.div=n;function r(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=r;function s(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}a.dist=s;function o(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}a.lerp=o})(Ns||(Ns={}));var Lf;(e=>{function i(n,r){return n[0]===r[0]&&n[1]===r[1]&&n[2]===r[2]&&n[3]===r[3]}e.isEqual=i;function t(n,r,s){return[n[0]+(r[0]-n[0])*s,n[1]+(r[1]-n[1])*s,n[2]+(r[2]-n[2])*s,n[3]+(r[3]-n[3])*s]}e.lerp=t})(Lf||(Lf={}));var Ma;(r=>{r.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}r.isEqual=t;function e(s){return s??r.identity}r.simplify=e;function n(s,o){let a=o.slice(0);for(var l=0,u=o.length;l<u;l+=3){let c=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/c,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/c,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/c}return a}r.applyMatrix4=n})(Ma||(Ma={}));var hr;(c=>{function i(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}c.isRGB=i,c.white={r:1,g:1,b:1},c.red={r:1,g:0,b:0},c.black={r:0,g:0,b:0};function r(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}c.toRgb255a1=r;function s(h){return{r:h.r,g:h.g,b:h.b}}c.clone=s;function o(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}c.fromHex=o;function a(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}c.toHex=a;function l(h,d){return h.r===d.r&&h.g===d.g&&h.b===d.b}c.equals=l;function u(h,d,f){return{r:h.r+(d.r-h.r)*f,g:h.g+(d.g-h.g)*f,b:h.b+(d.b-h.b)*f}}c.lerp=u})(hr||(hr={}));var Gr;(a=>{a.white={...hr.white,a:1},a.transparent={...hr.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=e;function n(l,u){return{...hr.fromHex(l),a:u}}a.fromHexAndA=n;function r(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=r;function s(l,u){return hr.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(Gr||(Gr={}));var cy;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(cy||(cy={}));var oP;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(oP||(oP={}));var aP;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(aP||(aP={}));var Ro;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))(Ro||(Ro={}));function cP(i){return typeof i=="string"&&i.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i):!1}var ns;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(n){return e.all.includes(n)}e.is=t})(ns||(ns={}));var Pa;(r=>{r.DefaultUp=[0,1,0],r.DefaultTargetOffset=1e3,r.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:r.DefaultUp,isUpVectorFlipped:!1,targetOffset:r.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}r.getZoom=n})(Pa||(Pa={}));var Bs;(e=>{function i(n,r=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(n[0],n[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[n[0]+n[0]*r,0,0]},grid:{count:[2,2,2],size:n.map(s=>s*(1+r)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=i;function t(n,r){let s={...n};if(lS.forEach(o=>{Object.assign(s,{[o]:r[o]??n[o]})}),s.radial={...n.radial},r.radial){let o=n.radial,a=r.radial;cS.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...n.linear},r.linear){let o=n.linear,a=r.linear;uS.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...n.grid},r.grid){let o=n.grid,a=r.grid;hS.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...n.toObject},r.toObject){let o=n.toObject,a=r.toObject;dS.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...n.randomnessObject},r.randomnessObject){let o=n.randomnessObject,a=r.randomnessObject;fS.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(Bs||(Bs={}));var uy;(n=>{n.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(r,s){let o=[];r.count!==void 0&&o.push({type:0,path:s,props:{count:r.count}});for(let a of t){let l=r[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}n.toOps=e})(uy||(uy={}));var lS=["count"],cS=["radius","start","end","position","scale","rotation"],uS=["position","scale","rotation"],hS=["count","size"],dS=["count","position","scale","rotation"],fS=["strength","scale","rotation","position","movement","seed","freqScale"];var hy;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(n){return e.all.includes(n)}e.is=t})(hy||(hy={}));var dy;(e=>{function i(n){return t(n)}e.defaultData=i;function t(n){if(n==="PointLight")return{type:n,color:Gr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(n==="SpotLight")return{type:n,color:Gr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(n==="DirectionalLight")return{type:n,color:Gr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(dy||(dy={}));var Da;(t=>t.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Da||(Da={}));var pS;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(n,r){return n.castShadow===r.castShadow&&n.receiveShadow===r.receiveShadow}e.equals=t})(pS||(pS={}));var mS;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(n,r){return n.flatShading===r.flatShading&&n.side===r.side&&n.wireframe===r.wireframe}e.equals=t})(mS||(mS={}));var fy;(t=>t.defaultData={...mS.defaultData,...pS.defaultData})(fy||(fy={}));var uP;(t=>{function i(e,n){let r=[];if("material"in e){let s=typeof e.material=="string"?n.materials[e.material]??n.lib.materials[e.material]?.asset:e.material;s&&r.push(s)}else if("materials"in e)for(let s of e.materials){let o=typeof s=="string"?n.materials[s]??n.lib.materials[s]?.asset:s;o&&r.push(o)}return r}t.getMaterialData=i})(uP||(uP={}));var Fu;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Fu||(Fu={}));var hP;(t=>{function i(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=i})(hP||(hP={}));function fP(i){return i.type!=="displace"}var dP;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(dP||(dP={}));var py=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],pP=["wrapping","image","video","name"],dr;(r=>{function i(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}r.patch=i;function t(s,o){return s==="light"&&o?e(o):n(s)}r.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function n(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Fu.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...o,type:"color",color:hr.fromHex(Zn)};case"depth":return{...o,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...hr.fromHex(6710886),a:1},colorB:{...hr.fromHex(6710886),a:1},colorC:{...hr.fromHex(16777215),a:1},colorD:{...hr.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...o,type:"fresnel",color:Gr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Gr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:Gr.fromHexAndA(0,1),contourColor:Gr.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...o,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...hr.fromHex(0),a:1},colorB:{...hr.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}}}})(dr||(dr={}));var Tn;(l=>{function i(u){return!u.layers.some(h=>h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="displace")}l.isMergable=i;function t(u){let c="";return u.layers.forEach(h=>{Object.entries(h.data).forEach(([d,f])=>{c+=`${d}${f}`,Array.isArray(f)?f.forEach(p=>c+=`${p}`):typeof f=="object"?Object.values(f).forEach(p=>{typeof p=="number"?c+=`${p.toFixed(4)}`:c+=`${p}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new Re}}l.defaultEmptyData=e;function n(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=n;function r(u,c){return{...u,name:c}}l.withName=r;function s(u,c="layer1",h="layer2"){let d=new Re;return d.push({fi:0,data:dr.defaultData("light",u),id:c}),d.push({fi:1,data:dr.defaultData("color"),id:h}),{layers:d}}l.defaultTwoLayerData=s;function o(u,c="phong",h="layer1",d="layer2"){let f=dr.defaultData("texture");Object.assign(f.texture,{image:u});let p=new Re;return p.push({fi:0,data:f,id:h}),p.push({fi:1,data:dr.defaultData("light",c),id:d}),{layers:p}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",h="layer1",d="layer2"){let f=dr.defaultData("video");Object.assign(f.texture,{video:u});let p=new Re;return p.push({fi:0,data:f,id:h}),p.push({fi:1,data:dr.defaultData("light",c),id:d}),{layers:p}}l.defaultTwoLayerVideoTextureData=a})(Tn||(Tn={}));var ku;(t=>{function i(){return{points:new Re,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(ku||(ku={}));var Uu;(t=>{function i(){return{points:new Re,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(Uu||(Uu={}));var gS={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var my;(t=>{function i(e,n){let r={...e};return yS.forEach(s=>{Object.assign(r,{[s]:n[s]??e[s]})}),r}t.merge=i})(my||(my={}));var gy={shape:gS,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},yS=["depth","offset","angle","twist","startScale","endScale"];var Nf;(e=>{function i(n){return n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"}e.is2DParametricMesh=i;function t(n){return n==="PolygonGeometry"||n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"||n==="PathGeometry"||n==="VectorGeometry"||n==="ConeGeometry"||n==="CubeGeometry"||n==="CylinderGeometry"||n==="DodecahedronGeometry"||n==="HelixGeometry"||n==="IcosahedronGeometry"||n==="LatheGeometry"||n==="PyramidGeometry"||n==="SphereGeometry"||n==="PlaneGeometry"||n==="BackdropGeometry"||n==="TorusGeometry"||n==="TorusKnotGeometry"||n==="BooleanGeometry"||n==="TextGeometry"}e.isParametricMesh=t})(Nf||(Nf={}));var yy;(t=>{function i(e,n){let r={...e};return Object.assign(r,n),r.type==="PathGeometry"&&"extrusion"in n&&n.extrusion&&(r.extrusion={...e.extrusion},Object.assign(r.extrusion,my.merge(r.extrusion,n.extrusion))),r}t.merge=i})(yy||(yy={}));var Ia;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:Uu.defaultData(),extrusion:gy};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:ku.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}t.defaultData=i})(Ia||(Ia={}));var vS=["width","height","depth"];var vy;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:hr.white,near:.1,far:2e3})(vy||(vy={}));var Vu;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focalLength:2,focusDistance:2,bokehScale:2},noise:{...i,blendFunction:16}}})(Vu||(Vu={}));var xS;(t=>t.defaultData={softShadowQuality:"low"})(xS||(xS={}));var bS;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(bS||(bS={}));var SS;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(SS||(SS={}));var Oa;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Oa||(Oa={}));var wS;(t=>t.defaultData={playCamera:Li,gameControlObject:null})(wS||(wS={}));var xy;(t=>t.defaultData={backgroundColor:Gr.fromHexAndA(lP,1),postprocessing:Vu.defaultData,fog:vy.defaultData,globalPhysics:Oa.defaultData,ambient:bS.defaultData,ao:SS.defaultData,shadow:xS.defaultData,publish:wS.defaultData})(xy||(xy={}));var mP;(e=>{function i(n){return n==="Component"||n==="Instance"}e.isComponentRelated=i;function t(n){return n==="Empty"||n==="Instance"}e.isEmptyOrComponent=t})(mP||(mP={}));var zu;(r=>{r.identity={...cy.identity,hiddenMatrix:Ma.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}r.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}r.merge=e;function n(s,o){return oC({position:Ns.isEqual(s.position,o.position)?void 0:o.position,rotation:Ns.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:Ns.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:Ma.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}r.diff=n})(zu||(zu={}));var Er;(t=>t.defaultData={states:new Re,events:new Re,visible:!0,raycastLock:!1,physics:Da.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...zu.identity,cloner:null})(Er||(Er={}));var by;(t=>t.defaultData={type:"Empty",...Er.defaultData})(by||(by={}));var gP;(t=>t.defaultData={type:"Component",...Er.defaultData})(gP||(gP={}));var kl;(t=>t.defaultData={type:"Mesh",...Er.defaultData,...fy.defaultData})(kl||(kl={}));var Ul;(t=>t.defaultData={...Er.defaultData,...zu.identity,position:[0,0,Pa.DefaultTargetOffset],...Pa.defaultData})(Ul||(Ul={}));var Sy;(e=>{function i(n){return{...Er.defaultData,...dy.defaultData(n)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Sy||(Sy={}));var Gu;(e=>{function i(n,r,s=0){for(;s<r.length;){let o=n?n[r[s]]:void 0;if(r.length===s+1)return o;if(o)n=o.descendants,s+=1;else return}}e.resolveWithDes=i;function t(n,r,s=0){let o=i(n,r,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(Gu||(Gu={}));var Fs;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function n(o,a){return{...Er.defaultData,...a,component:o,overrides:new Yt,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=n;function r(o){let a=zu.fromObject(o.data);return n(o.id,a)}s.fromComponentData=r})(Fs||(Fs={}));var Lo;(t=>t.defaultData={type:"Page",...Er.defaultData,physics:{...Da.defaultData,fusedBody:!1},...xy.defaultData,camera:Ul.defaultData})(Lo||(Lo={}));var wy;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Ma.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Da.defaultData,states:new Re,events:new Re,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Pa.defaultData},s.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},s.defaultMeshObject={name:"Rectangle",...Er.defaultData,...kl.defaultData,geometry:Ia.defaultData("RectangleGeometry"),material:Tn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Er.defaultData,...kl.defaultData,geometry:Ia.defaultData("BooleanGeometry"),material:Tn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Er.defaultData,...kl.defaultData,geometry:Ia.defaultData("TextGeometry"),material:Tn.defaultTwoLayerData("phong","layer1","layer2")}))(wy||(wy={}));var No;(r=>{function i(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Yt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Yt})))):ns.is(s.type)&&(a.perspective={},a.orthographic={}),a}r.newEmpty=i;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Aa(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let h=l.layers.data(u);h&&dr.patch(h,c)}}).data),a.materials&&o.materials&&(a.materials=Aa(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[h,d]of Object.entries(c.layers)){let f=l[u]?.layers?.data(h);f&&dr.patch(f,d)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(h,d){for(let[f,p]of Object.entries(d.layers)){let{texture:m,...g}=p;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...h,"layers",f,"texture"],props:m,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...h,"layers",f],props:g,type:0};l.push(y)}}}for(let[h,d]of Object.entries(o))if(h!=="name")if(h==="cloner")l.push(...uy.toOps(d,["cloner"]));else if(h==="pathSnapping")l.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")c(["material"],d);else if(h==="materials")for(let[f,p]of Object.entries(d))c(["materials",f],p);else if(u[h]===0){if(h==="geometry"&&d.extrusion!==void 0){let f={path:[h,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[h],props:d,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[h]=d;return l}r.toOps=e;function n(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,zu.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),ns.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:yy.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Bs.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:Bs.merge(a.cloner,o.cloner)});else if(hy.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=hr.clone(l.color))}return a}r.patch=n})(No||(No={}));var ju;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(ju||(ju={}));var ks;(t=>t.defaultData={orbitControls:ju.defaultData,playPage:Ca,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,n)=>{let r=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?r=30:(n===4||n===11||n===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(ks||(ks={}));var AS;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(AS||(AS={}));var ES;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(ES||(ES={}));var Ra;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...AS.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:ES.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Ra||(Ra={}));var La;(e=>{function i(n){return n.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(n,r,s){n.scene.objects.traverseFrom(r,(o,a)=>{if(a.type==="Instance"){let l=Wu.getComponentData(n,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(La||(La={}));var Na;(a=>{a.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(l={withLight:!0,withSquare:!0}){let u=[],c=wy.defaultMeshObject;l.withLight===!0&&u.push({fi:-1,data:Sy.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),l.withSquare===!0&&u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:c,children:[]});let h=new cn;return h.push({fi:1,id:Ca,data:{...Lo.defaultData,name:"Scene 1"},children:u}),h}a.defaultData={objects:t(),publish:ks.defaultData,styles:Ra.defaultData()},a.emptyDataWithoutPage=function(){return{objects:new cn,publish:ks.defaultData,styles:Ra.defaultData()}},a.emptyDataWithPage=function(l){return{objects:t(l),publish:ks.defaultData,styles:Ra.defaultData()}};function s(l){return{...a.defaultData,objects:Qr(l,cn.prototype)}}a.withObjs=s;function o(l,u){return s([{id:l,data:u,children:[],fi:0}])}a.withObj=o})(Na||(Na={}));var qu;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(qu||(qu={}));var Yu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Yu||(Yu={}));var Hr;(s=>{function i(o){return o.textValue!==void 0}s.isTextValue=i;function t(o){return typeof o=="number"}s.isNumber=t;function e(o){return typeof o=="boolean"}s.isBoolean=e;function n(o){return i(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=n;function r(o){return s.isTextValue(o)?Array.isArray(o.textValue)?o.textValue.map(a=>a.toString().padStart(o.padding??2,"0")).join(o.deliminator??":")+(o.suffix!==void 0?" "+o.suffix:""):o.textValue.toString():s.isBoolean(o)?o?"True":"False":s.isNumber(o)?parseFloat(o.toFixed(3)).toString():o.toString()}s.getDisplayedValue=r})(Hr||(Hr={}));var _S;(t=>t.all=["images","videos","colors","audios","fonts","materials","variables"])(_S||(_S={}));var yP;(t=>t.all=[..._S.all,"components"])(yP||(yP={}));var vP;(t=>{function i(){return{images:new tt,videos:new tt,colors:new tt,audios:new tt,fonts:new tt,materials:new tt,components:new tt,variables:new tt}}t.defaultData=i})(vP||(vP={}));var Ba;(t=>{function i(){return{images:new tt,videos:new tt,colors:new tt,audios:new tt,fonts:new tt,materials:new tt,components:new tt,variables:new tt}}t.defaultData=i})(Ba||(Ba={}));var wi;(s=>{function i(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Qr(o,tt.prototype)}s.defaultColors=i;function t(o){let a={};return o?.withAITexture&&(a["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Yu.emptyImage,name:"AI generated image"}),Qr(a,tt.prototype)}s.defaultImages=t;function e(){return{catelogs:new tt,materials:new tt,images:new tt,videos:new tt,colors:new tt,audios:new tt,fonts:new tt,variables:new Re,lib:Ba.defaultData()}}s.emptyData=e;function n(o){switch(o){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let a=[0,0,0];return{name:"Time",value:{textValue:a,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:a,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",o)}}s.defaultVariables=n;function r(o,a){if(a.format==="HH:mm:ss"){let l=Math.floor(o/3600),u=Math.floor((o-l*3600)/60),c=Math.round(o-l*3600-u*60);return{textValue:[l,u,c]}}else if(a.format==="mm:ss"){let l=Math.floor(o/60),u=Math.round(o-l*60);return{textValue:[l,u]}}else return a.format==="number"?o=Math.round(o):o=Math.round(o*1e3)/1e3,o}s.getFormattedTimerTime=r})(wi||(wi={}));var Xu;(t=>t.list=["idle","move","jump","run"])(Xu||(Xu={}));var Ku;(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 Re,move:new Re,jump:new Re,run:new Re},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Gr.fromHexAndA(3728051,1)}}))(Ku||(Ku={}));function xP(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,n=t.colorB,r=[[e.r,e.g,e.b,e.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let a=2;a<10;a++)r.push(r[1]),s.push(1);let o={...xi(pn(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:r,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...pn(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Bo(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function Fo(i,t){i.scene.objects.traverse((e,n)=>{"materials"in n?n.materials.forEach((r,s)=>{r===void 0&&(n.materials[s]=Tn.defaultData(),r=n.materials[s]),typeof r!="string"&&t(r)}):"material"in n?typeof n.material!="string"&&(n.material===void 0&&(n.material=Tn.defaultData()),t(n.material)):n.type==="Mesh"&&(n.material===void 0&&(n.material=Tn.defaultData()),t(n.material)),"overrides"in n&&Object.values(n.overrides).forEach(r=>{r.material&&typeof r.material!="string"&&t(r.material)})})}function Nj(i){Object.assign(i.scene.publish,{orbitControls:{...ju.defaultData,...pn(i.scene.publish.orbitControls)}})}function Bj(i){Object.assign(i.scene.publish.settings,{video:{...ks.defaultData.settings.video,...pn(i.scene.publish.settings.video)}})}function Fj(i){function t(e){if(e.layers){for(let n of Object.values(e.layers))if(n){for(let[r,s]of Object.entries(n))if((py.includes(r)||typeof s=="boolean")&&delete n[r],r==="texture")for(let[o,a]of Object.entries(s))(pP.includes(o)||typeof a=="boolean")&&delete s[o]}}}i.scene.objects.traverse((e,n)=>{n.states.forEach(r=>{let s=r;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function kj(i){i.scene.publish.withBackground=!0}function Uj(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function Vj(i){i.scene.objects.traverse((t,e)=>{let n=e.cloner;n&&(n.radial.scale=n.radial.scale.map(r=>r+1),n.linear.scale=n.linear.scale.map(r=>r+1))})}function zj(i){i.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function Gj(i){i.scene.objects.traverse((t,e)=>{let n=i.scene.objects.unproxy().parent(t);if(n){let r=pn(i.scene.objects.data(n));r&&r.type==="Mesh"&&r.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=pn(e).booleanExclude!==!0)}})}function Hj(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let n=e;e.geometry.type==="NonParametricGeometry"?n.material!==void 0&&delete n.material:n.materials!==void 0&&delete n.materials}})}function jj(i){function t(n){Object.setPrototypeOf(n,Yt.prototype),n.texture&&Object.setPrototypeOf(n.texture,Yt.prototype)}function e(n){Object.setPrototypeOf(n,Yt.prototype);for(let r in n)t(n[r])}i.scene.objects.traverse((n,r)=>{r.states.forEach(s=>{let o=s;if(o.material){let a=pn(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],u=pn(l).layers;e(u),l.layers=u}})})}function bP(i){i.layers===void 0&&Object.assign(i,Tn.defaultTwoLayerData("lambert"))}function TS(i){!i.layers||i.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let n=[...t.steps];n.push(t.steps[9]);let r={...pn(t),colors:e,steps:n};Object.assign(t,r)}})}function Wj(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function SP(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(n=>{typeof n!="string"&&TS(n)}):"material"in e&&typeof e.material!="string"&&TS(e.material)}),Object.values(i.shared.materials).forEach(t=>TS(t))}function qj(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function Yj(i){i.shared.audios=Qr({},tt.prototype)}function Xj(i){i.shared.videos=Qr({},tt.prototype)}function Kj(i){let t=i.shared.materials;Object.entries(t).forEach(([e,n])=>{if(!n.layers){let r={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:r})}})}function Qj(i){Object.entries(pn(i.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete i.shared.images[n]}),Object.entries(pn(i.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete i.shared.audios[n]})}function Zj(i){i.scene.publish.settings.web.preload=!1}function wP(i){i.layers&&i.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function AP(i){i.layers&&i.layers.forEach(t=>{fP(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 Jj(i){i.shared.fonts=Qr({},tt.prototype)}function $j(i){return i.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function eW(i){let t=[];i.scene.objects.traverse((e,n)=>{let r=n;if(r.type==="TextFrame"){let s=Tn.defaultTwoLayerData("phong"),o=typeof r.color=="string"?i.shared.colors[r.color]:r.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=r.alpha;let a=$j(r.font);i.shared.fonts[a]===void 0&&(i.shared.fonts[a]={name:a});let l={name:r.name,...Er.defaultData,...kl.defaultData,flatShading:!1,wireframe:!1,geometry:{...Ia.defaultData("TextGeometry"),width:r.width,height:r.height,font:a,depth:0,horizontalAlign:r.horizontalAlign,verticalAlign:r.verticalAlign,fontSize:r.fontSize*1.40625,lineHeight:r.lineHeight/1.40625,letterSpacing:r.letterSpacing-1,text:r.text,textTransform:r.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:pn(r.states),events:pn(r.events),visible:r.visible,raycastLock:r.raycastLock,position:r.position,rotation:r.rotation,scale:r.scale,hiddenMatrix:r.hiddenMatrix},u=pn(i.scene.objects).parent(e);i.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function tW(i){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.scene.objects.traverse((e,n)=>{n.events.forEach(r=>{if(!!t[Number(r.type)])if(Object.assign(r,{type:t[Number(r.type)]}),r.type==="Audio"&&"audioEvent"in r&&(Object.assign(r,{playAudio:r.audioEvent}),delete r.audioEvent),r.type==="GameControl")Object.assign(r,{gameActions:{idle:new Re,move:new Re,jump:new Re}});else{let s=new Re;Object.assign(r,{actions:s}),(r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp")&&"url"in r&&s.push({fi:0,id:Te.generateUUID(),data:{type:"Link",url:r.url,delay:0}}),"targets"in r&&(r.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,xi(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Re({fi:0,id:Te.generateUUID(),data:u},{fi:1,id:Te.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete r.targets)}})})}function nW(i){i.scene.objects.traverse((t,e)=>{function n(r,s){let o=new Re,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(u),l.interaction==="play"?h={...xi(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(h={...xi(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:c,id:u,data:h})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===r)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:Te.generateUUID(),data:{type:r,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}function EP(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=dr.defaultData("light","phong"),n=t;Object.assign(n,e),n.visible=!1}}function _P(i){Bo(i,EP),Fo(i,EP)}function rW(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function iW(i){i.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function sW(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Tn.defaultTwoLayerData("phong"))})}function oW(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function aW(i){i.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function lW(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function cW(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function uW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.resetYPosition=Math.abs(n.resetYPosition-e.position[1]))})})}function hW(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,n)=>{t&&n.physics===null?n.collision=!1:n.collision="visibility"})}function dW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.navmesh=Ku.defaultDataThirdPerson.navmesh)})})}function fW(i){i.scene.styles||(i.scene.styles=Ra.defaultData())}function TP(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function pW(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Fo(i,TP),Bo(i,TP)}function mW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&Object.assign(n.gameActions,{run:new Re})})})}function gW(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.keyAssignments=[...n.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function MP(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function CP(i,t){if(t<1&&(Fo(i,xP),Bo(i,xP),i.schema=1),t<2&&(Nj(i),i.schema=2),t<3&&(Fj(i),i.schema=3),t<4&&(kj(i),i.schema=4),t<5&&(Uj(i),i.schema=5),t<6&&(Vj(i),i.schema=6),t<7&&(zj(i),i.schema=7),t<8&&(i.schema=8),t<9&&(SP(i),i.schema=9),t<10&&(Wj(i),i.schema=10),t<11&&(qj(i),i.schema=11),t<12&&(SP(i),i.schema=12),t<13&&(Yj(i),i.schema=13),t<14&&(Kj(i),i.schema=14),t<15&&(Qj(i),i.schema=15),t<16&&(Zj(i),i.schema=16),t<17&&(Fo(i,wP),Bo(i,wP),i.schema=17),t<18&&(Fo(i,bP),Bo(i,bP),i.schema=18),t<19&&(Bj(i),i.schema=19),t<20&&(Jj(i),eW(i),i.schema=20),t<21&&(tW(i),nW(i),i.schema=21),t<22&&(_P(i),i.schema=22),t<23&&(rW(i),i.schema=23),t<24&&(iW(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(Xj(i),t<25&&(i.schema=25)),t<26&&(Gj(i),i.schema=26),t<27&&(Hj(i),i.schema=27),t<28&&(_P(i),i.schema=28),t<29&&(jj(i),i.schema=29),t<30&&(sW(i),i.schema=30),t<31&&(oW(i),i.schema=31),t<33&&(aW(i),i.schema=33),t<34&&(lW(i),i.schema=34),t<35&&(cW(i),i.schema=35),t<36&&(uW(i),i.schema=36),t<37&&(hW(i),i.schema=37),t<38&&(Fo(i,AP),Bo(i,AP),i.schema=38),t<39&&(dW(i),i.schema=39),t<40&&(fW(i),i.schema=40),t<41&&(pW(i),i.schema=41),t<42&&(mW(i),i.schema=42),t<43&&(gW(i),i.schema=43),t<99){Fo(i,MP),Bo(i,MP),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=Li);let e=pn(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=Ca,n.insertBefore(null,null,[{id:Ca,data:{...Lo.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:xi(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:xi(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Oa.defaultData,...xi(i.scene.environment,"usePhysics","gravity")},camera:pn(i.scene.ownerCamera)??Lo.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==Na.TRASH_CAN_ID&&n.move(Ca,o.fi,o.id);let r=0,s=0;i.shared.penumbraSize&&i.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=i.shared.penumbraSize[Math.min(r,2)],r+=1):a.type==="SpotLight"&&(a.penumbraSize=i.shared.penumbraSize[3+Math.min(s,1)],s+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,Da.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),i.schema=99}}function PP(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function yW(i){i.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&n.type==="PathGeometry"&&(n.extrusion.capType="flat",n.extrusion.bevel=50,n.extrusion.bevelSides=6,n.extrusion.shape.type==="Custom"&&(n.extrusion.shape.shapeQuality="low"))})}var Qu=180/Math.PI;function DP(i){i.rotation=i.rotation.slice(0,3).map(t=>t*Qu)}function IP(i){DP(i),i.type==="Page"&&DP(i.camera),i.states?.forEach(e=>{e.rotation!==void 0&&(e.rotation=e.rotation.slice(0,3).map(n=>n*Qu))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=t.thetaLength*Qu),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Qu),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Qu,t.extrusion.twist*=Qu),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(pn(i.events))&&i.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Once")})}function vW(i){i.shared.variables=Qr({},tt.prototype)}function xW(i){let t=pn(i.shared.variables);i.shared.variables=Qr(Object.entries(t??{}).map(([e,n],r)=>({fi:r,id:e,data:n})),Re.prototype)}var ko=107;function OP(i,t){t(i.data);for(let e of i.children)OP(e,t)}function bW(i){let t=i.schema??104;t!==ko&&t<105&&(OP(i.asset,IP),i.schema=105)}function Ay(i){let t=i.schema??0;if(t!==ko){console.warn("updating from ",t,"to ",ko),CP(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=ks.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(Fo(i,PP),Bo(i,PP),i.schema=101),t<102&&(yW(i),i.schema=102),t<104&&(i.shared.catelogs=new tt,i.shared.lib=Ba.defaultData(),i.schema=104),t<105&&(vW(i),i.scene.objects.traverse((e,n)=>{IP(n)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))bW(e);t<106&&(xW(i),i.schema=106),t<107&&(i.shared.lib.variables=Ba.defaultData().variables,i.schema=107)}}var Wu;(a=>{a.defaultData={schema:ko,scene:Na.defaultData,frames:new tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",qu.defaultData),shared:{...wi.emptyData(),colors:wi.defaultColors()}},a.emptyDataForImports=function(l){let u=Na.emptyDataWithPage(l);return{schema:ko,scene:u,frames:new tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",qu.defaultData),shared:{...wi.emptyData(),colors:wi.defaultColors(),images:wi.defaultImages(l)}}},a.emptyData=function(){return{schema:ko,scene:Na.emptyDataWithPage(),frames:new tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",qu.defaultData),shared:wi.emptyData()}},a.collabHelper={...Pf,updateSchema(l){return(l.schema??0)<ko?Aa(l,Ay):(l.schema??0)-ko}};function r(l){let u=a.collabHelper.updateSchema(l);return typeof u=="number"?u===0?l:null:u.data}a.updateSchemaDirectly=r;function s(l){return{...l,shared:{...l.shared,lib:Ba.defaultData()}}}a.withoutLib=s;function o(l,u){let c=l.scene.objects.get(u);if(c&&c.data.type==="Component")return c;{let h=l.shared.lib.components[u];if(h)return h.asset}}a.getComponentData=o})(Wu||(Wu={}));function rs(i,t=!1){let e=i[0].index!==null,n=new Set(Object.keys(i[0].attributes)),r=new Set(Object.keys(i[0].morphAttributes)),s={},o={},a=i[0].morphTargetsRelative,l=new Ae,u=0;for(let c=0;c<i.length;++c){let h=i[c],d=0;if(e!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in h.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(h.attributes[f]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in h.morphAttributes){if(!r.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(t){let f;if(e)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,f,c),u+=f}}if(e){let c=0,h=[];for(let d=0;d<i.length;++d){let f=i[d].index;for(let p=0;p<f.count;++p)h.push(f.getX(p)+c);c+=i[d].attributes.position.count}l.setIndex(h)}for(let c in s){let h=RP(s[c]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,h)}for(let c in o){let h=o[c][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let d=0;d<h;++d){let f=[];for(let m=0;m<o[c].length;++m)f.push(o[c][m][d]);let p=RP(f);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(p)}}return l}function RP(i){let t,e,n,r=0;for(let a=0;a<i.length;++a){let l=i[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=l.itemSize),e!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;r+=l.array.length}let s=new t(r),o=0;for(let a=0;a<i.length;++a)s.set(i[a].array,o),o+=i[a].array.length;return new Ge(s,e,n)}var LP=Math.pow(2,-24);var Vl=class{constructor(){}};function Ni(i,t,e){return e.min.x=t[i],e.min.y=t[i+1],e.min.z=t[i+2],e.max.x=t[i+3],e.max.y=t[i+4],e.max.z=t[i+5],e}function MS(i){let t=-1,e=-1/0;for(let n=0;n<3;n++){let r=i[n+3]-i[n];r>e&&(e=r,t=n)}return t}function CS(i,t){t.set(i)}function PS(i,t,e){let n,r;for(let s=0;s<3;s++){let o=s+3;n=i[s],r=t[s],e[s]=n<r?n:r,n=i[o],r=t[o],e[o]=n>r?n:r}}function Bf(i,t,e){for(let n=0;n<3;n++){let r=t[i+2*n],s=t[i+2*n+1],o=r-s,a=r+s;o<e[n]&&(e[n]=o),a>e[n+3]&&(e[n+3]=a)}}function Zu(i){let t=i[3]-i[0],e=i[4]-i[1],n=i[5]-i[2];return 2*(t*e+e*n+n*t)}function AW(i,t){if(!i.index){let e=i.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,r;e>65535?r=new Uint32Array(new n(4*e)):r=new Uint16Array(new n(2*e)),i.setIndex(new Ge(r,1));for(let s=0;s<e;s++)r[s]=s}}function EW(i){if(!i.groups||!i.groups.length)return[{offset:0,count:i.index.count/3}];let t=[],e=new Set;for(let r of i.groups)e.add(r.start),e.add(r.start+r.count);let n=Array.from(e.values()).sort((r,s)=>r-s);for(let r=0;r<n.length-1;r++){let s=n[r],o=n[r+1];t.push({offset:s/3,count:(o-s)/3})}return t}function IS(i,t,e,n,r=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,h=1/0,d=1/0,f=1/0,p=-1/0,m=-1/0,g=-1/0,y=r!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let b=i[v+0],w=i[v+1],E=b-w,_=b+w;E<s&&(s=E),_>l&&(l=_),y&&b<h&&(h=b),y&&b>p&&(p=b);let S=i[v+2],T=i[v+3],M=S-T,C=S+T;M<o&&(o=M),C>u&&(u=C),y&&S<d&&(d=S),y&&S>m&&(m=S);let D=i[v+4],P=i[v+5],I=D-P,L=D+P;I<a&&(a=I),L>c&&(c=L),y&&D<f&&(f=D),y&&D>g&&(g=D)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,y&&(r[0]=h,r[1]=d,r[2]=f,r[3]=p,r[4]=m,r[5]=g)}function _W(i,t,e,n){let r=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,h=(t+e)*6;c<h;c+=6){let d=i[c+0];d<r&&(r=d),d>a&&(a=d);let f=i[c+2];f<s&&(s=f),f>l&&(l=f);let p=i[c+4];p<o&&(o=p),p>u&&(u=p)}n[0]=r,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function TW(i,t,e,n,r){let s=e,o=e+n-1,a=r.pos,l=r.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=i[s*3+u];i[s*3+u]=i[o*3+u],i[o*3+u]=c;let h=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=h;let d=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=d}s++,o--}else return s}}var Uo=32,MW=(i,t)=>i.candidate-t.candidate,Fa=new Array(Uo).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ey=new Float32Array(6);function CW(i,t,e,n,r,s){let o=-1,a=0;if(s===0)o=MS(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=MS(i),o!==-1&&(a=PW(e,n,r,o));else if(s===2){let l=Zu(i),u=1.25*r,c=n*6,h=(n+r)*6;for(let d=0;d<3;d++){let f=t[d],g=(t[d+3]-f)/Uo;if(r<Uo/4){let y=[...Fa];y.length=r;let v=0;for(let b=c;b<h;b+=6,v++){let w=y[v];w.candidate=e[b+2*d],w.count=0;let{bounds:E,leftCacheBounds:_,rightCacheBounds:S}=w;for(let T=0;T<3;T++)S[T]=1/0,S[T+3]=-1/0,_[T]=1/0,_[T+3]=-1/0,E[T]=1/0,E[T+3]=-1/0;Bf(b,e,E)}y.sort(MW);let x=r;for(let b=0;b<x;b++){let w=y[b];for(;b+1<x&&y[b+1].candidate===w.candidate;)y.splice(b+1,1),x--}for(let b=c;b<h;b+=6){let w=e[b+2*d];for(let E=0;E<x;E++){let _=y[E];w>=_.candidate?Bf(b,e,_.rightCacheBounds):(Bf(b,e,_.leftCacheBounds),_.count++)}}for(let b=0;b<x;b++){let w=y[b],E=w.count,_=r-w.count,S=w.leftCacheBounds,T=w.rightCacheBounds,M=0;E!==0&&(M=Zu(S)/l);let C=0;_!==0&&(C=Zu(T)/l);let D=1+1.25*(M*E+C*_);D<u&&(o=d,u=D,a=w.candidate)}}else{for(let x=0;x<Uo;x++){let b=Fa[x];b.count=0,b.candidate=f+g+x*g;let w=b.bounds;for(let E=0;E<3;E++)w[E]=1/0,w[E+3]=-1/0}for(let x=c;x<h;x+=6){let E=~~((e[x+2*d]-f)/g);E>=Uo&&(E=Uo-1);let _=Fa[E];_.count++,Bf(x,e,_.bounds)}let y=Fa[Uo-1];CS(y.bounds,y.rightCacheBounds);for(let x=Uo-2;x>=0;x--){let b=Fa[x],w=Fa[x+1];PS(b.bounds,w.rightCacheBounds,b.rightCacheBounds)}let v=0;for(let x=0;x<Uo-1;x++){let b=Fa[x],w=b.count,E=b.bounds,S=Fa[x+1].rightCacheBounds;w!==0&&(v===0?CS(E,Ey):PS(E,Ey,Ey)),v+=w;let T=0,M=0;v!==0&&(T=Zu(Ey)/l);let C=r-v;C!==0&&(M=Zu(S)/l);let D=1+1.25*(T*v+M*C);D<u&&(o=d,u=D,a=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function PW(i,t,e,n){let r=0;for(let s=t,o=t+e;s<o;s++)r+=i[s*6+n*2];return r/e}function DW(i,t){let e=i.attributes.position,n=i.index.array,r=n.length/3,s=new Float32Array(r*6),o=e.normalized,a=e.array,l=e.offset||0,u=3;e.isInterleavedBufferAttribute&&(u=e.data.stride);let c=["getX","getY","getZ"];for(let h=0;h<r;h++){let d=h*3,f=h*6,p,m,g;o?(p=n[d+0],m=n[d+1],g=n[d+2]):(p=n[d+0]*u+l,m=n[d+1]*u+l,g=n[d+2]*u+l);for(let y=0;y<3;y++){let v,x,b;o?(v=e[c[y]](p),x=e[c[y]](m),b=e[c[y]](g)):(v=a[p+y],x=a[m+y],b=a[g+y]);let w=v;x<w&&(w=x),b<w&&(w=b);let E=v;x>E&&(E=x),b>E&&(E=b);let _=(E-w)/2,S=y*2;s[f+S+0]=w+_,s[f+S+1]=_+(Math.abs(w)+_)*LP,w<t[y]&&(t[y]=w),E>t[y+3]&&(t[y+3]=E)}}return s}function IW(i,t){function e(y){d&&d(y/f)}function n(y,v,x,b=null,w=0){if(!p&&w>=l&&(p=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),x<=c||w>=l)return e(v+x),y.offset=v,y.count=x,y;let E=CW(y.boundingData,b,o,v,x,h);if(E.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let _=TW(a,o,v,x,E);if(_===v||_===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=E.axis;let S=new Vl,T=v,M=_-v;y.left=S,S.boundingData=new Float32Array(6),IS(o,T,M,S.boundingData,s),n(S,T,M,s,w+1);let C=new Vl,D=_,P=x-M;y.right=C,C.boundingData=new Float32Array(6),IS(o,D,P,C.boundingData,s),n(C,D,P,s,w+1)}return y}AW(i,t);let r=new Float32Array(6),s=new Float32Array(6),o=DW(i,r),a=i.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,h=t.strategy,d=t.onProgress,f=i.index.count/3,p=!1,m=[],g=EW(i);if(g.length===1){let y=g[0],v=new Vl;v.boundingData=r,_W(o,y.offset,y.count,s),n(v,y.offset,y.count,s),m.push(v)}else for(let y of g){let v=new Vl;v.boundingData=new Float32Array(6),IS(o,y.offset,y.count,v.boundingData,s),n(v,y.offset,y.count,s),m.push(v)}return m}function FP(i,t){let e=IW(i,t),n,r,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let h=e[c],d=l(h),f=new a(32*d);n=new Float32Array(f),r=new Uint32Array(f),s=new Uint16Array(f),u(0,h),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,h){let d=c/4,f=c/2,p=!!h.count,m=h.boundingData;for(let g=0;g<6;g++)n[d+g]=m[g];if(p){let g=h.offset,y=h.count;return r[d+6]=g,s[f+14]=y,s[f+15]=65535,c+32}else{let g=h.left,y=h.right,v=h.splitAxis,x;if(x=u(c+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return r[d+6]=x/4,x=u(x,y),r[d+7]=v,x}}}var Jr=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,r=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];n=l<n?l:n,r=l>r?l:r}this.min=n,this.max=r}setFromPoints(t,e){let n=1/0,r=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);n=l<n?l:n,r=l>r?l:r}this.min=n,this.max=r}isSeparated(t){return this.min>t.max||t.min>this.max}};Jr.prototype.setFromBox=function(){let i=new A;return function(e,n){let r=n.min,s=n.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){i.x=r.x*l+s.x*(1-l),i.y=r.y*u+s.y*(1-u),i.z=r.z*c+s.z*(1-c);let h=e.dot(i);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var lce=function(){let i=new Jr;return function(e,n){let r=e.points,s=e.satAxes,o=e.satBounds,a=n.points,l=n.satAxes,u=n.satBounds;for(let c=0;c<3;c++){let h=o[c],d=s[c];if(i.setFromPoints(d,a),h.isSeparated(i))return!1}for(let c=0;c<3;c++){let h=u[c],d=l[c];if(i.setFromPoints(d,r),h.isSeparated(i))return!1}}}();var OW=function(){let i=new A,t=new A,e=new A;return function(r,s,o){let a=r.start,l=i,u=s.start,c=t;e.subVectors(a,u),i.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let h=e.dot(c),d=c.dot(l),f=c.dot(c),p=e.dot(l),g=l.dot(l)*f-d*d,y,v;g!==0?y=(h*d-p*f)/g:y=0,v=(h+y*d)/f,o.x=y,o.y=v}}(),Ff=function(){let i=new B,t=new A,e=new A;return function(r,s,o,a){OW(r,s,i);let l=i.x,u=i.y;if(l>=0&&l<=1&&u>=0&&u<=1){r.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?r.at(0,o):r.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=r.start:c=r.end;let h;u<0?h=s.start:h=s.end;let d=t,f=e;if(r.closestPointToPoint(h,!0,t),s.closestPointToPoint(c,!0,e),d.distanceToSquared(h)<=f.distanceToSquared(c)){o.copy(d),a.copy(h);return}else{o.copy(c),a.copy(f);return}}}}(),kP=function(){let i=new A,t=new A,e=new En,n=new Xn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:h}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a||(n.start=u,n.end=h,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a)||(n.start=c,n.end=h,n.closestPointToPoint(l,!0,i).distanceTo(l)<=a))return!0;let m=o.getPlane(e);if(Math.abs(m.distanceToPoint(l))<=a){let y=m.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var RW=1e-15;function Ju(i){return Math.abs(i)<RW}var $r=class extends an{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new Jr),this.points=[this.a,this.b,this.c],this.sphere=new ln,this.plane=new En,this.needsUpdate=!0}intersectsSphere(t){return kP(t,this)}update(){let t=this.a,e=this.b,n=this.c,r=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,r);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,r);let h=s[2],d=o[2];h.subVectors(e,n),d.setFromPoints(h,r);let f=s[3],p=o[3];f.subVectors(n,t),p.setFromPoints(f,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};$r.prototype.closestPointToSegment=function(){let i=new A,t=new A,e=new Xn;return function(r,s=null,o=null){let{start:a,end:l}=r,u=this.points,c,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;e.start.copy(u[d]),e.end.copy(u[f]),Ff(e,r,i,t),c=i.distanceToSquared(t),c<h&&(h=c,s&&s.copy(i),o&&o.copy(t))}return this.closestPointToPoint(a,i),c=a.distanceToSquared(i),c<h&&(h=c,s&&s.copy(i),o&&o.copy(a)),this.closestPointToPoint(l,i),c=l.distanceToSquared(i),c<h&&(h=c,s&&s.copy(i),o&&o.copy(l)),Math.sqrt(h)}}();$r.prototype.intersectsTriangle=function(){let i=new $r,t=new Array(3),e=new Array(3),n=new Jr,r=new Jr,s=new A,o=new A,a=new A,l=new A,u=new Xn,c=new Xn,h=new Xn;return function(f,p=null,m=!1){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(i.copy(f),i.update(),f=i);let g=this.plane,y=f.plane;if(Math.abs(g.normal.dot(y.normal))>1-1e-10){let v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let E=0;E<4;E++){let _=v[E],S=x[E];if(n.setFromPoints(S,e),_.isSeparated(n))return!1}let b=f.satBounds,w=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let E=0;E<4;E++){let _=b[E],S=w[E];if(n.setFromPoints(S,t),_.isSeparated(n))return!1}for(let E=0;E<4;E++){let _=x[E];for(let S=0;S<4;S++){let T=w[S];if(s.crossVectors(_,T),n.setFromPoints(s,t),r.setFromPoints(s,e),n.isSeparated(r))return!1}}return p&&(m||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,x=!1,b=0;for(let I=0;I<3;I++){let L=v[I],H=v[(I+1)%3];u.start.copy(L),u.end.copy(H),u.delta(o);let U=x?c.start:c.end,G=Ju(y.distanceToPoint(L));if(Ju(y.normal.dot(o))&&G){c.copy(u),b=2;break}if((y.intersectLine(u,U)||G)&&!Ju(U.distanceTo(H))){if(b++,x)break;x=!0}}if(b===1&&f.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(b!==2)return!1;let w=f.points,E=!1,_=0;for(let I=0;I<3;I++){let L=w[I],H=w[(I+1)%3];u.start.copy(L),u.end.copy(H),u.delta(a);let U=E?h.start:h.end,G=Ju(g.distanceToPoint(L));if(Ju(g.normal.dot(a))&&G){h.copy(u),_=2;break}if((g.intersectLine(u,U)||G)&&!Ju(U.distanceTo(H))){if(_++,E)break;E=!0}}if(_===1&&this.containsPoint(h.end))return p&&(p.start.copy(h.end),p.end.copy(h.end)),!0;if(_!==2)return!1;if(c.delta(o),h.delta(a),o.dot(a)<0){let I=h.start;h.start=h.end,h.end=I}let S=c.start.dot(o),T=c.end.dot(o),M=h.start.dot(o),C=h.end.dot(o),D=T<M,P=S<C;return S!==C&&M!==T&&D===P?!1:(p&&(l.subVectors(c.start,h.start),l.dot(o)>0?p.start.copy(c.start):p.start.copy(h.start),l.subVectors(c.end,h.end),l.dot(o)<0?p.end.copy(c.end):p.end.copy(h.end)),!0)}}}();$r.prototype.distanceToPoint=function(){let i=new A;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();$r.prototype.distanceToTriangle=function(){let i=new A,t=new A,e=["a","b","c"],n=new Xn,r=new Xn;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let h=0;h<3;h++){let d,f=e[h],p=o[f];this.closestPointToPoint(p,i),d=p.distanceToSquared(i),d<c&&(c=d,a&&a.copy(i),l&&l.copy(p));let m=this[f];o.closestPointToPoint(m,i),d=m.distanceToSquared(i),d<c&&(c=d,a&&a.copy(m),l&&l.copy(i))}for(let h=0;h<3;h++){let d=e[h],f=e[(h+1)%3];n.set(this[d],this[f]);for(let p=0;p<3;p++){let m=e[p],g=e[(p+1)%3];r.set(o[m],o[g]),Ff(n,r,i,t);let y=i.distanceToSquared(t);y<c&&(c=y,a&&a.copy(i),l&&l.copy(t))}}return Math.sqrt(c)}}();var ei=class{constructor(t,e,n){this.isOrientedBox=!0,this.min=new A,this.max=new A,this.matrix=new se,this.invMatrix=new se,this.points=new Array(8).fill().map(()=>new A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new Jr),this.alignedSatBounds=new Array(3).fill().map(()=>new Jr),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};ei.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,r=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){let d=1*u|2*c|4*h,f=r[d];f.x=u?n.x:e.x,f.y=c?n.y:e.y,f.z=h?n.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=r[0];for(let u=0;u<3;u++){let c=o[u],h=s[u],d=1<<u,f=r[d];c.subVectors(a,f),h.setFromPoints(c,r)}let l=this.alignedSatBounds;l[0].setFromPointsField(r,"x"),l[1].setFromPointsField(r,"y"),l[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();ei.prototype.intersectsBox=function(){let i=new Jr;return function(e){this.needsUpdate&&this.update();let n=e.min,r=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(i.min=n.x,i.max=r.x,a[0].isSeparated(i)||(i.min=n.y,i.max=r.y,a[1].isSeparated(i))||(i.min=n.z,i.max=r.z,a[2].isSeparated(i)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(i.setFromBox(u,e),c.isSeparated(i))return!1}return!0}}();ei.prototype.intersectsTriangle=function(){let i=new $r,t=new Array(3),e=new Jr,n=new Jr,r=new A;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(i.copy(o),i.update(),o=i);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let d=0;d<3;d++){let f=a[d],p=l[d];if(e.setFromPoints(p,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,h=this.points;for(let d=0;d<3;d++){let f=u[d],p=c[d];if(e.setFromPoints(p,h),f.isSeparated(e))return!1}for(let d=0;d<3;d++){let f=l[d];for(let p=0;p<4;p++){let m=c[p];if(r.crossVectors(f,m),e.setFromPoints(r,t),n.setFromPoints(r,h),e.isSeparated(n))return!1}}return!0}}();ei.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();ei.prototype.distanceToPoint=function(){let i=new A;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();ei.prototype.distanceToBox=function(){let i=["x","y","z"],t=new Array(12).fill().map(()=>new Xn),e=new Array(12).fill().map(()=>new Xn),n=new A,r=new A;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(r),this.closestPointToPoint(r,n),o.closestPointToPoint(n,r),l&&l.copy(n),u&&u.copy(r)),0;let c=a*a,h=o.min,d=o.max,f=this.points,p=1/0;for(let g=0;g<8;g++){let y=f[g];r.copy(y).clamp(h,d);let v=y.distanceToSquared(r);if(v<p&&(p=v,l&&l.copy(y),u&&u.copy(r),v<c))return Math.sqrt(v)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(g+1)%3,b=(g+2)%3,w=y<<x|v<<b,E=1<<g|y<<x|v<<b,_=f[w],S=f[E];t[m].set(_,S);let M=i[g],C=i[x],D=i[b],P=e[m],I=P.start,L=P.end;I[M]=h[M],I[C]=y?h[C]:d[C],I[D]=v?h[D]:d[C],L[M]=d[M],L[C]=y?h[C]:d[C],L[D]=v?h[D]:d[C],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){r.x=g?d.x:h.x,r.y=y?d.y:h.y,r.z=v?d.z:h.z,this.closestPointToPoint(r,n);let x=r.distanceToSquared(n);if(x<p&&(p=x,l&&l.copy(n),u&&u.copy(r),x<c))return Math.sqrt(x)}for(let g=0;g<12;g++){let y=t[g];for(let v=0;v<12;v++){let x=e[v];Ff(y,x,n,r);let b=n.distanceToSquared(r);if(b<p&&(p=b,l&&l.copy(n),u&&u.copy(r),b<c))return Math.sqrt(b)}}return Math.sqrt(p)}}();var $u=new A,eh=new A,th=new A,Ty=new B,My=new B,Cy=new B,UP=new A,VP=new A,zP=new A,Py=new A;function LW(i,t,e,n,r,s){let o;return s===kn?o=i.intersectTriangle(n,e,t,!0,r):o=i.intersectTriangle(t,e,n,s!==Ur,r),o===null?null:{distance:i.origin.distanceTo(r),point:r.clone()}}function NW(i,t,e,n,r,s,o,a,l){$u.fromBufferAttribute(t,s),eh.fromBufferAttribute(t,o),th.fromBufferAttribute(t,a);let u=LW(i,$u,eh,th,Py,l);if(u){n&&(Ty.fromBufferAttribute(n,s),My.fromBufferAttribute(n,o),Cy.fromBufferAttribute(n,a),u.uv=an.getInterpolation(Py,$u,eh,th,Ty,My,Cy,new B)),r&&(Ty.fromBufferAttribute(r,s),My.fromBufferAttribute(r,o),Cy.fromBufferAttribute(r,a),u.uv1=an.getInterpolation(Py,$u,eh,th,Ty,My,Cy,new B)),e&&(UP.fromBufferAttribute(e,s),VP.fromBufferAttribute(e,o),zP.fromBufferAttribute(e,a),u.normal=an.getInterpolation(Py,$u,eh,th,UP,VP,zP,new A),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let c={a:s,b:o,c:a,normal:new A,materialIndex:0};an.getNormal($u,eh,th,c.normal),u.face=c,u.faceIndex=s}return u}function RS(i,t,e,n,r){let s=n*3,o=i.index.getX(s),a=i.index.getX(s+1),l=i.index.getX(s+2),{position:u,normal:c,uv:h,uv1:d}=i.attributes,f=NW(e,u,c,h,d,o,a,l,t);return f?(f.faceIndex=n,r&&r.push(f),f):null}function GP(i,t,e,n,r,s){for(let o=n,a=n+r;o<a;o++)RS(i,t,e,o,s)}function HP(i,t,e,n,r){let s=1/0,o=null;for(let a=n,l=n+r;a<l;a++){let u=RS(i,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Bi(i,t,e,n){let r=i.a,s=i.b,o=i.c,a=t,l=t+1,u=t+2;e&&(a=e.getX(t),l=e.getX(t+1),u=e.getX(t+2)),r.x=n.getX(a),r.y=n.getY(a),r.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function LS(i,t,e,n,r,s,o){let a=e.index,l=e.attributes.position;for(let u=i,c=t+i;u<c;u++)if(Bi(o,u*3,a,l),o.needsUpdate=!0,n(o,u,r,s))return!0;return!1}var nh=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function Vo(i,t){return t[i+15]===65535}function zl(i,t){return t[i+6]}function rh(i,t){return t[i+14]}function ih(i){return i+8}function sh(i,t){return t[i+6]}function jP(i,t){return t[i+7]}var oh=new Tt,Iy=new A,FW=["x","y","z"];function Oy(i,t,e,n,r){let s=i*2,o=ah,a=ka,l=Ua;if(Vo(s,a)){let c=zl(i,l),h=rh(s,a);GP(t,e,n,c,h,r)}else{let c=ih(i);Ly(c,o,n,Iy)&&Oy(c,t,e,n,r);let h=sh(i,l);Ly(h,o,n,Iy)&&Oy(h,t,e,n,r)}}function Ry(i,t,e,n){let r=i*2,s=ah,o=ka,a=Ua;if(Vo(r,o)){let u=zl(i,a),c=rh(r,o);return HP(t,e,n,u,c)}else{let u=jP(i,a),c=FW[u],d=n.direction[c]>=0,f,p;d?(f=ih(i),p=sh(i,a)):(f=sh(i,a),p=ih(i));let g=Ly(f,s,n,Iy)?Ry(f,t,e,n):null;if(g){let x=g.point[c];if(d?x<=s[p+u]:x>=s[p+u+3])return g}let v=Ly(p,s,n,Iy)?Ry(p,t,e,n):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var WP=function(){let i,t,e=[],n=new nh(()=>new Tt);return function(...o){i=n.getPrimitive(),t=n.getPrimitive(),e.push(i,t);let a=r(...o);n.releasePrimitive(i),n.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],i=e[l-2]),a};function r(s,o,a,l,u=null,c=0,h=0){function d(x){let b=x*2,w=ka,E=Ua;for(;!Vo(b,w);)x=ih(x),b=x*2;return zl(x,E)}function f(x){let b=x*2,w=ka,E=Ua;for(;!Vo(b,w);)x=sh(x,E),b=x*2;return zl(x,E)+rh(b,w)}let p=s*2,m=ah,g=ka,y=Ua;if(Vo(p,g)){let x=zl(s,y),b=rh(p,g);return Ni(s,m,i),l(x,b,!1,h,c+s,i)}else{let x=ih(s),b=sh(s,y),w=x,E=b,_,S,T,M;if(u&&(T=i,M=t,Ni(w,m,T),Ni(E,m,M),_=u(T),S=u(M),S<_)){w=b,E=x;let U=_;_=S,S=U,T=M}T||(T=i,Ni(w,m,T));let C=Vo(w*2,g),D=a(T,C,_,h+1,c+w),P;if(D===2){let U=d(w),z=f(w)-U;P=l(U,z,!0,h+1,c+w,T)}else P=D&&r(w,o,a,l,u,c,h+1);if(P)return!0;M=t,Ni(E,m,M);let I=Vo(E*2,g),L=a(M,I,S,h+1,c+E),H;if(L===2){let U=d(E),z=f(E)-U;H=l(U,z,!0,h+1,c+E,M)}else H=L&&r(E,o,a,l,u,c,h+1);return!!H}}}(),qP=function(){let i=new $r,t=new $r,e=new se,n=new ei,r=new ei;return function s(o,a,l,u,c=null){let h=o*2,d=ah,f=ka,p=Ua;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),Vo(h,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,b=l.attributes.position,w=zl(o,p),E=rh(h,f);if(e.copy(u).invert(),l.boundsTree)return Ni(o,d,r),r.matrix.copy(e),r.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>r.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(u),S.b.applyMatrix4(u),S.c.applyMatrix4(u),S.needsUpdate=!0;for(let T=w*3,M=(E+w)*3;T<M;T+=3)if(Bi(t,T,y,v),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let _=w*3,S=E+w*3;_<S;_+=3){Bi(i,_,y,v),i.a.applyMatrix4(e),i.b.applyMatrix4(e),i.c.applyMatrix4(e),i.needsUpdate=!0;for(let T=0,M=x.count;T<M;T+=3)if(Bi(t,T,x,b),t.needsUpdate=!0,i.intersectsTriangle(t))return!0}}else{let g=o+8,y=p[o+6];return Ni(g,d,oh),!!(c.intersectsBox(oh)&&s(g,a,l,u,c)||(Ni(y,d,oh),c.intersectsBox(oh)&&s(y,a,l,u,c)))}}}();function Ly(i,t,e,n){return Ni(i,t,oh),e.intersectBox(oh,n)}var NS=[],Dy,ah,ka,Ua;function lh(i){Dy&&NS.push(Dy),Dy=i,ah=new Float32Array(i),ka=new Uint16Array(i),Ua=new Uint32Array(i)}function kf(){Dy=null,ah=null,ka=null,Ua=null,NS.length&&lh(NS.pop())}var BS=Symbol("skip tree generation"),FS=new Tt,kS=new Tt,ch=new se,Gl=new ei,Uf=new ei,Vf=new A,Ny=new A,kW=new A,UW=new A,VW=new A,YP=new Tt,Us=new nh(()=>new $r),Vs=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Vs.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let n=t.geometry,r=t._roots,s=n.getIndex(),o;return e.cloneBuffers?o={roots:r.map(a=>a.slice()),index:s.array.slice()}:o={roots:r,index:s.array},o}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Vs.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:r,roots:s}=t,o=new Vs(e,{...n,[BS]:!0});if(o._roots=s,n.setIndex){let a=e.getIndex();if(a===null){let l=new Ge(t.index,1,!1);e.setIndex(l)}else a.array!==r&&(a.array.set(r),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[BS]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[BS]||(this._roots=FP(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Tt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,r=e.attributes.position,s,o,a,l,u=0,c=this._roots;for(let d=0,f=c.length;d<f;d++)s=c[d],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),h(0,u),u+=s.byteLength;function h(d,f,p=!1){let m=d*2;if(a[m+15]===65535){let y=o[d+6],v=a[m+14],x=1/0,b=1/0,w=1/0,E=-1/0,_=-1/0,S=-1/0;for(let T=3*y,M=3*(y+v);T<M;T++){let C=n[T],D=r.getX(C),P=r.getY(C),I=r.getZ(C);D<x&&(x=D),D>E&&(E=D),P<b&&(b=P),P>_&&(_=P),I<w&&(w=I),I>S&&(S=I)}return l[d+0]!==x||l[d+1]!==b||l[d+2]!==w||l[d+3]!==E||l[d+4]!==_||l[d+5]!==S?(l[d+0]=x,l[d+1]=b,l[d+2]=w,l[d+3]=E,l[d+4]=_,l[d+5]=S,!0):!1}else{let y=d+8,v=o[d+6],x=y+f,b=v+f,w=p,E=!1,_=!1;t?w||(E=t.has(x),_=t.has(b),w=!E&&!_):(E=!0,_=!0);let S=w||E,T=w||_,M=!1;S&&(M=h(y,f,w));let C=!1;T&&(C=h(v,f,w));let D=M||C;if(D)for(let P=0;P<3;P++){let I=y+P,L=v+P,H=l[I],U=l[I+3],G=l[L],z=l[L+3];l[d+P]=H<G?H:G,l[d+P+3]=U>z?U:z}return D}}}traverse(t,e=0){let n=this._roots[e],r=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let h=r[a+6],d=s[u+14];t(l,c,new Float32Array(n,a*4,6),h,d)}else{let h=a+32/4,d=r[a+6],f=r[a+7];t(l,c,new Float32Array(n,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(t,e=fi){let n=this._roots,r=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=r.groups,u=o?e.side:e;for(let c=0,h=n.length;c<h;c++){let d=a?e[l[c].materialIndex].side:u,f=s.length;if(lh(n[c]),Oy(0,r,d,t,s),kf(),a){let p=l[c].materialIndex;for(let m=f,g=s.length;m<g;m++)s[m].face.materialIndex=p}}return s}raycastFirst(t,e=fi){let n=this._roots,r=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=r.groups,u=s?e.side:e;for(let c=0,h=n.length;c<h;c++){let d=o?e[l[c].materialIndex].side:u;lh(n[c]);let f=Ry(0,r,d,t);kf(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(t,e){let n=this.geometry,r=!1;for(let s of this._roots)if(lh(s),r=qP(0,n,t,e),kf(),r)break;return r}shapecast(t,e,n){let r=this.geometry;if(t instanceof Function){if(e){let d=e;e=(f,p,m,g)=>{let y=p*3;return d(f,y,y+1,y+2,m,g)}}t={boundsTraverseOrder:n,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=Us.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let d=l;l=(f,p,m,g,y)=>d(f,p,m,g,y)?!0:LS(f,p,r,u,m,g,s)}else l||(u?l=(d,f,p,m)=>LS(d,f,r,u,p,m,s):l=(d,f,p)=>p);let c=!1,h=0;for(let d of this._roots){if(lh(d),c=WP(0,r,a,l,o,h),kf(),c)break;h+=d.byteLength}return Us.releasePrimitive(s),c}bvhcast(t,e,n){let{intersectsRanges:r,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;ch.copy(e).invert();let c=Us.getPrimitive(),h=Us.getPrimitive();if(s){let f=function(p,m,g,y,v,x,b,w){for(let E=g,_=g+y;E<_;E++){Bi(h,E*3,l,u),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let S=p,T=p+m;S<T;S++)if(Bi(c,S*3,o,a),c.needsUpdate=!0,s(c,h,S,E,v,x,b,w))return!0}return!1};if(r){let p=r;r=function(m,g,y,v,x,b,w,E){return p(m,g,y,v,x,b,w,E)?!0:f(m,g,y,v,x,b,w,E)}}else r=f}t.getBoundingBox(kS),kS.applyMatrix4(e);let d=this.shapecast({intersectsBounds:f=>kS.intersectsBox(f),intersectsRange:(f,p,m,g,y,v)=>(FS.copy(v),FS.applyMatrix4(ch),t.shapecast({intersectsBounds:x=>FS.intersectsBox(x),intersectsRange:(x,b,w,E,_)=>r(f,p,x,b,g,y,E,_)}))});return Us.releasePrimitive(c),Us.releasePrimitive(h),d}intersectsBox(t,e){return Gl.set(t.min,t.max,e),Gl.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Gl.intersectsBox(n),intersectsTriangle:n=>Gl.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},r={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Gl.set(t.boundingBox.min,t.boundingBox.max,e),Gl.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,h=t.index,d=Us.getPrimitive(),f=Us.getPrimitive(),p=Ny,m=kW,g=null,y=null;r&&(g=UW,y=VW);let v=1/0,x=null,b=null;return ch.copy(e).invert(),Uf.matrix.copy(ch),this.shapecast({boundsTraverseOrder:w=>Gl.distanceToBox(w),intersectsBounds:(w,E,_)=>_<v&&_<o?(E&&(Uf.min.copy(w.min),Uf.max.copy(w.max),Uf.needsUpdate=!0),!0):!1,intersectsRange:(w,E)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:_=>Uf.distanceToBox(_),intersectsBounds:(_,S,T)=>T<v&&T<o,intersectsRange:(_,S)=>{for(let T=_*3,M=(_+S)*3;T<M;T+=3){Bi(f,T,h,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let C=w*3,D=(w+E)*3;C<D;C+=3){Bi(d,C,u,l),d.needsUpdate=!0;let P=d.distanceToTriangle(f,p,g);if(P<v&&(m.copy(p),y&&y.copy(g),v=P,x=C/3,b=T/3),P<s)return!0}}}});{let _=h?h.count:c.count;for(let S=0,T=_;S<T;S+=3){Bi(f,S,h,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let M=w*3,C=(w+E)*3;M<C;M+=3){Bi(d,M,u,l),d.needsUpdate=!0;let D=d.distanceToTriangle(f,p,g);if(D<v&&(m.copy(p),y&&y.copy(g),v=D,x=M/3,b=S/3),D<s)return!0}}}}}),Us.releasePrimitive(d),Us.releasePrimitive(f),v===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=v,n.faceIndex=x,r&&(r.point?r.point.copy(y):r.point=y.clone(),r.point.applyMatrix4(ch),m.applyMatrix4(ch),r.distance=m.sub(r.point).length(),r.faceIndex=b),n)}closestPointToPoint(t,e={},n=0,r=1/0){let s=n*n,o=r*r,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(Vf.copy(t).clamp(c.min,c.max),Vf.distanceToSquared(t)),intersectsBounds:(c,h,d)=>d<a&&d<o,intersectsTriangle:(c,h)=>{c.closestPointToPoint(t,Vf);let d=t.distanceToSquared(Vf);return d<a&&(Ny.copy(Vf),a=d,l=h),d<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(Ny):e.point=Ny.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{Ni(0,new Float32Array(n),YP),t.union(YP)}),t}};var ed=$o(KP());var zW=.5*(Math.sqrt(3)-1),zf=(3-Math.sqrt(3))/6,GW=1/3,zs=1/6,tue=(Math.sqrt(5)-1)/4,nue=(5-Math.sqrt(5))/20,Gf=i=>Math.floor(i)|0,QP=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]),VS=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 By(i=Math.random){let t=JP(i),e=new Float64Array(t).map(r=>QP[r%12*2]),n=new Float64Array(t).map(r=>QP[r%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*zW,h=Gf(s+c),d=Gf(o+c),f=(h+d)*zf,p=h-f,m=d-f,g=s-p,y=o-m,v,x;g>y?(v=1,x=0):(v=0,x=1);let b=g-v+zf,w=y-x+zf,E=g-1+2*zf,_=y-1+2*zf,S=h&255,T=d&255,M=.5-g*g-y*y;if(M>=0){let P=S+t[T],I=e[P],L=n[P];M*=M,a=M*M*(I*g+L*y)}let C=.5-b*b-w*w;if(C>=0){let P=S+v+t[T+x],I=e[P],L=n[P];C*=C,l=C*C*(I*b+L*w)}let D=.5-E*E-_*_;if(D>=0){let P=S+1+t[T+1],I=e[P],L=n[P];D*=D,u=D*D*(I*E+L*_)}return 70*(a+l+u)}}function ZP(i=Math.random){let t=JP(i),e=new Float64Array(t).map(s=>VS[s%12*3]),n=new Float64Array(t).map(s=>VS[s%12*3+1]),r=new Float64Array(t).map(s=>VS[s%12*3+2]);return function(o,a,l){let u,c,h,d,f=(o+a+l)*GW,p=Gf(o+f),m=Gf(a+f),g=Gf(l+f),y=(p+m+g)*zs,v=p-y,x=m-y,b=g-y,w=o-v,E=a-x,_=l-b,S,T,M,C,D,P;w>=E?E>=_?(S=1,T=0,M=0,C=1,D=1,P=0):w>=_?(S=1,T=0,M=0,C=1,D=0,P=1):(S=0,T=0,M=1,C=1,D=0,P=1):E<_?(S=0,T=0,M=1,C=0,D=1,P=1):w<_?(S=0,T=1,M=0,C=0,D=1,P=1):(S=0,T=1,M=0,C=1,D=1,P=0);let I=w-S+zs,L=E-T+zs,H=_-M+zs,U=w-C+2*zs,G=E-D+2*zs,z=_-P+2*zs,V=w-1+3*zs,$=E-1+3*zs,F=_-1+3*zs,j=p&255,X=m&255,q=g&255,k=.6-w*w-E*E-_*_;if(k<0)u=0;else{let W=j+t[X+t[q]];k*=k,u=k*k*(e[W]*w+n[W]*E+r[W]*_)}let Z=.6-I*I-L*L-H*H;if(Z<0)c=0;else{let W=j+S+t[X+T+t[q+M]];Z*=Z,c=Z*Z*(e[W]*I+n[W]*L+r[W]*H)}let Q=.6-U*U-G*G-z*z;if(Q<0)h=0;else{let W=j+C+t[X+D+t[q+P]];Q*=Q,h=Q*Q*(e[W]*U+n[W]*G+r[W]*z)}let K=.6-V*V-$*$-F*F;if(K<0)d=0;else{let W=j+1+t[X+1+t[q+1]];K*=K,d=K*K*(e[W]*V+n[W]*$+r[W]*F)}return 32*(u+c+h+d)}}function JP(i){let e=new Uint8Array(512);for(let n=0;n<512/2;n++)e[n]=n;for(let n=0;n<512/2-1;n++){let r=n+~~(i()*(256-n)),s=e[n];e[n]=e[r],e[r]=s}for(let n=256;n<512;n++)e[n]=e[n-256];return e}var is=new an,Fy=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let r=0;r<t.count;r+=3){let s=1;is.a.fromBufferAttribute(t,r),is.b.fromBufferAttribute(t,r+1),is.c.fromBufferAttribute(t,r+2),s*=is.getArea(),e[r/3]=s}this.distribution=new Float32Array(t.count/3);let n=0;for(let r=0;r<e.length;r++)n+=e[r],this.distribution[r]=n;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let n=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*n);return this.sampleFace(r,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,n=0,r=e.length-1,s=-1;for(;n<=r;){let o=Math.ceil((n+r)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?r=o-1:n=o+1}return s}sampleFace(t,e,n){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),is.a.fromBufferAttribute(this.positionAttribute,t*3),is.b.fromBufferAttribute(this.positionAttribute,t*3+1),is.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(is.a,r).addScaledVector(is.b,s).addScaledVector(is.c,1-(r+s)),is.getNormal(n),this}};var e2=$o(zS()),HW=new se,jW=new se,WW=new se,uh;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(uh||(uh={}));var hh=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new se;this.copyPreviousMatrix=!0;this.hiddenMatrix=new se;this.matrixWorldRigid=new se;this.shearScale=new se;this.shearScaleInv=new se}get __isSPEObject(){return!0}isDescendantOf(n){n instanceof mt&&(n=n.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===n)return!0;r=r.parent}return!1}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);for(let r of this.children)r.updateMatrixWorld(n)}updateWorldMatrix(n,r){let s=this.parent;if(n&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(n,r=0){for(let s of this.children)uh.is(s)&&s.traverseObject(n,r+1)}traverseObject(n,r=0){if(n(this,r)!==!0)for(let o of this.children)uh.is(o)&&o.traverseObject(n,r+1)}updateMatrixWorldSVD(){let n=this.matrixWorld.elements,r=[[n[0],n[4],n[8]],[n[1],n[5],n[9]],[n[2],n[6],n[10]]],{u:s,v:o,q:a}=(0,e2.SVD)(r),l=HW.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),u=jW.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=WW.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(n,r){this.updateWorldMatrix(!0,!1);let s=new se().copy(this.matrixWorld).invert();return n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),s.multiply(n.parent.matrixWorld)),"hiddenMatrix"in n&&n.hiddenMatrix instanceof se?n.hiddenMatrix.premultiply(s):n.applyMatrix4(s),n.updateWorldMatrix(!1,!1),this.add(n),r!==void 0&&(this.children.pop(),this.children.splice(r,0,n)),this}copy(n,r=!1){return super.copy(n,r),this.hasNonUniformScale=n.hasNonUniformScale,this}onAfterRender(n,r,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var GS=class extends hh(mt){},qW=i=>i.type==="Mesh",un=class extends GS{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,n){}expand(){let e=0,n=this.object.entityChildren(e);for(;n;){let r=this.children[e];r?.object!==n&&(r&&this.remove(r),r=new un(n),this.add(r),this.children.splice(e,0,this.children.pop()),r.matrixWorldNeedsUpdate=!0,r.matrixAutoUpdate=!1,r.matrix=n.matrix,r.hiddenMatrix=n.hiddenMatrix),r.expand(),e+=1,n=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return qW(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var Hl=new A,jl=new A,dh=new se,n2=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],YW=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],XW=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],t2=(i,t,e)=>{i.updateEntityBoxSize(Hl,jl),dh.copy(t).multiply(i.matrixWorld),jl.x===0&&jl.y===0&&jl.z===0?e.push(new A(Hl.x,Hl.y,Hl.z).applyMatrix4(dh)):n2.forEach(n=>{e.push(n.clone().multiply(jl).add(Hl).applyMatrix4(dh))})},Hf=class extends Tt{constructor(){super(...arguments);this.matrix=new se;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(n=>n.clone()),this.faces=e.faces.map(n=>n.clone()),this.edges=e.edges.map(n=>n.clone()),this.centerEdges=e.centerEdges.map(n=>n.clone()),this}setFromObjectSize(e,n=!1){e.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let r=new se().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,r,n)}expandByObjectSize(e,n,r=!1){let s=[];return r===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new A);return}t2(o,n,s)}}):t2(e,n,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(dh.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(jl).multiplyScalar(.5),this.getCenter(Hl),dh.copy(this.matrix).setPosition(Hl),this.vertices=n2.map(e=>e.clone().multiply(jl).applyMatrix4(dh))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=YW.map(([e,n])=>new Xn(this.vertices[e],this.vertices[n])),this.centerEdges=this.edges.map(e=>e.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=XW.map(([e,n])=>this.vertices[e].clone().add(this.vertices[n]).multiplyScalar(.5))}};var ss={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var jS=class extends of{constructor(){super()}getPoints(t=12){let e=[],n,r=this.getCurveLengths(),o=r[r.length-1]/r.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?r[a]:r[a]-r[a-1],h=Math.ceil(t*c/o),d=u.getPoints(h);for(let f=0;f<d.length;f++){let p=d[f];n&&n.equals(p)||(e.push(p),n=p)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var WS=.001;function qS(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=WS}function HS(i,t){let e=new A(...i.position),n=new A(...i.controlNext.position),r=new A(...t.controlPrevious.position),s=new A(...t.position);return qS(e,n,s)&&qS(e,r,s)}function Uy(i){let t=i.points.map(c=>new A(...c.data.position)),e=[i.points[0]],n=new A(...e[0].data.position);for(let c=0;c<i.points.length-1;c++)qS(n,t[c],t[c+1])||(e.push(i.points[c]),n=t[c]);e.push(i.points[i.points.length-1]);let r=i.isClosed,s=e.length-(r?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let h=e[c].data,d=new A(...h.position),f=new A(...h.controlPrevious.position),p=new A(...h.controlNext.position),m={position:d,baseRoundness:h.roundness,controlPrevious:f,controlNext:p};if(h.roundness===0||!i.isClosed&&(c===0||c===o-1)){a[c]={...m,removedLength:0};continue}let g=r&&c==0?o-1:c-1,y=r&&c==o-1?0:c+1,v=e[g].data,x=e[y].data,b=new A(...v.position),w=new A(...x.position),E=b.clone().sub(d).normalize(),_=w.clone().sub(d).normalize();Object.assign(m,{prevDir:E,nextDir:_});let S=HS(v,h),T=HS(h,x);if(!S||!T)a[c]={...m,removedLength:0};else{let M=E.clone().add(_).normalize(),C=M.clone().cross(E).length()/E.dot(M);a[c]={...m,tan:C,removedLength:h.roundness/C}}}for(let c=0;c<s;c++){let h=c,d=r&&c===o-1?0:c+1,f=a[h],p=a[d];if(f.removedLength!==0||p.removedLength!==0){let m=f.position.distanceTo(p.position);f.removedLength=Math.min(f.removedLength,m/2),p.removedLength=Math.min(p.removedLength,m/2)}}let l=[];for(let c=0;c<s;c++){let h=c,d=r&&c===o-1?0:c+1,f=a[h],p=a[d],m=null;if(!HS(e[h].data,e[d].data))f.position.distanceTo(p.position)>WS&&(m=new wl(f.position,f.controlNext,p.controlPrevious,p.position));else{let g=f.position.clone(),y=p.position.clone();(f.removedLength!==0||p.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),p.prevDir&&y.add(p.prevDir.clone().setLength(p.removedLength))),g.distanceTo(y)>WS&&(m=new wl(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*c+1]=m}for(let c=0;c<o;c++){let h=a[c];if(h.removedLength===0){l[2*c]=null;continue}let d=h.position,f=h.prevDir.clone().multiplyScalar(h.removedLength).add(d),p=h.nextDir.clone().multiplyScalar(h.removedLength).add(d),m=h.tan*h.removedLength,g=h.prevDir.clone().add(h.nextDir).normalize(),y=f.clone().lerp(p,.5),v=f.distanceTo(p)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(y),b=g.clone().multiplyScalar(-m).add(x),w=d.distanceTo(b)/d.distanceTo(y),E=h.prevDir.clone().multiplyScalar(w*d.distanceTo(f)).add(d),_=E.clone().lerp(b,2),S=f.clone().lerp(E,4/3),T=p.clone().lerp(_,4/3);l[2*c]=new wl(f,S,T,p)}let u=new jS;return l.forEach(c=>{c&&u.add(c)}),u}var at;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(at||(at={}));var Gs=i=>at.is(i),KW={type:"completeState",isfromEntity:!0},QW=["x","y","z"],YS=new A,ZW=new A().set(0,1,0),fh=i=>class extends hh(i){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Hf;this._recursiveBBox=new Hf;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(n){let r=this.children[n];if(at.is(r))return r}entityChildrenCount(){let n=this.children.length;for(;n--;)if(at.is(this.children[n]))return n+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let n=this;for(;n.data.type!=="Instance";){let r=n.parent;if(at.is(r))n=r;else return}return n}forInstancesRec(n){this.instances.forEach(r=>{r.disposed||n(r),r.forInstancesRec(n)})}super_Entity(n,r){typeof n=="string"&&(this.uuid=n),this.identity=n,this.data=r,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(n,r,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)No.toOps(this.data,o.data).forEach(l=>{let u=Hg.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,r)});if(n!==null){let o=this.data.states.data(n);o&&(this.dataPatched=No.patch(this.data,o),No.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,r)}))}s&&this.updateTransformState(this.dataPatched,r),this.stateSelection=n,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(n,r){n.setScalar(0),r.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(n=>{Gs(n)&&n.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(n=>{n.resetBBoxNeedsUpdateSelf()})}find(n){let r;return this.traverseEntity(s=>{s.uuid===n&&(r=s)}),r}traverseSortNextHelper(){let n=this.parent;if(n){let r=n.children,s=r.indexOf(this)+1;if(at.is(r[s]))return r[s];if(at.is(n))return n.traverseSortNextHelper()}}sortNext(){let n=this.children;return this.children.length>0&&at.is(this.children[0])?n[0]:this.traverseSortNextHelper()}goUp(n){let r=this;for(;n>0&&r!==null;)r=r.parent,n-=1;return r}hasAnccestorOrSelf(n){return this===n||this.hasAnccestor(n)}hasAnccestor(n){let r=this.parent;for(;r;){if(n===r)return!0;r=r.parent}return!1}countToAccestor(n){let r=0,s=this;for(;s!==n;){if(s===null)return-1;s=s.parent,r+=1}return r}forEachEntity(n){for(let r of this.children)Gs(r)&&n(r)}traverseEntityAncestors(n){this.traverseAncestors(r=>{at.is(r)&&n(r)})}traverseConcreteEntity(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Gs(o)&&o.isConcreteEntity&&o.traverseEntity(n,r+1)}traverseEntity(n,r=0){if(n(this,r)!==!0)for(let o of this.children)Gs(o)&&o.traverseEntity(n,r+1)}traverseVisibleEntity(n){n(this);for(let r of this.children)Gs(r)&&r.visible&&r.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(n){super.updateMatrixWorld(n),this.dispatchEvent({type:"updateMatrixWorld"})}copy(n,r=!1){return super.copy(n,r),this.dataPatched=n.dataPatched,this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),this}hasEntityChild(){return this.children.some(n=>Gs(n))}isAncestorOf(n){if(this.uuid===n)return!1;let r=!1;return this.traverseEntity(s=>{s.uuid===n&&(r=!0)}),r}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x*Te.RAD2DEG,this.rotation.y*Te.RAD2DEG,this.rotation.z*Te.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return omit(r,n)}getTransformValues(n,r,s){return r[n].map((o,a)=>s?.shared.getVariable(o,[this.uuid,n,QW[a]])??o)}updateTransformState(n,r){let s=!1;return n.position&&(this.position.fromArray(this.getTransformValues("position",n,r)),s=!0),n.rotation&&(YS.fromArray(this.getTransformValues("rotation",n,r)).multiplyScalar(Te.DEG2RAD),this.rotation.setFromVector3(YS),s=!0),n.scale&&(this.scale.fromArray(this.getTransformValues("scale",n,r)),s=!0),n.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(n.hiddenMatrix??Ma.identity)),s&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})),n.position&&n.rotation&&n.scale&&n.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),s}onVariableUpdate(n=!1){if(n){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(r=>{r.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let n of this.children)at.is(n)&&n.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(n=>{at.is(n)&&n.disposeRecursively()})}toState(n=[]){let r={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return omit(r,n)}updateByObjUpdateOp(n,r){n!==void 0&&this.updateByOp({type:0,props:n,path:[]},{...this.data,...n},r,!1)}updateByOp(n,r,s,o){let a=this.data;this.data=r;let l=n,u=Or(n.path,["states","*"]);if(u!==null){if(n.type===0){let[c]=u;if(this?.stateSelection===c){let h={...n.props};if(delete h.name,Object.values(n.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let f=Vn.zoom(d,n.path.slice(2));if(f)for(let p in n.props)n.props[p]===void 0&&p in f&&(h[p]=f[p])}}l={...n,props:h,path:n.path.slice(2)}}}}else if(n.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(n.props.name!==void 0&&c.name){let{name:d,...f}=c;c=f}if(n.props.material!==void 0&&"material"in c){let{material:d,...f}=c;c=f}let h=Vn.removeOverridden(n.path,n.props,c);l={...n,props:h}}}if(this.updateByPatchedOpBase(l,No.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Or(n.path,["overrides"])){let c=[],h=[...n.path];for(c.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)c.push(h[1]),h.splice(0,2);if(c[c.length-1]===void 0){if(n.type===0)for(let d of Object.keys(n.props)){c[c.length-1]=d;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=n.props[d],f.updateState(Ds.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...c]);if(d){let f=Vn.zoom(d.component.data,h);if(n={...n,path:h},n.type===0){let p=n.props;if(f)for(let[m,g]of Object.entries(n.props))g===void 0&&(p===n.props&&(p={...n.props}),p[m]=f[m]);n={...n,props:p}}d.overrideData=Gu.resolve(r.overrides,c),d.updateByOp(n,zn.applySimple(d.data,n),s,!1)}}}else if(this.instances.length>0){let c;if(n.path.length===0&&n.type===0){let h;for(let d of Fs.rootOverrideProps)d in n.props&&(h===void 0&&(h={}),h[d]=n.props[d]);h&&(c={...n,props:h})}else for(let h of Fs.rootOverrideProps)if(Or(n.path,[h])){c=n;break}c!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=Ds.filterOp(h.overrideData,c);d&&h.updateByOp(d,zn.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=Ds.filterOp(h.overrideData,n);if(d){let f;a===h.data&&n===d?f=r:f=zn.applySimple(h.data,d),h.updateByOp(d,f,s,!0)}}})}}updateByPatchedOpBase(n,r,s){if(this.dataPatched=r,n.path.length===0&&n.type===0)n.props.type!==void 0&&!ns.is(n.props.type)&&ss.changeEntityProptotype(this,r,s);else if(n.path.length===1&&n.path[0]==="geometry"&&n.type===0&&"type"in n.props){ss.changeEntityProptotype(this,r,s);for(let o of this.children)at.is(o)&&o.updateVisible()}this.updateByPatchedOp(n,r,s)}updateByPatchedOp(n,r,s){if(n.path.length===0&&n.type===0&&this.updateState(n.props,s),Or(n.path,["pathSnapping"])!==null&&this.updatePathSnapping(r.pathSnapping),Or(n.path,["cloner"])!==null){let o=zn.drop(n,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(r.cloner,s.scene):(this.setFromClonerState(r.cloner,s),this.expandCloner(s.scene)),this.updateVisible()}}updatePathSnapping(n){this._updatedPathSnapping=n,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(n){let r=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(r===null)return;let l=n.find(r);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=Uy(u.geometry.path),h=(s+o)%1;s+o===1&&h===0&&(h=1);let d=c.getPointAt(h),f=this.parent?this.parent?.matrixWorld:new se;l.updateMatrixWorld();let p=new se().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(p);let m={position:d.toArray(),rotation:u.rotation};if(a==="tangential"){let g=new se().extractRotation(l.matrixWorld),y=c.getTangentAt(h).applyMatrix4(g).add(d),v=new se().lookAt(d,y,ZW),x=YS.setFromEuler(new qt().setFromRotationMatrix(v)).multiplyScalar(Te.RAD2DEG);m={...m,rotation:x.toArray()}}this.updateTransformState(m),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(KW)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(n,r){n.name!==void 0&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),r&&"cloner"in n&&n.cloner!==void 0&&(this.setFromClonerState(n.cloner,r),this.updateVisible()),this.updateTransformState(n,r)}get attachedSurfaceCloners(){return this.children.filter(n=>n instanceof ss.Cloner&&n.parameters.type==="toObject")}setFromClonerState(n,r){this.disposed||(n===null||n.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new ss.Cloner(this,n),r.scene.addPendingExpandCloner(this)):this.cloner.updateState(n,r.scene))}expandCloner(n){!this.disposed&&this.cloner&&this.cloner.expandClones(n)}invalidateClonerTransform(n){this.cloner&&this.cloner.invalidateTransform(n)}};var Vy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);e.thetaLength=Te.clamp(e.thetaLength,0,360);let n=e.width/2,r=e.radiusTop??n,s=e.radiusBottom??n;return r===s?(r=n,s=n):r>s?(r=n,s=s*n/r):(r=r*n/s,s=n),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:r,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:h,cornerSegments:d,hollow:f}=i.parameters,p;return l===0?(p=new Ae,p.setAttribute("position",new be([],3))):h||f?p=new jf(u,c,n,r,s,o,a,l*Math.PI/180,h,h,d,f):p=new El(u,c,n,r,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"CylinderGeometry"}})}};function Va(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function r2(i){return new B(i.y,-i.x)}var jf=class extends Ae{constructor(t,e,n,r,s,o,a,l,u,c,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,n=n||1,r=Math.floor(r)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let p=[],m=[],g=[],y=[],v=0,x=n/2,b=new A,w=new A;f&&t==0&&(t=u),f&&e==0&&(e=c);let E=new B(t,x),_=new B(e,-x),S=null,T=null,M=null,C=null,D=E.clone().sub(_),P=0,I=0,L=0;d>0&&(P=Math.min(t,e)*(1-d),I=t-P,L=e-P);let H=E.clone();H.x-=P;let U=Math.PI-D.angle(),G=D.angle(),z=Math.tan(G/2),V=Math.tan(U/2),$=z+V,F=d?$:V,j=d?$:z;if(u=Math.min(u,(t-I)/F,D.length()/$),c=Math.min(c,(e-L)/j,D.length()/$),u>0){let K=u/z;S=E.clone().sub(new B(K,u)),d&&(M=S.clone(),M.x-=P-$*u),E.sub(D.clone().setLength(K))}if(c>0){let K=c/V;T=_.clone().sub(new B(K,-c)),_.add(D.clone().setLength(K)),d&&(C=T.clone(),C.x-=P-$*c,H.sub(D.clone().setLength(K)))}D=E.clone().sub(_);let X=D.length()<.5,q=[];for(let K=0;K<=r;K++){let W=[],ye=K/r,fe=ye*l+a,ie=new B(Math.sin(fe),Math.cos(fe));C&&T?(k(W,ye,ie,U,c,C,-1,!0),k(W,ye,ie,G,c,T,-1,!1)):T?(Z(W,ie,T.x,0,-1),k(W,ye,ie,G,c,T,-1,!1)):o||Z(W,ie,e,L,-1);let we=r2(D).normalize();if(Va(we,ie,b),!X)for(let xe=0;xe<=s;xe++){let Oe=xe/s,Ie=D.clone().multiplyScalar(Oe).add(_);Va(Ie,ie,w),m.push(w.x,w.y,w.z),g.push(b.x,b.y,b.z),y.push(ye,.5+w.y/n),W.push(v++)}if(M&&S?(k(W,ye,ie,U,u,S,1,!1),k(W,ye,ie,G,u,M,1,!0)):S?(k(W,ye,ie,U,u,S,1,!1),Z(W,ie,S.x,0,1)):o||Z(W,ie,t,I,1),d&&!X){let xe=r2(D).multiplyScalar(-1).normalize();Va(xe,ie,b);for(let Oe=0;Oe<=s;Oe++){let Ie=Oe/s,Pe=D.clone().multiplyScalar(-Ie).add(H);Va(Pe,ie,w),m.push(w.x,w.y,w.z),g.push(b.x,b.y,b.z),y.push(ye,.5+w.y/n),W.push(v++)}}d&&!o&&W.push(W[0]),q.push(W)}for(let K=0;K<q.length-1;K++)for(let W=0;W<q[0].length-1;W++){if(o&&d&&W==s)continue;let ye=q[K][W],fe=q[K+1][W],ie=q[K+1][W+1],we=q[K][W+1],xe=m[ie*3+0],Oe=m[ie*3+2];p.push(ye,fe,we),(xe!=0||Oe!=0)&&p.push(fe,ie,we)}l<Math.PI*2&&(Q(-1,q[0],a),Q(1,q[q.length-1],a+l)),this.setIndex(p),this.setAttribute("position",new be(m,3)),this.setAttribute("normal",new be(g,3)),this.setAttribute("uv",new be(y,2));function k(K,W,ye,fe,ie,we,xe,Oe){for(let Ie=0;Ie<h+1;Ie++){let Pe=Ie/h,_e=xe<0?Pe:1-Pe;Oe&&(_e-=1),_e*=fe;let Ve=new B(Math.sin(_e),Math.cos(_e)*xe),ze=Ve.clone().multiplyScalar(ie).add(we);Va(ze,ye,w),m.push(w.x,w.y,w.z),Va(Ve,ye,b),g.push(b.x,b.y,b.z),y.push(W,.5+w.y/n),K.push(v++)}}function Z(K,W,ye,fe,ie){let we=new A,xe=new B,Oe=[ye,fe];ie<0&&Oe.reverse();for(let Ie of Oe)xe.set(Ie,x*ie),Va(xe,W,we),m.push(we.x,we.y,we.z),g.push(0,ie,0),y.push(.5,.5),K.push(v++)}function Q(K,W,ye){let fe=new B(Math.sin(ye),Math.cos(ye)),ie=new B(-Math.cos(ye),Math.sin(ye)),we=new A,xe=K<0?(Pe,_e,Ve)=>p.push(Pe,_e,Ve):(Pe,_e,Ve)=>p.push(Pe,Ve,_e),Oe=new B((t+e+I+L)/4,0);Va(Oe,fe,we),m.push(we.x,we.y,we.z),g.push(ie.x,0,ie.y),y.push(.5,.5);let Ie=v++;for(let Pe of W){let _e=m.slice(Pe*3,Pe*3+3);m.push(..._e),g.push(ie.x,0,ie.y);let Ve=y.slice(Pe*2,Pe*2+2);y.push(...Ve),v++}for(let Pe=Ie+1;Pe<v-1;Pe++)xe(Ie,Pe,Pe+1);xe(Ie,v-1,Ie+1)}}};var i2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return e.thetaLength=Te.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:h}=i.parameters,d;return l===0?(d=new Ae,d.setAttribute("position",new be([],3))):u>0||c>0||l<360?d=new jf(0,t/2,n,r,s,o,a,l*Math.PI/180,u,c,h,0,!0):d=new Uc(t/2,n,r,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...i,type:"ConeGeometry"}})}};var s2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,widthSegments:r,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=i.parameters,u;return a==0?u=new sr(t,e,n,r,s,o):u=new KS(t,e,n,r,s,o,a,l),Object.assign(u,{userData:{...i,type:"CubeGeometry"}})}},XS=Math.PI/2,KS=class extends Ae{constructor(t=1,e=1,n=1,r=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,n/2);let c=[],h=[],d=[],f=[],p=0,m=0;g("z","y","x",-1,-1,n,e,t,o,s,0),g("z","y","x",1,-1,n,e,-t,o,s,1),g("x","z","y",1,1,t,n,e,r,o,2),g("x","z","y",1,-1,t,n,-e,r,o,3),g("x","y","z",1,-1,t,e,n,r,s,4),g("x","y","z",-1,-1,t,e,-n,r,s,5),a>0&&(y("z","y","x",-1,-1,1,n,e,t,o,0),y("z","y","x",1,-1,-1,n,e,t,o,1),y("z","y","x",-1,1,-1,n,e,t,o,1),y("z","y","x",1,1,1,n,e,t,o,0),y("x","y","z",-1,-1,-1,t,e,n,r,0),y("x","y","z",1,-1,1,t,e,n,r,1),y("x","y","z",-1,1,1,t,e,n,r,0),y("x","y","z",1,1,-1,t,e,n,r,1),y("y","x","z",-1,-1,1,e,t,n,s,0),y("y","x","z",1,-1,-1,e,t,n,s,1),y("y","x","z",1,1,1,e,t,n,s,1),y("y","x","z",-1,1,-1,e,t,n,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new be(h,3)),this.setAttribute("normal",new be(d,3)),this.setAttribute("uv",new be(f,2));function g(x,b,w,E,_,S,T,M,C,D,P){let I=(S-2*a)/C,L=(T-2*a)/D,H=S/2-a,U=T/2-a,G=M/2,z=C+1,V=D+1,$=0,F=0,j=new A;for(let X=0;X<V;X++){let q=X*L-U;for(let k=0;k<z;k++){let Z=k*I-H;j[x]=Z*E,j[b]=q*_,j[w]=G,h.push(j.x,j.y,j.z),j[x]=0,j[b]=0,j[w]=M>0?1:-1,d.push(j.x,j.y,j.z),f.push(k/C),f.push(1-X/D),$+=1}}for(let X=0;X<D;X++)for(let q=0;q<C;q++){let k=p+q+z*X,Z=p+q+z*(X+1),Q=p+(q+1)+z*(X+1),K=p+(q+1)+z*X;c.push(k,Z,K),c.push(Z,Q,K),F+=6}u.addGroup(m,F,P),m+=F,p+=$}function y(x,b,w,E,_,S,T,M,C,D,P){let I=(T-2*a)/D,L=T/2-a,H=M/2-a,U=C/2,G=D+1,z=0,V=0,$=new A,F=new A;for(let j=0;j<l+1;j++){let X=j/l*XS,q=Math.sin(X)*a,k=(1-Math.cos(X))*a,Z=Math.sin(X),Q=Math.cos(X);$[b]=(H+q)*_,$[w]=(U-k)*S,F[x]=0,F[b]=Z*Math.sign($[b]),F[w]=Q*Math.sign($[w]);for(let K=0;K<G;K++){let W=K*I-L;$[x]=W*E,h.push($.x,$.y,$.z),d.push(F.x,F.y,F.z),f.push(K/D),f.push(0),z+=1}}for(let j=0;j<l;j++)for(let X=0;X<D;X++){let q=p+X+G*j,k=p+X+G*(j+1),Z=p+(X+1)+G*(j+1),Q=p+(X+1)+G*j;c.push(q,k,Q),c.push(k,Z,Q),V+=6}u.addGroup(m,V,P),m+=V,p+=z}function v(x,b,w){let E=new A,_=new A(t/2,e/2,n/2);_.subScalar(a);let S=[],T=x*b*w>0?(C,D,P)=>c.push(C,D,P):(C,D,P)=>c.push(C,P,D);for(let C=0;C<=l;C++){let D=[],P=XS*(1-C/l),I=Math.cos(P),L=Math.sin(P),H=0;for(let U=0;U<=C;U++){let G=Math.cos(H),z=Math.sin(H);E.x=I*G,E.y=L,E.z=I*z;let V=_.clone().addScaledVector(E,a);h.push(x*V.x,b*V.y,w*V.z),d.push(x*E.x,b*E.y,w*E.z),f.push(0,0),D.push(p++),H+=XS/C}S.push(D)}let M=S.length-1;for(let C=0;C<M;C++){let D=S[C],P=S[C+1],I=D.length-1;T(D[0],P[1],P[0]);for(let L=1;L<=I;L++)T(D[L-1],D[L],P[L]),T(D[L],P[L+1],P[L])}}}};var za=class extends Ae{constructor(t=[],e=[],n="",r=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),h(),this.setAttribute("position",new be(a,3)),this.setAttribute("normal",new be(u,3)),this.setAttribute("uv",new be(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],p=new A,m=p.clone(),g=new an,y=s*r,v=r-y,x=o+1,b=new A,w=(z,V)=>b.subVectors(z,V).normalize(),E=(z,V)=>Array(z).fill(void 0).map(V),_=E(t.length/3,(z,V)=>new A().fromArray(t,V*3).setLength(r)),S=[],T=1e6;for(let z=0;z<_.length;z++){let V=_[z],$=[],F,j,X,q=1e10,k=-1;for(;(k=e.indexOf(z,k+1))!=-1;){let W=k-k%3;F=e[W+(k+1)%3],j=e[W+(k+2)%3],X=V.distanceToSquared(_[F]),q=Math.min(q,X),$.push([F,j,X])}q+=1e-6;let Z=[],Q=0,K=$.length;for(let W=0;W<K;W++){[F,j,X]=$[Q];let ye=S[F]?.includes(z)==!0;X<=q&&Z.push(F+ +ye*T),Q=$.findIndex(fe=>fe[0]==j)}S.push(Z)}let M=[];{let z=0,V=0,$,F,j=f==3;for(let X=0;X<=o;X++){$=X*(X+1)/2,F=(X+1)*(X+2)/2;for(let q=0;q<o-X;q++)[z,V]=[$+q+X+2,F+q+X+3],M.push($,F,...j?[V,$]:[z,F],V,z),[$,F]=[z,V];M.push($,F,$+o+2)}}let C=p.clone(),D=p.clone(),P=p.clone(),I=p.clone(),L=p.clone(),H=[],U=E(_.length,()=>E(f,()=>p.clone()));for(let z=0;z<_.length;z++){p.copy(_[z]).normalize(),C.copy(p).multiplyScalar(v);let V=S[z];for(let Z=0;Z<V.length;Z++){let Q=V[Z],K=V[(Z+1)%f];g.setFromPointsAndIndices(_,z,Q%T,K%T),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,U[z][Z])}let $=[],F=[],j=[],X=new A;o==0&&[...U[z]].reduce((Z,Q)=>Z.add(Q),X).multiplyScalar(1/f);for(let Z=0;Z<f;Z++){let Q=[],K=(Z-1+f)%f,W=U[z][K],ye=U[z][Z];p.copy(W).sub(C),m.copy(ye).sub(C);let fe=C.angleTo(p),ie=p.angleTo(m),we=Math.cos(fe)*y;o==0?D.copy(X):D.copy(C).setLength(v+we),F.push(we);let xe=[D,W,ye];for(let Oe=0;Oe<2;Oe++){let Ie=xe[Oe],Pe=xe[Oe+1];I.subVectors(Ie,C),L.subVectors(Pe,C),P.crossVectors(I,L).normalize();for(let _e=0;_e<x;_e++){let Ve=[fe,ie][Oe]*_e/x;p.copy(I).applyAxisAngle(P,Ve).add(C),$.push(p.clone()),Oe&&(w(p,C),Q.push([_e==0?Ie:p.clone(),b.clone()]))}Oe&&(w(Pe,C),Q.push([Pe,b.clone()]))}j.push(Q)}H.push(j);let q=2*x,k=2;for(let Z=0;Z<f;Z++){let Q=q*Z,K=q*((Z+1)%f),W=[$[Q]];for(let fe=1;fe<x;fe++){I=$[Q+fe],L=$[K+fe],W.push(I);for(let ie=1,we=fe-k+1;ie<=we;ie++)p.lerpVectors(I,L,ie/(we+1)),p.sub(C).setLength(F[Z]).add(C),W.push(p.clone());W.push(L)}for(let fe=0;fe<x;fe++)W.push($[fe+x+Q]);W.push($[K+x]);let ye=M.map(fe=>W[fe]);a.push(...ye.map(fe=>[fe.x,fe.y,fe.z]).flat()),u.push(...ye.map(fe=>(w(fe,C),[b.x,b.y,b.z])).flat())}}let G=[];for(let z=0;z<S.length;z++)for(let V=0;V<f;V++){let $=S[z][V];if($<T){let F=S[$].findIndex(q=>q%T==z),j=H[z][V],X=H[$][F];for(let q=0;q<x;q++){let k=j[q],Z=X[x-q],Q=j[q+1],K=X[x-(q+1)];[k,Z,Q,Q,Z,K].forEach(W=>{a.push(W[0].x,W[0].y,W[0].z),u.push(W[1].x,W[1].y,W[1].z)})}G.push(j[0][0],X[x][0],j[x][0],X[0][0])}}for(;G.length;){let z,V,$,F;[z,V]=G.splice(0,2);let j=[z];for(;z!=V;)j.push(V),$=G.indexOf(V),F=$%2,V=G.splice($-F,2)[1-F];b.subVectors(j[0],j[1]).cross(p.subVectors(j[0],j[2])).normalize();let X=b.dot(j[0])<0;X&&b.negate();for(let q=1;q<=j.length-2;q++)[j[q+ +X],j[q+1-+X],j[0]].forEach(k=>{a.push(k.x,k.y,k.z),u.push(b.x,b.y,b.z)})}}function h(){let d=new A;for(let _=0;_<a.length;_+=3){d.x=a[_+0],d.y=a[_+1],d.z=a[_+2];let S=w(d)/2/Math.PI+.5,T=E(d)/Math.PI+.5;l.push(S,1-T)}let f=new A,p=new A,m=new A,g=new A,y=new B,v=new B,x=new B,b=(_,S,T,M)=>{M<0&&_.x===1&&(l[S]=_.x-1),T.x===0&&T.z===0&&(l[S]=M/2/Math.PI+.5)};for(let _=0,S=0;_<a.length;_+=9,S+=6){f.set(a[_+0],a[_+1],a[_+2]),p.set(a[_+3],a[_+4],a[_+5]),m.set(a[_+6],a[_+7],a[_+8]),y.set(l[S+0],l[S+1]),v.set(l[S+2],l[S+3]),x.set(l[S+4],l[S+5]),g.copy(f).add(p).add(m).divideScalar(3);let T=w(g);b(y,S+0,f,T),b(v,S+2,p,T),b(x,S+4,m,T)}for(let _=0;_<l.length;_+=6){let S=l[_+0],T=l[_+2],M=l[_+4],C=Math.max(S,T,M),D=Math.min(S,T,M);C>.9&&D<.1&&(S<.2&&(l[_+0]+=1),T<.2&&(l[_+2]+=1),M<.2&&(l[_+4]+=1))}function w(_){return Math.atan2(_.z,-_.x)}function E(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(t){return new za(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var o2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,detail:r,corner:s,cornerSides:o}=i.parameters,a=r===0&&s!==0?new Wf(t*.5,s,o):new zc(t*.5,r);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},Wf=class extends za{constructor(t=1,e=.2,n=4){let r=(1+Math.sqrt(5))/2,s=1/r,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,n),this.type=l}static fromJSON(t){return new Wf(t.radius,t.corner,t.cornerSides)}};var qf=1e-12,ph=class{constructor(t){this.position=new B;this.startPosition=new B;this.uuid=Te.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new ph(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},mh=class extends ph{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new mh(this.parent).copy(this)}},os=class extends ph{constructor(e,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new mh(this),new mh(this))}static create(e,n){let r=new os(e,new B(...n.position));return r.controls[0].position.set(...n.controlPrevious.position),r.controls[1].position.set(...n.controlNext.position),r.roundness=n.roundness,r.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,r}getOppositeControl(e){let n=this.controls.indexOf(e);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(e,n=1){for(let r=0,s=this.controls.length;r<s;r++){let o=this.controls[r];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new os(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),n=this.curveAfter?.getTangentAt(0);return[e,n]}computeNormals(e=new B,n=new B){let[r,s]=this.computeTangents();return r&&s&&(a2(r,e),a2(s,n)),[e,n]}computeTangent(e=new B){let[n,r]=this.computeTangents();return n&&r&&e.copy(n).add(r).normalize(),e}computeNormal(e=new B){let[n,r]=this.computeNormals();return e.copy(n).add(r).normalize(),e}};function a2(i,t=new B){let e=i.length();return t.set(-i.y/e,i.x/e)}var ZS=i=>i,gh=new B,zy=new B,JW=new B,$W=new B,e6=new B,t6=new B,c2=new A,u2=new A;function h2(i){let t=new B;t.addVectors(i.v0,gh.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new B;return e.addVectors(i.v2,zy.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Dr(i.v0,t,e,i.v2)}function Yf(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function n6(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function r6(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function JS(i,t,e){let n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((r*r+n*n-s*s)/(2*r*n))}function d2(i,t,e){return l2(i,t)&&l2(t,e)&&QS(i.position,t.position,e.position)}function QS(i,t,e){return gh.copy(t).sub(i).cross(zy.copy(e).sub(i))===0}function f2(i,t,e,n,r){let s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=(i.y+t.y)/2,a=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(i.y-t.y)/s,u=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-i.x)/s;return n.set(a+l,o+u),r.set(a-l,o-u),[n,r]}function p2(i,t,e){let n=i.distanceTo(e),r=t.distanceTo(e);return n<r?t:i}function m2(i,t,e,n,r,s){let o=t.x-i.x,a=t.y-i.y,l=e.x-i.x,u=e.y-i.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),h;return JS(t,i,e)>Math.PI&&(c*=-1),Yf(u,a)?h=(a+u)*(n/c-.5)*8/3/(o-l):h=(o+l)*(n/c-.5)*8/3/(u-a),r.set(t.x-h*a,t.y+h*o),s.set(e.x+h*u,e.y-h*l),[r,s]}function $S(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function l2(i,t){return QS(i.position,i.controls[1].position,t.position)&&QS(i.position,t.controls[0].position,t.position)}function g2(i,t,e,n,r=.5){let s=gh.subVectors(t,i).multiplyScalar(r).add(i),o=zy.subVectors(e,t).multiplyScalar(r).add(t),a=JW.subVectors(n,e).multiplyScalar(r).add(e),l=s,u=$W.subVectors(o,s).multiplyScalar(r).add(s),c=e6.subVectors(a,o).multiplyScalar(r).add(o),h=a,d=t6.subVectors(c,u).multiplyScalar(r).add(u);return[i.x,i.y,l.x,l.y,u.x,u.y,d.x,d.y,c.x,c.y,h.x,h.y,n.x,n.y]}function y2(i,t,e=12,n=!0){let r=u2.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=ZS(t[l]),c=gh,h=Ga(u,e);a.push(h);for(let d=0;d<=h;d++)if(u instanceof Dr||u instanceof mi||u instanceof Ir){if(u.getPoint(d/h,c),r.set(c.x,c.y,0),s!==void 0&&r6(s,r))continue;s===void 0&&(s=c2),s.copy(r),i.setXYZ(o,r.x,r.y,r.z),o++}}return n&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),i}function v2(i,t,e,n=12,r=!0){let s=u2.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=ZS(t[l]),h=gh,d=Ga(c,n);a.push(d);for(let f=0;f<=d;f++)if(c instanceof Dr||c instanceof mi||c instanceof Ir){if(c.getPoint(f/d,h),s.set(h.x,h.y,0),u?.equals(s))continue;u===void 0?u=c2:(i.setXYZ(o,u.x,u.y,u.z),o++,i.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return r&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),a}function ew(i,t=12,e=!1){let n=[];for(let r=0,s=i.length;r<s;r++){let o=i[r],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=Ga(o.roundedCurveCorner,t)*.5;r>0&&(n[r-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Ga(o.curveAfter,t)),n.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(n[i.length-1]+=Ga(i[0].roundedCurveCorner,t)*.5),n}function Ga(i,t=12){return i&&i instanceof Sl?t*2:i&&(i instanceof Ir||i instanceof sf)?1:i&&i instanceof Fc?t*i.points.length:t}function x2(i,t,e=12,n=!0){let r,s=0;for(let o=0;o<t.length;o++){let a=ZS(t[o]),l=Ga(a,e),u=gh;for(let c=0;c<=l;c++)if(a instanceof Dr||a instanceof mi||a instanceof Ir){if(a.getPoint(c/l,u),r!==void 0&&n6(r,u,qf))continue;r===void 0&&(r=zy),r.copy(u),i.push(u.x,u.y),s++}}return Yf(i[0],i[i.length-2],qf)&&Yf(i[1],i[i.length-1],qf)&&(i.pop(),i.pop()),n&&s>1&&!(Yf(i[s-1],i[1],qf)&&Yf(i[s-2],i[0],qf))&&(i.push(i[0],i[1]),s++),i}var tw=new B,i6=new B,s6=new B,o6=new B,a6=new B,l6=new B,Pt=class extends _o{constructor(e=100,n=100){super();this.points=[];this.shapeHoles=[];this.plane=new En(new A(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Te.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=n}static createFromState(e,n,r){let s=new Pt;return s.isClosed=e.isClosed,s.points=e.points.map(o=>os.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Pt.createFromState(o)),n!==void 0&&r!==void 0&&s.applySize(n,r),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let n=0,r=this.points.length;n<r;n++)this.points[n].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(e){let n=this.points.length,r=this.points.findIndex(s=>s.uuid===e);if(r<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(e);if(c<0)s+=u;else return c+s}}return r}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let n=this.points.length;for(let r=0,s=this.shapeHoles.length;r<s;r++){let o=this.shapeHoles[r],a=e-n;if(a<=o.points.length-1)return o.points[a];n+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let n=this.points.indexOf(e);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let r=0,s=this.shapeHoles.length;r<s;r++){let o=this.shapeHoles[r],a=o.points.indexOf(e);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...e]}applySize(e,n){e===0&&(e=.001),n===0&&(n=.001),this._width=e,this._height=n}applyScale(e,n){let r=tw.set(e,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(r),a.controls[0].position.multiply(r),a.controls[1].position.multiply(r)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,n);this._update()}createPoint(e,n=0,r=Te.generateUUID()){let s;e instanceof B?s=e:s=new B(e,n);let o=new os(r,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,n){this.points.splice(n,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let n=0,r=this.points.length;n<r;n++){let s=this.points[n];if(s.uuid===e)return s}for(let n=0,r=this.shapeHoles.length;n<r;n++){let o=this.shapeHoles[n].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let n=this.points.indexOf(e);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(e){let n=this.points.find(r=>r.uuid===e);n&&this.removePoint(n)}update(){for(let e=0,n=this.shapeHoles.length;e<n;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,n=12,r=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=r?this.roundedCurveDivisions:this.curveDivisions;return y2(e,r?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=ew(this.points,e,!1),this.roundedCurveDivisions=ew(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,n,r=12){return v2(e,this.curves,n,r,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),x2(e,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(e,n=!1){let r=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=Ga(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l<u;l++){let c=s[l];if(a<r+c)return[l,(a-r+1)/c];r+=c}return[0,1]}getCurveT(e,n,r){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if($S(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(tw.set(r.x,r.y))/h}let u=0;for(let h=0;h<e;h++)u+=a[h];return(n-u)/l}dispose(){}_applyCurveForPoint(e,n){$S(n,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let r=this.curves[this.curves.length-1];e.curveBefore=r,n.curveAfter=r;let s=r.clone();e.roundedCurveBefore=s,n.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let n=0,r=this.points.length;n<r;n++){let s=this.points[n];if(n===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[n-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let n=this.points[0],r=this.points[this.points.length-1];this._applyCurveForPoint(n,r)}if(this.points.length>2){let n=0;for(let r=0,s=this.points.length;r<s;r++){let o=this.points[r],a=this.points[r-1]??this.points[this.points.length-1],l=this.points[r+1]??this.points[0],u=o.roundness,c=a&&l&&d2(a,o,l);if(!o.controlsMoved()&&u>0&&!c){let h=o.curveBefore,d=o.curveAfter;if(h===void 0||d===void 0)continue;let f=o.roundedCurveBefore,p=o.roundedCurveAfter,m=h.getLength(),g=d.getLength(),y=Math.min(u,m*.499),v=Math.min(u,g*.499),x=Math.min(y,v),b=1-x/m,w=x/g,E=h.getPointAt(b,tw),_=d.getPointAt(w,i6);this._subSplitCurve(h,f,b,E,void 0),this._subSplitCurve(d,p,w,void 0,_);let S;if(this.useCubicForRoundedCorners){let T=JS(E,o.position,_)/2,M=Math.tan(T)*E.distanceTo(o.position),[C,D]=f2(E,_,M,s6,o6),P=p2(C,D,o.position),[I,L]=m2(P,E,_,M,a6,l6);S=new Dr(E.clone(),I.clone(),L.clone(),_.clone())}else S=new mi(E.clone(),o.position.clone(),_.clone());o.roundedCurveCorner=S,this.roundedCurves.splice(r+n,0,S),n++}}}}_subSplitCurve(e,n,r,s,o){if(e instanceof Ir)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=e,l=n,u=a.getUtoTmapping(r,0),c=g2(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return n}clone(){let e=new Pt(this._width,this._height);return e.points=this.points.map(n=>n.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(n=>n.clone()),e}toJSON(){return{points:this.points.reduce((e,n)=>e.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let n=e.points.length/7;for(let r=0;r<n;r++){let s=r*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],u=e.points[s+3],c=e.points[s+4],h=e.points[s+5],d=e.points[s+6],f=new os(Te.generateUUID(),new B(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,h),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(r=>{let s=new Pt;return s.fromJSON(r),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let n=(s,o)=>{o instanceof Dr&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},r=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof mi&&(s[a]=h2(s[a]));for(a=0,l=s.length;a<l;a++){let h=s[a],d=a>0?s[a-1]:null,f;h instanceof Dr?(f=this.createPoint(h.v0),f.controls[1].position.copy(h.v1)):h instanceof Ir&&(f=this.createPoint(h.v1)),f!==void 0&&(d!==null&&n(f,d),o.push(f))}let u=s[s.length-1],c=!1;return u instanceof Dr?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof Ir&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=r(e.curves),e instanceof _o&&(this.shapeHoles=e.holes.map(s=>{let o=new Pt;return o.fromShape(s),o})),this.update(),this}updatePoint(e,n){let r=this.getPointByUuid(e);r&&(n.position!==void 0&&r.position.fromArray(n.position),n.roundness!==void 0&&(r.roundness=n.roundness),n.areControlsDirectionsMirrored!==void 0&&(r.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,n){let s=this.getPointByUuid(e)?.controls[0];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}updateNextControl(e,n){let s=this.getPointByUuid(e)?.controls[1];s&&(n.position&&s.position.fromArray(n.position),this.needsUpdate=!0)}};var rw=Math.PI*2;function nw({x:i,y:t},e,n,r,s){return{x:i*e+r,y:t*n+s}}function c6(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),n=Math.cos(i),r=Math.sin(i),s=Math.cos(i+t),o=Math.sin(i+t);return[{x:n-r*e,y:r+n*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function b2(i,t,e,n){let r=i*n-t*e<0?-1:1,s=Math.min(1,Math.max(-1,i*e+t*n));return r*Math.acos(s)}function u6(i,t,e,n,r,s,o,a,l,u){let c=Math.pow(r,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),p=c*h-c*f-h*d;p<0&&(p=0),p/=c*f+h*d,p=Math.sqrt(p)*(l===u?-1:1);let m=p*r/s*a,g=p*-s/r*o,y=m+(i+e)/2,v=g+(t+n)/2,x=(o-m)/r,b=(a-g)/s,w=(-o-m)/r,E=(-a-g)/s,_=b2(1,0,x,b),S=b2(x,b,w,E);return!u&&S>0&&(S-=rw),u&&S<0&&(S+=rw),{centerx:y,centery:v,ang1:_,ang2:S}}function S2({px:i,py:t,cx:e,cy:n,rx:r,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(r===0||s===0)return[];let u=(i-e)/2,c=(t-n)/2;if(u===0&&c===0)return[];r=Math.abs(r),s=Math.abs(s);let h=Math.pow(u,2)/Math.pow(r,2)+Math.pow(c,2)/Math.pow(s,2);h>1&&(r*=Math.sqrt(h),s*=Math.sqrt(h));let d=u6(i,t,e,n,r,s,u,c,o,a),{ang1:f,ang2:p}=d,{centerx:m,centery:g}=d,y=Math.abs(p)/(rw/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);p/=v;for(let x=0;x<v;x++)l.push(c6(f,p)),f+=p;return l.map(x=>{let{x:b,y:w}=nw(x[0],r,s,m,g),{x:E,y:_}=nw(x[1],r,s,m,g),{x:S,y:T}=nw(x[2],r,s,m,g);return{x1:b,y1:w,x2:E,y2:_,x:S,y:T}})}var xt;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(xt||(xt={}));var mn;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(mn||(mn={}));function nt(i,t){if(!i)throw t||"Assertion Failed!"}var Qe=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,n){nt(i.vertLeq(t,e)&&i.vertLeq(e,n));var r=e.s-t.s,s=n.s-e.s;return r+s>0?r<s?e.t-t.t+(t.t-n.t)*(r/(r+s)):e.t-n.t+(n.t-t.t)*(s/(r+s)):0},i.edgeSign=function(t,e,n){nt(i.vertLeq(t,e)&&i.vertLeq(e,n));var r=e.s-t.s,s=n.s-e.s;return r+s>0?(e.t-n.t)*r+(e.t-t.t)*s:0},i.transEval=function(t,e,n){nt(i.transLeq(t,e)&&i.transLeq(e,n));var r=e.t-t.t,s=n.t-e.t;return r+s>0?r<s?e.s-t.s+(t.s-n.s)*(r/(r+s)):e.s-n.s+(n.s-t.s)*(s/(r+s)):0},i.transSign=function(t,e,n){nt(i.transLeq(t,e)&&i.transLeq(e,n));var r=e.t-t.t,s=n.t-e.t;return r+s>0?(e.s-n.s)*r+(e.s-t.s)*s:0},i.vertCCW=function(t,e,n){return t.s*(e.t-n.t)+e.s*(n.t-t.t)+n.s*(t.t-e.t)>=0},i.interpolate=function(t,e,n,r){return t=t<0?0:t,n=n<0?0:n,t<=n?n===0?(e+r)/2:e+(r-e)*(t/(t+n)):r+(e-r)*(n/(t+n))},i.intersect=function(t,e,n,r,s){var o,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(n,r)||(l=n,n=r,r=l),i.vertLeq(t,n)||(l=t,t=n,n=l,l=e,e=r,r=l),i.vertLeq(n,e)?i.vertLeq(e,r)?(o=i.edgeEval(t,n,e),a=i.edgeEval(n,e,r),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,n.s,a,e.s)):(o=i.edgeSign(t,n,e),a=-i.edgeSign(t,r,e),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,n.s,a,r.s)):s.s=(n.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(n,r)||(l=n,n=r,r=l),i.transLeq(t,n)||(l=t,t=n,n=l,l=e,e=r,r=l),i.transLeq(n,e)?i.transLeq(e,r)?(o=i.transEval(t,n,e),a=i.transEval(n,e,r),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,n.t,a,e.t)):(o=i.transSign(t,n,e),a=-i.transSign(t,r,e),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,n.t,a,r.t)):s.t=(n.t+e.t)/2},i}(),Xf=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),Gy=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),yh=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),w2=function(){function i(){var t=new yh,e=new Xf,n=new Gy(0),r=new Gy(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,n.next=n,n.Sym=r,r.next=r,r.Sym=n,this.vHead=t,this.fHead=e,this.eHead=n,this.eHeadSym=r}return i.prototype.makeEdge_=function(t){var e=new Gy(0),n=new Gy(1);t.Sym.side<t.side&&(t=t.Sym);var r=t.Sym.next;return n.next=r,r.Sym.next=e,e.next=t,t.Sym.next=n,e.Sym=n,e.Onext=e,e.Lnext=n,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,n.Sym=e,n.Onext=n,n.Lnext=e,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,e},i.prototype.splice_=function(t,e){var n=t.Onext,r=e.Onext;n.Sym.Lnext=e,r.Sym.Lnext=t,t.Onext=r,e.Onext=n},i.prototype.makeVertex_=function(t,e,n){var r=t;nt(r,"Vertex can't be null!");var s=n.prev;r.prev=s,s.next=r,r.next=n,n.prev=r,r.anEdge=e;var o=e;do o.Org=r,o=o.Onext;while(o!==e)},i.prototype.makeFace_=function(t,e,n){var r=t;nt(r,"Face can't be null");var s=n.prev;r.prev=s,s.next=r,r.next=n,n.prev=r,r.anEdge=e,r.trail=null,r.marked=!1,r.inside=n.inside;var o=e;do o.Lface=r,o=o.Lnext;while(o!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,n=t.Sym.next;e.Sym.next=n,n.Sym.next=e},i.prototype.killVertex_=function(t,e){var n=t.anEdge,r=n;do r.Org=e,r=r.Onext;while(r!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.killFace_=function(t,e){var n=t.anEdge,r=n;do r.Lface=e,r=r.Lnext;while(r!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.makeEdge=function(){var t=new yh,e=new yh,n=new Xf,r=this.makeEdge_(this.eHead);return this.makeVertex_(t,r,this.vHead),this.makeVertex_(e,r.Sym,this.vHead),this.makeFace_(n,r,this.fHead),r},i.prototype.splice=function(t,e){var n=!1,r=!1;if(t!==e){if(e.Org!==t.Org&&(r=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!r){var s=new yh;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!n){var o=new Xf;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,n=!1;if(t.Lface!==t.Rface&&(n=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!n){var r=new Xf;this.makeFace_(r,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),n=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var r=new yh;return this.makeVertex_(r,n,e.Org),e.Lface=n.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),n=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,n),t.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=t.Rface,n.winding=t.winding,n.Sym.winding=t.Sym.winding,n.idx=t.idx,n.Sym.idx=t.Sym.idx,n},i.prototype.connect=function(t,e){var n=!1,r=this.makeEdge_(t),s=r.Sym;if(e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(r,t.Lnext),this.splice_(s,e),r.Org=t.Dst,s.Org=e.Org,r.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!n){var o=new Xf;this.makeFace_(o,r,t.Lface)}return r},i.prototype.zapFace=function(t){var e=t.anEdge,n,r,s,o,a;r=e.Lnext;do n=r,r=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,n=0;do n++,e=e.Lnext;while(e!==t.anEdge);return n},i.prototype.mergeConvexFaces=function(t){var e,n,r,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(n=e.anEdge,o=n.Org;r=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&Qe.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&Qe.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(r=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=r;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,n=this.eHead,r,s,o,a,l,u;for(s=t,s=t;(r=s.next)!==t;s=r){nt(r.prev===s),l=r.anEdge;do nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l),nt(l.Lface===r),l=l.Lnext;while(l!==r.anEdge)}for(nt(r.prev===s&&r.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){nt(o.prev===a),l=o.anEdge;do nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l),nt(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(nt(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)nt(l.Sym.next===u.Sym),nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Org!==null),nt(l.Dst!==null),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l);nt(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),A2=function(){function i(){this.handle=null}return i}(),E2=function(){function i(){this.key=null,this.node=0}return i}(),h6=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var n=0;n<t+1;n++)this.nodes[n]=new A2,this.handles[n]=new E2;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,n=this.handles,r,s,o;for(r=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(n[e[o+1].handle].key,n[e[o].handle].key)&&++o,nt(o<=this.max),s=e[o].handle,o>this.size||this.leq(n[r].key,n[s].key)){e[t].handle=r,n[r].node=t;break}e[t].handle=s,n[s].node=t,t=o}},i.prototype.floatUp_=function(t){var e=this.nodes,n=this.handles,r,s,o;for(r=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(n[s].key,n[r].key)){e[t].handle=r,n[r].node=t;break}e[t].handle=s,n[s].node=t,t=o}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,n;if(e=++this.size,e*2>this.max){this.max*=2;var r,s;for(s=this.nodes.length,this.nodes.length=this.max+1,r=s;r<this.nodes.length;r++)this.nodes[r]=new A2;for(s=this.handles.length,this.handles.length=this.max+1,r=s;r<this.handles.length;r++)this.handles[r]=new E2}return this.freeList===0?n=e:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[e].handle=n,this.handles[n].node=e,this.handles[n].key=t,this.initialized&&this.floatUp_(e),n},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,n=t[1].handle,r=e[n].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[n].key=null,e[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),r},i.prototype.delete=function(t){var e=this.nodes,n=this.handles,r;nt(t>=1&&t<=this.max&&n[t].key!==null),r=n[t].node,e[r].handle=e[this.size].handle,n[e[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(n[e[r>>1].handle].key,n[e[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),n[t].key=null,n[t].node=this.freeList,this.freeList=t},i}(),iw=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),_2=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),d6=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new _2,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var n=new _2;return n.key=e,n.next=t.next,t.next.prev=n,n.prev=t,t.next=n,n},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),f6=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,n){var r=t.event,s=e.eUp,o=n.eUp;if(s.Dst===r)return o.Dst===r?Qe.vertLeq(s.Org,o.Org)?Qe.edgeSign(o.Dst,s.Org,o.Org)<=0:Qe.edgeSign(s.Dst,o.Org,s.Org)>=0:Qe.edgeSign(o.Dst,r,o.Org)<=0;if(o.Dst===r)return Qe.edgeSign(s.Dst,r,s.Org)>=0;var a=Qe.edgeEval(s.Dst,r,s.Org),l=Qe.edgeEval(o.Dst,r,o.Org);return a>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&nt(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,n){nt(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=n,n.activeRegion=e},i.topLeftRegion=function(t,e){var n=e.eUp.Org,r;do e=i.regionAbove(e);while(e.eUp.Org===n);if(e.fixUpperEdge){if(r=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),r===null)return null;i.fixUpperEdge(t,e,r),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,n){var r=new iw;return r.eUp=n,r.nodeUp=t.dict.insertBefore(e.nodeUp,r),r.fixUpperEdge=!1,r.sentinel=!1,r.dirty=!1,n.activeRegion=r,r},i.isWindingInside=function(t,e){switch(t.windingRule){case xt.ODD:return(e&1)!==0;case xt.NONZERO:return e!==0;case xt.POSITIVE:return e>0;case xt.NEGATIVE:return e<0;case xt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var n=e.eUp,r=n.Lface;r.inside=e.inside,r.anEdge=n,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,n){for(var r,s=null,o=e,a=e.eUp;o!==n;){if(o.fixUpperEdge=!1,s=i.regionBelow(o),r=s.eUp,r.Org!=a.Org){if(!s.fixUpperEdge){i.finishRegion(t,o);break}r=t.mesh.connect(a.Lprev,r.Sym),i.fixUpperEdge(t,s,r)}a.Onext!==r&&(t.mesh.splice(r.Oprev,r),t.mesh.splice(a,r)),i.finishRegion(t,o),a=s.eUp,o=s}return a},i.addRightEdges=function(t,e,n,r,s,o){var a,l,u,c,h=!0;u=n;do nt(Qe.vertLeq(u.Org,u.Dst)),i.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==r);for(s===null&&(s=i.regionBelow(e).eUp.Rprev),l=e,c=s;a=i.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=i.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&i.checkForRightSplice(t,l)&&(i.addWinding(u,c),i.deleteRegion(t,l),t.mesh.delete(c)),h=!1,l=a,c=u;l.dirty=!0,nt(l.windingNumber-u.winding===a.windingNumber),o&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,n){t.mesh.splice(e,n)},i.vertexWeights=function(t,e,n){var r=Qe.vertL1dist(e,t),s=Qe.vertL1dist(n,t),o=.5*s/(r+s),a=.5*r/(r+s);t.coords[0]+=o*e.coords[0]+a*n.coords[0],t.coords[1]+=o*e.coords[1]+a*n.coords[1],t.coords[2]+=o*e.coords[2]+a*n.coords[2]},i.getIntersectData=function(t,e,n,r,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,n,r),i.vertexWeights(e,s,o)},i.checkForRightSplice=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp;if(Qe.vertLeq(r.Org,s.Org)){if(Qe.edgeSign(s.Dst,r.Org,s.Org)>0)return!1;Qe.vertEq(r.Org,s.Org)?r.Org!==s.Org&&(t.pq.delete(r.Org.pqHandle),i.spliceMergeVertices(t,s.Oprev,r)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(r,s.Oprev),e.dirty=n.dirty=!0)}else{if(Qe.edgeSign(r.Dst,s.Org,r.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(r.Sym),t.mesh.splice(s.Oprev,r)}return!0},i.checkForLeftSplice=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp,o;if(nt(!Qe.vertEq(r.Dst,s.Dst)),Qe.vertLeq(r.Dst,s.Dst)){if(Qe.edgeSign(r.Dst,s.Dst,r.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(r),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(Qe.edgeSign(s.Dst,r.Dst,s.Org)>0)return!1;e.dirty=n.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(r.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var n=i.regionBelow(e),r=e.eUp,s=n.eUp,o=r.Org,a=s.Org,l=r.Dst,u=s.Dst,c,h,d=new yh,f,p;if(nt(!Qe.vertEq(u,l)),nt(Qe.edgeSign(l,t.event,o)<=0),nt(Qe.edgeSign(u,t.event,a)>=0),nt(o!==t.event&&a!==t.event),nt(!e.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),h=Math.max(a.t,u.t),c>h))return!1;if(Qe.vertLeq(o,a)){if(Qe.edgeSign(u,o,a)>0)return!1}else if(Qe.edgeSign(l,a,o)<0)return!1;return i.debugEvent(t),Qe.intersect(l,o,u,a,d),nt(Math.min(o.t,l.t)<=d.t),nt(d.t<=Math.max(a.t,u.t)),nt(Math.min(u.s,l.s)<=d.s),nt(d.s<=Math.max(a.s,o.s)),Qe.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=Qe.vertLeq(o,a)?o:a,Qe.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),Qe.vertEq(d,o)||Qe.vertEq(d,a)?(i.checkForRightSplice(t,e),!1):!Qe.vertEq(l,t.event)&&Qe.edgeSign(l,t.event,d)>=0||!Qe.vertEq(u,t.event)&&Qe.edgeSign(u,t.event,d)<=0?u===t.event?(t.mesh.splitEdge(r.Sym),t.mesh.splice(s.Sym,r),e=i.topLeftRegion(t,e),r=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),n),i.addRightEdges(t,e,r.Oprev,r,r,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(r.Lnext,s.Oprev),n=e,e=i.topRightRegion(e),p=i.regionBelow(e).eUp.Rprev,n.eUp=s.Oprev,s=i.finishLeftRegions(t,n,null),i.addRightEdges(t,e,s.Onext,r.Rprev,p,!0),!0):(Qe.edgeSign(l,t.event,d)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(r.Sym),r.Org.s=t.event.s,r.Org.t=t.event.t),Qe.edgeSign(u,t.event,d)<=0&&(e.dirty=n.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(r.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,r),r.Org.s=d.s,r.Org.t=d.t,r.Org.pqHandle=t.pq.insert(r.Org),i.getIntersectData(t,r.Org,o,l,a,u),i.regionAbove(e).dirty=e.dirty=n.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var n=i.regionBelow(e),r,s;;){for(;n.dirty;)e=n,n=i.regionBelow(n);if(!e.dirty&&(n=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,r=e.eUp,s=n.eUp,r.Dst!==s.Dst&&i.checkForLeftSplice(t,e)&&(n.fixUpperEdge?(i.deleteRegion(t,n),t.mesh.delete(s),n=i.regionBelow(e),s=n.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(r),e=i.regionAbove(n),r=e.eUp)),r.Org!==s.Org)if(r.Dst!==s.Dst&&!e.fixUpperEdge&&!n.fixUpperEdge&&(r.Dst===t.event||s.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);r.Org===s.Org&&r.Dst===s.Dst&&(i.addWinding(s,r),i.deleteRegion(t,e),t.mesh.delete(r),e=i.regionAbove(n))}},i.connectRightVertex=function(t,e,n){var r,s=n.Onext,o=i.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),Qe.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=i.topLeftRegion(t,e),s=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),o),u=!0),Qe.vertEq(l.Org,t.event)&&(t.mesh.splice(n,l.Oprev),n=i.finishLeftRegions(t,o,null),u=!0),u){i.addRightEdges(t,e,n.Onext,s,s,!0);return}Qe.vertLeq(l.Org,a.Org)?r=l.Oprev:r=a,r=t.mesh.connect(n.Lprev,r),i.addRightEdges(t,e,r,r.Onext,r.Onext,!1),r.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,n){var r,s,o,a,l;if(r=e.eUp,Qe.vertEq(r.Org,n)){nt(!1),i.spliceMergeVertices(t,r,n.anEdge);return}if(!Qe.vertEq(r.Dst,n)){t.mesh.splitEdge(r.Sym),e.fixUpperEdge&&(t.mesh.delete(r.Onext),e.fixUpperEdge=!1),t.mesh.splice(n.anEdge,r),i.sweepEvent(t,n);return}nt(!1),e=i.topRightRegion(e),l=i.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(nt(s!==o),i.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(n.anEdge,o),Qe.edgeGoesLeft(s)||(s=null),i.addRightEdges(t,e,o.Onext,a,s,!0)},i.connectLeftVertex=function(t,e){var n,r,s,o,a,l,u=new iw;if(u.eUp=e.anEdge.Sym,n=t.dict.search(u).key,r=i.regionBelow(n),!!r){if(o=n.eUp,a=r.eUp,Qe.edgeSign(o.Dst,e,o.Org)===0){i.connectLeftDegenerate(t,n,e);return}if(s=Qe.vertLeq(a.Dst,o.Dst)?n:r,n.inside||s.fixUpperEdge){if(s===n)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var c=t.mesh.connect(a.Dnext,e.anEdge);l=c.Sym}s.fixUpperEdge?i.fixUpperEdge(t,s,l):i.computeWinding(t,i.addRegionBelow(t,n,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,n,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var n=e.anEdge;n.activeRegion===null;)if(n=n.Onext,n===e.anEdge){i.connectLeftVertex(t,e);return}var r=i.topLeftRegion(t,n.activeRegion);nt(r!==null);var s=i.regionBelow(r),o=s.eUp,a=i.finishLeftRegions(t,s,null);a.Onext===o?i.connectRightVertex(t,r,a):i.addRightEdges(t,r,a.Onext,o,o,!0)},i.addSentinel=function(t,e,n,r){var s=new iw,o=t.mesh.makeEdge();o.Org.s=n,o.Org.t=r,o.Dst.s=e,o.Dst.t=r,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},i.initEdgeDict=function(t){t.dict=new d6(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],n=t.bmax[1]-t.bmin[1],r=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-n,a=t.bmax[1]+n;i.addSentinel(t,r,s,o),i.addSentinel(t,r,s,a)},i.doneEdgeDict=function(t){for(var e,n=0;(e=t.dict.min().key)!==null;)e.sentinel||(nt(e.fixUpperEdge),nt(++n===1)),nt(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,n,r,s=t.mesh.eHead;for(e=s.next;e!==s;e=n)n=e.next,r=e.Lnext,Qe.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,r,e),t.mesh.delete(e),e=r,r=e.Lnext),r.Lnext===e&&(r!==e&&((r===n||r===n.Sym)&&(n=n.next),t.mesh.delete(r)),(e===n||e===n.Sym)&&(n=n.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,n,r,s=0;for(r=t.mesh.vHead,n=r.next;n!==r;n=n.next)s++;for(s+=8,e=t.pq=new h6(s,Qe.vertLeq),r=t.mesh.vHead,n=r.next;n!==r;n=n.next)n.pqHandle=e.insert(n);return n!==r?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var n,r,s;for(n=e.fHead.next;n!==e.fHead;n=r)r=n.next,s=n.anEdge,nt(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),t.mesh.delete(s));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var n,r;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(n=t.pq.extractMin())!==null;){for(;r=t.pq.min(),!(r===null||!Qe.vertEq(r,n));)r=t.pq.extractMin(),i.spliceMergeVertices(t,n.anEdge,r.anEdge);i.sweepEvent(t,n)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),p6=function(){function i(){this.mesh=new w2,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=xt.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,n,r,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],p=[null,null,null],m=this.mesh.vHead;e=m.next;for(var g=0;g<3;++g)s=e.coords[g],u[g]=s,p[g]=e,l[g]=s,f[g]=e;for(e=m.next;e!==m;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<u[y]&&(u[y]=s,p[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-u[1]>l[0]-u[0]&&(v=1),l[2]-u[2]>l[v]-u[v]&&(v=2),u[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,n=p[v],r=f[v],c[0]=n.coords[0]-r.coords[0],c[1]=n.coords[1]-r.coords[1],c[2]=n.coords[2]-r.coords[2],e=m.next;e!==m;e=e.next)h[0]=e.coords[0]-r.coords[0],h[1]=e.coords[1]-r.coords[1],h[2]=e.coords[2]-r.coords[2],d[0]=c[1]*h[2]-c[2]*h[1],d[1]=c[2]*h[0]-c[0]*h[2],d[2]=c[0]*h[1]-c[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,t[0]=d[0],t[1]=d[1],t[2]=d[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,n=this.mesh.vHead,r,s=0,o=t.next;o!==t;o=o.next)if(r=o.anEdge,!(r.winding<=0))do s+=(r.Org.s-r.Dst.s)*(r.Org.t+r.Dst.t),r=r.Lnext;while(r!==o.anEdge);if(s<0){for(e=n.next;e!==n;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],n,r,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),n=this.sUnit,r=this.tUnit;var o=this.longAxis_(e);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,r[o]=0,r[(o+1)%3]=0,r[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,r);s&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var n,r;if(n=e.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;Qe.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;Qe.vertLeq(n.Org,n.Dst);n=n.Lnext);r=n.Lprev;for(var s=void 0;n.Lnext!==r;)if(Qe.vertLeq(n.Dst,r.Org)){for(;r.Lnext!==n&&(Qe.edgeGoesLeft(r.Lnext)||Qe.edgeSign(r.Org,r.Dst,r.Lnext.Dst)<=0);)s=t.connect(r.Lnext,r),r=s.Sym;r=r.Lprev}else{for(;r.Lnext!==n&&(Qe.edgeGoesRight(n.Lprev)||Qe.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=t.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(r.Lnext===n)throw"Mono region invalid";for(;r.Lnext.Lnext!==n;)s=t.connect(r.Lnext,r),r=s.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)if(e=n.next,n.inside&&!this.tessellateMonoRegion_(t,n))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)e=n.next,n.inside||t.zapFace(n)},i.prototype.setWindingNumber_=function(t,e,n){for(var r,s=t.eHead.next;s!==t.eHead;s=r)r=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:n?t.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,n,r){var s,o=0,a=0,l;n>3&&t.mergeConvexFaces(n);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>n)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,e===mn.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*r,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var h=u.n*r;this.vertices[h+0]=u.coords[0],this.vertices[h+1]=u.coords[1],r>2&&(this.vertices[h+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var d=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[d++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[d++]=-1;if(e===mn.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var p=l;p<n;++p)this.elements[d++]=-1}}},i.prototype.outputContours_=function(t,e){var n,r,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){r=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==r);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,r=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],e>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==r);this.elements[c++]=s,this.elements[c++]=o,s+=o}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new w2),t<2&&(t=2),t>3&&(t=3);for(var n=null,r=0;r<e.length;r+=t)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=e[r+0],n.Org.coords[1]=e[r+1],t>2?n.Org.coords[2]=e[r+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},i.prototype.tesselate=function(t,e,n,r,s,o){if(t===void 0&&(t=xt.ODD),e===void 0&&(e=mn.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,r<2&&(r=2),r>3&&(r=3),!this.mesh)return!1;this.projectPolygon_(),f6.computeInterior(this,o);var a=this.mesh;return e===mn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===mn.BOUNDARY_CONTOURS?this.outputContours_(a,r):this.outputPolymesh_(a,e,n,r),!0},i}();function as(i){var t=i.windingRule,e=t===void 0?xt.ODD:t,n=i.elementType,r=n===void 0?mn.POLYGONS:n,s=i.polySize,o=s===void 0?3:s,a=i.vertexSize,l=a===void 0?2:a,u=i.normal,c=u===void 0?[0,0,1]:u,h=i.contours,d=h===void 0?[]:h,f=i.strict,p=f===void 0?!0:f,m=i.debug,g=m===void 0?!1:m;if(!d&&p)throw new Error("Contours can't be empty");if(!!d){var y=new p6;i.edgeCreateCallback&&(y.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(y.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<d.length;v++)y.addContour(l||2,d[v]);return y.tesselate(e,r,o,l,c,p),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var Phe=xt.ODD,Dhe=xt.NONZERO,Ihe=xt.POSITIVE,Ohe=xt.NEGATIVE,Rhe=xt.ABS_GEQ_TWO,Lhe=mn.POLYGONS,Nhe=mn.CONNECTED_POLYGONS,Bhe=mn.BOUNDARY_CONTOURS;var Hy=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let n=t*Hy.eSize;this.buffer=new ArrayBuffer(n);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*r,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*r,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let n=t*Hy.eSize,r=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(r,o*s,3*t);o+=3*t;let l=new Float32Array(r,o*s,3*t);o+=3*t;let u=new Float32Array(r,o*s,2*t);e?(a.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),u.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),l.set(this.normals),u.set(this.uvs)),this.buffer=r,this.positions=a,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let r=this.capacity;for(;e>r;)r*=2;this.realloc(r)}let n=this.size;return this.size=e,n}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Kf=Hy;Kf.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var P2=$o(C2()),Qf={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},cw={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},uw={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},lw=(i,t)=>([e,n])=>(n<e&&(n+=t),(i>=e?i:i+t)<=n),ja=class extends Ae{constructor(e,n,r=0,s=12,o=3,a=xt.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=n,this._curveSegments=s,this._bevelSegmentsInput=o;let u=this._shape.extractShapePointsToFlatArray([],s),c=this._shape.shapeHoles.map(C=>{let D=C.extractShapePointsToFlatArray([],s),P=[];for(let I=D.length-1;I>=1;I-=2){let L=D[I-1],H=D[I-0];P.push(L,H)}return P}),h=[],d=[];for(let C=0;C<u.length;C+=2)d.push([u[C],u[C+1]]);h.push(d);for(let C=0;C<c.length;C++){let D=c[C],P=[];for(let I=0;I<D.length;I+=2)P.push([D[I],D[I+1]]);h.push(P)}let f=h[0].length?(0,P2.default)(h).distance:r;r<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(r,f,n/2),this._bevelSegments=Math.floor(o));let p;try{p=as({windingRule:a,elementType:mn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{p=Qf}let m;try{m=as({windingRule:xt.ODD,elementType:mn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=cw}if(!p)throw new Error("error generating geometry");let g=p.elementCount;if(m){p.elementCount+=m.elementCount;for(let C=0;C<m.elements.length;C++){let D=m.elements[C],P=C%2===0?p.vertexCount:0;p.elements.push(D+P)}for(let C=0;C<m.vertexIndices.length;C++){let D=m.vertexIndices[C],P=p.vertexCount;p.vertexIndices.push(D+P)}for(let C=0;C<m.vertices.length;C++){let D=m.vertices[C];p.vertices.push(D)}}let y=1/0,v=-1/0,x=1/0,b=-1/0;for(let C=0,D=p.vertexCount;C<D;C++){let P=C*2,I=p.vertices[P+0],L=p.vertices[P+1];I<y&&(y=I),I>v&&(v=I),L<x&&(x=L),L>b&&(b=L)}this._minX=y,this._minY=x,this._width=v-y,this._height=b-x,this._buffer=new Kf(this._computeBufferEstimatedSize(p));let w=[],E=[];for(let C=p.elementCount-1;C>=0;C--){let D=C>=g,P=C*2,I=p.elements[P+0],L=p.elements[P+1],H=I+L,U={start:I,count:L,normals:[],continuous:[],concave:[]},G=I,z=H-1,V=I+1,$=this._shape.roundedCurves.length;do{let k=G-I,Z=p.vertices[z*2+0],Q=p.vertices[z*2+1],K=p.vertices[G*2+0],W=p.vertices[G*2+1],ye=p.vertices[V*2+0],fe=p.vertices[V*2+1],ie=K-Z,we=W-Q,xe=Math.sqrt(ie*ie+we*we);ie/=xe,we/=xe;let Oe=K-ye,Ie=W-fe,Pe=Math.sqrt(Oe*Oe+Ie*Ie);Oe/=Pe,Ie/=Pe,U.normals[k*2+0]=-Ie,U.normals[k*2+1]=Oe,U.concave[k]=ie*Ie-we*Oe>0;let _e=p.vertexIndices[G];if(Array.isArray(_e))U.continuous[k]=!1;else{let[Ve,ze]=this._shape.getCurveIndexFromVertexId(_e-1,!0);if(ze>0&&ze<1)U.continuous[k]=!0;else{let R=ze===1?Ve+1:Ve-1;R=(R+$)%$;let O=ze===1?0:1,ne=this._shape.roundedCurves[Ve].getTangent(ze),ue=this._shape.roundedCurves[R].getTangent(O);U.continuous[k]=ne.dot(ue)>.95}}D&&(U.normals[k*2+0]*=-1,U.normals[k*2+1]*=-1),[z,G,V]=[G,V,V+1],V>=H&&(V-=L)}while(V!==I+1);let F=[];F.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(I*2,H*2),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((k,Z)=>[Z,Z]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(I*2,H*2)});let j=0;for(let k=1;k<=this._bevelSegments;k++){let Z=k/this._bevelSegments*Math.PI/2,Q=(1-Math.cos(Z))*this._bevel,K=[],W=[],ye=[],fe=[],ie=0;for(let xe=0;xe<L;xe++){let Oe=xe*2,Ie=(xe-1+L)%L*2,Pe=p.vertices[U.start*2+Oe+0],_e=p.vertices[U.start*2+Oe+1],Ve=-U.normals[Ie+0]*Q,ze=-U.normals[Ie+1]*Q,R=-U.normals[Oe+0]*Q,O=-U.normals[Oe+1]*Q;if(U.concave[xe]||!U.concave[xe]&&D){let ne=Math.atan2(ze,Ve),ue=Math.atan2(O,R);ue>ne&&(ue-=Math.PI*2);let me=ue-ne;if(U.continuous[xe]||D){let De=ne+me/2,Me=Math.cos(De)*Q,Ee=Math.sin(De)*Q;K[2*ie+0]=Pe+Me*(D?-1:1),K[2*ie+1]=_e+Ee*(D?-1:1),fe[ie]=xe,ie++}else{let De=Math.max(1,Math.floor(s/4*Math.abs(me)/Math.PI));for(let Me=0;Me<=De;Me++){let Ee=ne+me*(Me/De),le=Math.cos(Ee)*Q,Ke=Math.sin(Ee)*Q;K[2*ie+0]=Pe+le,K[2*ie+1]=_e+Ke,fe[ie]=xe,ie++}}}else K[2*ie+0]=Pe+Ve,K[2*ie+1]=_e+ze,fe[ie]=xe,W[xe]=ie,ie++,K[2*ie+0]=Pe,K[2*ie+1]=_e,fe[ie]=xe,ie++,K[2*ie+0]=Pe+R,K[2*ie+1]=_e+O,fe[ie]=xe,ye[xe]=ie,ie++}let we=as({windingRule:xt.POSITIVE,elementType:mn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[K],edgeCreateCallback:xe=>{let Ie=xe.Org.idx,Pe=fe[Ie],_e=fe[(Ie+1)%fe.length];xe.idx=[Pe,_e],xe.Sym.idx=[_e,Pe]},vertexIdCallback:xe=>{let Oe=xe.Lprev.idx;return[Oe?Oe[1]:0,xe.idx?xe.idx[0]:0]}});if(!we)throw console.log("Error"),new Error(`error generating bevel geometry for ${k}'th loop`);if(!we.vertexCount){let xe=(k-1)/this._bevelSegments*Math.PI/2;j=(1-Math.sin(xe))*this._bevel;break}for(let xe=0;xe<we.vertexIndices.length;xe++){let[Oe,Ie]=we.vertexIndices[xe];if(Oe===Ie)continue;let Pe=Ie;Ie<Oe&&(Pe+=L);for(let _e=Oe;_e<Pe;_e++){let Ve=_e%L,ze=(_e+1)%L;if(!U.continuous[Ve]||!U.continuous[ze]){we.vertexIndices[xe]=[Oe,Ve],we.vertexIndices.splice(xe+1,0,[ze,Ie]),we.vertices.splice((xe+1)*2,0,we.vertices[xe*2],we.vertices[xe*2+1]);break}}}F.push({bevelI:k,angle:Z,size:Q,boundary:we,reverseMap:fe,insetPoints:K})}let X=(k,Z,Q)=>{let K=0,W=k.boundary.vertexIndices.length;for(;K<W&&Q(k.boundary.vertexIndices[Z]);)Z=(Z+1)%W,K++;return K},q=w.length;for(let k=1;k<F.length;k++){let Z=F[k-1],Q=F[k],K=Z.boundary.vertexIndices.length,W=Q.boundary.vertexIndices.length;if(!K||!W)break;let ye=U.concave.length,fe=0,ie=lw(fe,L);for(;!Z.boundary.vertexIndices.filter(ie).length||!Q.boundary.vertexIndices.filter(ie).length;)fe++,ie=lw(fe,L);let we=Z.boundary.vertexIndices.findIndex(ie),xe=Q.boundary.vertexIndices.findIndex(ie);do we=(we+1)%K;while(ie(Z.boundary.vertexIndices[we]));do xe=(xe+1)%W;while(ie(Q.boundary.vertexIndices[xe]));fe=(fe+1)%L;let Oe=fe,Ie=0,Pe=this._buildBevelVert(U,Z,(we-1+K)%K,void 0,Ie),_e=this._buildBevelVert(U,Q,(xe-1+W)%W,void 0,Ie),Ve=Pe,ze=_e,R,O,ne=!1;do{Ie=(fe||ye)/ye,ie=lw(fe,L);let ue=X(Z,we,ie),me=X(Q,xe,ie),De=ne;if(ne=!1,ue&&!me){for(let Me=0;Me<ue;Me++)R=this._buildBevelVert(U,Z,(we+Me)%K,Me/(ue-1),Ie),w.push(Ve.topN,R.topP,ze.topN),l===!1&&w.push(R.bottomP,Ve.bottomN,ze.bottomN),Ve=R;ne=!0}else if(!ue&&me)for(let Me=0;Me<me;Me++)O=this._buildBevelVert(U,Q,(xe+Me)%W,Me/(me-1),Ie),w.push(ze.topN,Ve.topP,O.topP),l===!1&&w.push(Ve.bottomP,ze.bottomN,O.bottomP),ze=O;else if(ue&&me)if(R=this._buildBevelVert(U,Z,we,0,Ie),O=this._buildBevelVert(U,Q,xe,0,Ie),De?(w.push(Ve.topN,O.topP,ze.topN),w.push(Ve.topN,R.topP,O.topP),l===!1&&(w.push(O.bottomP,Ve.bottomN,ze.bottomN),w.push(O.bottomP,R.bottomP,Ve.bottomN))):(w.push(ze.topN,Ve.topN,R.topP),w.push(ze.topN,R.topP,O.topP),l===!1&&(w.push(R.bottomP,Ve.bottomN,ze.bottomN),w.push(R.bottomP,ze.bottomN,O.bottomP))),Ve=R,ze=O,ue===me)for(let Me=1;Me<ue;Me++)R=this._buildBevelVert(U,Z,(we+Me)%K,Me/(ue-1),Ie),O=this._buildBevelVert(U,Q,(xe+Me)%W,Me/(me-1),Ie),w.push(Ve.topN,R.topP,ze.topN),w.push(ze.topN,R.topP,O.topP),l===!1&&(w.push(R.bottomP,Ve.bottomN,ze.bottomN),w.push(R.bottomP,ze.bottomN,O.bottomP)),Ve=R,ze=O;else if(ue>me){let Me=ue/me,Ee=0;for(let le=1;le<ue;le++)R=this._buildBevelVert(U,Z,(we+le)%K,le/(ue-1),Ie),w.push(Ve.topN,R.topP,ze.topN),l===!1&&w.push(R.bottomP,Ve.bottomN,ze.bottomN),Ve=R,le>(Ee+1)*Me&&(Ee++,O=this._buildBevelVert(U,Q,(xe+Ee)%W,Ee/(me-1),Ie),w.push(ze.topN,R.topP,O.topP),l===!1&&w.push(R.bottomP,ze.bottomN,O.bottomP),ze=O)}else{let Me=me/ue,Ee=0;for(let le=1;le<me;le++)O=this._buildBevelVert(U,Q,(xe+le)%W,le/(me-1),Ie),w.push(ze.topN,R.topP,O.topP),l===!1&&w.push(R.bottomP,ze.bottomN,O.bottomP),ze=O,le>(Ee+1)*Me&&(Ee++,R=this._buildBevelVert(U,Z,(we+Ee)%K,Ee/(ue-1),Ie),w.push(Ve.topN,R.topP,ze.topN),l===!1&&w.push(R.bottomP,Ve.bottomN,ze.bottomN),Ve=R)}we=(we+ue)%K,xe=(xe+me)%W,fe=(fe+1)%ye}while(fe!==Oe)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(F,U,w),D){let k=[];for(let Z=w.length-1;Z>=q+2;Z-=3){let Q=w[Z-2],K=w[Z-1],W=w[Z-0];k.push(W,K,Q)}w.splice(q,w.length-q,...k)}if(D){let k=[];for(let Z=F[F.length-1].boundary.vertices.length-1;Z>=1;Z-=2){let Q=F[F.length-1].boundary.vertices[Z-1],K=F[F.length-1].boundary.vertices[Z-0];k.push(Q,K)}E.push(k)}if(!D){let k=F[F.length-1],Z;try{Z=as({windingRule:F.length>1?xt.POSITIVE:xt.ODD,elementType:mn.POLYGONS,vertexSize:2,strict:!0,contours:[k.insetPoints,...E]})}catch{Z=uw}if(!Z)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let Q=0;Q<Z.elementCount*3;Q+=3){let K=this._buildSurfaceVert(Z,Z.elements[Q+0],j),W=this._buildSurfaceVert(Z,Z.elements[Q+1],j),ye=this._buildSurfaceVert(Z,Z.elements[Q+2],j);w.push(K.top,W.top,ye.top),l===!1&&w.push(ye.bottom,W.bottom,K.bottom)}}this.vertexCache={}}this._buffer.shrink();let _=new Ge(Uint32Array.from(w),1),S=new Ge(this._buffer.positions,3),T=new Ge(this._buffer.normals,3),M=new Ge(this._buffer.uvs,2);S.needsUpdate=!0,T.needsUpdate=!0,M.needsUpdate=!0,_.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",T),this.setAttribute("uv",M),this.setIndex(_)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,r){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);r.push(u.topP,l.topN,l.bottomN),r.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,n,r){let s=n.toString();if(s in this.vertexCache)return this.vertexCache[s];let o=e.vertices[n*2+0],a=e.vertices[n*2+1],l=(o-this._minX)/this._width,u=(a-this._minY)/this._height;this.forPathBevel&&(u=1);let c=this._buffer.get(this.forPathBevel?1:2),h=c*3,d=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[h+0]=o,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-r,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=u,this.forPathBevel===!1&&(this._buffer.positions[h+3]=o,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=r,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=u),this.vertexCache[s]=f,f}_buildBevelVert(e,n,r,s=1,o){let a=`${n.bevelI}:${r}`;if(a in this.vertexCache&&o!==0&&o!==1&&(!o||o===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[l,u]=n.boundary.vertexIndices[r],c,h,d,f;l!==u?(h=l,c=u,f=!1,d=e.continuous[h]&&e.continuous[c]):(c=l,h=(c-1+e.count)%e.count,f=e.concave[c]&&n.bevelI>0,d=e.continuous[c]||f);let p=Math.cos(n.angle),m=Math.sin(n.angle),g=r*2,y=c*2,v=h*2,x=n.boundary.vertices[g+0],b=n.boundary.vertices[g+1],w=(1-m)*this._bevel,E=(x-this._minX)/this._width,_=(b-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(E=o),_=1);let S=e.normals[y+0],T=e.normals[y+1],M=e.normals[v+0],C=e.normals[v+1];if(f){let H=M-S,U=C-T;S=S+H*(1-s),T=T+U*(1-s);let G=Math.sqrt(S*S+T*T);S/=G,T/=G}let D=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),P=D*3,I=D*2,L={i:r,fi:c,topP:D+0,topN:D+0,bottomP:D+1,bottomN:D+1,pathBevelUCoord:o};return this._buffer.positions[P+0]=x,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[P+0]=S*p,this._buffer.normals[P+1]=T*p,this._buffer.normals[P+2]=m,this._buffer.uvs[I+0]=E,this._buffer.uvs[I+1]=_,this.forPathBevel===!1&&(this._buffer.positions[P+3]=x,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=S*p,this._buffer.normals[P+4]=T*p,this._buffer.normals[P+5]=-m,this._buffer.uvs[I+2]=_,this._buffer.uvs[I+3]=E),d||(this.forPathBevel?(D+=1,P+=3,I+=2):(D+=2,P+=6,I+=4),L.topP=D+0,L.bottomP=D+1,this._buffer.positions[P+0]=x,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=(this.forPathBevel?this._bevel:this._depth)-w,this._buffer.normals[P+0]=M*p,this._buffer.normals[P+1]=C*p,this._buffer.normals[P+2]=m,this._buffer.uvs[I+0]=E,this._buffer.uvs[I+1]=_,this.forPathBevel===!1&&(this._buffer.positions[P+3]=x,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=M*p,this._buffer.normals[P+4]=C*p,this._buffer.normals[P+5]=-m,this._buffer.uvs[I+2]=_,this._buffer.uvs[I+3]=E)),this.vertexCache[a]=L,L}clone(){let e=new ja(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Io(this.userData),e}};var vh=class extends Ae{constructor(e,n=12,r={}){super();this.type="ShapeGeometry";this.windingRule=xt.ODD;this.elementType=mn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:xt.ODD,elementType:mn.POLYGONS,polySize:3,vertexSize:2,strict:!0},r);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,h;for(let p=0,m=s.length/2;p<m;p++){let g=p*2,y=s[g+0],v=s[g+1];if(c!==void 0&&y!==c&&(l=!1),h!==void 0&&v!==h&&(u=!1),c=y,h=v,!l&&!u)break}if(!l&&!u)try{a=as({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=Qf}let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Ge(new Float32Array(d*3),3),this._normalAttribute=new Ge(new Float32Array(d*3),3),this._uvAttribute=new Ge(new Float32Array(d*2),2),this._indexAttribute=new Ge(new Uint32Array(f*3),1),a){let p=1/0,m=-1/0,g=1/0,y=-1/0;for(let b=0,w=d;b<w;b++){let E=b*2,_=a.vertices[E+0],S=a.vertices[E+1];_<p&&(p=_),_>m&&(m=_),S<g&&(g=S),S>y&&(y=S)}let v=m-p,x=y-g;for(let b=0,w=d;b<w;b++){let E=b*2,_=a.vertices[E+0],S=a.vertices[E+1],T=(_-p)/v,M=(S-g)/x;this._positionAttribute.setXYZ(b,_,S,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,T,M)}for(let b=0,w=f;b<w;b++){let E=b*3,_=a.elements[E+0],S=a.elements[E+1],T=a.elements[E+2];this._indexAttribute.setX(E+0,_),this._indexAttribute.setX(E+1,S),this._indexAttribute.setX(E+2,T)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new vh(this._shape,this._curveSegments);return e.userData=Io(this.userData),e}};var xh=class extends ja{constructor(e,n,r=0,s=12,o=3,a=xt.ODD){super(e,n,r,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,r){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(n,s,o),u=this._buildBevelVert(n,s,(o+1)%a);r.push(u.topP,l.topN,l.bottomN),r.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new xh(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Io(this.userData),e}};var ti=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:xt.ODD},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=i.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof Pt?(o.width!==n||o.height!==r)&&o.applySize(n,r):o=new Pt(n,r).fromJSON(o),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&o.update());let l=o??new Pt(n,r);return{parameters:Object.assign(e,{width:n,height:r,depth:s,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:n,subdivisions:r,roundness:s,windingRule:o}=i.parameters;i.shape.roundness=s;let a;return t<=0?a=new vh(i.shape,r,{windingRule:o}):a=new xh(i.shape,t,e,r,n,o),Object.assign(a,{userData:{...i,type:"VectorGeometry"}})}};var I2=Math.PI*2,Sh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=Te.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:n,angle:r,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u=i.shape,c=t*.5,h=e*.5,d=x6(u,c,h,r*Math.PI/180,n,s);u.isClosed=!0,u.update();let f;return r===0?(f=new Ae,f.setAttribute("position",new be([],3))):f=ti.create({shape:u,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function x6(i,t,e,n,r,s){if(n>=I2)return r>30||r%4===0?(S6(i,t,e,s),Math.round(r/4)):D2(i,n,r,t,e,s);n=Math.max(n,.001);let o={x:0,y:e},a=n+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},u=S2({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:n>Math.PI,sweepFlag:!0});return r>30||r%u.length===0?b6(i,o.x,o.y,u,r,t,e,s):D2(i,n,r,t,e,s)}function b6(i,t,e,n,r,s,o,a){let l=Math.round(r/n.length);i.addPoint(bh(t,e));for(let u=0,c=n.length;u<c;u++){let h=n[u],d=i.points[u],f=bh(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),f.controls[0].position.set(h.x2,h.y2),i.addPoint(f)}return a>0?O2(i,s,o,a):i.addPoint(bh(0,0)),l}function D2(i,t,e,n,r,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,u=Math.sin(l)*n,c=Math.cos(l)*r;i.addPoint(bh(u,c))}return t<I2?s>0?O2(i,n,r,s):i.addPoint(bh(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&R2(i,n,r,s)),1}function S6(i,t,e,n=0,r=0,s=0){let o=.5522847498,a=t*o,l=e*o;i.addPoint(Wy(r-t,s,r-t,s-l,r-t,s+l)),i.addPoint(Wy(r,s+e,r-a,s+e,r+a,s+e)),i.addPoint(Wy(r+t,s,r+t,s+l,r+t,s-l)),i.addPoint(Wy(r,s-e,r+a,s-e,r-a,s-e)),n>0&&R2(i,t,e,n)}function bh(i,t){return new os(Te.generateUUID(),new B(i,t))}function Wy(i,t,e,n,r,s){let o=bh(i,t);return o.controls[0].position.set(e,n),o.controls[1].position.set(r,s),o}function O2(i,t,e,n){L2(i,t,e,n).forEach(s=>i.addPoint(s))}function R2(i,t,e,n){let r=L2(i,t,e,n),s=new Pt;r.forEach(o=>s.addPoint(o)),s.isClosed=!0,i.shapeHoles.push(s)}function L2(i,t,e,n){let r=n*t/100,s=r*(Math.abs(e)/Math.abs(t)),o=new B(r/t,s/e),a=i.points.map(l=>{let u=l.clone();return u.uuid=Te.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var N2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??n),s=Math.abs(e.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(e,{width:n,height:r,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:n,radius:r,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:h}=i.parameters,d=new Zf(!1,t,e,n,r,s,o,a,l,u,c,h);return Object.assign(d,{userData:{...i,type:"HelixGeometry"}})}},hw=new Ms([0,0,0],1),Zf=class extends Ae{constructor(t=!0,e=1,n=1,r=1,s=1,o=1,a=1,l=1,u=1,c=1,h=1,d=1){if(super(),o===0)return;let f=t&&o===1;f&&(d=0),h>100&&(h=100),h===0&&(d=0);let p=()=>new A,m=new A,g=p(),y=p(),v=p(),x,b,w,E,_,S,T,M,C=p(),D=p(),P=p(),I=p(),L=p(),H=p(),U=p(),G=p(),z=n-2*l+.001,V=z/o,$=Math.ceil(a*o),F=$+1,j=z/$,X=-z/2,q=c+1,k=2*Math.PI/c,Z=Math.PI/2/d,Q=.01,K=Math.min((1-h/100)*l,l-Q),W=l-K,ye=0,fe=2,ie=d*fe+fe,we=q*ie/fe,xe=we+q*F,Oe=Math.max(0,q*(F+ie)),[Ie,Pe,_e]=[3,3,2].map(ke=>Array(Oe*ke).fill(0)),Ve=[],ze=s-l;function R(ke,Le){let je=Math.PI/2;S=Le*j,M=2*Math.PI*(S%V)/V+je,S+=X,T=Math.sin(M)*ze,_=Math.cos(M)*ze,t?ke.set(_,T,S):ke.set(_,S,T)}R(m,-1e-10),R(g,0),C.copy(m),R(m,1);let O=m.distanceTo(g),ne=f?0:W+K,ue=O*$+2*ne,me=K,De=ue-ne;for(let ke=0;ke<=$;ke++){R(y,ke),G.subVectors(y,C).normalize(),C.copy(y),H.copy(y).setComponent(+t+1,0).normalize(),U.crossVectors(G,H).normalize();let Le=ke===0,je=ke===$,Je=Le?3*Math.PI/2:Z,St=Le?me:De,Zt=Le?q:xe,On=Le?0:Oe-q,Y=G.clone().multiplyScalar(Le?-W:W).add(y),ce=G.clone().multiplyScalar(Le?-1:1).normalize();for(let ve=0;ve<q;ve++){let Ue=ve*k;if(D.addVectors(m.copy(H).multiplyScalar(l*Math.cos(Ue)),g.copy(U).multiplyScalar(l*Math.sin(Ue))),P.copy(D).normalize(),Le||je){f||(ye=On+ve,[0,1,2].forEach(Be=>{Ie[ye*3+Be]=Y.getComponent(Be),Pe[ye*3+Be]=ce.getComponent(Be)}),_e[ye*2]=+je,_e[ye*2+1]=ve/c),g.copy(P).multiplyScalar(K),v.addVectors(y,g);for(let Be=0;Be<d;Be++){let wt=Be*Z+Je;I.addVectors(m.copy(G).multiplyScalar(W*Math.sin(wt)),g.copy(P).multiplyScalar(W*Math.cos(wt))),L.copy(I).normalize(),g.addVectors(v,I),I.normalize(),ye=Zt+Be*q+ve,[0,1,2].forEach(Sn=>{Ie[ye*3+Sn]=g.getComponent(Sn),Pe[ye*3+Sn]=L.getComponent(Sn)});let Rn=+Le+Math.sin(wt);_e[ye*2]=(St+W*Rn)/ue,_e[ye*2+1]=ve/c}}g.addVectors(y,D),ye=we+ke*q+ve,[0,1,2].forEach(Be=>{Ie[ye*3+Be]=g.getComponent(Be),Pe[ye*3+Be]=P.getComponent(Be)}),_e[ye*2]=(ne+ke*O)/ue,_e[ye*2+1]=ve/c}}let Me=F+2*d+fe,Ee=1,[le,Ke]=[+f,Me-1];for(let ke=le;ke<=Ke-1;ke++){let Le=f&&ke===Ke-1;for(let je=0;je<q-1;je++)x=ke*q+je,b=x+1,w=(Le?je:x)+q,E=(Le?je+1:b)+q,ke===0?Ve.push(b,E,w):ke===Me-2?Ve.push(x,b,w):Ve.push(x,b,w,b,E,w)}this.setIndex(Ve),this.setAttribute("position",new be(Ie,3)),this.setAttribute("normal",new be(Pe,3)),this.setAttribute("uv",new be(_e,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),n=t.radialSegments+1,r=Array.from(this.getIndex().array),s,o,a,l,u=6*(e-1)*t.radialSegments,c=e,h=c===e;for(let d=0;d<t.radialSegments;d++)s=c*n+d,o=s+1,a=(h?d:s)+n,l=(h?d+1:o)+n,r[u++]=s,r[u++]=o,r[u++]=a,r[u++]=o,r[u++]=l,r[u++]=a;return r.length=u,hw.array=r,hw.count=r.length,hw}};var B2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,detail:r,corner:s,cornerSides:o}=i.parameters,a=r===0&&s!==0?new Jf(t*.5,s,o):new Hc(t*.5,r);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...i,type:"IcosahedronGeometry"}})}},Jf=class extends za{constructor(t=1,e=.2,n=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,n),this.type=a}static fromJSON(t){return new Jf(t.radius,t.corner,t.cornerSides)}};var F2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:n}=i.parameters,r=new _o;r.moveTo(t[0].x,t[0].y),r.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new kc(r.extractPoints(n).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...i,type:"LatheGeometry"}})}};var Hs=new se,dw=new mt,qy=new A,Wa=class extends Ht{constructor(){super(),this.uuid=Te.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new $t().getNormalMatrix(t);for(let n=0,r=this.vertices.length;n<r;n++)this.vertices[n].applyMatrix4(t);for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return Hs.makeRotationX(t),this.applyMatrix4(Hs),this}rotateY(t){return Hs.makeRotationY(t),this.applyMatrix4(Hs),this}rotateZ(t){return Hs.makeRotationZ(t),this.applyMatrix4(Hs),this}translate(t,e,n){return Hs.makeTranslation(t,e,n),this.applyMatrix4(Hs),this}scale(t,e,n){return Hs.makeScale(t,e,n),this.applyMatrix4(Hs),this}lookAt(t){return dw.lookAt(t),dw.updateMatrix(),this.applyMatrix4(dw.matrix),this}fromBufferGeometry(t){let e=this,n=t.index!==null?t.index:void 0,r=t.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,o=r.normal,a=r.color,l=r.uv,u=r.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)e.vertices.push(new A().fromBufferAttribute(s,d)),a!==void 0&&e.colors.push(new Fe().fromBufferAttribute(a,d));function c(d,f,p,m){let g=a===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[p].clone()],y=o===void 0?[]:[new A().fromBufferAttribute(o,d),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,p)],v=new wh(d,f,p,y,g,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new B().fromBufferAttribute(l,d),new B().fromBufferAttribute(l,f),new B().fromBufferAttribute(l,p)]),u!==void 0&&e.faceVertexUvs[1].push([new B().fromBufferAttribute(u,d),new B().fromBufferAttribute(u,f),new B().fromBufferAttribute(u,p)])}let h=t.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],p=f.start,m=f.count;for(let g=p,y=p+m;g<y;g+=3)n!==void 0?c(n.getX(g),n.getX(g+1),n.getX(g+2),f.materialIndex):c(g,g+1,g+2,f.materialIndex)}else if(n!==void 0)for(let d=0;d<n.count;d+=3)c(n.getX(d),n.getX(d+1),n.getX(d+2));else for(let d=0;d<s.count;d+=3)c(d,d+1,d+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(qy).negate(),this.translate(qy.x,qy.y,qy.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,n=e===0?1:1/e,r=new se;return r.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let t=new A,e=new A;for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let n=0,r=this.vertices.length;n<r;n++)e[n]=new A;if(t){let n=new A,r=new A;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];n.subVectors(c,u),r.subVectors(l,u),n.cross(r),e[a.a].add(n),e[a.b].add(n),e[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let n=0,r=this.vertices.length;n<r;n++)e[n].normalize();for(let n=0,r=this.faces.length;n<r;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let n=this.faces[t],r=n.vertexNormals;r.length===3?(r[0].copy(n.normal),r[1].copy(n.normal),r[2].copy(n.normal)):(r[0]=n.normal.clone(),r[1]=n.normal.clone(),r[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,o=r.vertexNormals.length;s<o;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let t=new Wa;t.faces=this.faces;for(let e=0,n=this.morphTargets.length;e<n;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new A,c={a:new A,b:new A,c:new A};s.push(u),o.push(c)}}let r=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=r.faceNormals[s],u=r.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let e=0,n=this.faces.length;e<n;e++){let r=this.faces[e];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Tt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ln),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,n=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let r,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,h=t.colors;e!==void 0&&(r=new $t().getNormalMatrix(e));for(let d=0,f=a.length;d<f;d++){let m=a[d].clone();e!==void 0&&m.applyMatrix4(e),o.push(m)}for(let d=0,f=h.length;d<f;d++)c.push(h[d].clone());for(let d=0,f=u.length;d<f;d++){let p=u[d],m,g,y=p.vertexNormals,v=p.vertexColors,x=new wh(p.a+s,p.b+s,p.c+s);x.normal.copy(p.normal),r!==void 0&&x.normal.applyMatrix3(r).normalize();for(let b=0,w=y.length;b<w;b++)m=y[b].clone(),r!==void 0&&m.applyMatrix3(r).normalize(),x.vertexNormals.push(m);x.color.copy(p.color);for(let b=0,w=v.length;b<w;b++)g=v[b],x.vertexColors.push(g.clone());x.materialIndex=p.materialIndex+n,l.push(x)}for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,b=y.length;x<b;x++)v.push(y[x].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},n=[],r=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],h=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[h]===void 0?(e[h]=l,n.push(this.vertices[l]),r[l]=n.length-1):r[l]=r[e[h]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=r[c.a],c.b=r[c.b],c.c=r[c.c];let h=[c.a,c.b,c.c];for(let d=0;d<3;d++)if(h[d]===h[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,h=this.faceVertexUvs.length;c<h;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(t){this.vertices=[];for(let e=0,n=t.length;e<n;e++){let r=t[e];this.vertices.push(new A(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}t.sort(n);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;r&&r.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(r[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let m in p)p[m]!==void 0&&(t[m]=p[m]);return t}let e=[];for(let p=0;p<this.vertices.length;p++){let m=this.vertices[p];e.push(m.x,m.y,m.z)}let n=[],r=[],s={},o=[],a={},l=[],u={};for(let p=0;p<this.faces.length;p++){let m=this.faces[p],g=!0,y=!1,v=this.faceVertexUvs[0][p]!==void 0,x=m.normal.length()>0,b=m.vertexNormals.length>0,w=m.color.r!==1||m.color.g!==1||m.color.b!==1,E=m.vertexColors.length>0,_=0;if(_=c(_,0,0),_=c(_,1,g),_=c(_,2,y),_=c(_,3,v),_=c(_,4,x),_=c(_,5,b),_=c(_,6,w),_=c(_,7,E),n.push(_),n.push(m.a,m.b,m.c),n.push(m.materialIndex),v){let S=this.faceVertexUvs[0][p];n.push(f(S[0]),f(S[1]),f(S[2]))}if(x&&n.push(h(m.normal)),b){let S=m.vertexNormals;n.push(h(S[0]),h(S[1]),h(S[2]))}if(w&&n.push(d(m.color)),E){let S=m.vertexColors;n.push(d(S[0]),d(S[1]),d(S[2]))}}function c(p,m,g){return g?p|1<<m:p&~(1<<m)}function h(p){let m=p.x.toString()+p.y.toString()+p.z.toString();return s[m]!==void 0||(s[m]=r.length/3,r.push(p.x,p.y,p.z)),s[m]}function d(p){let m=p.r.toString()+p.g.toString()+p.b.toString();return a[m]!==void 0||(a[m]=o.length,o.push(p.getHex())),a[m]}function f(p){let m=p.x.toString()+p.y.toString();return u[m]!==void 0||(u[m]=l.length/2,l.push(p.x,p.y)),u[m]}return t.data={},t.data.vertices=e,t.data.normals=r,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=n,t}clone(){return new Wa().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let d=0,f=e.length;d<f;d++)this.vertices.push(e[d].clone());let n=t.colors;for(let d=0,f=n.length;d<f;d++)this.colors.push(n[d].clone());let r=t.faces;for(let d=0,f=r.length;d<f;d++)this.faces.push(r[d].clone());for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,b=y.length;x<b;x++){let w=y[x];v.push(w.clone())}this.faceVertexUvs[d].push(v)}}let s=t.morphTargets;for(let d=0,f=s.length;d<f;d++){let p={};if(p.name=s[d].name,s[d].vertices!==void 0){p.vertices=[];for(let m=0,g=s[d].vertices.length;m<g;m++)p.vertices.push(s[d].vertices[m].clone())}if(s[d].normals!==void 0){p.normals=[];for(let m=0,g=s[d].normals.length;m<g;m++)p.normals.push(s[d].normals[m].clone())}this.morphTargets.push(p)}let o=t.morphNormals;for(let d=0,f=o.length;d<f;d++){let p={};if(o[d].vertexNormals!==void 0){p.vertexNormals=[];for(let m=0,g=o[d].vertexNormals.length;m<g;m++){let y=o[d].vertexNormals[m],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),p.vertexNormals.push(v)}}if(o[d].faceNormals!==void 0){p.faceNormals=[];for(let m=0,g=o[d].faceNormals.length;m<g;m++)p.faceNormals.push(o[d].faceNormals[m].clone())}this.morphNormals.push(p)}let a=t.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=t.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let u=t.lineDistances;for(let d=0,f=u.length;d<f;d++)this.lineDistances.push(u[d]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let h=t.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new fw().fromGeometry(this),e=new Ae,n=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Yy.call(new Ge(n,3),t.vertices)),t.normals.length>0){let r=new Float32Array(t.normals.length*3);e.setAttribute("normal",Yy.call(new Ge(r,3),t.normals))}if(t.colors.length>0){let r=new Float32Array(t.colors.length*3);e.setAttribute("color",k2.call(new Ge(r,3),t.colors))}if(t.uvs.length>0){let r=new Float32Array(t.uvs.length*2);e.setAttribute("uv",U2.call(new Ge(r,2),t.uvs))}if(t.uvs2.length>0){let r=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",U2.call(new Ge(r,2),t.uvs2))}e.groups=t.groups;for(let r in t.morphTargets){let s=[],o=t.morphTargets[r];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new be(u.data.length*3,3);c.name=u.name,s.push(Yy.call(c,u.data))}e.morphAttributes[r]=s}if(t.skinIndices.length>0){let r=new be(t.skinIndices.length*4,4);e.setAttribute("skinIndex",V2.call(r,t.skinIndices))}if(t.skinWeights.length>0){let r=new be(t.skinWeights.length*4,4);e.setAttribute("skinWeight",V2.call(r,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Ae,n=t.geometry;if(t.isPoints||t.isLine){let r=new be(n.vertices.length*3,3),s=new be(n.colors.length*3,3);if(e.setAttribute("position",Yy.call(r,n.vertices)),e.setAttribute("color",k2.call(s,n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new be(n.lineDistances.length,1);e.setAttribute("lineDistance",w6.call(o,n.lineDistances))}n.boundingSphere!==null&&(e.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(e.boundingBox=n.boundingBox.clone())}else t.isMesh&&(e=n.toBufferGeometry());return e}};Wa.prototype.isGeometry=!0;var fw=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],n,r,s,o=t.faces;for(r=0;r<o.length;r++){let a=o[r];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=r*3-n.start,e.push(n)),n={start:r*3,materialIndex:s})}n!==void 0&&(n.count=r*3-n.start,e.push(n)),this.groups=e}fromGeometry(t){let e=t.faces,n=t.vertices,r=t.faceVertexUvs,s=r[0]&&r[0].length>0,o=r[1]&&r[1].length>0,a=t.morphTargets,l=a.length,u;if(l>0){u=[];for(let y=0;y<l;y++)u[y]={name:a[y].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,h=c.length,d;if(h>0){d=[];for(let y=0;y<h;y++)d[y]={name:c[y].name,data:[]};this.morphTargets.normal=d}let f=t.skinIndices,p=t.skinWeights,m=f.length===n.length,g=p.length===n.length;n.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<e.length;y++){let v=e[y];this.vertices.push(n[v.a],n[v.b],n[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let w=v.normal;this.normals.push(w,w,w)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let w=v.color;this.colors.push(w,w,w)}if(s===!0){let w=r[0][y];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new B,new B,new B))}if(o===!0){let w=r[1][y];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new B,new B,new B))}for(let w=0;w<l;w++){let E=a[w].vertices;u[w].data.push(E[v.a],E[v.b],E[v.c])}for(let w=0;w<h;w++){let E=c[w].vertexNormals[y];d[w].data.push(E.a,E.b,E.c)}m&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},wh=class{constructor(t,e,n,r,s,o=0){this.a=t,this.b=e,this.c=n,this.normal=r&&r.isVector3?r:new A,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new Fe,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,n=t.vertexNormals.length;e<n;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,n=t.vertexColors.length;e<n;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function w6(i){return this.array.set(i),this}function k2(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),s=new Fe),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function U2(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),s=new B),t[e++]=s.x,t[e++]=s.y}return this}function Yy(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),s=new A),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function V2(i){let t=this.array,e=0;for(let n=0,r=i.length;n<r;n++){let s=i[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),s=new Xe),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var A6=["a","b","c"];function E6(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function pw(i,t,e){let n=Math.min(i,t),r=Math.max(i,t),s=n+"_"+r;return e.get(s)}function mw(i,t,e,n,r,s){let o=Math.min(i,t),a=Math.max(i,t),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=e[o],h=e[a];u={a:c,b:h,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(r),s[i].edges.push(u),s[t].edges.push(u)}function _6(i,t,e,n){let r,s,o;for(r=0,s=i.length;r<s;r++)e[r]={edges:[]};for(r=0,s=t.length;r<s;r++)o=t[r],mw(o.a,o.b,i,n,o,e),mw(o.b,o.c,i,n,o,e),mw(o.c,o.a,i,n,o,e)}function Xy(i,t,e,n,r){i.push(new wh(t,e,n,void 0,void 0,r))}function Ah(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function Ky(i,t,e,n){i.push([t.clone(),e.clone(),n.clone()])}var Qy=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Ae?t=new Wa().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new A,n,r,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],h=c!==void 0&&c.length>0,d=[],f=new Map;_6(l,u,d,f);let p=[],m,g,y,v,x,b,w;for(let Q of Array.from(f.keys())){for(g=f.get(Q),y=new A,x=3/8,b=1/8,w=g.faces.length,w!=2&&(x=.5,b=0,w!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<w;o++){for(v=g.faces[o],a=0;a<3&&(m=l[E6(v,A6[a])],!(m!==g.a&&m!==g.b));a++);m&&e.add(m)}e.multiplyScalar(b),y.add(e),g.newEdge=p.length,p.push(y)}let E,_,S,T,M,C,D,P=[];for(r=0,s=l.length;r<s;r++){for(C=l[r],M=d[r].edges,n=M.length,n==3?E=3/16:n>3&&(E=3/(8*n)),_=1-n*Number(E),S=E,n<=2&&(n==2?(_=3/4,S=1/8):n==1||n==0),D=C.clone().multiplyScalar(_),e.set(0,0,0),o=0;o<n;o++)T=M[o],m=T.a!==C?T.a:T.b,e.add(m);e.multiplyScalar(Number(S)),D.add(e),P.push(D)}let I=P.concat(p),L=P.length,H,U,G,z=[],V=[],$,F,j,X,q=new B,k=new B,Z=new B;for(r=0,s=u.length;r<s;r++)v=u[r],H=Number(pw(v.a,v.b,f).newEdge)+L,U=Number(pw(v.b,v.c,f).newEdge)+L,G=Number(pw(v.c,v.a,f).newEdge)+L,Xy(z,H,U,G,v.materialIndex),Xy(z,v.a,H,G,v.materialIndex),Xy(z,v.b,U,H,v.materialIndex),Xy(z,v.c,G,U,v.materialIndex),h&&($=c[r],F=$[0],j=$[1],X=$[2],q.set(Ah(F.x,j.x),Ah(F.y,j.y)),k.set(Ah(j.x,X.x),Ah(j.y,X.y)),Z.set(Ah(F.x,X.x),Ah(F.y,X.y)),Ky(V,q,k,Z),Ky(V,F,q,Z),Ky(V,j,k,q),Ky(V,X,Z,k));t.vertices=I,t.faces=z,h&&(t.faceVertexUvs[0]=V)}};var Jn=new A,z2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ae().copy(new sr(100,100,100)),n;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Jn),n={width:Jn.x,height:Jn.y,depth:Jn.z,subdivisions:0}):n=t.parameters;let r={...n,...i.parameters};return{parameters:{width:Math.abs(r.width),height:Math.abs(r.height),depth:Math.abs(r.depth),subdivisions:Math.abs(r.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:n,subdivisions:r}=i.parameters,s=i.geometry??new Ae().copy(new sr(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Jn)):Jn.set(o.width,o.height,o.depth),(t!==Jn.x||e!==Jn.y||n!==Jn.z)&&s.scale(Jn.x===0?1:t/Jn.x,Jn.y===0?1:e/Jn.y,Jn.z===0?1:n/Jn.z);let a=s.originalGeometry;try{r>0?(a===void 0||o?.subdivisions!==r)&&(a===void 0&&(a=s),s=new Qy(r).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete i.geometry,Object.assign(s,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Zc(e).load(i,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(Jn);let o=100/Jn.x;Object.assign(s.parameters,{width:100,height:Jn.y*o,depth:Jn.z*o}),t(this.build(s))})}};var Zy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:n,cornerRadius:r,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5,h=0,d=0,f=2*Math.PI/n;for(let m=0;m<n;m++){let g=f*m,y=h+Math.sin(g)*u,v=d+Math.cos(g)*c;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=r;l.roundness=r,l.update();let p=ti.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...i,type:"PolygonGeometry"}})}};var G2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,radialSegments:r,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=new yw(t*.5,e,r,s,o,a,l);return u.scale(1,1,n/t),Object.assign(u,{userData:{...i,type:"PyramidGeometry"}})}};function $f(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function gw(i,t,e,n,r,s){let o=t.clone().sub(i),a=e.clone().sub(i),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===r){let u=o.add(a).normalize();s.copy(i).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(i),s.addScaledVector(o,r/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function T6(i,t,e){let n=i.clone().sub(t),r=e.clone().sub(t);return n.projectOnVector(r),n.add(t)}var yw=class extends Ae{constructor(t=.5,e=1,n=4,r=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),r=Math.floor(r),a=Math.floor(a);let l=[],u=[],c=[],h=[],d=0,f=e/2,p=Math.PI/n,m=t*Math.cos(Math.PI/n),g=2*Math.PI/n,y=(n-2)*Math.PI/n,v=Math.PI-y,x=new A(0,-f,0),b=new A(0,f,0),w=new B(t,-f),E=new B(m,-f),_=new B(0,b.y).sub(E),S=new B(0,b.y).sub(w),T=new B(_.y,-_.x).normalize(),M=new B(S.y,-S.x).normalize(),D=t*Math.cos(Math.PI/n)*Math.tan((Math.PI-_.angle())/2)-1e-8;o=Math.min(o,D);let P;{let V=new A(T.x,T.y,0),$=new A(Math.cos(g)*V.x,V.y,Math.sin(g)*V.x);P=V.angleTo($)}let I=o/Math.tan((Math.PI-_.angle())/2),L=o/Math.tan((Math.PI-P)/2),H=new A;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),h.push(0,0);let V=d++,$=[],F=w.clone(),j=I/Math.cos(Math.PI/n);F.x-=j;for(let X=0;X<n;X++){let q=X/n*Math.PI*2+p,k=new B(Math.sin(q),Math.cos(q));$f(F,k,H),u.push(H.x,H.y,H.z),c.push(0,-1,0),h.push(0,0),$.push(d++)}for(let X=0;X<$.length;X++)l.push($[X],V,$[(X+1)%$.length])}let U=[];{let V=new A,$=new A,F=new A,j=new A,X=new A,q=new A;for(let k=0;k<n;k++){let Z=k/n*Math.PI*2+p,Q=(k+.5)/n*Math.PI*2+p,K=(k+1)/n*Math.PI*2+p,W=new B(Math.sin(Z),Math.cos(Z)),ye=new B(Math.sin(Q),Math.cos(Q)),fe=new B(Math.sin(K),Math.cos(K));$f(w,W,$),$f(w,fe,F),$f(T,ye,V),gw(b,$,F,L,L,j),u.push(j.x,j.y,j.z),gw($,b,F,L,I,X),u.push(X.x,X.y,X.z),gw(F,$,b,I,L,q),u.push(q.x,q.y,q.z),c.push(V.x,V.y,V.z),c.push(V.x,V.y,V.z),c.push(V.x,V.y,V.z),h.push(0,0),h.push(0,0),h.push(0,0);let ie=d++,we=d++,xe=d++;if(l.push(ie,we,xe),o>0){{let Pe=$.clone().add(F).multiplyScalar(.5),_e=b.clone().sub(Pe).normalize(),ze=x.clone().sub(Pe).normalize().add(_e).normalize().multiplyScalar(-1),R=q.clone().sub(X);G(Pe,R,ze,_.angle())}let Oe,Ie;{let Pe=new A;$f(M,fe,Pe);let _e=q.clone().add(j).multiplyScalar(.5);_e=T6(_e,F,b);let Ve=q.clone().sub(j);[Oe,Ie]=G(_e,Ve,Pe,P,j.y)}{let Pe=Oe,_e=Pe.clone().setY(0).normalize(),Ve=new A(0,-1,0),ze=_e.clone().cross(Ve);z(Pe,_e,Ve,ze)}U.concat(Ie);{let Pe=_.angle(),_e=Math.PI-Pe,Ve=b.clone();Ve.y-=o/Math.sin(Pe-Math.PI/2);let ze=new A,R=[];for(let ne=0;ne<a;ne++){let ue=[],me=Math.PI/2-_e*ne/a,De=Math.cos(me),Me=Math.sin(me),Ee=Q;for(let le=0;le<=ne;le++){let Ke=Math.cos(Ee),ke=Math.sin(Ee);V.x=De*ke,V.y=Me,V.z=De*Ke,ze.copy(Ve).addScaledVector(V,o),u.push(ze.x,ze.y,ze.z),c.push(V.x,V.y,V.z),h.push(0,0),ue.push(d++),Ee+=Math.PI*2/ne/n}R.push(ue)}Ie.reverse(),R.push(Ie);let O=R.length-1;for(let ne=0;ne<O;ne++){let ue=R[ne],me=R[ne+1],De=ue.length-1;l.push(me[1],ue[0],me[0]);for(let Me=1;Me<=De;Me++)l.push(ue[Me],ue[Me-1],me[Me]),l.push(me[Me+1],ue[Me],me[Me])}}}}}this.setIndex(l),this.setAttribute("position",new be(u,3)),this.setAttribute("normal",new be(c,3)),this.setAttribute("uv",new be(h,2));function G(V,$,F,j,X){let q=-j/2,k=(Math.PI-j)/2,Z=$.clone().normalize().cross(F);V.addScaledVector(F,-o/Math.sin(k));let Q=new A,K=new A,W=1,ye=d,fe=[];for(let ie=0;ie<=a;ie++){let we=q+ie/a*j;K.set(0,0,0),K.addScaledVector(Z,Math.sin(we)),K.addScaledVector(F,Math.cos(we));for(let xe=0;xe<=W;xe++){let Oe=xe/W-.5;if(Q.copy(V),Q.addScaledVector($,Oe),Q.addScaledVector(K,o),X!=null){let Ie=Math.max(0,Q.y-X);Q.addScaledVector($,-Ie/$.y)}u.push(Q.x,Q.y,Q.z),c.push(K.x,K.y,K.z),h.push(0,0),xe===0&&fe.push(d),d++}}for(let ie=0;ie<a;ie++)for(let we=0;we<W;we++){let xe=ye+we+(W+1)*ie,Oe=xe+(W+1),Ie=Oe+1,Pe=xe+1;l.push(xe,Oe,Pe),l.push(Oe,Ie,Pe)}return[V.clone().addScaledVector($,.5),fe]}function z(V,$,F,j){let X=Math.PI/2,q=S.angle()-X,k=[],Z=new A,Q=new A;for(let W=0;W<=a;W++){let ye=[],fe=W/a;for(let ie=0;ie<=W;ie++){let xe=((W?ie/W:0)-.5)*v,Oe=Math.cos(xe),Ie=Math.sin(xe),Pe=Math.atan(Math.tan(q)*Oe),_e=(X+Pe)*fe,Ve=Math.cos(_e),ze=Math.sin(_e);Z.set(0,0,0),Z.addScaledVector($,ze*Oe),Z.addScaledVector(F,Ve),Z.addScaledVector(j,ze*Ie),Q.copy(V).addScaledVector(Z,o),u.push(Q.x,Q.y,Q.z),c.push(Z.x,Z.y,Z.z),h.push(0,0),ye.push(d++)}k.push(ye)}let K=k.length-1;for(let W=0;W<K;W++){let ye=k[W],fe=k[W+1],ie=ye.length-1;l.push(ye[0],fe[1],fe[0]);for(let we=1;we<=ie;we++)l.push(ye[we-1],ye[we],fe[we]),l.push(ye[we],fe[we+1],fe[we])}}}};var Jy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),n=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:n}}static build(i){let t=i.shape,{width:e,height:n,cornerRadius:r,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u={x:e*.5,y:n*.5},c={x:-u.x,y:-u.y},h={x:u.x,y:u.y};function d(b,w,E){return w>e&&E>n?Math.min(b*e/w,b*n/E):w>e?b*e/w:E>n?b*n/E:b}let f=[];f[0]=r[0]===0?0:d(r[0],r[0]+r[3],r[0]+r[1]),f[1]=r[1]===0?0:d(r[1],r[1]+r[2],r[1]+r[0]),f[2]=r[2]===0?0:d(r[2],r[2]+r[1],r[2]+r[3]),f[3]=r[3]===0?0:d(r[3],r[3]+r[0],r[3]+r[2]);let p=c.x,m=h.x,g=h.y,y=c.y;t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(p,y)),t.isClosed=!0;let v=!0;for(let b=0,w=t.points.length;b<w;b++)t.points[b].roundness=f[b],b>0&&f[b]!==f[b-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=ti.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...i,type:"RectangleGeometry"}})}};var H2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=Te.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:n=t,widthSegments:r=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=i.parameters,c;return u===0?(c=new Ae,c.setAttribute("position",new be([],3))):c=new Tl(.5*t,r,s,o,a,l,u*Te.DEG2RAD),c.scale(1,e/t,n/t),Object.assign(c,{userData:{...i,type:"SphereGeometry"}})}};var j2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:n=8,heightSegments:r=8}=i.parameters,s=new Ao(t,e,n,r);return s.scale(1,1,1),Object.assign(s,{userData:{...i,type:"PlaneGeometry"}})}};var W2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:n,angle:r,cornerRadius:s,cornerSegments:o}=i.parameters,a=new vw(t,e,n,r,s,o);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},vw=class extends Ae{constructor(t=1,e=1,n=1,r=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),r=Math.min(180-c,r),r*=Math.PI/180;let h=[],d=Math.PI/2,f=(Q=0,K=0,W=0)=>new A(Q,K,W),p=f(),m=f(),[g,y,v]=[e/2,t/2,n/2],x=-y,b=+y,[w,E,_]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],S=(Q,K=!1)=>Math.sin(Q-Math.PI/(1+ +K)),T=(Q,K=!1)=>Math.cos(Q-Math.PI/(1+ +K));_.y=Math.sin(r)*e-g;let M=Math.cos(r)*e-v,C=w.z-c;r<=d?(_.z=Math.min(M,C),_.z==C&&(_.y-=(M-C)/Math.tan(d-r))):E.z=Math.min(E.z-M-v,w.z-c),p.subVectors(w,E),m.subVectors(_,E);let D=Math.min(p.length(),m.length())*s/100,P=D*Math.tan(r/2),I=D/Math.cos(r/2),L=p.clone().normalize().add(m.normalize()).setLength(I).add(E);p.set(0,S(r,!0),T(r,!0)),h.push([_,p.clone()]);let H=(Math.PI-r)/o;for(let Q=0;Q<=o;Q++){let K=d+r+Q*H;p.set(0,Math.sin(K)*P,Math.cos(K)*P),p.add(L),m.set(0,S(K),T(K)),h.push([p.clone(),m.clone()])}h.push([w,f(0,1,0)]);let U=Math.sin(H/2)*P*2,G=h.length-1,z=h[0][0].distanceTo(h[1][0]),V=h[G-1][0].distanceTo(h[G][0]),$=z+U*o+V;h[0].push(1);for(let Q=0;Q<=o;Q++)h[Q+1].push(1-(z+Q*U)/$);h[G].push(0);let[F,j,X]=h[0],q,k,Z;for(let Q=1;Q<h.length;Q++)[q,k,Z]=h[Q],a.push(x,F.y,F.z,x,q.y,q.z,b,F.y,F.z,b,F.y,F.z,x,q.y,q.z,b,q.y,q.z),l.push(0,j.y,j.z,0,k.y,k.z,0,j.y,j.z,0,j.y,j.z,0,k.y,k.z,0,k.y,k.z),u.push(0,X,0,Z,1,X,1,X,0,Z,1,Z),[F,j,X]=[q,k,Z];this.setAttribute("position",new be(a,3)),this.setAttribute("normal",new be(l,3)),this.setAttribute("uv",new be(u,2))}};var $y=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:n,spikes:r,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=i.parameters,c=i.shape,h=t*.5,d=e*.5,f=0,p=0,m=o*Math.PI/360/r,g=Math.PI/2*3*-1,y=h*n/100,v=d*n/100;if(r===3&&n===50){m=2*Math.PI/r;for(let b=0;b<r;b++){let w=m*b,E=f+Math.sin(w)*h,_=p+Math.cos(w)*d;c.addPoint(c.createPoint(E,_))}}else for(let b=0;b<r;b++){let w=f+Math.cos(g)*h,E=p+Math.sin(g)*d;c.addPoint(c.createPoint(w,E)),g+=m,w=f+Math.cos(g)*y,E=p+Math.sin(g)*v,b<=r,c.addPoint(c.createPoint(w,E)),g+=m}c.isClosed=!0;for(let b=0,w=c.points.length;b<w;b++)c.points[b].roundness=s;c.roundness=s,c.update();let x=ti.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...i,type:"StarGeometry"}})}};var q2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,n=new Ao(t,e);return Object.assign(n,{userData:{...i,type:"TextFrameGeometry"}})}};var Y2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:n,height:r,depth:s})}}static build(i){let{width:t,height:e,depth:n,radialSegments:r,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=M6(t,e,n,t*.5,o,s,0,0,r,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...i,type:"TorusGeometry"}})}};function M6(i,t,e,n,r,s,o,a,l,u,c){[t,e]=[e,t],o=t/2;let h=Te.clamp(r/360,0,1);if(h===0){let d=new Ae;return d.setAttribute("position",new be([],3)),d}return h===1&&(u=0),new Zf(!0,i,t,e,n,h,s,o,a,l,u,c)}var X2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:n,radialSegments:r,p:s,q:o}=i.parameters,a=t*.5;a!==e&&(a-=e);let l=new jc(a,e,n,r,s,o);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var K2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Pt?i.shape:new Pt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:n,depth:r,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5;a?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=n;l.roundness=n,l.update();let h=ti.create({shape:l,parameters:{roundness:n,depth:r,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...i,type:"TriangleGeometry"}})}};function Q2(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}var xw=class{add(t,e,n){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(r){this[r]=this[r]||[],e&&this[r][n?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(n){n.call(e&&e.context?e.context:e,e)})}},bw=class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(e=>{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}},ae=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+ae.version}static addUnaryOp(t){return ae.max_unop_len=Math.max(t.length,ae.max_unop_len),ae.unary_ops[t]=1,ae}static addBinaryOp(t,e,n){return ae.max_binop_len=Math.max(t.length,ae.max_binop_len),ae.binary_ops[t]=e,n?ae.right_associative.add(t):ae.right_associative.delete(t),ae}static addIdentifierChar(t){return ae.additional_identifier_chars.add(t),ae}static addLiteral(t,e){return ae.literals[t]=e,ae}static removeUnaryOp(t){return delete ae.unary_ops[t],t.length===ae.max_unop_len&&(ae.max_unop_len=ae.getMaxKeyLen(ae.unary_ops)),ae}static removeAllUnaryOps(){return ae.unary_ops={},ae.max_unop_len=0,ae}static removeIdentifierChar(t){return ae.additional_identifier_chars.delete(t),ae}static removeBinaryOp(t){return delete ae.binary_ops[t],t.length===ae.max_binop_len&&(ae.max_binop_len=ae.getMaxKeyLen(ae.binary_ops)),ae.right_associative.delete(t),ae}static removeAllBinaryOps(){return ae.binary_ops={},ae.max_binop_len=0,ae}static removeLiteral(t){return delete ae.literals[t],ae}static removeAllLiterals(){return ae.literals={},ae}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new ae(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(e=>e.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return ae.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!ae.binary_ops[String.fromCharCode(t)]||ae.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return ae.isIdentifierStart(t)||ae.isDecimalDigit(t)}throwError(t){let e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(ae.hooks[t]){let n={context:this,node:e};return ae.hooks.run(t,n),n.node}return e}searchHook(t){if(ae.hooks[t]){let e={context:this};return ae.hooks[t].find(function(n){return n.call(e.context,e),e.node}),e.node}}gobbleSpaces(){let t=this.code;for(;t===ae.SPACE_CODE||t===ae.TAB_CODE||t===ae.LF_CODE||t===ae.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),e=t.length===1?t[0]:{type:ae.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e=[],n,r;for(;this.index<this.expr.length;)if(n=this.code,n===ae.SEMCOL_CODE||n===ae.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())e.push(r);else if(this.index<this.expr.length){if(n===t)break;this.throwError('Unexpected "'+this.char+'"')}return e}gobbleExpression(){let t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,ae.max_binop_len),e=t.length;for(;e>0;){if(ae.binary_ops.hasOwnProperty(t)&&(!ae.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!ae.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=e,t;t=t.substr(0,--e)}return!1}gobbleBinaryExpression(){let t,e,n,r,s,o,a,l,u;if(o=this.gobbleToken(),!o||(e=this.gobbleBinaryOp(),!e))return o;for(s={value:e,prec:ae.binaryPrecedence(e),right_a:ae.right_associative.has(e)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+e),r=[o,s,a];e=this.gobbleBinaryOp();){if(n=ae.binaryPrecedence(e),n===0){this.index-=e.length;break}s={value:e,prec:n,right_a:ae.right_associative.has(e)},u=e;let c=h=>s.right_a&&h.right_a?n>h.prec:n<=h.prec;for(;r.length>2&&c(r[r.length-2]);)a=r.pop(),e=r.pop().value,o=r.pop(),t={type:ae.BINARY_EXP,operator:e,left:o,right:a},r.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+u),r.push(s,t)}for(l=r.length-1,t=r[l];l>1;)t={type:ae.BINARY_EXP,operator:r[l-1].value,left:r[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,n,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(t=this.code,ae.isDecimalDigit(t)||t===ae.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===ae.SQUOTE_CODE||t===ae.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(t===ae.OBRACK_CODE)r=this.gobbleArray();else{for(e=this.expr.substr(this.index,ae.max_unop_len),n=e.length;n>0;){if(ae.unary_ops.hasOwnProperty(e)&&(!ae.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!ae.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=n;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:ae.UNARY_EXP,operator:e,argument:s,prefix:!0})}e=e.substr(0,--n)}ae.isIdentifierStart(t)?(r=this.gobbleIdentifier(),ae.literals.hasOwnProperty(r.name)?r={type:ae.LITERAL,value:ae.literals[r.name],raw:r.name}:r.name===ae.this_str&&(r={type:ae.THIS_EXP})):t===ae.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let e=this.code;for(;e===ae.PERIOD_CODE||e===ae.OBRACK_CODE||e===ae.OPAREN_CODE||e===ae.QUMARK_CODE;){let n;if(e===ae.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==ae.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),e=this.code}this.index++,e===ae.OBRACK_CODE?(t={type:ae.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},this.gobbleSpaces(),e=this.code,e!==ae.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):e===ae.OPAREN_CODE?t={type:ae.CALL_EXP,arguments:this.gobbleArguments(ae.CPAREN_CODE),callee:t}:(e===ae.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:ae.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t="",e,n;for(;ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(this.code===ae.PERIOD_CODE)for(t+=this.expr.charAt(this.index++);ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(e=this.char,e==="e"||e==="E"){for(t+=this.expr.charAt(this.index++),e=this.char,(e==="+"||e==="-")&&(t+=this.expr.charAt(this.index++));ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);ae.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+t+this.char+")")}return n=this.code,ae.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(n===ae.PERIOD_CODE||t.length===1&&t.charCodeAt(0)===ae.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:ae.LITERAL,value:parseFloat(t),raw:t}}gobbleStringLiteral(){let t="",e=this.index,n=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===n){r=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":t+=`
|
|
3139
|
+
`;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=s}else t+=s}return r||this.throwError('Unclosed quote after "'+t+'"'),{type:ae.LITERAL,value:t,raw:this.expr.substring(e,this.index)}}gobbleIdentifier(){let t=this.code,e=this.index;for(ae.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,ae.isIdentifierPart(t));)this.index++;return{type:ae.IDENTIFIER,name:this.expr.slice(e,this.index)}}gobbleArguments(t){let e=[],n=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===t){n=!0,this.index++,t===ae.CPAREN_CODE&&r&&r>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(s===ae.COMMA_CODE){if(this.index++,r++,r!==e.length){if(t===ae.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===ae.CBRACK_CODE)for(let o=e.length;o<r;o++)e.push(null)}}else if(e.length!==r&&r!==0)this.throwError("Expected comma");else{let o=this.gobbleExpression();(!o||o.type===ae.COMPOUND)&&this.throwError("Expected comma"),e.push(o)}}return n||this.throwError("Expected "+String.fromCharCode(t)),e}gobbleGroup(){this.index++;let t=this.gobbleExpressions(ae.CPAREN_CODE);if(this.code===ae.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:ae.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:ae.ARRAY_EXP,elements:this.gobbleArguments(ae.CBRACK_CODE)}}},C6=new xw;Object.assign(ae,{hooks:C6,plugins:new bw(ae),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});ae.max_unop_len=ae.getMaxKeyLen(ae.unary_ops);ae.max_binop_len=ae.getMaxKeyLen(ae.binary_ops);var Wl=i=>new ae(i).parse(),P6=Object.getOwnPropertyNames(ae);P6.forEach(i=>{Wl[i]===void 0&&i!=="prototype"&&(Wl[i]=ae[i])});Wl.Jsep=ae;var D6="ConditionalExpression",I6={name:"ternary",init(i){i.hooks.add("after-expression",function(e){if(e.node&&this.code===i.QUMARK_CODE){this.index++;let n=e.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===i.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),e.node={type:D6,test:n,consequent:r,alternate:s},n.operator&&i.binary_ops[n.operator]<=.9){let o=n;for(;o.right.operator&&i.binary_ops[o.right.operator]<=.9;)o=o.right;e.node.test=o.right,o.right=e.node,e.node=n}}else this.throwError("Expected :")}})}};Wl.plugins.register(I6);var O6=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],R6=["0","1","2","3","4","5","6","7","8","9","."],L6=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function N6(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}Wl.addBinaryOp("^",11,!0);function ev(i,t,e="number"){let n="";for(let o=0;o<i.length;o++){let a=i[o];if("id"in a){let l=i[o-1];if(o>0&&"id"in l){console.error("Two variables in a row",i);return}let u=t.getVariable(a.id),c=Hr.getDisplayedValue(u);e==="number"&&Hr.isTextValue(u)&&Array.isArray(u.textValue)&&u.textValue.length===1?c=parseFloat(c).toString():e==="boolean"&&Hr.isBoolean(u)?c=u?"true":"false":e==="boolean"&&Hr.isTextValue(u)&&!Array.isArray(u.textValue)&&(c='"'+c+'"'),n+=c;continue}else if(e==="string"){a.name!=='"'&&a.name!=="+"&&(n+=a.name),a.name==="+"&&n[n.length-1]==="\\"&&(n=n.slice(0,-1)+a.name);continue}if(a.name==="and"){n+="&&";continue}if(a.name==="or"){n+="||";continue}if(a.name==="True"){n+="true";continue}if(a.name==="False"){n+="false";continue}if(e==="boolean"&&!N6(a.name)&&!R6.includes(a.name)&&!O6.includes(a.name)&&!L6.includes(a.name.replace(/\($/g,""))){n+='"'+a.name+'"';continue}n+=a.name}if(e==="string")return n;if(i.length===0){if(e==="number")return 0;if(e==="boolean")return!1}let r;try{r=Wl(n)}catch(o){console.error(n,o);return}let s;try{s=Mt(r)}catch(o){console.error(n,r,o)}return s}function Mt(i){switch(i.type){case"BinaryExpression":switch(i.operator){case"==":return Number(Mt(i.left)===Mt(i.right));case"!=":return Number(Mt(i.left)!==Mt(i.right));case">":return Number(Mt(i.left)>Mt(i.right));case">=":return Number(Mt(i.left)>=Mt(i.right));case"<":return Number(Mt(i.left)<Mt(i.right));case"<=":return Number(Mt(i.left)<=Mt(i.right));case"+":return Mt(i.left)+Mt(i.right);case"-":return Mt(i.left)-Mt(i.right);case"*":return Mt(i.left)*Mt(i.right);case"/":return Mt(i.left)/Mt(i.right);case"%":return Mt(i.left)%Mt(i.right);case"&&":return Mt(i.left)&&Mt(i.right);case"||":return Mt(i.left)||Mt(i.right);case"^":return Math.pow(Mt(i.left),Mt(i.right));default:throw new Error("Unknown operator: "+i.operator)}case"UnaryExpression":switch(i.operator){case"-":return-Mt(i.argument);case"!":return Number(!Mt(i.argument));default:throw new Error("Unknown operator: "+i.operator)}case"Identifier":throw new Error("Unknown identifier: "+i.name);case"Literal":return i.value;case"CallExpression":if(i.callee.type==="Identifier"){if(i.callee.name==="random"){let t=0,e=1;if(i.arguments.length>=1)try{t=Mt(i.arguments[0])}catch(n){console.warn(n)}if(i.arguments.length>=2)try{e=Mt(i.arguments[1])}catch(n){console.warn(n)}return t=Math.min(e,t),e=Math.max(e,t),t+Math.random()*(e-t)}return Math[i.callee.name].apply(null,i.arguments.map(Mt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+i.type)}}var B6=new se,F6=new se;function k6(i,t,e){let n=[new A,new A,new A],r=[new A,new A,new A];return i.extractBasis(n[0],n[1],n[2]),t.extractBasis(r[0],r[1],r[2]),n.forEach((s,o)=>{let a=r[o],l=Te.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new se().makeBasis(n[0],n[1],n[2])}var Z2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),n=Math.abs(e.width),r=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??Sh.create({parameters:gS}).userData.shape;return{path:i.path??Uu.defaultData(),parameters:Object.assign(e,{width:n,height:r,depth:s,extrusion:{...gy,...e.extrusion}}),shapeData:o}}static build(i){if(i.path.points.length>=2){let e=new Sw(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ae,{userData:{...i,type:"PathGeometry"}})}},Sw=class extends Ae{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)||!Q2(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let n=this._computeBasisMatrices(e),{depth:r,offset:s}=this.inputs.parameters.extrusion,o=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(s*o),l=this.inputs.path.isClosed?Math.ceil((r+s)*o):Math.ceil(Math.min(1,r+s)*o),u=Math.min(Math.max(2,l-a+1),o+2),c=[],h=[];for(let z=0;z<u;z++){let V=this.inputs.path.isClosed?(z+a)%e.length:Math.min(z+a,e.length-1);c.push(e[V].clone()),h.push(n[V].clone())}let d=(z,V,$)=>{c[z]=c[z].clone().lerp(c[V],$),h[z]=k6(h[z],h[V],$)},f=0,p=s*o%1;(!this.inputs.path.isClosed||r<=1)&&(p||s===0)&&(f=p,d(0,1,f));let m=0,g=(s+r)*o%1;if((this.inputs.path.isClosed&&r<=1||!this.inputs.path.isClosed&&s+r<1)&&g&&(m=g,d(c.length-1,c.length-2,1-m)),r===0){let z=c.length-1;c[z].copy(c[0]),h[z].copy(h[0])}this._applyPathModifiers(h,f,m);let{bevel:y,bevelSides:v}=this.inputs.parameters.extrusion,x=y>0?this.inputs.parameters.extrusion.capType:"flat",b=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(b=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:w,infos:E,vertices:_}=this._computeShapePoints(b),S=0,T;x==="round"&&(T=new ja(this.inputs.shapeData,2*y,y,b,v,void 0,!0),S=T.getAttribute("position").count);let M=0,C=0;E.sort((z,V)=>z.start-V.start),E.forEach(z=>{z.verticesStart=M,z.verticesCount=z.continuous.reduce((V,$,F)=>V+(F===0||!$?2:1),0),C+=z.verticesCount,M=C});let D=C*u,P,I=0;if(this._isOpenEnded()&&x==="flat"){try{P=as({windingRule:xt.ODD,elementType:mn.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:w})}catch{P=uw}I=P.vertexCount}let L=D+2*I+S*2,H=D+2*I,U={positions:new Float32Array(L*3),normals:new Float32Array(L*3),uvs:new Float32Array(L*2)},G=[];if(E.forEach(z=>{this._extrudeRegion(z,_,h,c,U,G,this._isGeometryClosed()&&!this._isOpenEnded())}),P&&(this._closeEnd(P,D,G,U,h[0],c[0],!1),this._closeEnd(P,D+I,G,U,h[h.length-1],c[c.length-1],!0)),T){U.positions.set(T.getAttribute("position").array,H*3),U.normals.set(T.getAttribute("normal").array,H*3),U.uvs.set(T.getAttribute("uv").array,H*2);let z=G.length;G.push(...T.getIndex().array.map(F=>F+H)),H+=S,U.positions.set(T.getAttribute("position").array,H*3),U.normals.set(T.getAttribute("normal").array,H*3),U.uvs.set(T.getAttribute("uv").array,H*2);let V=G.length;G.push(...T.getIndex().array.map(F=>F+H)),this.setAttribute("position",new Ge(U.positions,3)),this.setAttribute("normal",new Ge(U.normals,3)),this.setAttribute("uv",new Ge(U.uvs,2)),this.setIndex(G);let $=B6;$.copy(h[h.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange($,H,L),$.copy(h[0]).setPosition(c[0]).multiply(F6.makeScale(1,1,-1)),this.applyMatrix4OnRange($,H-S,H),this.reverseIndicesOnRange(z,V)}else this.setAttribute("position",new Ge(U.positions,3)),this.setAttribute("normal",new Ge(U.normals,3)),this.setAttribute("uv",new Ge(U.uvs,2)),this.setIndex(G)}_extractPathPoints(){let n=Uy(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(n.length<2)return[];let r=[n[0]];return n.forEach(o=>{r[r.length-1].distanceToSquared(o)>.001&&r.push(o)}),this.inputs.path.isClosed&&r[r.length-1].distanceTo(r[0])<.001&&r.pop(),r}_computeBasisMatrices(e){let n=[],r=e.length,s=this.inputs.path.isClosed,o=new A,a=new A,l=new A,u=new A,c=new A(0,1,0);for(let g=0;g<r;g++){let y=e[g],v;g===0?v=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):v=e[g-1];let x;g===r-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[g-1]):x=e[g+1];let b=y.clone().sub(v).normalize(),w=x.clone().sub(y).normalize(),E=b.clone().add(w).normalize();l.copy(E),g===0&&(E.equals(c)||E.clone().negate().equals(c))&&c.set(0,0,1);let _=c.clone().cross(E).normalize(),S=E.clone().cross(_).normalize();c.copy(S),u.copy(_),g===0&&(o.copy(S),a.copy(E));let T=new se().makeBasis(_,S,E);n.push(T)}let h=s?a:l,d=s?o:new A(0,1,0),f=h.clone().cross(u).normalize(),p=Math.acos(d.dot(f));if(isNaN(p))return n;let m=d.clone().cross(f);h.dot(m)>0&&(p*=-1);for(let g=1;g<n.length;g++){let y=new se().makeRotationZ(p*g/n.length);n[g].multiply(y)}return n}_applyPathModifiers(e,n,r){let s=e.length,{angle:o,twist:a,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new se,h=new se;return e.forEach((d,f)=>{let p=f===0?0:f===s-1?1:(f-n)/(s-(r===0?0:1)-(n+(1-r)));c.makeRotationZ(Te.lerp(o,o+a,p)*Te.DEG2RAD);let m=Te.lerp(l,u,p);h.makeScale(m,m,m),d.multiply(c).multiply(h)}),e}_computeShapePoints(e=12,n=xt.ODD){let r=this.inputs.shapeData,s=r.extractShapePointsToFlatArray([],e),o=r.shapeHoles.map(m=>{let g=m.extractShapePointsToFlatArray([],e),y=[];for(let v=g.length-1;v>=1;v-=2){let x=g[v-1],b=g[v-0];y.push(x,b)}return y}),a;try{a=as({windingRule:n,elementType:mn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=Qf}let l;try{l=as({windingRule:xt.ODD,elementType:mn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=cw}if(!a)throw new Error("error generating geometry");let u=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let g=l.elements[m],y=m%2===0?a.vertexCount:0;a.elements.push(g+y)}for(let m=0;m<l.vertexIndices.length;m++){let g=l.vertexIndices[m],y=a.vertexCount;a.vertexIndices.push(g+y)}for(let m=0;m<l.vertices.length;m++){let g=l.vertices[m];a.vertices.push(g)}}let c=1/0,h=-1/0,d=1/0,f=-1/0;for(let m=0,g=a.vertexCount;m<g;m++){let y=m*2,v=a.vertices[y+0],x=a.vertices[y+1];v<c&&(c=v),v>h&&(h=v),x<d&&(d=x),x>f&&(f=x)}let p=[];for(let m=a.elementCount-1;m>=0;m--){let g=m>=u,y=m*2,v=a.elements[y+0],x=a.elements[y+1],b=v+x,w={start:v,count:x,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};p.push(w);let E=v,_=b-1,S=v+1,T=r.roundedCurves.length;do{let M=E-v,C=a.vertices[_*2+0],D=a.vertices[_*2+1],P=a.vertices[E*2+0],I=a.vertices[E*2+1],L=a.vertices[S*2+0],H=a.vertices[S*2+1],U=P-C,G=I-D,z=Math.sqrt(U*U+G*G);U/=z,G/=z;let V=P-L,$=I-H,F=Math.sqrt(V*V+$*$);V/=F,$/=F,w.normals[M*2+0]=-$,w.normals[M*2+1]=V;let j=a.vertexIndices[E];if(Array.isArray(j))w.continuous[M]=!1;else{let[X,q]=r.getCurveIndexFromVertexId(j-1,!0);if(q>0&&q<1)w.continuous[M]=!0;else{let k=q===1?X+1:X-1;k=(k+T)%T;let Z=q===1?0:1,Q=r.roundedCurves[X].getTangent(q),K=r.roundedCurves[k].getTangent(Z);w.continuous[M]=Q.dot(K)>.95}}g&&(w.normals[M*2+0]*=-1,w.normals[M*2+1]*=-1),[_,E,S]=[E,S,S+1],S>=b&&(S-=x)}while(S!==v+1)}return{regions:[s,...o],infos:p,vertices:a.vertices}}_insertVertex(e,n,r,s,o){let a=n*2,l=n*3;e.positions[l+0]=r.x,e.positions[l+1]=r.y,e.positions[l+2]=r.z,e.normals[l+0]=s.x,e.normals[l+1]=s.y,e.normals[l+2]=s.z,e.uvs[a+0]=o.x,e.uvs[a+1]=o.y}_extrudeRegion(e,n,r,s,o,a,l){let u=new A,c=new A,h=new A,d=new A,f=new B;r.forEach((m,g)=>{let y=s[g],v=e.verticesStart*r.length+e.verticesCount*g;for(let x=0;x<e.count;x++){let b=(e.start+x)*2;if(u.set(n[b+0],n[b+1],0),h.copy(u).applyMatrix4(m).add(y),e.continuous[x])d.set(e.normals[x*2+0],e.normals[x*2+1],0);else{let w=x===0?(e.start+e.count-1)*2:b-2;c.set(n[w+0],n[w+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(m).normalize(),f.set(x===0?1:x/e.count,g/(r.length-1)),this._insertVertex(o,v,h,d,f),v++,!e.continuous[x]||x===0){if(x===0)d.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,g/(r.length-1));else{let w=x===e.count-1?e.start*2:b+2;c.set(n[w+0],n[w+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(m).normalize(),this._insertVertex(o,v,h,d,f),v++}}});let p=r.length-1;for(let m=0;m<p;m++){let g=e.verticesStart*r.length+e.verticesCount*m,y=e.verticesStart*r.length+e.verticesCount*(m+1),v=0;for(let x=0;x<e.count;x++){(!e.continuous[x]||x===0)&&v++;let b=x===e.count-1?0:v+1,w=g+v,E=g+b,_=y+b,S=y+v;e.isHole?a.push(w,_,E,w,S,_):a.push(w,E,_,w,_,S),v++}}}_closeEnd(e,n,r,s,o,a,l){let u=e.vertexCount,c=new A(0,0,l?-1:1).applyMatrix4(o),h=new A,d=new B;for(let p=0;p<u;p++){let m=2*p;h.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(o).add(a),this._insertVertex(s,n+p,h,c,d)}let f=e.elements;for(let p=0;p<e.elementCount;p++){let m=3*p,g=f[m+0]+n,y=f[m+(l?1:2)]+n,v=f[m+(l?2:1)]+n;r.push(g,y,v)}}applyMatrix4OnRange(e,n,r){let s=e.elements,o=new $t().getNormalMatrix(e).elements,a,l,u,c,h=this.attributes.position,d=this.attributes.normal;if(!h||!d)return;let f=h.array,p=d.array,m=h.itemSize;for(let g=n*m,y=r*m;g<y;g+=m){if(g===n)debugger;a=f[g+0],l=f[g+1],u=f[g+2],c=1/(s[3]*a+s[7]*l+s[11]*u+s[15]),f[g+0]=(s[0]*a+s[4]*l+s[8]*u+s[12])*c,f[g+1]=(s[1]*a+s[5]*l+s[9]*u+s[13])*c,f[g+2]=(s[2]*a+s[6]*l+s[10]*u+s[14])*c,a=p[g+0],l=p[g+1],u=p[g+2],p[g+0]=o[0]*a+o[3]*l+o[6]*u,p[g+1]=o[1]*a+o[4]*l+o[7]*u,p[g+2]=o[2]*a+o[5]*l+o[8]*u}h.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,n){let r=this.index;if(r){for(let s=e;s<n;s+=3){let o=r.getX(s),a=r.getX(s+1),l=r.getX(s+2);r.setXYZ(s,l,a,o)}r.needsUpdate=!0}}};function J2(){let i=new Ae;return i.setAttribute("position",new Ge(new Float32Array([]),3)),i.setIndex(new Ge(new Uint16Array([]),1)),i}var U6=J2().attributes,V6=12,z6=1,Eh=class extends Ae{constructor(e,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,U6),this.userData={parameters:e,type:"TextGeometry"};let r=n.getFont(e.font);r?.isLoaded?(this.font=r,this.update(e)):this.updateFont(e.font,n).then(()=>{this.update(e),n?.requestRender()})}async updateFont(e,n){let r=n.getFont(e);r&&(this.font=r,await r.loadingPromise)}update(e){let n=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!n?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:r,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=e,h=Hr.getDisplayedValue(u),d=c===2?h.toUpperCase():c===3?h.toLowerCase():h,f=G6(e,n,d),{shapes:p,charWidths:m,charCoords:g}=n.generateShapes(f,e),y=(typeof r=="number"?r:1)*.5,v=(typeof s=="number"?s:1)*.5,x=p.map(E=>new Pt().fromShape(E));this.vectorShapes=x;let b=x.map(E=>ti.create({shape:E,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?xt.NONZERO:xt.ODD,subdivisions:this.isLowResolution&&o>0?z6:V6}})),w=b.length?rs(b):J2();w.translate(-y,v,0),this.dispose(),this.wrappedText=f,this.charCoords=g,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([E,_])=>{this.setAttribute(E,_)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=Qr(new Ae,Eh.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([n,r])=>{this.setAttribute(n,r)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function G6(i,t,e){let n=[""],r="";for(let s of e)r+=s,s===" "||s===`
|
|
3140
3140
|
`?(n[n.length-1]+=r,r="",s===`
|
|
3141
|
-
`&&n.push("")):t.getTextWidth(n[n.length-1]+r,i)>i.width&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+r,i)>i.width&&(r.length===1?(n[n.length-1]+=r,r=""):(n[n.length-1]+=r.slice(0,-1),r=r[r.length-1],n.push(""))));return n[n.length-1]+=r,n}var eD,_h=new Promise(i=>{eD=i}),$2=!1;var tv;function tD(){if($2)return;if(tv)return tv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.458/build",r=import("./process.js"),[s,o]=await Promise.all([r,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});eD(l),$2=!0}return tv=i(),tv}function ql(i,t,e,n){let r,s,o;i.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(i)),o=[[],["extrusion"]]):(s={...i},o=[[]]);for(let u of o){let c=s;for(let h of u)c=c[h];for(r in c){let h=c[r];cP(h)&&(c[r]=t.getVariable(h,[n.uuid,"geometry",...u,r]))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let u=Pt.createFromState(s.shape,s.width,s.height);a.shape=u}else if(s.type==="NonParametricGeometry")s.data.groups&&s.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),a.geometry=new Zc().parse(s);else if(s.type==="SubdivGeometry"){let u=new Mn(s,e);return u.data=i,u}else if(s.type==="TextGeometry")return new Eh(s,t);let l;try{l=ww(a)}catch(u){console.error(u)}if(!l){let u=Pt.createFromState(ku.defaultData(),100,100);a.shape=u,l=ww(a)}return l}var H6=new se;function ep(i,t,e,n){let r=i.position.array,s=i.normal.array,o=H6.makeScale(t,e,n).invert().elements,a,l,u;for(var c=0,h=r.length;c<h;c+=3)r[c]*=t,r[c+1]*=e,r[c+2]*=n,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var nv=new Tt,Th=new A,et;_h.then(i=>{et=i});var nD=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),rD=new Uint32Array([0,1,2,3]),iD=new Uint8Array([4]),Mn=class extends Ae{constructor(e,n){super();this.data=e;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,n){this.freeSubdivPointer();let r=this.data.scaleBaked,s=Ns.div(n,r);this.subdividedGeometry&&ep(this.subdividedGeometry.attributes,...s),this.originalGeometry&&ep(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(Th.fromArray(s));let a=Th.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,n,r;try{({originalGeometry:e,subdividedGeometry:n,subdivPointer:r}=Mn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new sr(100,100,100),r=0}this.subdivPointer=r,this.originalGeometry=e,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Mn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new ln,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,r=e.boundingSphere.center;nv.setFromBufferAttribute(n),nv.getCenter(r),e.boundingSphere.radius=r.distanceTo(nv.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),nv.getSize(Th);let s={width:Th.x,height:Th.y,depth:Th.z};return this.userData.parameters=s,s}static build(e,n,r,s){let o,a,l,u=e?.phongAngle??35;r===!1&&(u=-1),n&&(et.free_bvh(n),et.free_subdivision_surface(n));try{o=Mn.allocate(e,s)}catch(c){console.error(c,e),o=Mn.allocate({positionWASM:nD,indexWASM:rD,verticesPerFaceWASM:iD},s)}if(et.set_destination_refinement_level(o,0),a=Mn.buildLevel(o,!0,u),e.subdivisions>0)try{et.set_destination_refinement_level(o,e.subdivisions),l=Mn.buildLevel(o,!1,u)}catch{try{et.set_destination_refinement_level(o,e.subdivisions-1),l=Mn.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,n,r){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s=e.shape!==void 0||e.path!==void 0?n.geometry:ql(e,r,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,u,c;({positions:a,triIndices:c}=Yl(s.getAttribute("position"),o));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;h=[d,f]}return{indices:l,verticesPerFace:u}=Tw(a,c,s,h),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,n){let r,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(r=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(r=nD,s=rD,o=iD);let u=r.length,c=s.length,h=o.length,d=r.length+a.length+l.length,f=s.length+o.length,p=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=et._malloc(p),v=new Float32Array(et.HEAPF32.buffer,y,d),x=new Uint32Array(et.HEAPU32.buffer,y+m,f);v.set(r,0),v.set(a,r.length),v.set(l,r.length+a.length),x.set(s,0),x.set(o,s.length);let b;e?.scaleBaked?.some(E=>E!==1)&&(b=new se().makeScale(...e.scaleBaked)),n&&(b?b.premultiply(n):b=n);let w=b?et.alloc_subdivision_surface2(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h,b.elements):et.alloc_subdivision_surface(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return et._free(y),w}static buildLevel(e,n,r,s,o){let a=o?et.get_mesh_data2(e,n?et.Level.CONTROL:et.Level.REFINED,r,o.elements):et.get_mesh_data(e,n?et.Level.CONTROL:et.Level.REFINED,r),l=8,u=et.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),h=0,d=et.HEAPU32[u[h]>>2],f=et.HEAPF32.subarray(d>>2,(d>>2)+c[h]);h++;let p=et.HEAPU32[u[h]>>2],m=et.HEAPF32.subarray(p>>2,(p>>2)+c[h]);h++;let g=et.HEAPU32[u[h]>>2],y=et.HEAPU32.subarray(g>>2,(g>>2)+c[h]);h++;let v=et.HEAPU32[u[h]>>2],x=et.HEAPU32.subarray(v>>2,(v>>2)+c[h]);if(h++,s===void 0){let b=new Ae;if(b.setIndex(new Ms(x,1)),b.setAttribute("position",new be(f,3)),b.setAttribute("normal",new be(m,3)),n){b.setAttribute("faceMap",new Ms(y,1));let w=new Float32Array(m.length/3*4).fill(0);b.setAttribute("color",new Ge(w,4))}return et.free_mesh_data(a),b.userData.type="SubdivGeometry",b}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(m),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,et.free_mesh_data(a)}static freeSubdivPointer(e){et.free_bvh(e),et.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,r){let s=et.get_wireframe_data_for_base_level(e),o=4,a=et.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=et.HEAPU32[a[u]>>2],h=et.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=et.HEAPU32[a[u]>>2],f=et.HEAPU32.subarray(d>>2,(d>>2)+l[u]);if(n===void 0){let p=new Ae;p.setAttribute("position",new be(h,3));let m=new Float32Array(h.length);for(let g=0,y=h.length;g<y;)m[g++]=r.r,m[g++]=r.g,m[g++]=r.b;return p.setAttribute("color",new Ge(m,3)),p.setIndex(new Ms(f,1)),et.free_wireframe_data_for_base_level(s),p}n.getAttribute("position").copyArray(h),n.attributes.position.needsUpdate=!0,et.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,r){let s=n===0;s||et.set_destination_refinement_level(e,n);let o=r?et.get_topological_data2(e,s?et.Level.CONTROL:et.Level.REFINED,r.elements):et.get_topological_data(e,s?et.Level.CONTROL:et.Level.REFINED),a=6,l=et.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,h=et.HEAPU32[l[c]>>2],d=new Float32Array(et.HEAPF32.subarray(h>>2,(h>>2)+u[c]));c++;let f=et.HEAPU32[l[c]>>2],p=new Uint32Array(et.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=et.HEAPU32[l[c]>>2],g=new Uint8Array(et.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return et.free_topological_data(o),{positions:d,indices:p,verticesPerFace:g}}};var sD=["getX","getY","getZ"];function Yl(i,t){let e={},n=t?t.count:i.count,r=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=t?t.getX(u):u,h="";for(let d=0;d<3;d++)h+=`${~~(i[sD[d]](c)*a)},`;if(h in e)s.push(e[h]);else{for(let d=0;d<3;d++)o.push(i[sD[d]](c));e[h]=r,s.push(r),r++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var rv=new A,Aw=new A,Ew=new A,_w=new A;function Tw(i,t,e,n){let r=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),u=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&u<=24&&u%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/u;l=l.filter((f,p)=>Math.floor(p/2)%d===0)}let c=0;for(let d=0;d<l.length;d+=2)c+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let h=0;if(c<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),r.push(h++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),r.push(h++);return s.push(h),{indices:r,verticesPerFace:s}}let o=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[a]*3+2]===o||i[t[a]*3+2]===0)&&l++,(i[t[a+1]*3+2]===o||i[t[a+1]*3+2]===0)&&l++,(i[t[a+2]*3+2]===o||i[t[a+2]*3+2]===0)&&l++,l===3)break}if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){rv.set(i[t[a]*3],i[t[a]*3+1],i[t[a]*3+2]),Aw.set(i[t[a+1]*3],i[t[a+1]*3+1],i[t[a+1]*3+2]),Ew.set(i[t[a+4]*3],i[t[a+4]*3+1],i[t[a+4]*3+2]),_w.set(i[t[a+5]*3],i[t[a+5]*3+1],i[t[a+5]*3+2]),Aw.sub(rv).normalize(),Ew.sub(rv).normalize(),_w.sub(rv).normalize();let l=Aw.cross(Ew).dot(_w);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:a>=n[c]&&a<n[c+1])?(r.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3):(r.push(t[a],t[a+1],t[a+4],t[a+5]),s.push(4),a+=6)}else r.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],u=[],c=0;for(let h=0,d=0;h<i.length;h+=3,d++)i[h+2]===0&&(l.push(d),c++),i[h+2]===o&&u.push(d);if(e.userData.parameters.extrudeBevelSize===0){let h=u[0];u[0]=u[1],u[1]=h}l.reverse(),r.push(...l,...u),s.push(c,c)}return{indices:r,verticesPerFace:s}}var Fi={};O1(Fi,{calcBoolean:()=>q6,calcBooleanTopological:()=>W6,freeMeshSet:()=>Q6,getMeshSet:()=>Y6,hasOpenEdges:()=>X6,transformMeshSet:()=>K6});var oD,aD=new Promise(i=>{oD=i});var iv;function lD(){if(iv)return iv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.458/build",r=import("./boolean.js"),[s,o]=await Promise.all([r,fetch(`${e}/boolean.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});oD(l)}return iv=i(),iv}var dt,Mh;aD.then(i=>dt=i);function j6(i,t,e){let n,r;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?r=i.getClosedTorusIndicesForBooleanOrSubdiv():r=i.getIndex();let{positions:s,triIndices:o}=Yl(i.getAttribute("position"),r),a;if(t&&e){let{indices:l,verticesPerFace:u}=Tw(s,o,i);a=u.length,n=[];for(let c=0,h=0;c<a;c++){n.push(u[c]);for(let d=0;d<u[c];d++)n.push(l[h++])}}else{let l=o.length;n=Array(l+l/3),a=0;for(let u=0,c=0;c<n.length;)n[c++]=3,a++,n[c++]=o[u++],n[c++]=o[u++],n[c++]=o[u++]}return{positions:s,faceIndices:n,nFaces:a}}function cD(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,n=t*Float32Array.BYTES_PER_ELEMENT,r=Number.isInteger(i[0])?e:n,s=dt._malloc(r);return(Number.isInteger(i[0])?new Uint32Array(dt.HEAPU32.buffer,s,t):new Float32Array(dt.HEAPF32.buffer,s,t)).set(i,0),s}function uD(i){switch(i){case 0:return dt.OP.UNION;case 1:return dt.OP.INTERSECTION;case 2:return dt.OP.A_MINUS_B;case 3:return dt.OP.B_MINUS_A;case 4:return dt.OP.SYMMETRIC_DIFFERENCE;case 5:return dt.OP.ALL;default:throw new Error("Unknown boolean operation "+i)}}function W6(i,t){Mh===void 0&&(Mh=dt.init_csg());let e=cD(i),n=dt.csg_calc_topological(Mh,e,i.length,uD(t));dt._free(e);let r=6,s=dt.HEAPU32.subarray(n>>2,(n>>2)+r),o=s.subarray(3,3+3),a=0,l=dt.HEAPU32[s[a]>>2],u=new Float32Array(dt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=dt.HEAPU32[s[a]>>2],h=new Uint32Array(dt.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let d=dt.HEAPU32[s[a]>>2],f=new Uint8Array(dt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return dt.free_mesh_data(n),{positions:u,indices:h,verticesPerFace:f}}function q6(i,t,e,n){Mh===void 0&&(Mh=dt.init_csg());let r=cD(i),s=dt.csg_calc(Mh,r,i.length,n,uD(t));dt._free(r);let o=5,a=dt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=dt.HEAPU32[a[u]>>2],h=dt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=dt.HEAPU32[a[u]>>2],f=dt.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let p=l[u];e.setAttribute("position",new be(h,3)),e.setAttribute("normal",new be(f,3));let m=dt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new ln),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},dt.free_mesh_data(s),p}function Y6(i,t,e){if(dt===void 0)return-1;let n,r,s;if(t&&i.userData.positions!==void 0){let g=i.userData;s=g.verticesPerFace.length,n=g.positions,r=Array(g.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<g.verticesPerFace.length;y++){r[x++]=g.verticesPerFace[y];for(let b=0;b<g.verticesPerFace[y];b++)r[x++]=g.indices[v++]}}else({positions:n,faceIndices:r,nFaces:s}=j6(i,t,e));let o=n.length,a=r.length,l=n.length,u=r.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,d=u*Uint32Array.BYTES_PER_ELEMENT,f=dt._malloc(c),p=new Float32Array(dt.HEAPF32.buffer,f,l),m=new Uint32Array(dt.HEAPU32.buffer,f+h,u);return p.set(n,0),m.set(r,0),dt.get_csg_mesh(f,o,f+h,a,s)}function X6(i){return dt.has_open_edges(i)}function K6(i,t){dt.transform_csg_mesh(i,t.elements)}function Q6(i){dt.free_csg_mesh(i)}var Z6={ConeGeometry:i2,CubeGeometry:s2,CylinderGeometry:Vy,DodecahedronGeometry:o2,EllipseGeometry:Sh,HelixGeometry:N2,IcosahedronGeometry:B2,LatheGeometry:F2,NonParametricGeometry:z2,PolygonGeometry:Zy,PyramidGeometry:G2,RectangleGeometry:Jy,SphereGeometry:H2,PlaneGeometry:j2,BackdropGeometry:W2,StarGeometry:$y,TextFrameGeometry:q2,TorusGeometry:Y2,TorusKnotGeometry:X2,TriangleGeometry:K2,PathGeometry:Z2,VectorGeometry:ti},ww=i=>Z6[i.type].create(i);function Ch(i){return i!==null&&"booleanOp"in i}var Ph=class extends fh(Fn){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new se}updateVisible(){super.updateVisible(),this.visible=!Ch(this.parent)&&this.visible,Ch(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Fi.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ch(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ph&&(e.freeBooleanPointer(),Ch(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,n){let r=super.updateTransformState(e,n);return r&&Ch(this.parent)&&this.invalidateDownstreamBooleanData(!0),r}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ch(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var sv=new Tt;function tp(i,t=0,e=i.count,n,r){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let h=t;h<e;h++){let d=i.getX(h),f=i.getY(h),p=i.getZ(h);d<s&&(s=d),f<o&&(o=f),p<a&&(a=p),d>l&&(l=d),f>u&&(u=f),p>c&&(c=p)}sv.min.set(s,o,a),sv.max.set(l,u,c),sv.getCenter(n),sv.getSize(r).multiplyScalar(.5)}var J6=new Ae,$6=new wo,Xt=class extends Ph{constructor(t,e){super(J6,$6),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?tp(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var np=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var fr=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Te.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,n){return n=n??{},this.analyze(t,n),this.flow(t,e,n)}flow(t,e,n){n=n??{},t.addFlow(n.slot,n.cache,n.context);let r={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),r}build(t,e,n){e=e??this.getType(t,e);let r=t.getNodeData(n??this);return t.analyzing&&this.appendDepsNode(t,r,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,n)}updateFrame(t){}generateReadonly(t,e,n,r,s,o){return""}generate(t,e,n,r,s){return""}parse(t,e,n,r){}appendDepsNode(t,e,n){e.deps=(e.deps||0)+1;let r=t.getTypeLength(n);(r>(e.outputMax||0)||this.getType(t,n))&&(e.outputMax=r,e.output=n)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,n;for(e in this)n=this[e],n instanceof fr&&(t+='"'+e+'":'+n.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)e=this.hashProperties[r],n=this[e],t+='"'+e+'":"'+String(n)+'",';return t+='"id":"'+this.uuid+'"}',t}};var Mw=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,n){n=n!==void 0?n:!0,this.keywords[t]={callback:e,cache:n}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},$n=new Mw;var qe=class extends fr{constructor(e,n){super(e);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(e,n,r,s){if(n=n??this.getType(e),this.getShared(e,n)){let o=this.getUnique(e,n);o&&this.uuid===void 0&&(this.uuid=Te.generateUUID()),r=e.getUUID(r??this.getUUID(),!o);let a=e.getNodeData(r),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,n),this.generate(e,n,r)):super.build(e,n,r);if(o)return a.name=a.name||super.build(e,n,r),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,n,r);r=this.getUUID(!1);let u=this.getTemp(e,r);if(u)return e.format(u,l,n);{u=super.generate(e,n,r,a.output,s);let c=this.generate(e,l,r);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,n)}}return super.build(e,n,r)}getShared(e,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(e,n){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(e,n){n=n||this.uuid;let r=e.getVars()[n];return r?r.name:void 0}generate(e,n,r,s,o){return this.getShared(e,n)||console.error("TempNode is not shared"),r=r??this.uuid,e.getTempVar(r,s??this.getType(e),o,this.getLabel()).name}};var Ut=class extends qe{constructor(e,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(e,n);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,n,r,s,o,a){r=e.getUUID(r??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(r);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,n,r,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,n))}};var mn=class extends Ut{constructor(e=0,n){super("v2");this.nodeType="Vector2";this.value=e instanceof B?e:new B(e,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,n,r,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var _r=class extends Ut{constructor(e=0,n,r){super("v3");this.nodeType="Vector3";this.value=e instanceof A?e:new A(e,n,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,n,r,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var hn=class extends Fe{constructor(e,n,r,s){super(e,n,r);this.isColorA=!0;this.a=s}setRGBA(e,n,r,s){super.setRGB(e,n,r),this.a=s}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,n="srgb"){let r;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(r=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,n);break}}return super.setStyle(e,n)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var ni=class extends Ut{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof hn?e:new hn(e.r,e.g,e.b,e.a)}generateReadonly(e,n,r,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var e8=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,hD=/[a-z_0-9]+/gi,ge=class extends qe{constructor(e,n,r,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,n,r,s)}getShared(e,n){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}}getIncludeByName(e){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===e)return this.includes[n]}}generate(e,n,r,s,o){let a,l=0,u=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let c=[];for(;a=hD.exec(this.src);)c.push(a);for(let h=0;h<c.length;h++){let d=c[h],f=d[0],p=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&p&&$n.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=$n.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||$n.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}m=g.build(e)}f!==m&&u[d.index+l-1]!=="."&&(u=u.substring(0,d.index+l)+m+u.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&$n.contains(m)&&e.include($n.get(m))}return n==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),n)}parse(e,n,r,s){if(this.src=e||"",this.includes=n??[],this.extensions=r??{},this.keywords=s??{},this.isMethod){let o=e8.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(hD);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let h=a[l++];this.inputs.push({name:h,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var t8=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Cw=class extends qe{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Cw.PI,void 0,void 0,void 0,n)}getType(e){return e.getTypeByFormat(this.type)}parse(e,n,r,s,o){this.src=e||"";let a,l,u="",c=t8.exec(e);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(e,n){if(n==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),n)}generate(e,n,r,s,o){return e.format(this.name,this.getType(e),n)}},Ct=Cw;Ct.PI="PI",Ct.PI2="PI2",Ct.RECIPROCAL_PI="RECIPROCAL_PI",Ct.RECIPROCAL_PI2="RECIPROCAL_PI2",Ct.LOG2="LOG2",Ct.EPSILON="EPSILON";var n8=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3141
|
+
`&&n.push("")):t.getTextWidth(n[n.length-1]+r,i)>i.width&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+r,i)>i.width&&(r.length===1?(n[n.length-1]+=r,r=""):(n[n.length-1]+=r.slice(0,-1),r=r[r.length-1],n.push(""))));return n[n.length-1]+=r,n}var eD,_h=new Promise(i=>{eD=i}),$2=!1;var tv;function tD(){if($2)return;if(tv)return tv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.459/build",r=import("./process.js"),[s,o]=await Promise.all([r,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});eD(l),$2=!0}return tv=i(),tv}function ql(i,t,e,n){let r,s,o;i.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(i)),o=[[],["extrusion"]]):(s={...i},o=[[]]);for(let u of o){let c=s;for(let h of u)c=c[h];for(r in c){let h=c[r];cP(h)&&(c[r]=t.getVariable(h,[n.uuid,"geometry",...u,r]))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let u=Pt.createFromState(s.shape,s.width,s.height);a.shape=u}else if(s.type==="NonParametricGeometry")s.data.groups&&s.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),a.geometry=new Zc().parse(s);else if(s.type==="SubdivGeometry"){let u=new Mn(s,e);return u.data=i,u}else if(s.type==="TextGeometry")return new Eh(s,t);let l;try{l=ww(a)}catch(u){console.error(u)}if(!l){let u=Pt.createFromState(ku.defaultData(),100,100);a.shape=u,l=ww(a)}return l}var H6=new se;function ep(i,t,e,n){let r=i.position.array,s=i.normal.array,o=H6.makeScale(t,e,n).invert().elements,a,l,u;for(var c=0,h=r.length;c<h;c+=3)r[c]*=t,r[c+1]*=e,r[c+2]*=n,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var nv=new Tt,Th=new A,et;_h.then(i=>{et=i});var nD=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),rD=new Uint32Array([0,1,2,3]),iD=new Uint8Array([4]),Mn=class extends Ae{constructor(e,n){super();this.data=e;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,n){this.freeSubdivPointer();let r=this.data.scaleBaked,s=Ns.div(n,r);this.subdividedGeometry&&ep(this.subdividedGeometry.attributes,...s),this.originalGeometry&&ep(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(Th.fromArray(s));let a=Th.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,n,r;try{({originalGeometry:e,subdividedGeometry:n,subdivPointer:r}=Mn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new sr(100,100,100),r=0}this.subdivPointer=r,this.originalGeometry=e,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Mn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new ln,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,r=e.boundingSphere.center;nv.setFromBufferAttribute(n),nv.getCenter(r),e.boundingSphere.radius=r.distanceTo(nv.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),nv.getSize(Th);let s={width:Th.x,height:Th.y,depth:Th.z};return this.userData.parameters=s,s}static build(e,n,r,s){let o,a,l,u=e?.phongAngle??35;r===!1&&(u=-1),n&&(et.free_bvh(n),et.free_subdivision_surface(n));try{o=Mn.allocate(e,s)}catch(c){console.error(c,e),o=Mn.allocate({positionWASM:nD,indexWASM:rD,verticesPerFaceWASM:iD},s)}if(et.set_destination_refinement_level(o,0),a=Mn.buildLevel(o,!0,u),e.subdivisions>0)try{et.set_destination_refinement_level(o,e.subdivisions),l=Mn.buildLevel(o,!1,u)}catch{try{et.set_destination_refinement_level(o,e.subdivisions-1),l=Mn.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,n,r){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s=e.shape!==void 0||e.path!==void 0?n.geometry:ql(e,r,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,u,c;({positions:a,triIndices:c}=Yl(s.getAttribute("position"),o));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;h=[d,f]}return{indices:l,verticesPerFace:u}=Tw(a,c,s,h),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,n){let r,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(r=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(r=nD,s=rD,o=iD);let u=r.length,c=s.length,h=o.length,d=r.length+a.length+l.length,f=s.length+o.length,p=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=et._malloc(p),v=new Float32Array(et.HEAPF32.buffer,y,d),x=new Uint32Array(et.HEAPU32.buffer,y+m,f);v.set(r,0),v.set(a,r.length),v.set(l,r.length+a.length),x.set(s,0),x.set(o,s.length);let b;e?.scaleBaked?.some(E=>E!==1)&&(b=new se().makeScale(...e.scaleBaked)),n&&(b?b.premultiply(n):b=n);let w=b?et.alloc_subdivision_surface2(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h,b.elements):et.alloc_subdivision_surface(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return et._free(y),w}static buildLevel(e,n,r,s,o){let a=o?et.get_mesh_data2(e,n?et.Level.CONTROL:et.Level.REFINED,r,o.elements):et.get_mesh_data(e,n?et.Level.CONTROL:et.Level.REFINED,r),l=8,u=et.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),h=0,d=et.HEAPU32[u[h]>>2],f=et.HEAPF32.subarray(d>>2,(d>>2)+c[h]);h++;let p=et.HEAPU32[u[h]>>2],m=et.HEAPF32.subarray(p>>2,(p>>2)+c[h]);h++;let g=et.HEAPU32[u[h]>>2],y=et.HEAPU32.subarray(g>>2,(g>>2)+c[h]);h++;let v=et.HEAPU32[u[h]>>2],x=et.HEAPU32.subarray(v>>2,(v>>2)+c[h]);if(h++,s===void 0){let b=new Ae;if(b.setIndex(new Ms(x,1)),b.setAttribute("position",new be(f,3)),b.setAttribute("normal",new be(m,3)),n){b.setAttribute("faceMap",new Ms(y,1));let w=new Float32Array(m.length/3*4).fill(0);b.setAttribute("color",new Ge(w,4))}return et.free_mesh_data(a),b.userData.type="SubdivGeometry",b}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(m),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,et.free_mesh_data(a)}static freeSubdivPointer(e){et.free_bvh(e),et.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,r){let s=et.get_wireframe_data_for_base_level(e),o=4,a=et.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=et.HEAPU32[a[u]>>2],h=et.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=et.HEAPU32[a[u]>>2],f=et.HEAPU32.subarray(d>>2,(d>>2)+l[u]);if(n===void 0){let p=new Ae;p.setAttribute("position",new be(h,3));let m=new Float32Array(h.length);for(let g=0,y=h.length;g<y;)m[g++]=r.r,m[g++]=r.g,m[g++]=r.b;return p.setAttribute("color",new Ge(m,3)),p.setIndex(new Ms(f,1)),et.free_wireframe_data_for_base_level(s),p}n.getAttribute("position").copyArray(h),n.attributes.position.needsUpdate=!0,et.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,r){let s=n===0;s||et.set_destination_refinement_level(e,n);let o=r?et.get_topological_data2(e,s?et.Level.CONTROL:et.Level.REFINED,r.elements):et.get_topological_data(e,s?et.Level.CONTROL:et.Level.REFINED),a=6,l=et.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,h=et.HEAPU32[l[c]>>2],d=new Float32Array(et.HEAPF32.subarray(h>>2,(h>>2)+u[c]));c++;let f=et.HEAPU32[l[c]>>2],p=new Uint32Array(et.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=et.HEAPU32[l[c]>>2],g=new Uint8Array(et.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return et.free_topological_data(o),{positions:d,indices:p,verticesPerFace:g}}};var sD=["getX","getY","getZ"];function Yl(i,t){let e={},n=t?t.count:i.count,r=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=t?t.getX(u):u,h="";for(let d=0;d<3;d++)h+=`${~~(i[sD[d]](c)*a)},`;if(h in e)s.push(e[h]);else{for(let d=0;d<3;d++)o.push(i[sD[d]](c));e[h]=r,s.push(r),r++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var rv=new A,Aw=new A,Ew=new A,_w=new A;function Tw(i,t,e,n){let r=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),u=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&u<=24&&u%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/u;l=l.filter((f,p)=>Math.floor(p/2)%d===0)}let c=0;for(let d=0;d<l.length;d+=2)c+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let h=0;if(c<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),r.push(h++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),r.push(h++);return s.push(h),{indices:r,verticesPerFace:s}}let o=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[a]*3+2]===o||i[t[a]*3+2]===0)&&l++,(i[t[a+1]*3+2]===o||i[t[a+1]*3+2]===0)&&l++,(i[t[a+2]*3+2]===o||i[t[a+2]*3+2]===0)&&l++,l===3)break}if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){rv.set(i[t[a]*3],i[t[a]*3+1],i[t[a]*3+2]),Aw.set(i[t[a+1]*3],i[t[a+1]*3+1],i[t[a+1]*3+2]),Ew.set(i[t[a+4]*3],i[t[a+4]*3+1],i[t[a+4]*3+2]),_w.set(i[t[a+5]*3],i[t[a+5]*3+1],i[t[a+5]*3+2]),Aw.sub(rv).normalize(),Ew.sub(rv).normalize(),_w.sub(rv).normalize();let l=Aw.cross(Ew).dot(_w);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:a>=n[c]&&a<n[c+1])?(r.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3):(r.push(t[a],t[a+1],t[a+4],t[a+5]),s.push(4),a+=6)}else r.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],u=[],c=0;for(let h=0,d=0;h<i.length;h+=3,d++)i[h+2]===0&&(l.push(d),c++),i[h+2]===o&&u.push(d);if(e.userData.parameters.extrudeBevelSize===0){let h=u[0];u[0]=u[1],u[1]=h}l.reverse(),r.push(...l,...u),s.push(c,c)}return{indices:r,verticesPerFace:s}}var Fi={};O1(Fi,{calcBoolean:()=>q6,calcBooleanTopological:()=>W6,freeMeshSet:()=>Q6,getMeshSet:()=>Y6,hasOpenEdges:()=>X6,transformMeshSet:()=>K6});var oD,aD=new Promise(i=>{oD=i});var iv;function lD(){if(iv)return iv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.459/build",r=import("./boolean.js"),[s,o]=await Promise.all([r,fetch(`${e}/boolean.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});oD(l)}return iv=i(),iv}var dt,Mh;aD.then(i=>dt=i);function j6(i,t,e){let n,r;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?r=i.getClosedTorusIndicesForBooleanOrSubdiv():r=i.getIndex();let{positions:s,triIndices:o}=Yl(i.getAttribute("position"),r),a;if(t&&e){let{indices:l,verticesPerFace:u}=Tw(s,o,i);a=u.length,n=[];for(let c=0,h=0;c<a;c++){n.push(u[c]);for(let d=0;d<u[c];d++)n.push(l[h++])}}else{let l=o.length;n=Array(l+l/3),a=0;for(let u=0,c=0;c<n.length;)n[c++]=3,a++,n[c++]=o[u++],n[c++]=o[u++],n[c++]=o[u++]}return{positions:s,faceIndices:n,nFaces:a}}function cD(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,n=t*Float32Array.BYTES_PER_ELEMENT,r=Number.isInteger(i[0])?e:n,s=dt._malloc(r);return(Number.isInteger(i[0])?new Uint32Array(dt.HEAPU32.buffer,s,t):new Float32Array(dt.HEAPF32.buffer,s,t)).set(i,0),s}function uD(i){switch(i){case 0:return dt.OP.UNION;case 1:return dt.OP.INTERSECTION;case 2:return dt.OP.A_MINUS_B;case 3:return dt.OP.B_MINUS_A;case 4:return dt.OP.SYMMETRIC_DIFFERENCE;case 5:return dt.OP.ALL;default:throw new Error("Unknown boolean operation "+i)}}function W6(i,t){Mh===void 0&&(Mh=dt.init_csg());let e=cD(i),n=dt.csg_calc_topological(Mh,e,i.length,uD(t));dt._free(e);let r=6,s=dt.HEAPU32.subarray(n>>2,(n>>2)+r),o=s.subarray(3,3+3),a=0,l=dt.HEAPU32[s[a]>>2],u=new Float32Array(dt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=dt.HEAPU32[s[a]>>2],h=new Uint32Array(dt.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let d=dt.HEAPU32[s[a]>>2],f=new Uint8Array(dt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return dt.free_mesh_data(n),{positions:u,indices:h,verticesPerFace:f}}function q6(i,t,e,n){Mh===void 0&&(Mh=dt.init_csg());let r=cD(i),s=dt.csg_calc(Mh,r,i.length,n,uD(t));dt._free(r);let o=5,a=dt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=dt.HEAPU32[a[u]>>2],h=dt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=dt.HEAPU32[a[u]>>2],f=dt.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let p=l[u];e.setAttribute("position",new be(h,3)),e.setAttribute("normal",new be(f,3));let m=dt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new ln),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},dt.free_mesh_data(s),p}function Y6(i,t,e){if(dt===void 0)return-1;let n,r,s;if(t&&i.userData.positions!==void 0){let g=i.userData;s=g.verticesPerFace.length,n=g.positions,r=Array(g.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<g.verticesPerFace.length;y++){r[x++]=g.verticesPerFace[y];for(let b=0;b<g.verticesPerFace[y];b++)r[x++]=g.indices[v++]}}else({positions:n,faceIndices:r,nFaces:s}=j6(i,t,e));let o=n.length,a=r.length,l=n.length,u=r.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,d=u*Uint32Array.BYTES_PER_ELEMENT,f=dt._malloc(c),p=new Float32Array(dt.HEAPF32.buffer,f,l),m=new Uint32Array(dt.HEAPU32.buffer,f+h,u);return p.set(n,0),m.set(r,0),dt.get_csg_mesh(f,o,f+h,a,s)}function X6(i){return dt.has_open_edges(i)}function K6(i,t){dt.transform_csg_mesh(i,t.elements)}function Q6(i){dt.free_csg_mesh(i)}var Z6={ConeGeometry:i2,CubeGeometry:s2,CylinderGeometry:Vy,DodecahedronGeometry:o2,EllipseGeometry:Sh,HelixGeometry:N2,IcosahedronGeometry:B2,LatheGeometry:F2,NonParametricGeometry:z2,PolygonGeometry:Zy,PyramidGeometry:G2,RectangleGeometry:Jy,SphereGeometry:H2,PlaneGeometry:j2,BackdropGeometry:W2,StarGeometry:$y,TextFrameGeometry:q2,TorusGeometry:Y2,TorusKnotGeometry:X2,TriangleGeometry:K2,PathGeometry:Z2,VectorGeometry:ti},ww=i=>Z6[i.type].create(i);function Ch(i){return i!==null&&"booleanOp"in i}var Ph=class extends fh(Fn){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new se}updateVisible(){super.updateVisible(),this.visible=!Ch(this.parent)&&this.visible,Ch(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Fi.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ch(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ph&&(e.freeBooleanPointer(),Ch(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,n){let r=super.updateTransformState(e,n);return r&&Ch(this.parent)&&this.invalidateDownstreamBooleanData(!0),r}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ch(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var sv=new Tt;function tp(i,t=0,e=i.count,n,r){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let h=t;h<e;h++){let d=i.getX(h),f=i.getY(h),p=i.getZ(h);d<s&&(s=d),f<o&&(o=f),p<a&&(a=p),d>l&&(l=d),f>u&&(u=f),p>c&&(c=p)}sv.min.set(s,o,a),sv.max.set(l,u,c),sv.getCenter(n),sv.getSize(r).multiplyScalar(.5)}var J6=new Ae,$6=new wo,Xt=class extends Ph{constructor(t,e){super(J6,$6),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?tp(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var np=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var fr=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Te.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,n){return n=n??{},this.analyze(t,n),this.flow(t,e,n)}flow(t,e,n){n=n??{},t.addFlow(n.slot,n.cache,n.context);let r={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),r}build(t,e,n){e=e??this.getType(t,e);let r=t.getNodeData(n??this);return t.analyzing&&this.appendDepsNode(t,r,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,n)}updateFrame(t){}generateReadonly(t,e,n,r,s,o){return""}generate(t,e,n,r,s){return""}parse(t,e,n,r){}appendDepsNode(t,e,n){e.deps=(e.deps||0)+1;let r=t.getTypeLength(n);(r>(e.outputMax||0)||this.getType(t,n))&&(e.outputMax=r,e.output=n)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,n;for(e in this)n=this[e],n instanceof fr&&(t+='"'+e+'":'+n.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)e=this.hashProperties[r],n=this[e],t+='"'+e+'":"'+String(n)+'",';return t+='"id":"'+this.uuid+'"}',t}};var Mw=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,n){n=n!==void 0?n:!0,this.keywords[t]={callback:e,cache:n}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},$n=new Mw;var qe=class extends fr{constructor(e,n){super(e);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(e,n,r,s){if(n=n??this.getType(e),this.getShared(e,n)){let o=this.getUnique(e,n);o&&this.uuid===void 0&&(this.uuid=Te.generateUUID()),r=e.getUUID(r??this.getUUID(),!o);let a=e.getNodeData(r),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,n),this.generate(e,n,r)):super.build(e,n,r);if(o)return a.name=a.name||super.build(e,n,r),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,n,r);r=this.getUUID(!1);let u=this.getTemp(e,r);if(u)return e.format(u,l,n);{u=super.generate(e,n,r,a.output,s);let c=this.generate(e,l,r);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,n)}}return super.build(e,n,r)}getShared(e,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(e,n){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(e,n){n=n||this.uuid;let r=e.getVars()[n];return r?r.name:void 0}generate(e,n,r,s,o){return this.getShared(e,n)||console.error("TempNode is not shared"),r=r??this.uuid,e.getTempVar(r,s??this.getType(e),o,this.getLabel()).name}};var Ut=class extends qe{constructor(e,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(e,n);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,n,r,s,o,a){r=e.getUUID(r??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(r);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,n,r,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,n))}};var gn=class extends Ut{constructor(e=0,n){super("v2");this.nodeType="Vector2";this.value=e instanceof B?e:new B(e,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,n,r,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var _r=class extends Ut{constructor(e=0,n,r){super("v3");this.nodeType="Vector3";this.value=e instanceof A?e:new A(e,n,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,n,r,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var hn=class extends Fe{constructor(e,n,r,s){super(e,n,r);this.isColorA=!0;this.a=s}setRGBA(e,n,r,s){super.setRGB(e,n,r),this.a=s}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,n="srgb"){let r;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(r=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,n);break}}return super.setStyle(e,n)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var ni=class extends Ut{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof hn?e:new hn(e.r,e.g,e.b,e.a)}generateReadonly(e,n,r,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var e8=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,hD=/[a-z_0-9]+/gi,ge=class extends qe{constructor(e,n,r,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,n,r,s)}getShared(e,n){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}}getIncludeByName(e){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===e)return this.includes[n]}}generate(e,n,r,s,o){let a,l=0,u=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let c=[];for(;a=hD.exec(this.src);)c.push(a);for(let h=0;h<c.length;h++){let d=c[h],f=d[0],p=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&p&&$n.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=$n.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||$n.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}m=g.build(e)}f!==m&&u[d.index+l-1]!=="."&&(u=u.substring(0,d.index+l)+m+u.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&$n.contains(m)&&e.include($n.get(m))}return n==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),n)}parse(e,n,r,s){if(this.src=e||"",this.includes=n??[],this.extensions=r??{},this.keywords=s??{},this.isMethod){let o=e8.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(hD);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let h=a[l++];this.inputs.push({name:h,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var t8=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Cw=class extends qe{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Cw.PI,void 0,void 0,void 0,n)}getType(e){return e.getTypeByFormat(this.type)}parse(e,n,r,s,o){this.src=e||"";let a,l,u="",c=t8.exec(e);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(e,n){if(n==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),n)}generate(e,n,r,s,o){return e.format(this.name,this.getType(e),n)}},Ct=Cw;Ct.PI="PI",Ct.PI2="PI2",Ct.RECIPROCAL_PI="RECIPROCAL_PI",Ct.RECIPROCAL_PI2="RECIPROCAL_PI2",Ct.LOG2="LOG2",Ct.EPSILON="EPSILON";var n8=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3142
3142
|
)*?)}`,"gim"),r8=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Dh=class extends qe{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===e)return this.inputs[n]}generate(e,n,r,s,o){return n==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),n)}parse(e=""){this.src=e,this.inputs=[];let n=n8.exec(e);if(n){let r=n[2],s;for(;s=r8.exec(r);)this.inputs.push({type:s[1],name:s[2]});this.name=n[1]}else this.name="";this.type=this.name}};var Ih=class extends qe{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,n){e.requires.uv[this.index]=!0;let r=this.index>0?this.index+1:"",s=e.isShader("vertex")?"uv"+r:"vUv"+r;return e.format(s,this.getType(e),n)}};$n.addKeyword("uv",function(){return new Ih});$n.addKeyword("uv2",function(){return new Ih(1)});var Xl=class extends qe{constructor(e,n){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=n??Xl.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case pi:return["Linear"];case $e:return["sRGB"];default:return[]}}generate(e,n){let r=this.input.build(e,"v4"),s=this.getType(e),o=Xl.Nodes[this.method],a=e.include(o);if(a===Xl.LINEAR_TO_LINEAR)return e.format(r,s,n);if(o.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+r+", "+l+" )",s,n)}else return e.format(a+"( "+r+" )",s,n)}fromEncoding(e){let n=Xl.getEncodingComponents(e);this.method="LinearTo"+n[0],this.factor=n[1]}fromDecoding(e){let n=Xl.getEncodingComponents(e);this.method=n[0]+"ToLinear",this.factor=n[1]}},jr=Xl;jr.Nodes={LinearToLinear:new ge(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3143
3143
|
`)),sRGBToLinear:new ge(["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(`
|
|
3144
3144
|
`)),LinearTosRGB:new ge(["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(`
|
|
@@ -3368,7 +3368,7 @@ gVelocity = vec4(velocity, 0.0, 1.0);
|
|
|
3368
3368
|
`}addVaryCode(t){this.addVertexParsCode(t),this.addFragmentParsCode(t)}isCache(t){return this.caches.indexOf(t)!==-1}isSlot(t){return this.slots.indexOf(t)!==-1}define(t,e){this.defines[t]=e===void 0?1:e}require(t){this.requires[t]=!0}isDefined(t){return this.defines[t]!==void 0}getVar(t,e,n,r="varying",s="V",o=""){let a=this.getVars(r),l=a[t];if(!l){let u=a.length;l={name:n||"node"+s+u+(o?"_"+o:""),type:e},a.push(l),a[t]=l}return l}getTempVar(t,e,n,r){return this.getVar(t,e,n,this.shader,"T",r)}getAttribute(t,e){if(!this.attributes[t]){let n=this.getVar(t,e);this.addVertexParsCode("attribute "+e+" "+t+";"),this.addVertexFinalCode(n.name+" = "+t+";"),this.attributes[t]={varying:n,name:t,type:e}}return this.attributes[t]}getCode(t){return[this.prefixCode,this.parsCode[t],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[t],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[t],"uniform"),this.getIncludesCode("consts",t),this.getIncludesCode("structs",t),this.getIncludesCode("functions",t),"void main() {",this.getVarListCode(this.getVars(t)),this.code[t],this.resultCode[t],this.finalCode[t],"}"].join(`
|
|
3369
3369
|
`)}getVarListCode(t,e){e=e??"";let n="";for(let r=0,s=t.length;r<s;++r){let o=t[r],a=o.type,l=o.name,u=o.size,c=this.getFormatByType(a);if(c===void 0)throw new Error("Node pars "+c+" not found.");c.includes("[]")?n+=e+" "+c.substring(0,c.length-2)+" "+l+`[${u}];
|
|
3370
3370
|
`:n+=e+" "+c+" "+l+`;
|
|
3371
|
-
`}return n}getVars(t){return this.inputs.vars[t??this.shader]}getNodeData(t){let e=t instanceof fr?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,n,r,s,o){if(e.includes("[]")){let a=this.inputs.arrayUniforms,l=a.list.length,u=new np({type:e,size:n.size,name:r||"nodeUA"+l+(o?"_"+o:""),node:n,needsUpdate:s});return a.list.push(u),a[t].push(u),a[t][u.name]=u,this.uniforms[u.name]=u,u}else{let a=this.inputs.uniforms,l=a.list.length,u=new np({type:e,name:r||"nodeU"+l+(o?"_"+o:""),node:n,needsUpdate:s});return a.list.push(u),a[t].push(u),a[t][u.name]=u,this.uniforms[u.name]=u,u}}createVertexUniform(t,e,n,r,s){return this.createUniform("vertex",t,e,n,r,s)}createFragmentUniform(t,e,n,r,s){return this.createUniform("fragment",t,e,n,r,s)}include(t,e,n){let r;if(t=typeof t=="string"?$n.get(t):t,this.context.include===!1)return t.name;t instanceof ge?r=this.includes.functions:t instanceof Ct?r=this.includes.consts:t instanceof Dh&&(r=this.includes.structs);let s=r[this.shader]=r[this.shader]||[];if(t){let o=s[t.name];if(o||(o=s[t.name]={node:t,deps:[]},s.push(o),o.src=t.build(this,"source")),t instanceof ge&&e&&s[e.name]&&s[e.name].deps.indexOf(t)===-1&&(s[e.name].deps.push(t),t.includes?.length)){let a=0;do this.include(t.includes[a++],e);while(a<t.includes.length)}return n&&(o.src=n),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return i8[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let n=t[e];if(n?.isNode)return n}}resolve(...t){for(let e=0;e<arguments.length;e++){let n=t[e];if(n!==void 0){if(n.isNode)return n;if(n.isTexture)switch(n.mapping){case oa:case aa:return new av(n);case $c:return new ov(new Wr(n));default:return new Wr(n)}else{if(n.isVector2)return new
|
|
3371
|
+
`}return n}getVars(t){return this.inputs.vars[t??this.shader]}getNodeData(t){let e=t instanceof fr?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,n,r,s,o){if(e.includes("[]")){let a=this.inputs.arrayUniforms,l=a.list.length,u=new np({type:e,size:n.size,name:r||"nodeUA"+l+(o?"_"+o:""),node:n,needsUpdate:s});return a.list.push(u),a[t].push(u),a[t][u.name]=u,this.uniforms[u.name]=u,u}else{let a=this.inputs.uniforms,l=a.list.length,u=new np({type:e,name:r||"nodeU"+l+(o?"_"+o:""),node:n,needsUpdate:s});return a.list.push(u),a[t].push(u),a[t][u.name]=u,this.uniforms[u.name]=u,u}}createVertexUniform(t,e,n,r,s){return this.createUniform("vertex",t,e,n,r,s)}createFragmentUniform(t,e,n,r,s){return this.createUniform("fragment",t,e,n,r,s)}include(t,e,n){let r;if(t=typeof t=="string"?$n.get(t):t,this.context.include===!1)return t.name;t instanceof ge?r=this.includes.functions:t instanceof Ct?r=this.includes.consts:t instanceof Dh&&(r=this.includes.structs);let s=r[this.shader]=r[this.shader]||[];if(t){let o=s[t.name];if(o||(o=s[t.name]={node:t,deps:[]},s.push(o),o.src=t.build(this,"source")),t instanceof ge&&e&&s[e.name]&&s[e.name].deps.indexOf(t)===-1&&(s[e.name].deps.push(t),t.includes?.length)){let a=0;do this.include(t.includes[a++],e);while(a<t.includes.length)}return n&&(o.src=n),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return i8[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let n=t[e];if(n?.isNode)return n}}resolve(...t){for(let e=0;e<arguments.length;e++){let n=t[e];if(n!==void 0){if(n.isNode)return n;if(n.isTexture)switch(n.mapping){case oa:case aa:return new av(n);case $c:return new ov(new Wr(n));default:return new Wr(n)}else{if(n.isVector2)return new gn(n);if(n.isVector3)return new _r(n);if(n.isVector4)return new ni(n)}}}}format(t,e,n){switch(this.colorToVector(n+" <- "+e)){case"f <- v2":return t+".x";case"f <- v3":return t+".x";case"f <- v4":return t+".x";case"f <- i":case"f <- b":return"float( "+t+" )";case"v2 <- f":return"vec2( "+t+" )";case"v2 <- v3":return t+".xy";case"v2 <- v4":return t+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+t+" ) )";case"v3 <- f":return"vec3( "+t+" )";case"v3 <- v2":return"vec3( "+t+", 0.0 )";case"v3 <- v4":return t+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+t+" ) )";case"v4 <- f":return"vec4( "+t+" )";case"v4 <- v2":return"vec4( "+t+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+t+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+t+" ) )";case"i <- f":case"i <- b":return"int( "+t+" )";case"i <- v2":return"int( "+t+".x )";case"i <- v3":return"int( "+t+".x )";case"i <- v4":return"int( "+t+".x )";case"b <- f":return"( "+t+" != 0.0 )";case"b <- v2":return"( "+t+" != vec2( 0.0 ) )";case"b <- v3":return"( "+t+" != vec3( 0.0 ) )";case"b <- v4":return"( "+t+" != vec4( 0.0 ) )";case"b <- i":return"( "+t+" != 0 )"}return t}getTypeByFormat(t){return s8[t]||t}getFormatByType(t){return o8[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return gD[t]}getIndexByElement(t){return gD.indexOf(t)}isShader(t){return this.shader===t}setShader(t){return this.shader=t,this}mergeDefines(t){for(let e in t)this.defines[e]=t[e];return this.defines}mergeUniform(t){for(let e in t)this.uniforms[e]=t[e];return this.uniforms}getTextureEncodingFromMap(t){let e;return t?t.isTexture&&(e=t.encoding):e=pi,e===pi&&this.context.gamma&&(e=$e),e}};var Bt=class extends Ut{constructor(e=0,n,r,s){super("c");this.nodeType="Color";this.value=e instanceof hn?e:new hn(e||0,n,r,s)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,n,r,s,o,a){r=e.getUUID(r??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(r),u=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let c=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${c};`)}return u?this.generateReadonly(e,n,r,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,n))}generateReadonly(e,n,r,s,o,a){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",s,n)}};var gt=class extends Ut{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,n,r,s,o,a){return e.format(this.value.toString(),s,n)}};var bn=class extends Ut{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,n,r,s){return e.format(this.value?"true":"false",s,n)}};var cs=class extends Ut{constructor(e=1,n){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(n)?n:typeof n=="number"?new Array(e).fill(n):new Array(e).fill(0)}};var qa=class extends Ut{};var cv=class extends qa{constructor(e){super("v3");this.image=e;this._value=new A}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var Ql=class extends qa{constructor(e,n){super("t");this.image=e;this.wrap=n}get value(){return this.image.getTexture(this.wrap)}};var Lh=class extends Ut{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new $t}generateReadonly(e,n,r,s,o,a){return e.format("mat3("+this.value.elements.join(", ")+")",s,n)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Tr=class extends Ut{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new se}generateReadonly(e,n,r,s,o,a){return e.format("mat4("+this.value.elements.join(", ")+")",s,n)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};function yD(i,t,e){i.setUvTransform(e[0],e[1],t[0],t[1],0,0,0)}var uv=class extends Lh{constructor(e,n){super(new $t);this.repeat=e;this.offset=n;yD(this.value,e,n)}updateMatrix(){yD(this.value,this.repeat,this.offset)}};var us=class extends Ut{constructor(e=1,n){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(n)?n:n instanceof Xe?new Array(e).fill(n):new Array(e).fill(new Xe(0))}};var Nh=class extends qe{constructor(e,n,r,s){super("v3");this.nodeType="Blend";this.a=e,this.b=n,this.alpha=r,this.mode=s}generate(e,n){if(e.isShader("fragment")){let r=[];return r.push(this.a.build(e,"c")),r.push(this.b.build(e,"c")),r.push(this.alpha.build(e,"f")),r.push(this.mode.build(e,"i")),e.format("spe_blend("+r.join(",")+")",this.getType(e),n)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}};var Dw=class extends qe{constructor(e,n){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=n,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,n){if(e.isShader("fragment")){let r=e.include(Dw.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let s=[];return s.push(this.color.build(e,"v3")),s.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(r+"("+s.join(",")+")",this.getType(e),n)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),n)}},Zl=Dw;Zl.Nodes=function(){return{customColor:new ge(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
|
|
3372
3372
|
float lalpha = alpha * mask;
|
|
3373
3373
|
calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
|
|
3374
3374
|
accumAlpha += (1.0 - accumAlpha) * lalpha;
|
|
@@ -4948,7 +4948,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
4948
4948
|
vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
|
4949
4949
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
4950
4950
|
return displaced_position;
|
|
4951
|
-
}`,[e,n])}}();var He={normalRenderTarget:new Wr,normalRenderTargetDepth:new Wr,transmissionRenderTarget:new Wr,aspectRatio:new
|
|
4951
|
+
}`,[e,n])}}();var He={normalRenderTarget:new Wr,normalRenderTargetDepth:new Wr,transmissionRenderTarget:new Wr,aspectRatio:new gn,transmissionSize:new gn(2048,2048),transmissionRenderTargetDepth:new Wr,aoRenderTarget:new Wr,aoEnabled:new bn,pixelRatioNode:new Ce(1),resolution:new gn,penumbraSize:new cs(5,.5),frameIndex:new gt(0),transmissionLod:new gt(2)};for(let i of Object.values(He))i.isRenderGlobal=!0;var $l=class extends fr{constructor(){super("basic");this.nodeType="Basic";this.color=new Bt(Zn),this.shadingAlpha=new Ce(1),this.shadingBlend=new gt(0),this.previousModelViewMatrix=new Tr,this.previouseProjectionMatrix=new Tr}get category(){return"phong"}generate(e){let n;if(e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:He.frameIndex}),e.mergeUniform({resolution:He.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(es.merge([Se.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
|
|
4952
4952
|
`));let s=["#include <beginnormal_vertex>",`
|
|
4953
4953
|
#if !defined( USE_LAYER_DISPLACE )
|
|
4954
4954
|
#include <defaultnormal_vertex>
|
|
@@ -5350,7 +5350,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
5350
5350
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result} * ${f}, ${l.result} );
|
|
5351
5351
|
}
|
|
5352
5352
|
`),u&&d.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),c?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.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>"),n=d.join(`
|
|
5353
|
-
`)}return n}};var hv=class{constructor(t=1e3*10){this.timeout=t;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(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),n=this.cache.get(t);return n===void 0?(n={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,n)):(n.time=e,n.prev.next=n.next,n.next.prev=n.prev),n.prev=this.tail.prev,n.next=this.tail,this.tail.prev.next=n,this.tail.prev=n,this.scheduleCleanup(),n.data}};var zw=class extends hv{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},Vw;function bD(i){return typeof i=="string"?i:(Vw||(Vw=new zw),Vw.load(i))}var dv=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},fv=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var Kh=class extends dv{constructor(e,n){super(e,n.imageHolderCache);this.data=e;this.shared=n;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 n=()=>{this.loaded=!0;let s=[1e3,1001,1002];for(let o of s){let a=this[o];a&&(a.image=this.img,a.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 r=new FileReader;r.readAsDataURL(new Blob([e],{type:"video/mp4"}));let s;await new Promise(o=>{r.onloadend=a=>{s=a.target?.result,o(null)}}),this.img.src=s}else this.img.src=e;this.img.onloadeddata=()=>{n()}}else this.img=new Image,this.img.src=bD(e),this.img.onload=n}getTexture(e){let n=this[e];if(n)return n;{let r;return this.isVideo?r=new Gm(this.img,void 0,e,e):r=new en(this.img,void 0,e,e),this.loaded&&(r.needsUpdate=!0),this[e]=r,r}}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()}};1e3,1001,1002;var ki=class extends Kh{};function Hw(i,t){var e=u8(t);return e.formatToParts?l8(e,i):c8(e,i)}var a8={year:0,month:1,day:2,hour:3,minute:4,second:5};function l8(i,t){try{for(var e=i.formatToParts(t),n=[],r=0;r<e.length;r++){var s=a8[e[r].type];s>=0&&(n[s]=parseInt(e[r].value,10))}return n}catch(o){if(o instanceof RangeError)return[NaN];throw o}}function c8(i,t){var e=i.format(t).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(e);return[n[3],n[1],n[2],n[4],n[5],n[6]]}var Gw={};function u8(i){if(!Gw[i]){var t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:"America/New_York",year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),e=t==="06/25/2014, 00:00:00"||t==="\u200E06\u200E/\u200E25\u200E/\u200E2014\u200E \u200E00\u200E:\u200E00\u200E:\u200E00";Gw[i]=e?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:i,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:i,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return Gw[i]}function pv(i,t,e,n,r,s,o){var a=new Date(0);return a.setUTCFullYear(i,t,e),a.setUTCHours(n,r,s,o),a}var SD=36e5,h8=6e4,jw={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function up(i,t,e){var n,r;if(!i||(n=jw.timezoneZ.exec(i),n))return 0;var s;if(n=jw.timezoneHH.exec(i),n)return s=parseInt(n[1],10),wD(s)?-(s*SD):NaN;if(n=jw.timezoneHHMM.exec(i),n){s=parseInt(n[1],10);var o=parseInt(n[2],10);return wD(s,o)?(r=Math.abs(s)*SD+o*h8,s>0?-r:r):NaN}if(p8(i)){t=new Date(t||Date.now());var a=e?t:d8(t),l=Ww(a,i),u=e?l:f8(t,l,i);return-u}return NaN}function d8(i){return pv(i.getFullYear(),i.getMonth(),i.getDate(),i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds())}function Ww(i,t){var e=Hw(i,t),n=pv(e[0],e[1]-1,e[2],e[3]%24,e[4],e[5],0).getTime(),r=i.getTime(),s=r%1e3;return r-=s>=0?s:1e3+s,n-r}function f8(i,t,e){var n=i.getTime(),r=n-t,s=Ww(new Date(r),e);if(t===s)return t;r-=s-t;var o=Ww(new Date(r),e);return s===o?s:Math.max(s,o)}function wD(i,t){return-23<=i&&i<=23&&(t==null||0<=t&&t<=59)}var AD={};function p8(i){if(AD[i])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:i}),AD[i]=!0,!0}catch{return!1}}var RD=$o(_D(),1),Xw=$o(MD(),1);var y8=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,CD=y8;var qw=36e5,PD=6e4,v8=2,qr={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:CD};function Kw(i,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(i===null)return new Date(NaN);var e=t||{},n=e.additionalDigits==null?v8:(0,RD.default)(e.additionalDigits);if(n!==2&&n!==1&&n!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]")return new Date(i.getTime());if(typeof i=="number"||Object.prototype.toString.call(i)==="[object Number]")return new Date(i);if(!(typeof i=="string"||Object.prototype.toString.call(i)==="[object String]"))return new Date(NaN);var r=x8(i),s=b8(r.date,n),o=s.year,a=s.restDateString,l=S8(a,o);if(isNaN(l))return new Date(NaN);if(l){var u=l.getTime(),c=0,h;if(r.time&&(c=w8(r.time),isNaN(c)))return new Date(NaN);if(r.timeZone||e.timeZone){if(h=up(r.timeZone||e.timeZone,new Date(u+c)),isNaN(h))return new Date(NaN)}else h=(0,Xw.default)(new Date(u+c)),h=(0,Xw.default)(new Date(u+c+h));return new Date(u+c+h)}else return new Date(NaN)}function x8(i){var t={},e=qr.dateTimePattern.exec(i),n;if(e?(t.date=e[1],n=e[3]):(e=qr.datePattern.exec(i),e?(t.date=e[1],n=e[2]):(t.date=null,n=i)),n){var r=qr.timeZone.exec(n);r?(t.time=n.replace(r[1],""),t.timeZone=r[1].trim()):t.time=n}return t}function b8(i,t){var e=qr.YYY[t],n=qr.YYYYY[t],r;if(r=qr.YYYY.exec(i)||n.exec(i),r){var s=r[1];return{year:parseInt(s,10),restDateString:i.slice(s.length)}}if(r=qr.YY.exec(i)||e.exec(i),r){var o=r[1];return{year:parseInt(o,10)*100,restDateString:i.slice(o.length)}}return{year:null}}function S8(i,t){if(t===null)return null;var e,n,r,s;if(i.length===0)return n=new Date(0),n.setUTCFullYear(t),n;if(e=qr.MM.exec(i),e)return n=new Date(0),r=parseInt(e[1],10)-1,ID(t,r)?(n.setUTCFullYear(t,r),n):new Date(NaN);if(e=qr.DDD.exec(i),e){n=new Date(0);var o=parseInt(e[1],10);return _8(t,o)?(n.setUTCFullYear(t,0,o),n):new Date(NaN)}if(e=qr.MMDD.exec(i),e){n=new Date(0),r=parseInt(e[1],10)-1;var a=parseInt(e[2],10);return ID(t,r,a)?(n.setUTCFullYear(t,r,a),n):new Date(NaN)}if(e=qr.Www.exec(i),e)return s=parseInt(e[1],10)-1,OD(t,s)?DD(t,s):new Date(NaN);if(e=qr.WwwD.exec(i),e){s=parseInt(e[1],10)-1;var l=parseInt(e[2],10)-1;return OD(t,s,l)?DD(t,s,l):new Date(NaN)}return null}function w8(i){var t,e,n;if(t=qr.HH.exec(i),t)return e=parseFloat(t[1].replace(",",".")),Yw(e)?e%24*qw:NaN;if(t=qr.HHMM.exec(i),t)return e=parseInt(t[1],10),n=parseFloat(t[2].replace(",",".")),Yw(e,n)?e%24*qw+n*PD:NaN;if(t=qr.HHMMSS.exec(i),t){e=parseInt(t[1],10),n=parseInt(t[2],10);var r=parseFloat(t[3].replace(",","."));return Yw(e,n,r)?e%24*qw+n*PD+r*1e3:NaN}return null}function DD(i,t,e){t=t||0,e=e||0;var n=new Date(0);n.setUTCFullYear(i,0,4);var r=n.getUTCDay()||7,s=t*7+e+1-r;return n.setUTCDate(n.getUTCDate()+s),n}var A8=[31,28,31,30,31,30,31,31,30,31,30,31],E8=[31,29,31,30,31,30,31,31,30,31,30,31];function LD(i){return i%400===0||i%4===0&&i%100!==0}function ID(i,t,e){if(t<0||t>11)return!1;if(e!=null){if(e<1)return!1;var n=LD(i);if(n&&e>E8[t]||!n&&e>A8[t])return!1}return!0}function _8(i,t){if(t<1)return!1;var e=LD(i);return!(e&&t>366||!e&&t>365)}function OD(i,t,e){return!(t<0||t>52||e!=null&&(e<0||e>6))}function Yw(i,t,e){return!(i!=null&&(i<0||i>=25)||t!=null&&(t<0||t>=60)||e!=null&&(e<0||e>=60))}function yv(i,t,e){var n=Kw(i,e),r=up(t,n,!0),s=new Date(n.getTime()-r),o=new Date(0);return o.setFullYear(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()),o.setHours(s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()),o}function Mr(i,t){return t.color(i)}function Qw(i=new Date,t){let e=t.format,n=i.getSeconds(),r=i;t&&t.timeZone!==null&&(r=yv(new Date,t.timeZone));let s=r.getHours(),o=r.getMinutes(),a;t.format12h24h==="12ampm"&&(a=s>=12?"PM":"AM");let l=s;t.format12h24h!=="24"&&(l=s%12,l===0&&(l=12));let u,c;switch(e){case"HH:mm:ss":u=[l,o,n];break;case"HH:mm":u=[l,o];break;case"HH":u=[l],a=void 0;break;case"mm":u=[o],a=void 0;break;case"ss":u=[n],a=void 0;break;case"year":c=r.getFullYear();break;case"month":c=r.getMonth()+1;break;case"dayOfYear":c=Math.floor((r.getTime()-new Date(r.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":c=r.getDate();break;case"secondOfDay":c=s*60*60+o*60+n;break;default:console.error("Unknown time format",e),c=0;break}return u!==void 0?{textValue:u,suffix:a}:c}function ND(i,t){switch(i.type){case"fresnel":return C8(i,t);case"gradient":return P8(i,t);case"depth":return D8(i,t);case"normal":return I8(i,t);case"noise":return O8(i,t);case"rainbow":return R8(i,t);case"toon":return L8(i,t);case"outline":return N8(i,t);case"transmission":return B8(i,t);case"color":return M8(i,t);case"pattern":return F8(i,t)}}function T8(i){return{type:i.type}}function hs(i,t){let{alpha:e,mode:n,isMask:r}=i,s=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...T8(i),alpha:s,mode:n,isMask:r}}function M8(i,t){return{...hs(i,t),color:Mr(i.color,t)}}function C8(i,t){let{bias:e,scale:n,intensity:r,factor:s,color:o}=i;return{...hs(i,t),color:Mr(o,t),bias:e,scale:n,intensity:r,factor:s}}function P8(i,t){let{gradientType:e,smooth:n,colors:r,steps:s,angle:o,offset:a,morph:l}=i;return{...hs(i,t),gradientType:e,smooth:n,colors:r.map(u=>new Xe(u[0],u[1],u[2],u[3])),num:r.length,steps:s,offset:new B(...a),morph:new B(...l),angle:o}}function D8(i,t){let{gradientType:e,near:n,far:r,isVector:s,isWorldSpace:o,origin:a,direction:l,colors:u,steps:c,smooth:h}=i;return{...hs(i,t),gradientType:e,near:n,far:r,isVector:s,isWorldSpace:o,origin:new A(...a),direction:l?new A(...l):new A(1,0,0),colors:u.map(d=>d!==void 0?new Xe(d[0],d[1],d[2],d[3]):new Xe(0,0,0,0)),steps:c.slice(0,u.length),smooth:h}}function I8(i,t){let{cnormal:e}=i;return{...hs(i,t),cnormal:new A(e[0],e[1],e[2])}}function O8(i,t){return{...hs(i,t),scale:i.scale,move:i.move,fA:new B(...i.fA),fB:new B(...i.fB),size:new A(...i.size),distortion:new B(...i.distortion),colorA:Mr(i.colorA,t),colorB:Mr(i.colorB,t),colorC:Mr(i.colorC,t),colorD:Mr(i.colorD,t),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function R8(i,t){return{...hs(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new A(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new A(...i.offset)}}function L8(i,t){return{...hs(i,t),positioning:i.positioning,colors:i.colors.map(e=>new Xe(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new A(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:Mr(i.shadowColor,t),offset:new A(...i.offset)}}function N8(i,t){return{...hs(i,t),outlineColor:Mr(i.outlineColor,t),contourColor:Mr(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new A(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function B8(i,t){return{...hs(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function F8(i,t){return{...hs(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new B(...i.offset),colorA:Mr(i.colorA,t),colorB:Mr(i.colorB,t),frequency:new B(...i.frequency),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new B(...i.vertical),horizontal:new B(...i.horizontal),sides:i.sides}}var Xa=class extends hn{};var Zw={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Jw={depth:["colors"]};function k8(i,t,e){if(t==="isMask")return!0;let n=Zw[i.type],r=Jw[i.type];if(r!==void 0){let s=i.color;if(r.includes(t)){let o=s[t]?.value?.length;if(o!==void 0&&o!==e.length)return!0}}return n!==void 0?n.includes(t):!1}function $w(i,t,e){let n=e.uniforms[`f${e.id}_texture`];if(!n)return!1;let r=!1,s=i;if("image"in s){let o=s.image,a=t.image(o),l=n;l.image instanceof ki||l.image.deref(),l.image=a}if("video"in s){let o=s.video,a=t.video(o),l=n;l.image instanceof ki||l.image.deref(),l.image=a}if("wrapping"in s){let o=n;o.wrap=s.wrapping}if("repeat"in s||"offset"in s){let o="mat",a=e.uniforms[`f${e.id}_${o}`];"repeat"in s&&(a.repeat=s.repeat),"offset"in s&&(a.offset=s.offset),a.updateMatrix()}return r}function BD(i,t,e,n){let r=!1;for(let[s,o]of Object.entries(i)){if(s==="bumpMap"||s==="roughnessMap"){r=!0;continue}if(!s||o===void 0)continue;if(eA(s,e,n,t)){s==="visible"&&e.type==="light"&&(r=!0);continue}e.visible=n.visible;let a=e.uniforms[`f${e.id}_${s}`];if(!!a&&!(a instanceof qa))switch(r=r||k8(e,s,o),a.constructor){case Bt:if(typeof o=="string"){let l=t.getColor(o);l&&(a.value=l);break}else{let l=o;a.value instanceof Xa?a.value=new hn(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case ni:if(typeof o=="string"){let l=t.getColor(o);l&&(a.value=l);break}else{let l=o;a.value instanceof Xa?a.value=new hn(l.r,l.g,l.b,l.a):a.value.setRGBA(l.r,l.g,l.b,l.a);break}case mn:{let l=o;a.value.setX(l[0]),a.value.setY(l[1]);break}case _r:{let l=o;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case Wr:{$w(o,t,e);break}case us:{a.value=o.map(l=>new Xe(...l));break}default:{a.value=o;break}}}return r}var hp=(i,t)=>(typeof i=="string"?Math.max(0,Math.min(1,Number(t.getVariable(i)??100)/100)):i)??1,Ys=class{constructor(t,e,n,r,s){this.id=t;this.uuid=e;this.data=n;this.uniforms={};for(let o in r)this.uniforms[`f${this.id}_${o}`]=r[o];for(let o in n)eA(o,this,n,s)}get type(){return this.data.type}static create(t,e,n,r){if(n.type==="light")return Ai.createLigherLayer(t,e,n,r);if(n.type==="texture"||n.type==="video"){let s=n.type==="texture"?r.image(n.texture.image):r.video(n.texture.video),o=new Ql(s,n.texture.wrapping),a=new cv(s),l=new uv(n.texture.repeat,n.texture.offset),u=new Ce(n.crop?1:0),c=new gt(n.projection??0),h=new gt(["x","y","z"].indexOf(n.axis)??0),d=new gt(n.side??0),f=new mn(n.size?new B(n.size[0],n.size[1]):new B(100,100)),p=new Ce(n.blending??0),m=new Ce(hp(n.alpha,r)),g=new gt(n.mode??0),y=new bn(n.isMask??!1),v=new Ya(o,a,u,c,h,d,f,p,l,m,g,y),x=new Dt(v.calpha,"f");return new sn(t,e,n,{texture:o,textureSize:a,crop:u,projection:c,axis:h,side:d,size:f,blending:p,mat:l,alpha:m,mode:g,isMask:y},v,g,x,y,r)}else if(n.type==="matcap"){let s=r.image(n.texture.image),o=new Ql(s,n.texture.wrapping),a=new Ce(hp(n.alpha,r)),l=new gt(n.mode??0),u=new bn(n.isMask??!1),c=new zh(o,a,l,u),h=new Dt(c.calpha,"f");return new sn(t,e,n,{texture:o,alpha:a,mode:l,isMask:u},c,l,h,u,r)}else if(n.type==="displace")if(n.displacementType==="noise"){let s=new _r(new A(...n.offset)),o=new Ce(n.scale??10),a=new Ce(n.intensity??8),l=new Ce(n.movement??1),u=new gt(n.noiseType??0),c=new gt(n.voronoiStyle??0),h=new Ce(n.smoothness??.5),d=new Ce(n.seed??0),f=new Ce(n.highCut??1),p=new Ce(n.lowCut??0),m=new gt(n.quality??1),g=new Xh(a,l,s,c,h,d,f,p,m,o,u);return new dp(t,e,n,{offset:s,scale:o,intensity:a,movement:l,noiseType:u,voronoiStyle:c,smoothness:h,seed:d,highCut:f,lowCut:p,quality:m},g,r)}else throw new Error;else return z8(t,e,n,r)}updateByOp(t,e,n){let r=t;if(r.path[0]===void 0){if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props?(n.scene.markNeedsUpdateRendererDirty(),!0):BD(r.props,n.shared,this,e)}else if(r.path[0]==="texture")return"texture"in e||"video"in e?$w(r.props,n.shared,this):!0;return!1}dispose(){if(U8(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof ki||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let n=`f${this.id}_${t}`;this.hasValueByKey(n)&&e!==void 0&&(this.uniforms[n].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let n=/f\d+_(.*)/.exec(t);if(n&&n.length>1)return n[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let n=this.getName(e);n&&t.push(n)}return t}},sn=class extends Ys{constructor(e,n,r,s,o,a,l,u,c){super(e,n,r,s,c);this.params=s;this.color=o;this.mode=a;this.alpha=l;this.isMask=u}},dp=class extends Ys{constructor(e,n,r,s,o,a){super(e,n,r,s,a);this.position=o}},Ai=class extends Ys{constructor(e,n,r,s,o,a){super(e,n,r,o,a);this.node=s}static createLigherLayer(e,n,r,s){let o,a=new Ce(hp(r.alpha,s)),l=new gt(r.mode),u=new Ce(r.bumpMapIntensity),c=new Ce(hp(r.alphaOverride,s)),h;if(!r.visible)o=new $l,h={};else if(r.category==="lambert"){o=new op;let d=new Bt(s.color(r.emissive)??0),f=new bn(r.occlusion??!0);h={emissive:d,occlusion:f},o.emissive=d,o.occlusion=f}else if(r.category==="toon"){o=new cp;let d=new Ce(r.shininess??30),f=new Bt(s.color(r.specular)??1118481);h={shininess:d,specular:f},o.shininess=d,o.specular=f}else if(r.category==="physical"){o=new lp;let d=new Ce(r.roughness??.3),f=new Ce(r.metalness??0),p=new Ce(r.reflectivity??.5),m=new bn(r.occlusion??!0);h={roughness:d,metalness:f,reflectivity:p,occlusion:m},o.roughness=d,o.metalness=f,o.reflectivity=p,o.occlusion=m}else{o=new ap;let d=new Ce(r.shininess??30),f=new Bt(r.specular!==void 0?s.color(r.specular)??1118481:1118481),p=new bn(r.occlusion??!0);h={shininess:d,specular:f,occlusion:p},o.shininess=d,o.specular=f,o.occlusion=p}return o.alpha=new Ce(1),o.shadingAlpha=a,o.shadingBlend=l,o.bumpMapIntensity=u,o.alphaOverride=c,h.alpha=o.shadingAlpha,h.mode=o.shadingBlend,h.bumpMapIntensity=o.bumpMapIntensity,h.alphaOverride=o.alphaOverride,new Ai(e,n,r,o,h,s)}get category(){return this.node.category}};function U8(i){let t=i instanceof Ys?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Ui(i){return{alpha:new Ce(i.alpha??1),mode:new gt(i.mode??0),isMask:new bn(i.isMask??!1)}}function V8(i,t,e,n,r){switch(i.type){case"color":{let s=new Bt(n.color??Zn),o=Ui(n),a=new Zl(s,o.alpha),l=new Dt(a.calpha,"f");return new sn(t,e,i,{color:s,...o},a,o.mode,l,o.isMask,r)}case"fresnel":{let s=new Bt(n.color??16777215),o=new Ce(n.bias??.1),a=new Ce(n.scale??1),l=new Ce(n.intensity??2),u=new Ce(n.factor??1),c=Ui(n),h=new ip(s,o,a,l,u,c.alpha,c.mode,c.isMask),d=new Dt(h.calpha,"f");return new sn(t,e,i,{color:s,bias:o,scale:a,intensity:l,factor:u,...c},h,c.mode,d,c.isMask,r)}case"rainbow":{let s=new Ce(n.filmThickness??30),o=new Ce(n.movement??0),a=new _r(n.wavelengths??new A(0,0,0)),l=new Ce(n.noiseStrength??0),u=new Ce(n.noiseScale??1),c=new _r(n.offset??new A(0,0,0)),h=Ui(n),d=new Wh(s,o,a,l,u,c,h.alpha,h.isMask),f=new Dt(d.calpha,"f");return new sn(t,e,i,{filmThickness:s,movement:o,wavelengths:a,noiseStrength:l,noiseScale:u,offset:c,...h},d,h.mode,f,h.isMask,r)}case"transmission":{let s=new Ce(n.thickness??10),o=new Ce(n.ior??1.5),a=new Ce(n.roughness??.5),l=He.transmissionSize,u=He.transmissionRenderTarget,c=He.transmissionRenderTargetDepth,h=window.innerWidth,d=window.innerHeight,f=h>=d?new mn(d/h,1):new mn(1,h/d),p=Ui(n),m=new Yh(s,o,a,l,u,c,f,p.alpha),g=new Dt(m.calpha,"f");return new sn(t,e,i,{thickness:s,ior:o,roughness:a,aspectRatio:f,...p},m,p.mode,g,p.isMask,r)}case"toon":{let s=new gt(n.positioning??0),o;n.colors?o=new us(n.colors.length,n.colors):(o=new us(10,new Xe(0,0,0,1)),o.value[1]=new Xe(1,1,1,1));let a;n.steps?a=new cs(n.steps.length,n.steps):(a=new cs(10,1),a.value[0]=0);let l=new _r(n.source??new A(0,0,0)),u=new bn(n.isWorldSpace??!0),c=new Ce(n.noiseStrength??0),h=new Ce(n.noiseScale??1),d=new ni(n.shadowColor),f=new _r(n.offset??new A(0,0,0)),p=Ui(n),m=new qh(s,o,a,l,u,c,h,d,f,p.alpha),g=new Dt(m.calpha,"f");return new sn(t,e,i,{positioning:s,colors:o,steps:a,source:l,isWorldSpace:u,noiseStrength:c,noiseScale:h,shadowColor:d,offset:f,...p},m,p.mode,g,p.isMask,r)}case"outline":{let s=new Bt(n.outlineColor??16777215),o=new Bt(n.contourColor??16777215),a=new Ce(n.outlineWidth??.1),l=new Ce(n.contourWidth??.1),u=new Ce(n.outlineThreshold??.1),c=new Ce(n.contourThreshold??.1),h=new Ce(n.outlineSmoothing??.1),d=new Ce(n.contourFrequency??.1),f=new _r(n.contourDirection??new A(0,1,0)),p=new bn(n.positionalLines??!1),m=new bn(n.compensation??!0),g=He.normalRenderTarget,y=He.normalRenderTargetDepth,v=He.pixelRatioNode,x=He.resolution,b=Ui(n),w=new Hh(s,o,a,l,u,c,h,d,f,p,m,x,g,y,v,b.alpha),E=new Dt(w.calpha,"f");return new sn(t,e,i,{outlineColor:s,contourColor:o,outlineWidth:a,contourWidth:l,outlineThreshold:u,contourThreshold:c,outlineSmoothing:h,contourFrequency:d,contourDirection:f,positionalLines:p,compensation:m,...b},w,b.mode,E,b.isMask,r)}case"depth":{let s=new gt(n.gradientType??0),o=new bn(n.smooth??!1),a=new Ce(n.near??50),l=new Ce(n.far??200),u=new Ce(n.isVector??1),c=new Ce(n.isWorldSpace??0),h=new _r(n.origin??new A),d=new _r(n.direction??new A),f;n.colors?f=new us(n.colors.length,n.colors):(f=new us(2,new Xe(0,0,0,1)),f.value[1]=new Xe(1,1,1,1));let p;n.steps?p=new cs(n.steps.length,n.steps):(p=new cs(2,1),p.value[0]=0);let m=Ui(n),g=new Uh(s,o,a,l,u,c,h,d,f,p,m.alpha,m.isMask),y=new Dt(g.calpha,"f");return new sn(t,e,i,{gradientType:s,smooth:o,near:a,far:l,isVector:u,isWorldSpace:c,origin:h,direction:d,colors:f,steps:p,...m},g,m.mode,y,m.isMask,r)}case"noise":{let s=new Ce(n.scale??1),o=new _r(n.size??new A(100,100,100)),a=new Ce(n.move??1),l=new mn(n.fA??new B(1.7,9.2)),u=new mn(n.fB??new B(8.3,2.8)),c=new mn(n.distortion??new B(1,1)),h=new ni(n.colorA),d=new ni(n.colorB),f=new ni(n.colorC),p=new ni(n.colorD),m=new gt(n.noiseType??0),g=new gt(n.voronoiStyle??0),y=new Ce(n.highCut??1),v=new Ce(n.lowCut??0),x=new Ce(n.smoothness??.5),b=new Ce(n.seed??.5),w=new gt(n.quality??1),E=Ui(n),_=new Gh(s,o,a,l,u,c,h,d,f,p,E.alpha,m,E.isMask,g,y,v,x,b,w),S=new Dt(_.calpha,"f");return new sn(t,e,i,{scale:s,size:o,move:a,fA:l,fB:u,distortion:c,colorA:h,colorB:d,colorC:f,colorD:p,noiseType:m,...E,voronoiStyle:g,highCut:y,lowCut:v,smoothness:x,seed:b,quality:w},_,E.mode,S,E.isMask,r)}case"normal":{let s=new _r(n.cnormal??new A(1,1,1)),o=Ui(n),a=new Bh(s,o.alpha),l=new Dt(a.calpha,"f");return new sn(t,e,i,{cnormal:s,...o},a,o.mode,l,o.isMask,r)}case"gradient":{let s=new gt(n.gradientType??0),o=new bn(n.smooth??!1),a;n.colors?a=new us(n.colors.length,n.colors):(a=new us(10,new Xe(0,0,0,1)),a.value[1]=new Xe(1,1,1,1));let l;n.steps?l=new cs(n.steps.length,n.steps):(l=new cs(10,1),l.value[0]=0);let u=new mn(n.offset??new B(0,0)),c=new mn(n.morph??new B(0,0)),h=new Ce(n.angle??0),d=Ui(n),f=new Vh(s,o,a,l,u,c,h,d.alpha,d.isMask),p=new Dt(f.calpha,"f");return new sn(t,e,i,{gradientType:s,smooth:o,colors:a,steps:l,offset:u,morph:c,angle:h,...d},f,d.mode,p,d.isMask,r)}case"pattern":{let s=new gt(n.style??0),o=new gt(n.projection??0),a=new gt(["x","y","z"].indexOf(n.axis)??0),l=new Ce(n.blending??0),u=new mn(n.offset??new B(0,0)),c=new ni(n.colorA),h=new ni(n.colorB),d=new mn(n.frequency??new B(10,10)),f=new Ce(n.size??.5),p=new Ce(n.variation??0),m=new Ce(n.smoothness??.5),g=new Ce(n.zigzag??0),y=new Ce(n.rotation??0),v=new mn(n.vertical??new B(0,1)),x=new mn(n.horizontal??new B(0,1)),b=new gt(n.sides??6),w=Ui(n),E=new jh(s,o,a,l,u,c,h,d,f,p,m,g,y,v,x,b,w.alpha,w.isMask),_=new Dt(E.calpha,"f");return new sn(t,e,i,{style:s,projection:o,axis:a,blending:l,offset:u,colorA:c,colorB:h,frequency:d,size:f,variation:p,smoothness:m,zigzag:g,rotation:y,vertical:v,horizontal:x,sides:b,...w},E,w.mode,_,w.isMask,r)}default:{let s=new Bt(1,0,0,1),o=Ui(n),a=new Zl(s,o.alpha),l=new Dt(a.calpha,"f");return new sn(t,e,i,{color:s,...o},a,o.mode,l,o.isMask,r)}}}function z8(i,t,e,n){let r=ND(e,n);return V8(e,i,t,r,n)}function eA(i,t,e,n){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=e.intensity*(e.visible?1:0),r):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let r=t.uniforms[`f${t.id}_alpha`];if(!r)return;if(r.value=hp(e.alpha,n)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let s=t.uniforms[`f${t.id}_compensation`];s&&(s.value=e.compensation&&e.visible)}return r}}function fp(i,t){let e=0,n=i.layers.find(r=>r.data.type==="light");if(n){let r=n.data,s=Number(t.getVariable(r.alphaOverride));if((typeof r.alphaOverride=="string"?s/100:r.alphaOverride)<1)return!0}for(let r of i.layers){if(r.data.type!=="displace"&&r.data.isMask)return!0;if(r.data.type!=="displace"&&"alpha"in r.data&&r.data.type!=="light"&&r.data.type!=="fresnel"&&r.data.type!=="texture"&&r.data.type!=="matcap"&&r.data.type!=="rainbow"&&r.data.type!=="outline"&&r.data.type!=="pattern"){let s=r.data.visible?r.data.alpha:0;if(typeof s=="string"&&(s=Math.max(0,Math.min(1,Number(t.getVariable(s)??100)/100))),s===1&&r.data.type==="depth"||r.data.type==="gradient"){for(let o of r.data.colors)if(o[3]<1){s=o[3];break}}else if(s===1&&r.data.type==="noise"){let o=t.color(r.data.colorA).a,a=t.color(r.data.colorB).a,l=t.color(r.data.colorC).a,u=t.color(r.data.colorD).a,c=Math.min(o,Math.min(a,Math.min(l,u)));c<1&&(s=c)}e+=(1-e)*s}}return e<1}var ii=class extends ot{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}},vv=class extends ii{constructor(e,n,r,s){super();this.flatShading=e;this.side=n;this.wireframe=r;this.root=s}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,n){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,n,r){return this.root.getFlavor(e,n,r)}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,n,r){this.root.updateByOp(e,n,r)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},Go=class extends ii{constructor(e,n,r=!0){super();this.data=e;this.allowVariableSaves=r;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.reset0(e,n)}get nodeMaterial(){return this}getFlavor(e,n,r){let s=r?6:(e?3:0)+n;if(s===0)return this;this.flavors===void 0&&(this.flavors=[]),s-=1;let o=this.flavors[s];return o===void 0&&(o=new vv(e,n,r,this),this.flavors[s]=o,o.flatShading=e,o.side=n,o.updateAfterBuild()),o}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,n){this.data!==e&&this.reset0(e,n)}reset0(e,n){this.data=e;let r=e.layers??Tn.defaultTwoLayerData("phong").layers;try{this.layers=r.map(s=>Ys.create(this.layerIdGen++,s.id,s.data,n.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(n.shared),this.transparent=fp(e,n.shared),this.saveVariableLocations(n)}saveVariableLocations(e){if(!this.allowVariableSaves)return;let n=this.data.layers.find(r=>r.data.type==="light");n&&e.shared.getVariable(n.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(r=>{"alpha"in r.data&&typeof r.data.alpha=="string"&&e.shared.getVariable(r.data.alpha,["material",this.uuid,"layer",r.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(n=>n.type===e)}getLayerByUuid(e){return this.layers.find(n=>n.uuid===e)}onUpdate(e){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(n=>n instanceof Ai),this.lightLayer===void 0&&(this.lightLayer=new Ai(0,"",{...dr.defaultData("light","phong"),visible:!1},new $l,{},e)),this.dispose();for(let n of this.flavors)n&&n.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(o=>o instanceof Ai);if(!e)return;let n=e.data,r=n.bumpMap,s=n.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let o=0;o<this.layers.length;++o){let a=this.layers[o];a instanceof sn&&a.color instanceof Ya&&(a.uuid===r&&(e.node.bumpMap=a.color),a.uuid===s&&(e.node.roughnessMap=a.color))}}updateByOp(e,n,r){if(n!==void 0?this.data=n:n=this.data,this.transparent=fp(n,r.shared),e.path[0]==="layers"){this.data=n;let s=r.shared,o=e.path[1];if(o===void 0){if(this.layers.reverse(),e.type===4){let a=Ys.create(this.layerIdGen++,e.id,e.data,r.shared);this.layers.splice(e.localIndex,0,a),r.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),r.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let a=this.layers.findIndex(u=>u.uuid===e.id),l=this.layers[a];this.layers.splice(a,1),this.layers.splice(e.localIndex,0,l),r.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(r.shared)}else{e.type===0&&e.props.occlusion!==void 0&&r.scene.markNeedsUpdateRendererDirty();let a=this.layers.find(l=>l.uuid===o);if(a){let l=n.layers.data(o);if(a.updateByOp({...e,path:e.path.slice(2)},l,r)){let c=Ys.create(this.layerIdGen++,o,l,s);this.layers.splice(this.layers.findIndex(h=>h.uuid===o),1,c),this.onUpdate(r.shared)}}}}else this.reset(n,r)}applyMasks(){for(let e=0;e<this.layers.length;++e){let n=this.layers[e];n instanceof sn?n.color.mask=void 0:n instanceof Ai&&(n.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let n=this.layers[e];if(n instanceof sn&&n.isMask.value&&n.data.visible&&e>0){let r=e-1,s=this.layers[r];s instanceof Ai?s.node.mask=new pr(n.color,n.alpha,pr.MUL):s instanceof sn&&(s.isMask.value||(s.color.mask=new pr(n.color,n.alpha,pr.MUL)))}}}blendColors(){let e=this.layers.findIndex(r=>r instanceof sn),n=this.layers.findIndex(r=>r instanceof Ai);if(e!==-1&&e<n){let r=this.layers[e].color;for(let s=e+1;s<n;++s){let o=this.layers[s];if(o instanceof sn){if(o.isMask.value)continue;r=new Nh(r,o.color,o.alpha,o.mode)}}this.fragment.color=r}else this.fragment.color=void 0}blendAfterColors(){let e=new Dt("outgoingLight","f"),n=this.layers.findIndex(r=>r instanceof Ai);if(this.layers.length>n+1){for(let r=n+1;r<this.layers.length;++r){let s=this.layers[r];if(s instanceof sn){if(s.isMask.value)continue;e=new Nh(e,s.color,s.alpha,s.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(n=>n instanceof dp);if(e.length>0){let n=e[0].position;for(let r=1;r<e.length;++r)e[r]&&(n=new pr(n,e[r].position,pr.ADD),n=new pr(n,new Ce(.5).setReadonly(!0),pr.MUL));this.fragment.position=n}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,n){let r=(s,o,a)=>Math.min(Math.max(s,o),a);for(let s of this.layers)if(s.type==="displace"){let o=r(s.uniforms[`f${s.id}_intensity`].value,e,n);s.uniforms[`f${s.id}_intensity`].value=o}}computeCacheKey(){let e="[";for(let{data:n}of this.data.layers)if(n.type==="light")e+=`"${n.visible?n.category.toUpperCase():"Basic"}"`;else{let r=(Zw[n.type]??[]).map(u=>n[u]),s=(Jw[n.type]??[]).map(u=>n[u]?.length??0),o=[...r,...s],a="isMask"in n&&n.isMask,l=`"${n.type}-${n.visible}-${a}"`;o.length?e+=`[${l}, "${o.join('","')}"],`:e+=l}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let n=0;n<this.updaters.length;++n)e.updateNode(this.updaters[n])}build(){let e=new lv;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 n of this.flavors)n&&n.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 sn){let n=e.params.texture;if(n instanceof Ql&&!n.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(ii.prototype,{properties:{get:function(){return this.fragment.properties}}});var ec=class extends Go{constructor(t,e,n){super(t,e,!1),this.uuid=n,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var VD=$o(FD());var kD=new Map;function UD(i){if(typeof i=="string")return i;let t=kD.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},kD.set(i,t)),t.url}var Ho=class{constructor({src:t,volume:e,delay:n,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 t=="string"?s={src:t}:s={src:UD(t),format:"wav"},this.sound=new VD.Howl(s),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),n!==void 0&&(this.delay=n),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,n){this.sound.on(t,e,n)}off(t,e,n){this.sound.off(t,e,n)}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(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var bv=class{constructor(){this.type="ShapePath";this.color=new Fe;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Al,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,n,r){return this.currentPath?.quadraticCurveTo(t,e,n,r),this}bezierCurveTo(t,e,n,r,s,o){return this.currentPath?.bezierCurveTo(t,e,n,r,s,o),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},n={loc:e.ORIGIN,t:0};function r(m,g,y,v){let x=m.x,b=g.x,w=y.x,E=v.x,_=m.y,S=g.y,T=y.y,M=v.y,C=(E-w)*(_-T)-(M-T)*(x-w),D=(b-x)*(_-T)-(S-_)*(x-w),P=(M-T)*(b-x)-(E-w)*(S-_),I=C/P,L=D/P;if(P===0&&C!==0||I<=0||I>=1||L<0||L>1)return null;if(C===0&&P===0){for(let H=0;H<2;H++)if(s(H===0?y:v,m,g),n.loc===e.ORIGIN){let U=H===0?y:v;return{x:U.x,y:U.y,t:n.t}}else if(n.loc===e.BETWEEN){let U=+(x+n.t*(b-x)).toPrecision(10),G=+(_+n.t*(S-_)).toPrecision(10);return{x:U,y:G,t:n.t}}return null}else{for(let G=0;G<2;G++)if(s(G===0?y:v,m,g),n.loc===e.ORIGIN){let z=G===0?y:v;return{x:z.x,y:z.y,t:n.t}}let H=+(x+I*(b-x)).toPrecision(10),U=+(_+I*(S-_)).toPrecision(10);return{x:H,y:U,t:I}}}function s(m,g,y){let v=y.x-g.x,x=y.y-g.y,b=m.x-g.x,w=m.y-g.y,E=v*w-b*x;if(m.x===g.x&&m.y===g.y){n.loc=e.ORIGIN,n.t=0;return}if(m.x===y.x&&m.y===y.y){n.loc=e.DESTINATION,n.t=1;return}if(E<-Number.EPSILON){n.loc=e.LEFT;return}if(E>Number.EPSILON){n.loc=e.RIGHT;return}if(v*b<0||x*w<0){n.loc=e.BEHIND;return}if(Math.sqrt(v*v+x*x)<Math.sqrt(b*b+w*w)){n.loc=e.BEYOND;return}let _;v!==0?_=b/v:_=w/x,n.loc=e.BETWEEN,n.t=_}function o(m,g){let y=[],v=[];for(let x=1;x<m.length;x++){let b=m[x-1],w=m[x];for(let E=1;E<g.length;E++){let _=g[E-1],S=g[E],T=r(b,w,_,S);T!==null&&y.find(M=>M.t<=T.t+Number.EPSILON&&M.t>=T.t-Number.EPSILON)===void 0&&(y.push(T),v.push(new B(T.x,T.y)))}}return v}function a(m,g,y){let v=new B;g.getCenter(v);let x=[];return y.forEach(b=>{b.boundingBox.containsPoint(v)&&o(m,b.points).forEach(E=>{x.push({identifier:b.identifier,isCW:b.isCW,point:E})})}),x.sort((b,w)=>b.point.x-w.point.x),x}function l(m,g,y,v,x){(x==null||x==="")&&(x="nonzero");let b=new B;m.boundingBox.getCenter(b);let w=[new B(y,b.y),new B(v,b.y)],E=a(w,m.boundingBox,g);E.sort((D,P)=>D.point.x-P.point.x);let _=[],S=[];E.forEach(D=>{D.identifier===m.identifier?_.push(D):S.push(D)});let T=_[0].point.x,M=[],C=0;for(;C<S.length&&S[C].point.x<T;)M.length>0&&M[M.length-1]===S[C].identifier?M.pop():M.push(S[C].identifier),C++;if(M.push(m.identifier),x==="evenodd"){let D=M.length%2===0,P=M[M.length-2];return{identifier:m.identifier,isHole:D,for:P}}else if(x==="nonzero"){let D=!0,P=null,I=null;for(let L=0;L<M.length;L++){let H=M[L];g[H]&&(D?(I=g[H].isCW,D=!1,P=H):I!==g[H].isCW&&(I=g[H].isCW,D=!0))}return{identifier:m.identifier,isHole:D,for:P}}else console.warn('fill-rule: "'+x+'" is currently not implemented.')}let u=0,c=999999999,h=-999999999,d=[];this.subPaths.forEach(m=>{let g=m.getPoints(),y=-999999999,v=999999999,x=-999999999,b=999999999;for(let w=0;w<g.length;w++){let E=g[w];E.y>y&&(y=E.y),E.y<v&&(v=E.y),E.x>x&&(x=E.x),E.x<b&&(b=E.x)}h<=x&&(h=x+1),c>=b&&(c=b-1),g.length&&d.push({curves:m.curves,points:g,isCW:Gc.isClockWise(g),identifier:u++,boundingBox:new Zm(new B(b,v),new B(x,y))})});let f=d.map(m=>l(m,d,c,h,this.userData?.style.fillRule)),p=[];return d.forEach(m=>{let g=f[m.identifier];if(g&&!g.isHole){let y=new _o;y.curves=m.curves,f.filter(x=>x?.isHole&&x.for===m.identifier).forEach(x=>{if(x){let b=d[x.identifier],w=new Al;w.curves=b.curves,y.holes.push(w)}}),p.push(y)}}),p}};var GD,tA=new Promise(i=>{GD=i}),zD=!1;var Sv;function HD(){if(zD)return;if(Sv)return Sv;async function i(){let e=await import("./opentype.js");GD(e),zD=!0}return Sv=i(),Sv}var pp=class{async load(t,e,n=()=>{}){let{load:r}=await tA;r(t,(s,o)=>{s||!o?n(s??"Something went wrong"):e(o)})}async parse(t){let{parse:e,Bidi:n}=await tA;try{let r=e(t),s=new n,o=a=>r.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,o),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};async function G8(i){return await(await fetch(i)).arrayBuffer()}var H8=new pp;async function nA(i){let t,e,n=!1;if(i.url?(t=await G8(i.url),e=i.url,n=i.url.startsWith("/")):i.data&&(t=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),t){let r=await H8.parse(t);if(r)return{font:r.font,url:e,intercepted:n,arr:t,bidi:r.bidi}}}function j8(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var wv=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=nA(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=nA(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,n){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(e);let s=r.tokenizer.tokens,o=[],a=0,l=n.length===s.length;for(let u=0;u<n.length;u++){let c=n[u].index,h=String.fromCharCode(n[u].unicode),d=s[a];if(j8(c,d)||l)o.push({char:h,index:c,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let f=d.char,p="",m=[d.state.glyphIndex],g=[],y=!1;for(;!y;)a++,p=e.charAt(a),f+=p,m.push(t.charToGlyphIndex(p)),g=t.stringToGlyphs(f),g.length===1&&g[0].index===c&&(y=!0),a>e.length&&(y=!0);o.push({char:h,index:c,replacements:m,replacementChars:Array.from(f)}),a++}}return o}generateShapes(t,e){if(!this._isLoaded)return;let n=this.font,r=e.fontSize/this.unitsPerEm,s=e.fontSize*e.lineHeight,o=t.map(v=>this.getTextWidth(v,e)),a=e.width,l=this.getCharWidth(`
|
|
5353
|
+
`)}return n}};var hv=class{constructor(t=1e3*10){this.timeout=t;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(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),n=this.cache.get(t);return n===void 0?(n={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,n)):(n.time=e,n.prev.next=n.next,n.next.prev=n.prev),n.prev=this.tail.prev,n.next=this.tail,this.tail.prev.next=n,this.tail.prev=n,this.scheduleCleanup(),n.data}};var zw=class extends hv{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},Vw;function bD(i){return typeof i=="string"?i:(Vw||(Vw=new zw),Vw.load(i))}var dv=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},fv=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var Kh=class extends dv{constructor(e,n){super(e,n.imageHolderCache);this.data=e;this.shared=n;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 n=()=>{this.loaded=!0;let s=[1e3,1001,1002];for(let o of s){let a=this[o];a&&(a.image=this.img,a.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 r=new FileReader;r.readAsDataURL(new Blob([e],{type:"video/mp4"}));let s;await new Promise(o=>{r.onloadend=a=>{s=a.target?.result,o(null)}}),this.img.src=s}else this.img.src=e;this.img.onloadeddata=()=>{n()}}else this.img=new Image,this.img.src=bD(e),this.img.onload=n}getTexture(e){let n=this[e];if(n)return n;{let r;return this.isVideo?r=new Gm(this.img,void 0,e,e):r=new en(this.img,void 0,e,e),this.loaded&&(r.needsUpdate=!0),this[e]=r,r}}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()}};1e3,1001,1002;var ki=class extends Kh{};function Hw(i,t){var e=u8(t);return e.formatToParts?l8(e,i):c8(e,i)}var a8={year:0,month:1,day:2,hour:3,minute:4,second:5};function l8(i,t){try{for(var e=i.formatToParts(t),n=[],r=0;r<e.length;r++){var s=a8[e[r].type];s>=0&&(n[s]=parseInt(e[r].value,10))}return n}catch(o){if(o instanceof RangeError)return[NaN];throw o}}function c8(i,t){var e=i.format(t).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(e);return[n[3],n[1],n[2],n[4],n[5],n[6]]}var Gw={};function u8(i){if(!Gw[i]){var t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:"America/New_York",year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),e=t==="06/25/2014, 00:00:00"||t==="\u200E06\u200E/\u200E25\u200E/\u200E2014\u200E \u200E00\u200E:\u200E00\u200E:\u200E00";Gw[i]=e?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:i,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:i,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return Gw[i]}function pv(i,t,e,n,r,s,o){var a=new Date(0);return a.setUTCFullYear(i,t,e),a.setUTCHours(n,r,s,o),a}var SD=36e5,h8=6e4,jw={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function up(i,t,e){var n,r;if(!i||(n=jw.timezoneZ.exec(i),n))return 0;var s;if(n=jw.timezoneHH.exec(i),n)return s=parseInt(n[1],10),wD(s)?-(s*SD):NaN;if(n=jw.timezoneHHMM.exec(i),n){s=parseInt(n[1],10);var o=parseInt(n[2],10);return wD(s,o)?(r=Math.abs(s)*SD+o*h8,s>0?-r:r):NaN}if(p8(i)){t=new Date(t||Date.now());var a=e?t:d8(t),l=Ww(a,i),u=e?l:f8(t,l,i);return-u}return NaN}function d8(i){return pv(i.getFullYear(),i.getMonth(),i.getDate(),i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds())}function Ww(i,t){var e=Hw(i,t),n=pv(e[0],e[1]-1,e[2],e[3]%24,e[4],e[5],0).getTime(),r=i.getTime(),s=r%1e3;return r-=s>=0?s:1e3+s,n-r}function f8(i,t,e){var n=i.getTime(),r=n-t,s=Ww(new Date(r),e);if(t===s)return t;r-=s-t;var o=Ww(new Date(r),e);return s===o?s:Math.max(s,o)}function wD(i,t){return-23<=i&&i<=23&&(t==null||0<=t&&t<=59)}var AD={};function p8(i){if(AD[i])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:i}),AD[i]=!0,!0}catch{return!1}}var RD=$o(_D(),1),Xw=$o(MD(),1);var y8=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,CD=y8;var qw=36e5,PD=6e4,v8=2,qr={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:CD};function Kw(i,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(i===null)return new Date(NaN);var e=t||{},n=e.additionalDigits==null?v8:(0,RD.default)(e.additionalDigits);if(n!==2&&n!==1&&n!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]")return new Date(i.getTime());if(typeof i=="number"||Object.prototype.toString.call(i)==="[object Number]")return new Date(i);if(!(typeof i=="string"||Object.prototype.toString.call(i)==="[object String]"))return new Date(NaN);var r=x8(i),s=b8(r.date,n),o=s.year,a=s.restDateString,l=S8(a,o);if(isNaN(l))return new Date(NaN);if(l){var u=l.getTime(),c=0,h;if(r.time&&(c=w8(r.time),isNaN(c)))return new Date(NaN);if(r.timeZone||e.timeZone){if(h=up(r.timeZone||e.timeZone,new Date(u+c)),isNaN(h))return new Date(NaN)}else h=(0,Xw.default)(new Date(u+c)),h=(0,Xw.default)(new Date(u+c+h));return new Date(u+c+h)}else return new Date(NaN)}function x8(i){var t={},e=qr.dateTimePattern.exec(i),n;if(e?(t.date=e[1],n=e[3]):(e=qr.datePattern.exec(i),e?(t.date=e[1],n=e[2]):(t.date=null,n=i)),n){var r=qr.timeZone.exec(n);r?(t.time=n.replace(r[1],""),t.timeZone=r[1].trim()):t.time=n}return t}function b8(i,t){var e=qr.YYY[t],n=qr.YYYYY[t],r;if(r=qr.YYYY.exec(i)||n.exec(i),r){var s=r[1];return{year:parseInt(s,10),restDateString:i.slice(s.length)}}if(r=qr.YY.exec(i)||e.exec(i),r){var o=r[1];return{year:parseInt(o,10)*100,restDateString:i.slice(o.length)}}return{year:null}}function S8(i,t){if(t===null)return null;var e,n,r,s;if(i.length===0)return n=new Date(0),n.setUTCFullYear(t),n;if(e=qr.MM.exec(i),e)return n=new Date(0),r=parseInt(e[1],10)-1,ID(t,r)?(n.setUTCFullYear(t,r),n):new Date(NaN);if(e=qr.DDD.exec(i),e){n=new Date(0);var o=parseInt(e[1],10);return _8(t,o)?(n.setUTCFullYear(t,0,o),n):new Date(NaN)}if(e=qr.MMDD.exec(i),e){n=new Date(0),r=parseInt(e[1],10)-1;var a=parseInt(e[2],10);return ID(t,r,a)?(n.setUTCFullYear(t,r,a),n):new Date(NaN)}if(e=qr.Www.exec(i),e)return s=parseInt(e[1],10)-1,OD(t,s)?DD(t,s):new Date(NaN);if(e=qr.WwwD.exec(i),e){s=parseInt(e[1],10)-1;var l=parseInt(e[2],10)-1;return OD(t,s,l)?DD(t,s,l):new Date(NaN)}return null}function w8(i){var t,e,n;if(t=qr.HH.exec(i),t)return e=parseFloat(t[1].replace(",",".")),Yw(e)?e%24*qw:NaN;if(t=qr.HHMM.exec(i),t)return e=parseInt(t[1],10),n=parseFloat(t[2].replace(",",".")),Yw(e,n)?e%24*qw+n*PD:NaN;if(t=qr.HHMMSS.exec(i),t){e=parseInt(t[1],10),n=parseInt(t[2],10);var r=parseFloat(t[3].replace(",","."));return Yw(e,n,r)?e%24*qw+n*PD+r*1e3:NaN}return null}function DD(i,t,e){t=t||0,e=e||0;var n=new Date(0);n.setUTCFullYear(i,0,4);var r=n.getUTCDay()||7,s=t*7+e+1-r;return n.setUTCDate(n.getUTCDate()+s),n}var A8=[31,28,31,30,31,30,31,31,30,31,30,31],E8=[31,29,31,30,31,30,31,31,30,31,30,31];function LD(i){return i%400===0||i%4===0&&i%100!==0}function ID(i,t,e){if(t<0||t>11)return!1;if(e!=null){if(e<1)return!1;var n=LD(i);if(n&&e>E8[t]||!n&&e>A8[t])return!1}return!0}function _8(i,t){if(t<1)return!1;var e=LD(i);return!(e&&t>366||!e&&t>365)}function OD(i,t,e){return!(t<0||t>52||e!=null&&(e<0||e>6))}function Yw(i,t,e){return!(i!=null&&(i<0||i>=25)||t!=null&&(t<0||t>=60)||e!=null&&(e<0||e>=60))}function yv(i,t,e){var n=Kw(i,e),r=up(t,n,!0),s=new Date(n.getTime()-r),o=new Date(0);return o.setFullYear(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()),o.setHours(s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()),o}function Mr(i,t){return t.color(i)}function Qw(i=new Date,t){let e=t.format,n=i.getSeconds(),r=i;t&&t.timeZone!==null&&(r=yv(new Date,t.timeZone));let s=r.getHours(),o=r.getMinutes(),a;t.format12h24h==="12ampm"&&(a=s>=12?"PM":"AM");let l=s;t.format12h24h!=="24"&&(l=s%12,l===0&&(l=12));let u,c;switch(e){case"HH:mm:ss":u=[l,o,n];break;case"HH:mm":u=[l,o];break;case"HH":u=[l],a=void 0;break;case"mm":u=[o],a=void 0;break;case"ss":u=[n],a=void 0;break;case"year":c=r.getFullYear();break;case"month":c=r.getMonth()+1;break;case"dayOfYear":c=Math.floor((r.getTime()-new Date(r.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":c=r.getDate();break;case"secondOfDay":c=s*60*60+o*60+n;break;default:console.error("Unknown time format",e),c=0;break}return u!==void 0?{textValue:u,suffix:a}:c}function ND(i,t){switch(i.type){case"fresnel":return C8(i,t);case"gradient":return P8(i,t);case"depth":return D8(i,t);case"normal":return I8(i,t);case"noise":return O8(i,t);case"rainbow":return R8(i,t);case"toon":return L8(i,t);case"outline":return N8(i,t);case"transmission":return B8(i,t);case"color":return M8(i,t);case"pattern":return F8(i,t)}}function T8(i){return{type:i.type}}function hs(i,t){let{alpha:e,mode:n,isMask:r}=i,s=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...T8(i),alpha:s,mode:n,isMask:r}}function M8(i,t){return{...hs(i,t),color:Mr(i.color,t)}}function C8(i,t){let{bias:e,scale:n,intensity:r,factor:s,color:o}=i;return{...hs(i,t),color:Mr(o,t),bias:e,scale:n,intensity:r,factor:s}}function P8(i,t){let{gradientType:e,smooth:n,colors:r,steps:s,angle:o,offset:a,morph:l}=i;return{...hs(i,t),gradientType:e,smooth:n,colors:r.map(u=>new Xe(u[0],u[1],u[2],u[3])),num:r.length,steps:s,offset:new B(...a),morph:new B(...l),angle:o}}function D8(i,t){let{gradientType:e,near:n,far:r,isVector:s,isWorldSpace:o,origin:a,direction:l,colors:u,steps:c,smooth:h}=i;return{...hs(i,t),gradientType:e,near:n,far:r,isVector:s,isWorldSpace:o,origin:new A(...a),direction:l?new A(...l):new A(1,0,0),colors:u.map(d=>d!==void 0?new Xe(d[0],d[1],d[2],d[3]):new Xe(0,0,0,0)),steps:c.slice(0,u.length),smooth:h}}function I8(i,t){let{cnormal:e}=i;return{...hs(i,t),cnormal:new A(e[0],e[1],e[2])}}function O8(i,t){return{...hs(i,t),scale:i.scale,move:i.move,fA:new B(...i.fA),fB:new B(...i.fB),size:new A(...i.size),distortion:new B(...i.distortion),colorA:Mr(i.colorA,t),colorB:Mr(i.colorB,t),colorC:Mr(i.colorC,t),colorD:Mr(i.colorD,t),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function R8(i,t){return{...hs(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new A(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new A(...i.offset)}}function L8(i,t){return{...hs(i,t),positioning:i.positioning,colors:i.colors.map(e=>new Xe(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new A(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:Mr(i.shadowColor,t),offset:new A(...i.offset)}}function N8(i,t){return{...hs(i,t),outlineColor:Mr(i.outlineColor,t),contourColor:Mr(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new A(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function B8(i,t){return{...hs(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function F8(i,t){return{...hs(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new B(...i.offset),colorA:Mr(i.colorA,t),colorB:Mr(i.colorB,t),frequency:new B(...i.frequency),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new B(...i.vertical),horizontal:new B(...i.horizontal),sides:i.sides}}var Xa=class extends hn{};var Zw={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Jw={depth:["colors"]};function k8(i,t,e){if(t==="isMask")return!0;let n=Zw[i.type],r=Jw[i.type];if(r!==void 0){let s=i.color;if(r.includes(t)){let o=s[t]?.value?.length;if(o!==void 0&&o!==e.length)return!0}}return n!==void 0?n.includes(t):!1}function $w(i,t,e){let n=e.uniforms[`f${e.id}_texture`];if(!n)return!1;let r=!1,s=i;if("image"in s){let o=s.image,a=t.image(o),l=n;l.image instanceof ki||l.image.deref(),l.image=a}if("video"in s){let o=s.video,a=t.video(o),l=n;l.image instanceof ki||l.image.deref(),l.image=a}if("wrapping"in s){let o=n;o.wrap=s.wrapping}if("repeat"in s||"offset"in s){let o="mat",a=e.uniforms[`f${e.id}_${o}`];"repeat"in s&&(a.repeat=s.repeat),"offset"in s&&(a.offset=s.offset),a.updateMatrix()}return r}function BD(i,t,e,n){let r=!1;for(let[s,o]of Object.entries(i)){if(s==="bumpMap"||s==="roughnessMap"){r=!0;continue}if(!s||o===void 0)continue;if(eA(s,e,n,t)){s==="visible"&&e.type==="light"&&(r=!0);continue}e.visible=n.visible;let a=e.uniforms[`f${e.id}_${s}`];if(!!a&&!(a instanceof qa))switch(r=r||k8(e,s,o),a.constructor){case Bt:if(typeof o=="string"){let l=t.getColor(o);l&&(a.value=l);break}else{let l=o;a.value instanceof Xa?a.value=new hn(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case ni:if(typeof o=="string"){let l=t.getColor(o);l&&(a.value=l);break}else{let l=o;a.value instanceof Xa?a.value=new hn(l.r,l.g,l.b,l.a):a.value.setRGBA(l.r,l.g,l.b,l.a);break}case gn:{let l=o;a.value.setX(l[0]),a.value.setY(l[1]);break}case _r:{let l=o;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case Wr:{$w(o,t,e);break}case us:{a.value=o.map(l=>new Xe(...l));break}default:{a.value=o;break}}}return r}var hp=(i,t)=>(typeof i=="string"?Math.max(0,Math.min(1,Number(t.getVariable(i)??100)/100)):i)??1,Ys=class{constructor(t,e,n,r,s){this.id=t;this.uuid=e;this.data=n;this.uniforms={};for(let o in r)this.uniforms[`f${this.id}_${o}`]=r[o];for(let o in n)eA(o,this,n,s)}get type(){return this.data.type}static create(t,e,n,r){if(n.type==="light")return Ai.createLigherLayer(t,e,n,r);if(n.type==="texture"||n.type==="video"){let s=n.type==="texture"?r.image(n.texture.image):r.video(n.texture.video),o=new Ql(s,n.texture.wrapping),a=new cv(s),l=new uv(n.texture.repeat,n.texture.offset),u=new Ce(n.crop?1:0),c=new gt(n.projection??0),h=new gt(["x","y","z"].indexOf(n.axis)??0),d=new gt(n.side??0),f=new gn(n.size?new B(n.size[0],n.size[1]):new B(100,100)),p=new Ce(n.blending??0),m=new Ce(hp(n.alpha,r)),g=new gt(n.mode??0),y=new bn(n.isMask??!1),v=new Ya(o,a,u,c,h,d,f,p,l,m,g,y),x=new Dt(v.calpha,"f");return new sn(t,e,n,{texture:o,textureSize:a,crop:u,projection:c,axis:h,side:d,size:f,blending:p,mat:l,alpha:m,mode:g,isMask:y},v,g,x,y,r)}else if(n.type==="matcap"){let s=r.image(n.texture.image),o=new Ql(s,n.texture.wrapping),a=new Ce(hp(n.alpha,r)),l=new gt(n.mode??0),u=new bn(n.isMask??!1),c=new zh(o,a,l,u),h=new Dt(c.calpha,"f");return new sn(t,e,n,{texture:o,alpha:a,mode:l,isMask:u},c,l,h,u,r)}else if(n.type==="displace")if(n.displacementType==="noise"){let s=new _r(new A(...n.offset)),o=new Ce(n.scale??10),a=new Ce(n.intensity??8),l=new Ce(n.movement??1),u=new gt(n.noiseType??0),c=new gt(n.voronoiStyle??0),h=new Ce(n.smoothness??.5),d=new Ce(n.seed??0),f=new Ce(n.highCut??1),p=new Ce(n.lowCut??0),m=new gt(n.quality??1),g=new Xh(a,l,s,c,h,d,f,p,m,o,u);return new dp(t,e,n,{offset:s,scale:o,intensity:a,movement:l,noiseType:u,voronoiStyle:c,smoothness:h,seed:d,highCut:f,lowCut:p,quality:m},g,r)}else throw new Error;else return z8(t,e,n,r)}updateByOp(t,e,n){let r=t;if(r.path[0]===void 0){if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props?(n.scene.markNeedsUpdateRendererDirty(),!0):BD(r.props,n.shared,this,e)}else if(r.path[0]==="texture")return"texture"in e||"video"in e?$w(r.props,n.shared,this):!0;return!1}dispose(){if(U8(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof ki||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let n=`f${this.id}_${t}`;this.hasValueByKey(n)&&e!==void 0&&(this.uniforms[n].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let n=/f\d+_(.*)/.exec(t);if(n&&n.length>1)return n[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let n=this.getName(e);n&&t.push(n)}return t}},sn=class extends Ys{constructor(e,n,r,s,o,a,l,u,c){super(e,n,r,s,c);this.params=s;this.color=o;this.mode=a;this.alpha=l;this.isMask=u}},dp=class extends Ys{constructor(e,n,r,s,o,a){super(e,n,r,s,a);this.position=o}},Ai=class extends Ys{constructor(e,n,r,s,o,a){super(e,n,r,o,a);this.node=s}static createLigherLayer(e,n,r,s){let o,a=new Ce(hp(r.alpha,s)),l=new gt(r.mode),u=new Ce(r.bumpMapIntensity),c=new Ce(hp(r.alphaOverride,s)),h;if(!r.visible)o=new $l,h={};else if(r.category==="lambert"){o=new op;let d=new Bt(s.color(r.emissive)??0),f=new bn(r.occlusion??!0);h={emissive:d,occlusion:f},o.emissive=d,o.occlusion=f}else if(r.category==="toon"){o=new cp;let d=new Ce(r.shininess??30),f=new Bt(s.color(r.specular)??1118481);h={shininess:d,specular:f},o.shininess=d,o.specular=f}else if(r.category==="physical"){o=new lp;let d=new Ce(r.roughness??.3),f=new Ce(r.metalness??0),p=new Ce(r.reflectivity??.5),m=new bn(r.occlusion??!0);h={roughness:d,metalness:f,reflectivity:p,occlusion:m},o.roughness=d,o.metalness=f,o.reflectivity=p,o.occlusion=m}else{o=new ap;let d=new Ce(r.shininess??30),f=new Bt(r.specular!==void 0?s.color(r.specular)??1118481:1118481),p=new bn(r.occlusion??!0);h={shininess:d,specular:f,occlusion:p},o.shininess=d,o.specular=f,o.occlusion=p}return o.alpha=new Ce(1),o.shadingAlpha=a,o.shadingBlend=l,o.bumpMapIntensity=u,o.alphaOverride=c,h.alpha=o.shadingAlpha,h.mode=o.shadingBlend,h.bumpMapIntensity=o.bumpMapIntensity,h.alphaOverride=o.alphaOverride,new Ai(e,n,r,o,h,s)}get category(){return this.node.category}};function U8(i){let t=i instanceof Ys?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Ui(i){return{alpha:new Ce(i.alpha??1),mode:new gt(i.mode??0),isMask:new bn(i.isMask??!1)}}function V8(i,t,e,n,r){switch(i.type){case"color":{let s=new Bt(n.color??Zn),o=Ui(n),a=new Zl(s,o.alpha),l=new Dt(a.calpha,"f");return new sn(t,e,i,{color:s,...o},a,o.mode,l,o.isMask,r)}case"fresnel":{let s=new Bt(n.color??16777215),o=new Ce(n.bias??.1),a=new Ce(n.scale??1),l=new Ce(n.intensity??2),u=new Ce(n.factor??1),c=Ui(n),h=new ip(s,o,a,l,u,c.alpha,c.mode,c.isMask),d=new Dt(h.calpha,"f");return new sn(t,e,i,{color:s,bias:o,scale:a,intensity:l,factor:u,...c},h,c.mode,d,c.isMask,r)}case"rainbow":{let s=new Ce(n.filmThickness??30),o=new Ce(n.movement??0),a=new _r(n.wavelengths??new A(0,0,0)),l=new Ce(n.noiseStrength??0),u=new Ce(n.noiseScale??1),c=new _r(n.offset??new A(0,0,0)),h=Ui(n),d=new Wh(s,o,a,l,u,c,h.alpha,h.isMask),f=new Dt(d.calpha,"f");return new sn(t,e,i,{filmThickness:s,movement:o,wavelengths:a,noiseStrength:l,noiseScale:u,offset:c,...h},d,h.mode,f,h.isMask,r)}case"transmission":{let s=new Ce(n.thickness??10),o=new Ce(n.ior??1.5),a=new Ce(n.roughness??.5),l=He.transmissionSize,u=He.transmissionRenderTarget,c=He.transmissionRenderTargetDepth,h=window.innerWidth,d=window.innerHeight,f=h>=d?new gn(d/h,1):new gn(1,h/d),p=Ui(n),m=new Yh(s,o,a,l,u,c,f,p.alpha),g=new Dt(m.calpha,"f");return new sn(t,e,i,{thickness:s,ior:o,roughness:a,aspectRatio:f,...p},m,p.mode,g,p.isMask,r)}case"toon":{let s=new gt(n.positioning??0),o;n.colors?o=new us(n.colors.length,n.colors):(o=new us(10,new Xe(0,0,0,1)),o.value[1]=new Xe(1,1,1,1));let a;n.steps?a=new cs(n.steps.length,n.steps):(a=new cs(10,1),a.value[0]=0);let l=new _r(n.source??new A(0,0,0)),u=new bn(n.isWorldSpace??!0),c=new Ce(n.noiseStrength??0),h=new Ce(n.noiseScale??1),d=new ni(n.shadowColor),f=new _r(n.offset??new A(0,0,0)),p=Ui(n),m=new qh(s,o,a,l,u,c,h,d,f,p.alpha),g=new Dt(m.calpha,"f");return new sn(t,e,i,{positioning:s,colors:o,steps:a,source:l,isWorldSpace:u,noiseStrength:c,noiseScale:h,shadowColor:d,offset:f,...p},m,p.mode,g,p.isMask,r)}case"outline":{let s=new Bt(n.outlineColor??16777215),o=new Bt(n.contourColor??16777215),a=new Ce(n.outlineWidth??.1),l=new Ce(n.contourWidth??.1),u=new Ce(n.outlineThreshold??.1),c=new Ce(n.contourThreshold??.1),h=new Ce(n.outlineSmoothing??.1),d=new Ce(n.contourFrequency??.1),f=new _r(n.contourDirection??new A(0,1,0)),p=new bn(n.positionalLines??!1),m=new bn(n.compensation??!0),g=He.normalRenderTarget,y=He.normalRenderTargetDepth,v=He.pixelRatioNode,x=He.resolution,b=Ui(n),w=new Hh(s,o,a,l,u,c,h,d,f,p,m,x,g,y,v,b.alpha),E=new Dt(w.calpha,"f");return new sn(t,e,i,{outlineColor:s,contourColor:o,outlineWidth:a,contourWidth:l,outlineThreshold:u,contourThreshold:c,outlineSmoothing:h,contourFrequency:d,contourDirection:f,positionalLines:p,compensation:m,...b},w,b.mode,E,b.isMask,r)}case"depth":{let s=new gt(n.gradientType??0),o=new bn(n.smooth??!1),a=new Ce(n.near??50),l=new Ce(n.far??200),u=new Ce(n.isVector??1),c=new Ce(n.isWorldSpace??0),h=new _r(n.origin??new A),d=new _r(n.direction??new A),f;n.colors?f=new us(n.colors.length,n.colors):(f=new us(2,new Xe(0,0,0,1)),f.value[1]=new Xe(1,1,1,1));let p;n.steps?p=new cs(n.steps.length,n.steps):(p=new cs(2,1),p.value[0]=0);let m=Ui(n),g=new Uh(s,o,a,l,u,c,h,d,f,p,m.alpha,m.isMask),y=new Dt(g.calpha,"f");return new sn(t,e,i,{gradientType:s,smooth:o,near:a,far:l,isVector:u,isWorldSpace:c,origin:h,direction:d,colors:f,steps:p,...m},g,m.mode,y,m.isMask,r)}case"noise":{let s=new Ce(n.scale??1),o=new _r(n.size??new A(100,100,100)),a=new Ce(n.move??1),l=new gn(n.fA??new B(1.7,9.2)),u=new gn(n.fB??new B(8.3,2.8)),c=new gn(n.distortion??new B(1,1)),h=new ni(n.colorA),d=new ni(n.colorB),f=new ni(n.colorC),p=new ni(n.colorD),m=new gt(n.noiseType??0),g=new gt(n.voronoiStyle??0),y=new Ce(n.highCut??1),v=new Ce(n.lowCut??0),x=new Ce(n.smoothness??.5),b=new Ce(n.seed??.5),w=new gt(n.quality??1),E=Ui(n),_=new Gh(s,o,a,l,u,c,h,d,f,p,E.alpha,m,E.isMask,g,y,v,x,b,w),S=new Dt(_.calpha,"f");return new sn(t,e,i,{scale:s,size:o,move:a,fA:l,fB:u,distortion:c,colorA:h,colorB:d,colorC:f,colorD:p,noiseType:m,...E,voronoiStyle:g,highCut:y,lowCut:v,smoothness:x,seed:b,quality:w},_,E.mode,S,E.isMask,r)}case"normal":{let s=new _r(n.cnormal??new A(1,1,1)),o=Ui(n),a=new Bh(s,o.alpha),l=new Dt(a.calpha,"f");return new sn(t,e,i,{cnormal:s,...o},a,o.mode,l,o.isMask,r)}case"gradient":{let s=new gt(n.gradientType??0),o=new bn(n.smooth??!1),a;n.colors?a=new us(n.colors.length,n.colors):(a=new us(10,new Xe(0,0,0,1)),a.value[1]=new Xe(1,1,1,1));let l;n.steps?l=new cs(n.steps.length,n.steps):(l=new cs(10,1),l.value[0]=0);let u=new gn(n.offset??new B(0,0)),c=new gn(n.morph??new B(0,0)),h=new Ce(n.angle??0),d=Ui(n),f=new Vh(s,o,a,l,u,c,h,d.alpha,d.isMask),p=new Dt(f.calpha,"f");return new sn(t,e,i,{gradientType:s,smooth:o,colors:a,steps:l,offset:u,morph:c,angle:h,...d},f,d.mode,p,d.isMask,r)}case"pattern":{let s=new gt(n.style??0),o=new gt(n.projection??0),a=new gt(["x","y","z"].indexOf(n.axis)??0),l=new Ce(n.blending??0),u=new gn(n.offset??new B(0,0)),c=new ni(n.colorA),h=new ni(n.colorB),d=new gn(n.frequency??new B(10,10)),f=new Ce(n.size??.5),p=new Ce(n.variation??0),m=new Ce(n.smoothness??.5),g=new Ce(n.zigzag??0),y=new Ce(n.rotation??0),v=new gn(n.vertical??new B(0,1)),x=new gn(n.horizontal??new B(0,1)),b=new gt(n.sides??6),w=Ui(n),E=new jh(s,o,a,l,u,c,h,d,f,p,m,g,y,v,x,b,w.alpha,w.isMask),_=new Dt(E.calpha,"f");return new sn(t,e,i,{style:s,projection:o,axis:a,blending:l,offset:u,colorA:c,colorB:h,frequency:d,size:f,variation:p,smoothness:m,zigzag:g,rotation:y,vertical:v,horizontal:x,sides:b,...w},E,w.mode,_,w.isMask,r)}default:{let s=new Bt(1,0,0,1),o=Ui(n),a=new Zl(s,o.alpha),l=new Dt(a.calpha,"f");return new sn(t,e,i,{color:s,...o},a,o.mode,l,o.isMask,r)}}}function z8(i,t,e,n){let r=ND(e,n);return V8(e,i,t,r,n)}function eA(i,t,e,n){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=e.intensity*(e.visible?1:0),r):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let r=t.uniforms[`f${t.id}_alpha`];if(!r)return;if(r.value=hp(e.alpha,n)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let s=t.uniforms[`f${t.id}_compensation`];s&&(s.value=e.compensation&&e.visible)}return r}}function fp(i,t){let e=0,n=i.layers.find(r=>r.data.type==="light");if(n){let r=n.data,s=Number(t.getVariable(r.alphaOverride));if((typeof r.alphaOverride=="string"?s/100:r.alphaOverride)<1)return!0}for(let r of i.layers){if(r.data.type!=="displace"&&r.data.isMask)return!0;if(r.data.type!=="displace"&&"alpha"in r.data&&r.data.type!=="light"&&r.data.type!=="fresnel"&&r.data.type!=="texture"&&r.data.type!=="matcap"&&r.data.type!=="rainbow"&&r.data.type!=="outline"&&r.data.type!=="pattern"){let s=r.data.visible?r.data.alpha:0;if(typeof s=="string"&&(s=Math.max(0,Math.min(1,Number(t.getVariable(s)??100)/100))),s===1&&r.data.type==="depth"||r.data.type==="gradient"){for(let o of r.data.colors)if(o[3]<1){s=o[3];break}}else if(s===1&&r.data.type==="noise"){let o=t.color(r.data.colorA).a,a=t.color(r.data.colorB).a,l=t.color(r.data.colorC).a,u=t.color(r.data.colorD).a,c=Math.min(o,Math.min(a,Math.min(l,u)));c<1&&(s=c)}e+=(1-e)*s}}return e<1}var ii=class extends ot{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}},vv=class extends ii{constructor(e,n,r,s){super();this.flatShading=e;this.side=n;this.wireframe=r;this.root=s}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,n){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,n,r){return this.root.getFlavor(e,n,r)}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,n,r){this.root.updateByOp(e,n,r)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},Go=class extends ii{constructor(e,n,r=!0){super();this.data=e;this.allowVariableSaves=r;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.reset0(e,n)}get nodeMaterial(){return this}getFlavor(e,n,r){let s=r?6:(e?3:0)+n;if(s===0)return this;this.flavors===void 0&&(this.flavors=[]),s-=1;let o=this.flavors[s];return o===void 0&&(o=new vv(e,n,r,this),this.flavors[s]=o,o.flatShading=e,o.side=n,o.updateAfterBuild()),o}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,n){this.data!==e&&this.reset0(e,n)}reset0(e,n){this.data=e;let r=e.layers??Tn.defaultTwoLayerData("phong").layers;try{this.layers=r.map(s=>Ys.create(this.layerIdGen++,s.id,s.data,n.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(n.shared),this.transparent=fp(e,n.shared),this.saveVariableLocations(n)}saveVariableLocations(e){if(!this.allowVariableSaves)return;let n=this.data.layers.find(r=>r.data.type==="light");n&&e.shared.getVariable(n.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(r=>{"alpha"in r.data&&typeof r.data.alpha=="string"&&e.shared.getVariable(r.data.alpha,["material",this.uuid,"layer",r.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(n=>n.type===e)}getLayerByUuid(e){return this.layers.find(n=>n.uuid===e)}onUpdate(e){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(n=>n instanceof Ai),this.lightLayer===void 0&&(this.lightLayer=new Ai(0,"",{...dr.defaultData("light","phong"),visible:!1},new $l,{},e)),this.dispose();for(let n of this.flavors)n&&n.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(o=>o instanceof Ai);if(!e)return;let n=e.data,r=n.bumpMap,s=n.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let o=0;o<this.layers.length;++o){let a=this.layers[o];a instanceof sn&&a.color instanceof Ya&&(a.uuid===r&&(e.node.bumpMap=a.color),a.uuid===s&&(e.node.roughnessMap=a.color))}}updateByOp(e,n,r){if(n!==void 0?this.data=n:n=this.data,this.transparent=fp(n,r.shared),e.path[0]==="layers"){this.data=n;let s=r.shared,o=e.path[1];if(o===void 0){if(this.layers.reverse(),e.type===4){let a=Ys.create(this.layerIdGen++,e.id,e.data,r.shared);this.layers.splice(e.localIndex,0,a),r.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),r.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let a=this.layers.findIndex(u=>u.uuid===e.id),l=this.layers[a];this.layers.splice(a,1),this.layers.splice(e.localIndex,0,l),r.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(r.shared)}else{e.type===0&&e.props.occlusion!==void 0&&r.scene.markNeedsUpdateRendererDirty();let a=this.layers.find(l=>l.uuid===o);if(a){let l=n.layers.data(o);if(a.updateByOp({...e,path:e.path.slice(2)},l,r)){let c=Ys.create(this.layerIdGen++,o,l,s);this.layers.splice(this.layers.findIndex(h=>h.uuid===o),1,c),this.onUpdate(r.shared)}}}}else this.reset(n,r)}applyMasks(){for(let e=0;e<this.layers.length;++e){let n=this.layers[e];n instanceof sn?n.color.mask=void 0:n instanceof Ai&&(n.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let n=this.layers[e];if(n instanceof sn&&n.isMask.value&&n.data.visible&&e>0){let r=e-1,s=this.layers[r];s instanceof Ai?s.node.mask=new pr(n.color,n.alpha,pr.MUL):s instanceof sn&&(s.isMask.value||(s.color.mask=new pr(n.color,n.alpha,pr.MUL)))}}}blendColors(){let e=this.layers.findIndex(r=>r instanceof sn),n=this.layers.findIndex(r=>r instanceof Ai);if(e!==-1&&e<n){let r=this.layers[e].color;for(let s=e+1;s<n;++s){let o=this.layers[s];if(o instanceof sn){if(o.isMask.value)continue;r=new Nh(r,o.color,o.alpha,o.mode)}}this.fragment.color=r}else this.fragment.color=void 0}blendAfterColors(){let e=new Dt("outgoingLight","f"),n=this.layers.findIndex(r=>r instanceof Ai);if(this.layers.length>n+1){for(let r=n+1;r<this.layers.length;++r){let s=this.layers[r];if(s instanceof sn){if(s.isMask.value)continue;e=new Nh(e,s.color,s.alpha,s.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(n=>n instanceof dp);if(e.length>0){let n=e[0].position;for(let r=1;r<e.length;++r)e[r]&&(n=new pr(n,e[r].position,pr.ADD),n=new pr(n,new Ce(.5).setReadonly(!0),pr.MUL));this.fragment.position=n}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,n){let r=(s,o,a)=>Math.min(Math.max(s,o),a);for(let s of this.layers)if(s.type==="displace"){let o=r(s.uniforms[`f${s.id}_intensity`].value,e,n);s.uniforms[`f${s.id}_intensity`].value=o}}computeCacheKey(){let e="[";for(let{data:n}of this.data.layers)if(n.type==="light")e+=`"${n.visible?n.category.toUpperCase():"Basic"}"`;else{let r=(Zw[n.type]??[]).map(u=>n[u]),s=(Jw[n.type]??[]).map(u=>n[u]?.length??0),o=[...r,...s],a="isMask"in n&&n.isMask,l=`"${n.type}-${n.visible}-${a}"`;o.length?e+=`[${l}, "${o.join('","')}"],`:e+=l}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let n=0;n<this.updaters.length;++n)e.updateNode(this.updaters[n])}build(){let e=new lv;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 n of this.flavors)n&&n.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 sn){let n=e.params.texture;if(n instanceof Ql&&!n.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(ii.prototype,{properties:{get:function(){return this.fragment.properties}}});var ec=class extends Go{constructor(t,e,n){super(t,e,!1),this.uuid=n,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var VD=$o(FD());var kD=new Map;function UD(i){if(typeof i=="string")return i;let t=kD.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},kD.set(i,t)),t.url}var Ho=class{constructor({src:t,volume:e,delay:n,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 t=="string"?s={src:t}:s={src:UD(t),format:"wav"},this.sound=new VD.Howl(s),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),n!==void 0&&(this.delay=n),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,n){this.sound.on(t,e,n)}off(t,e,n){this.sound.off(t,e,n)}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(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var bv=class{constructor(){this.type="ShapePath";this.color=new Fe;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Al,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,n,r){return this.currentPath?.quadraticCurveTo(t,e,n,r),this}bezierCurveTo(t,e,n,r,s,o){return this.currentPath?.bezierCurveTo(t,e,n,r,s,o),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},n={loc:e.ORIGIN,t:0};function r(m,g,y,v){let x=m.x,b=g.x,w=y.x,E=v.x,_=m.y,S=g.y,T=y.y,M=v.y,C=(E-w)*(_-T)-(M-T)*(x-w),D=(b-x)*(_-T)-(S-_)*(x-w),P=(M-T)*(b-x)-(E-w)*(S-_),I=C/P,L=D/P;if(P===0&&C!==0||I<=0||I>=1||L<0||L>1)return null;if(C===0&&P===0){for(let H=0;H<2;H++)if(s(H===0?y:v,m,g),n.loc===e.ORIGIN){let U=H===0?y:v;return{x:U.x,y:U.y,t:n.t}}else if(n.loc===e.BETWEEN){let U=+(x+n.t*(b-x)).toPrecision(10),G=+(_+n.t*(S-_)).toPrecision(10);return{x:U,y:G,t:n.t}}return null}else{for(let G=0;G<2;G++)if(s(G===0?y:v,m,g),n.loc===e.ORIGIN){let z=G===0?y:v;return{x:z.x,y:z.y,t:n.t}}let H=+(x+I*(b-x)).toPrecision(10),U=+(_+I*(S-_)).toPrecision(10);return{x:H,y:U,t:I}}}function s(m,g,y){let v=y.x-g.x,x=y.y-g.y,b=m.x-g.x,w=m.y-g.y,E=v*w-b*x;if(m.x===g.x&&m.y===g.y){n.loc=e.ORIGIN,n.t=0;return}if(m.x===y.x&&m.y===y.y){n.loc=e.DESTINATION,n.t=1;return}if(E<-Number.EPSILON){n.loc=e.LEFT;return}if(E>Number.EPSILON){n.loc=e.RIGHT;return}if(v*b<0||x*w<0){n.loc=e.BEHIND;return}if(Math.sqrt(v*v+x*x)<Math.sqrt(b*b+w*w)){n.loc=e.BEYOND;return}let _;v!==0?_=b/v:_=w/x,n.loc=e.BETWEEN,n.t=_}function o(m,g){let y=[],v=[];for(let x=1;x<m.length;x++){let b=m[x-1],w=m[x];for(let E=1;E<g.length;E++){let _=g[E-1],S=g[E],T=r(b,w,_,S);T!==null&&y.find(M=>M.t<=T.t+Number.EPSILON&&M.t>=T.t-Number.EPSILON)===void 0&&(y.push(T),v.push(new B(T.x,T.y)))}}return v}function a(m,g,y){let v=new B;g.getCenter(v);let x=[];return y.forEach(b=>{b.boundingBox.containsPoint(v)&&o(m,b.points).forEach(E=>{x.push({identifier:b.identifier,isCW:b.isCW,point:E})})}),x.sort((b,w)=>b.point.x-w.point.x),x}function l(m,g,y,v,x){(x==null||x==="")&&(x="nonzero");let b=new B;m.boundingBox.getCenter(b);let w=[new B(y,b.y),new B(v,b.y)],E=a(w,m.boundingBox,g);E.sort((D,P)=>D.point.x-P.point.x);let _=[],S=[];E.forEach(D=>{D.identifier===m.identifier?_.push(D):S.push(D)});let T=_[0].point.x,M=[],C=0;for(;C<S.length&&S[C].point.x<T;)M.length>0&&M[M.length-1]===S[C].identifier?M.pop():M.push(S[C].identifier),C++;if(M.push(m.identifier),x==="evenodd"){let D=M.length%2===0,P=M[M.length-2];return{identifier:m.identifier,isHole:D,for:P}}else if(x==="nonzero"){let D=!0,P=null,I=null;for(let L=0;L<M.length;L++){let H=M[L];g[H]&&(D?(I=g[H].isCW,D=!1,P=H):I!==g[H].isCW&&(I=g[H].isCW,D=!0))}return{identifier:m.identifier,isHole:D,for:P}}else console.warn('fill-rule: "'+x+'" is currently not implemented.')}let u=0,c=999999999,h=-999999999,d=[];this.subPaths.forEach(m=>{let g=m.getPoints(),y=-999999999,v=999999999,x=-999999999,b=999999999;for(let w=0;w<g.length;w++){let E=g[w];E.y>y&&(y=E.y),E.y<v&&(v=E.y),E.x>x&&(x=E.x),E.x<b&&(b=E.x)}h<=x&&(h=x+1),c>=b&&(c=b-1),g.length&&d.push({curves:m.curves,points:g,isCW:Gc.isClockWise(g),identifier:u++,boundingBox:new Zm(new B(b,v),new B(x,y))})});let f=d.map(m=>l(m,d,c,h,this.userData?.style.fillRule)),p=[];return d.forEach(m=>{let g=f[m.identifier];if(g&&!g.isHole){let y=new _o;y.curves=m.curves,f.filter(x=>x?.isHole&&x.for===m.identifier).forEach(x=>{if(x){let b=d[x.identifier],w=new Al;w.curves=b.curves,y.holes.push(w)}}),p.push(y)}}),p}};var GD,tA=new Promise(i=>{GD=i}),zD=!1;var Sv;function HD(){if(zD)return;if(Sv)return Sv;async function i(){let e=await import("./opentype.js");GD(e),zD=!0}return Sv=i(),Sv}var pp=class{async load(t,e,n=()=>{}){let{load:r}=await tA;r(t,(s,o)=>{s||!o?n(s??"Something went wrong"):e(o)})}async parse(t){let{parse:e,Bidi:n}=await tA;try{let r=e(t),s=new n,o=a=>r.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,o),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};async function G8(i){return await(await fetch(i)).arrayBuffer()}var H8=new pp;async function nA(i){let t,e,n=!1;if(i.url?(t=await G8(i.url),e=i.url,n=i.url.startsWith("/")):i.data&&(t=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),t){let r=await H8.parse(t);if(r)return{font:r.font,url:e,intercepted:n,arr:t,bidi:r.bidi}}}function j8(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var wv=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=nA(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=nA(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,n){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(e);let s=r.tokenizer.tokens,o=[],a=0,l=n.length===s.length;for(let u=0;u<n.length;u++){let c=n[u].index,h=String.fromCharCode(n[u].unicode),d=s[a];if(j8(c,d)||l)o.push({char:h,index:c,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let f=d.char,p="",m=[d.state.glyphIndex],g=[],y=!1;for(;!y;)a++,p=e.charAt(a),f+=p,m.push(t.charToGlyphIndex(p)),g=t.stringToGlyphs(f),g.length===1&&g[0].index===c&&(y=!0),a>e.length&&(y=!0);o.push({char:h,index:c,replacements:m,replacementChars:Array.from(f)}),a++}}return o}generateShapes(t,e){if(!this._isLoaded)return;let n=this.font,r=e.fontSize/this.unitsPerEm,s=e.fontSize*e.lineHeight,o=t.map(v=>this.getTextWidth(v,e)),a=e.width,l=this.getCharWidth(`
|
|
5354
5354
|
`,e),u=e.horizontalAlign===1?l:0,c=this.computeSpaceWidthForLine(t,0,e),h=this.getLineInitialOffsetX(o[0],a,e.horizontalAlign,t[0],l),d=this.getLineInitialOffsetY(s,t.length,e.height,r,e.verticalAlign),f=[],p=t.map(v=>[]),m=t.map(v=>[]),g;for(let v=0;v<t.length;v++){let x=t[v],b={features:{liga:!0}},w=[];try{w=n.stringToGlyphs(x,b)}catch(_){console.warn(_)}h=this.getLineInitialOffsetX(o[v],a,e.horizontalAlign,x,l);let E=[];try{E=this.reverseLigaturesTable(n,x,w)}catch(_){console.warn(_)}c=this.computeSpaceWidthForLine(t,v,e);for(let _=0;_<w.length;_++){let S=w[_],T=S.index===0?`
|
|
5355
5355
|
`:S.unicode?String.fromCharCode(S.unicode):void 0,M=E[_],C=0,D=0;_===0&&e.horizontalAlign===2&&S.leftSideBearing!==void 0&&(D=-S.leftSideBearing*r),g&&(C=n.getKerningValue(S,g)*r),h+=D+C;let P=0;if(T===`
|
|
5356
5356
|
`)P=u;else if(T===" ")P=c;else{let I=this.createPath(S,r,h,d,e);I&&(P=I.offsetX-(C+D),f.push(I.path))}if(M.replacements.length===1)m[v].push([h,d]),p[v].push(P);else{let I=M.replacements.map(G=>(n.glyphs.get(G).advanceWidth??0)*r),L=I.reduce((G,z)=>G+=z,0),H=I.map(G=>G/L),U=h;for(let G=0;G<H.length;G++){let z=P*H[G];m[v].push([U,d]),p[v].push(z),U+=z}}h+=P,g=S}d-=s}let y=[];for(let v=0,x=f.length;v<x;v++)y.push(...f[v].toShapes());return{shapes:y,charWidths:p,lineWidths:o,charCoords:m}}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(t,e,n,r,s){return(n===3||n===2)&&r.indexOf(`
|
|
@@ -6236,7 +6236,7 @@ gl_FragColor = vec4(resultColor, vColor.r);
|
|
|
6236
6236
|
}
|
|
6237
6237
|
`,Hv=new ot({vertexShader:k9,fragmentShader:U9,uniforms:{depthContrast:{value:1}}});var QI=new en,jv=class extends xb{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new B;this.pipeline=new Ap(this);this.dummyCamra=new Kt;this.sceneTransitionDuration=0;this.sceneTransitionTimeRemaining=-1;this.isXRCopyPassSet=!1;this.clear=(e=!0,n=!0,r=!0)=>{let s=this.getContext(),o=0;e&&(o|=s.COLOR_BUFFER_BIT),n&&(o|=s.DEPTH_BUFFER_BIT),r&&(o|=s.STENCIL_BUFFER_BIT),s.clear(o),s.clearBufferfv(s.COLOR,1,[0,0,0,1])};this.autoClear=!1;let n=this.setPixelRatio.bind(this),r=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=ng;let s=this.getContext();if(s&&"drawingBufferColorSpace"in s)try{s.drawingBufferColorSpace="display-p3"}catch(o){console.warn(o)}this.setPixelRatio=o=>{this._pixelRatio!==o&&(this._pixelRatio=o,n(o))},this.setSize=(o,a,l=!0)=>{(this.viewportWidth!==o||this.viewportHeight!==a)&&(this.viewportWidth=o,this.viewportHeight=a,r(o,a,l),this.normalRenderTarget?.setSize(o*this._pixelRatio,a*this._pixelRatio),this._resizeTransmission(o,a),this.transmissionDepthTarget?.setSize(o*this._pixelRatio/2,a*this._pixelRatio/2),this.pipeline.resize(o,a,l))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new ut(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Ze,magFilter:Ze,wrapS:Jt,wrapT:Jt,depthBuffer:!1}))}_resizeTransmission(e,n){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),n*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,n*this._pixelRatio/1)}get hdTransmission(){return He.transmissionLod.value===1}set hdTransmission(e){He.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new ut(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:gl,magFilter:Ze,wrapS:Jt,wrapT:Jt,depthBuffer:!1}),this.transmissionDepthTarget=new ut(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Lt,magFilter:Lt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new ut(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Lt,magFilter:Lt,type:Sr,depthTexture:new Ci(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,n,r){this.normalRenderTarget&&(this.setClearColor(0),r.layers.enable(8),r.layers.disable(0),r.layers.disable(3),n.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),r instanceof Kt?Hv.uniforms.depthContrast.value=(r.far-r.near)/1e4:Hv.uniforms.depthContrast.value=1,n.overrideMaterial=Hv,this.render(n,r),this.setClearColor(n.bgColor,n.bgColor.a),this.setRenderTarget(null),n.overrideMaterial=e.wireframeState?Wv:null,r.layers.enable(0),r.layers.enable(3),n.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,n,r=1){this.dummyCamra.updateCameraState(n.dataPatched);let s=n.height,o=n.width,a=this.viewportWidth/this.viewportHeight;o<s?o=s*a:s=o/a,this.dummyCamra.setViewplaneSize(o,s);for(let l=0;l<r;l++)this.renderSplineScene(e,this.dummyCamra)}renderSplineScene(e,n,{sceneHelpers:r=void 0,sceneHelpersOnTop:s=void 0,overrideTransmission:o=void 0,overrideNormal:a=void 0}={}){let l=e instanceof Ja?e.activePage:e,u=l.visible;l.visible=!0;let c=l.scene;this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(n)),this.setClearColor(l.bgColor,l.bgColor.a),l.penumbraSizeArray.forEach((p,m)=>{He.penumbraSize.value[m]=p}),He.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?He.resolution.value.set(this.resolution.x,this.resolution.y):He.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),a!==void 0?(He.normalRenderTarget.value=a,He.normalRenderTargetDepth.value=QI):c.needsNormal()&&(this.createNormalRenderTarget(),He.normalRenderTarget.value=this.normalRenderTarget.texture,He.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(c,l,n));let h=l.data.ao,d=h.occlusion;d&&(this.createAORenderTarget(),He.aoRenderTarget.value=this.aoRenderTarget.texture),He.aoEnabled.value=d,this.pipeline.setAmbientOcclusionParams(h.occlusion,h.radius,h.bias,l.aoColor,l.fog!==null,l.backupFog.near,l.backupFog.far,h.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let f=!1;if(o!==void 0)He.transmissionRenderTarget.value=o,He.transmissionRenderTargetDepth.value=QI,this.pipeline.setTransmissionPassEnabled(!1);else{let p=c.needsTransmission();p&&(this.transmissionRenderTarget===void 0&&(f=!0),this.createTransmissionRenderTarget(),He.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,He.aspectRatio.value=xD(this.viewportWidth,this.viewportHeight),He.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(p)}n.layers.enable(3),n.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=l,this.pipeline.camera=n,f&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==l.postprocessing&&(this.pipeline.updatePostprocessing(l.postprocessing),!r&&!s&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),l.overrideMaterial=c.wireframeState?Wv:null,this.pipeline.render(),He.frameIndex.value=(He.frameIndex.value+1)%16,n instanceof Kt&&n.copyHistory(),l.visible=u}renderFromSceneForSceneTransitionPass(e,n,r){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,n),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=r,this.sceneTransitionTimeRemaining=r,this.pipeline.renderToScreen=!0;let s=this.pipeline.sceneTransitionPass.uniforms;s.uDPR.value=window.devicePixelRatio,s.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var gd=class extends Qs(eg){constructor(e,n=15,r=10066329){super(e,n,r);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,n){Zs(this.object,gd.geometryHelper,e,n)}};var yd=class extends Qs($m){constructor(e,n=15,r=6710886){super(e,n,r);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,n){Zs(this.object,yd.geometryHelper,e,n)}};var qv=class extends Qs(Jm){constructor(e,n=6710886){super(e,n);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,n){Zs(this.object,qv.geometryHelper,e,n)}update(){if(this.object!==void 0){let e=qv._vector,n=this.object.distance?this.object.distance:1e3,r=n*Math.tan(this.object.angle);this.cone.scale.set(r,r,n),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},Ep=qv;Ep._vector=new A;function V9(i,t){i.shadow.camera.right=t/2,i.shadow.camera.left=-t/2,i.shadow.camera.top=t/2,i.shadow.camera.bottom=-t/2,i.shadow.needsUpdate=!0}var vd=class extends rd(Xm,gd){constructor(t,e,n){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.top=1250,s.bottom=-1250,s.right=1250,s.left=-1250,s.near=-1e4,s.far=2500;let o=new pa(this.shadow.camera);o.visible=!1,this.gizmos.shadowmap=o}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof pa&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let n=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&V9(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),n&&this.update()}};var ZI=new A,JI=new A,$I=new Ye,xd=class extends rd(qm,Ep){constructor(t,e,n){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.fov=Te.RAD2DEG*2*this.angle,s.aspect=1,s.near=100,s.far=2500;let o=new pa(this.shadow.camera);o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof pa&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),JI.setFromMatrixPosition(this.matrixWorld),$I.setFromRotationMatrix(this.matrixWorld),ZI.copy(this.up).applyQuaternion($I).negate().multiplyScalar(this.distance),this.target.position.copy(JI).add(ZI),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var oi=class extends fh(wr){constructor(e,n){super();this.data=n;this.bgColor=new hn(1,1,1,1);this.fog=null;this.backupFog=new Bc(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new Fe;this.penumbraSizeArrayCache=null;this.super_Entity(e,n),this.personalCamera=new Kt(Li,{...Ul.defaultData,...n.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new Wm(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}updateAmbientLight(e,n){e.color!==void 0&&(this.ambientLight.color=Mr(e.color,n)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof Vi)if(Array.isArray(e.material))for(let n of e.material)n.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&KI(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,n){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let r=this.scene;r.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Mr(e.color,n),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,n){e.aoColor!==void 0&&(this.aoColor=Mr(e.aoColor,n))}updateByOp(e,n,r,s){super.updateByOp(e,n,r,s);let o=n;Or(e.path,["fog"])?this.updateFog(o.fog,r.shared):Or(e.path,["ao"])?this.updateAo(o.ao,r.shared):Or(e.path,["ambient"])?this.updateAmbientLight(o.ambient,r.shared):Or(e.path,["shadow"])&&this.updateShadow(o.shadow)}updateState(e,n){this.updateState_Entity(e,n),e.backgroundColor!==void 0&&this.setBackgroundColor(Mr(e.backgroundColor,n.shared)),e.fog!==void 0&&this.updateFog(e.fog,n.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,n.shared),e.ao!==void 0&&this.updateAo(e.ao,n.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}raycast(e,n){super.raycast(e,n)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,n=0;this.traverseEntity(r=>{if(!r.visible)return!0;r instanceof vd&&r.visible&&e<3&&(this.penumbraSizeArrayCache[e]=r.data.penumbraSize,e+=1),r instanceof xd&&r.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+n]=r.data.penumbraSize,n+=1)})}raycastWithClones(e){let n=[],r=s=>{for(let o of s.children){let a=o.cloner;at.is(o)&&(o.visible||a?.object.data.visible)&&((Rr(o)||bp(o)&&this.scene.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,n),_p(o,e,n,!0)),r(o))}};return r(this),n}};var Yv=class extends rd(Ym,yd){constructor(t,e,n){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.fov=90,s.aspect=1,s.near=100,s.far=2500;let o=new A(-s.far+this.position.x,-s.far+this.position.y,-s.far+this.position.z),a=new A(s.far+this.position.x,s.far+this.position.y,s.far+this.position.z),l=new Tt(o,a),u=new ma(l,new Fe(16755200));u.visible=!1,this.gizmos.shadowmap=u,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof ma){let n=this.shadow.camera,r=new A(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),s=new A(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z);e.box.set(r,s),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Xv=class extends jt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let n=this.geometry.getAttribute("position");n!==void 0?tp(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var $a=class extends jt{constructor(e,n,r){super(e,n,r);this._shapeId=null;this._context=r}updateState(e,n){super.updateState(e,n),this.updateShape()}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let s in e)typeof e[s]=="string"&&(e[s]=this._context.shared.getVariable(e[s],[this.uuid,"geometry","extrusion","shape",s]));let n;if(e.type==="Custom"){let s=e.shapeId;if(s!==this._shapeId&&this.detachShape(),s){this._shapeId=s;let o=this._context.scene.find(s);o?.data&&(o.attachedPaths.add(this),n=o.geometry.userData?.shape),n||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let s;switch(e.type){case"Rectangle":s=Jy;break;case"Ellipse":s=Sh;break;case"Polygon":s=Zy;break;case"Star":s=$y;break;default:throw new Error(`Unknown shape type: ${e.type}`)}n=s.create({parameters:e}).userData.shape}let r=this.geometry;n&&r.inputs&&(r.inputs.shapeData=n,r.build(),this.attachedSurfaceCloners.forEach(s=>s.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,n){return super.updateTransformState(e,n)}updateGeometryInteractions(e,n){super.updateGeometryInteractions(e,n),this.updateShape()}updateEntityBoxSize(e,n){let r=this.geometry.getAttribute("position");r!==void 0?tp(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,e,n):super.updateEntityBoxSize(e,n)}};var gs=class extends Js(Ts,$s){constructor(e,n,r){super();n.type==="Instance"&&typeof e=="string"&&(n=this.transformAssignData(n,r)),this.super_Entity(e,n),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,n){let r=Wu.getComponentData({scene:n.scene.data,shared:n.shared.data},e.component);if(r){let s,o;for(let a of Fs.rootOverrideProps)e[a]===void 0?(s===void 0&&(s={...e}),s[a]=r.data[a]):(o===void 0&&(o={}),o[a]=e[a],s===void 0&&(s={...e}),s[a]=Ds.apply(r.data[a],e[a]));return this.overrideData=o,s}else return{...Er.defaultData,...e,...xi(Er.defaultData,Fs.rootOverrideProps)}}updateByOp(e,n,r,s){let o;if(this.isInstanceRoot&&!s){if(n=this.transformAssignData(n,r),e.type===0&&e.path.length===0&&this.component)for(let a of Fs.rootOverrideProps)a in e.props&&e.props[a]===void 0&&(o===void 0&&(o={...e,props:{...e.props}}),o.props[a]=this.component.data[a]);else if(e.type===0&&e.path.length>0&&Fs.rootOverrideProps.includes(e.path[0])){let a=e.path[0];o===void 0&&(o={...e,path:[],props:{[a]:n[a]}})}}super.updateByOp(o??e,n,r,s)}updateState(e,n){this.updateState_Entity(e,n)}expandInstanceChildren(e){let n=this.data;if(this.component===void 0){let r=e.scene.find(n.component)??null,s=!1;if(r!==this.oldComponent){if(this.oldComponent){let o=0;for(let a of this.children)if(at.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Kv(a),o+=1;else break;this.children.splice(0,o)}s=!0}if(r){let o={};tO(e,[this.uuid],n.overrides,this,r,r,0,s,o);for(let a of this.children)if(at.is(a)){let l=a.data;l.type==="Empty"&&l.animations&&a.traverseEntity(u=>{if(u instanceof jt&&u.isSkinnedMesh){let c=u.dataPatched;if(c.bones&&c.boneInverses){let h=c.bones.map(p=>e.scene.find(o[p])),d=c.boneInverses.map(p=>new se().fromArray(p)),f=new ca(h,d);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function Kv(i){if(i.component){let t=i.component.instances.indexOf(i);t>=0&&i.component.instances.splice(t,1);for(let e of i.children)at.is(e)&&Kv(e)}}function eO(i,t,e,n){return i.component===t&&Af(i.identity,n)?i.overrideData===e?2:1:0}function tO(i,t,e,n,r,s,o,a,l){if(o>50)return!1;if(n.component!==r){if(n.component){let c=n.component.instances.indexOf(n);c>=0&&n.component.instances.splice(c,1)}r.instances.push(n),n.component=r}r instanceof gs&&r.isInstanceRoot&&r.expandInstanceChildren(i);let u=0;for(let c of r.children)if(at.is(c)){let h=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],d=Gu.resolve(e,h,1);if(d!=null&&!(d instanceof Yt)){if(!1)debugger;Object.setPrototypeOf(d,Yt.prototype),console.error("wrong prototype")}let f=null,p;if(!a){let m=n.children[u];if(f=at.is(m)?m:null,f!==null){let g=eO(f,c,d,h);p=g>=1?f.stateSelection:void 0,g!==2&&(f=null)}if(f===null&&(f=i.scene.findInstance(h)??null,f!==null)){let g=eO(f,c,d,h);if(p=g>=1?f.stateSelection:void 0,g!==2)f=null;else{let y=f.parent.children.indexOf(f);f.parent.children.splice(y,1),n.children.splice(u,0,f),f.parent===n?(y<=u&&console.error("not possible"),void 0):(f.parent=n,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),i.pendingDeletes.delete(f),void 0)}}}if(f===null){let m=d?Ds.apply(c.data,d):c.data;ns.is(m.type)&&(m={...m,type:"Empty"}),f=ss.createEntity(h,m,i),f.overrideData=d,n.add(f),n.children.splice(n.children.length-1,1),n.children.splice(u,0,f),f.updateState(f.data,i),p&&f.changeSelectedState(p,i),i.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let m=f.identity[f.identity.length-1];l[m]=f.uuid}u+=1,tO(i,t,e,f,c,s,o+1,a,l)}if(!a){let c=u;for(;;){let h=n.children[u];if(at.is(h))i.pendingDeletes.add(h);else break;u+=1}n.children.splice(c,u-c)}return!0}var Qv=class extends Js(rf,$s){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}};function z9(i,t,e){let n;return t.geometry.type==="TextGeometry"?new $h(i,t,e):(t.geometry.type==="SubdivGeometry"?n=new ds(i,t,e):t.geometry.type==="PathGeometry"?n=new $a(i,t,e):t.geometry.type==="VectorGeometry"?n=new Xv(i,t,e):t.geometry.type==="BooleanGeometry"?n=new Hi(i,t,e):n=new jt(i,t,e),n)}function Zv(i,t,e){return t.type==="Mesh"?z9(i,t,e):t.type==="Empty"?new ps(i,t):t.type==="Bone"?new Qv(i,t):t.type==="Page"?new oi(i,t):t.type==="PointLight"?new Yv(i,t,e):t.type==="SpotLight"?new xd(i,t,e):t.type==="DirectionalLight"?new vd(i,t,e):t.type==="Component"||t.type==="Instance"?new gs(i,t,e):ns.is(t.type)?new Kt(i,t):(console.error(t),new ps(i,t))}ss.createEntity=Zv;function G9(i,t,e){let n=Zv(i.identity,t,e),r=i.children,s=i.attachedPaths,o=i.parent,a=i.component,l=i.instances,u=i.overrideData,c=i.uuid,h=i.stateSelection;i.dispose();for(let d of Object.keys(i))delete i[d];Object.setPrototypeOf(i,Object.getPrototypeOf(n));for(let d of Object.keys(n))i[d]=n[d];i.children=[...i.children,...r],i.attachedPaths=s,i.parent=o,i.component=a,i.instances=l,i.uuid=c,i.overrideData=u,i.updateState(i.data,e),h&&i.changeSelectedState(h,e),i.resetBBoxNeedsUpdate()}ss.changeEntityProptotype=G9;ss.Cloner=yr;function nO(i,t,e,n){i.updateByOp(t,e,n,!1)}function rO(i,t){let e=!1,n=t.getLayersOfType("transmission"),r=t.getLayersOfType("outline");return r.length>0&&(i.layers.set(8),n.length>0&&i.layers.enable(3),e=!0,Zh(i),Qh(i)),n.length===0&&r.length===0&&i.layers.set(0),i instanceof Vi&&i.needsAO&&i.layers.enable(5),e}function iO(i,t){if(!t.layers)return!1;let e=!1,n=t.getLayersOfType("transmission").filter(s=>s.data.visible),r=t.getLayersOfType("outline").filter(s=>s.data.visible);return n.length>0&&(i.layers.set(3),r.length>0&&i.layers.enable(8),e=!0),n.length===0&&r.length===0&&i.layers.set(0),i.needsAO&&i.layers.enable(5),e}function sO(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof Vi)if(Array.isArray(e.material))for(let n=0;n<e.material.length;n++)rO(e,e.material[n])&&(t=!0);else rO(e,e.material)&&(t=!0)}),t}function oO(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof Vi)if(Array.isArray(e.material))for(let n=0;n<e.material.length;n++)iO(e,e.material[n])&&(t=!0);else iO(e,e.material)&&(t=!0)}),t}var H9=new Jc,j9=new se,W9=new Ji;function _p(i,t,e,n=!1){let r=i.cloner;if(r)for(let s of r.children){let o=j9.copy(s.matrixWorld).invert(),a=W9.copy(t.ray).applyMatrix4(o),l=i.matrixWorld;a.applyMatrix4(l);let u=H9;u.set(a.origin,a.direction),u.near=t.near,u.far=t.far;let c=u.intersectObject(i,!1);c.length>0&&e.push({...c[0],object:n?s:i})}}var Jv=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((n,r)=>{let s=[r,n],o=n;for(;this._constraints.has(o);)o=this._constraints.get(o),e.has(o)||s.push(o);for(let a=s.length-2;a>=0;a--)if(!e.has(s[a])){let l=t.find(s[a]);l?l.applyPathSnapping(t):console.warn(`missing entity ${s[a]}`),e.add(s[a])}})}findDependency(t,e){let n=t;for(;this._constraints.has(n);)if(n=this._constraints.get(n),n===e)return!0;return!1}};var Wv=new wo;Wv.wireframe=!0;var aO=new A,Ja=class extends wr{constructor(e,n){super();this.data=e;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Jv;this.errorPage=new oi("fdasfa",{...Lo.defaultData,name:""});this.invisibleObjects=new ps("jflkdsafjasdifjaslk",{...by.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,n),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=oO(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=sO(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let n=e.identity.join("-"),r=this.entityIdentityToEntity[n];r&&(e.uuid=r.uuid),this.entityIdentityToEntity[n]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof oi&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let n=this.find(e);if(n===void 0)return;let r=[],s=n;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);r.splice(0,0,a)}return{entity:n,sortKey:r}}getAllSorted(e){let n=[];for(let r of e){let s=this.getWithSortKey(r.id);s!==void 0&&n.push(s)}return n.sort((r,s)=>lC(r.sortKey,s.sortKey)),n.map(r=>r.entity)}nonExistOrDescendantOf(e,n){let r=this.find(e);if(r===void 0)return!0;for(;r;){if(r.uuid===n)return!0;r=r.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===Li)return this.activePage.personalCamera}if(e===""||e===void 0)return;let n=this.entityByUuid[e];return n===void 0?this.getObjectByProperty("uuid",e):n}debugEnsureEntity(e){let n=this.find(e);if(n){if(Array.isArray(n.identity)&&this.findInstance(n.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(n=>{this.toExpandCloner.add(n)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,n){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,n)}updateTreeByOp(e,n){if(e.path.length===0&&e.type===7){let r=e.parent===null?this:this.find(e.parent);if(r===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,r,e.localIndex,n);s.updateVisible(),s.resetBBoxNeedsUpdate(),Rr(s)&&Lr(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s),this.markPenumbraSizeDirty()}else if(e.path.length===0&&e.type===8){let r=this.find(e.id);if(r===void 0)throw new Error("unexpected");this.markToExpandCloner(r),r.resetBBoxNeedsUpdate(),this.unregisterObject(r);let s=r.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(r),this.markPenumbraSizeDirty(),r.parent.remove(r),Lr(r.parent)&&(r.parent.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Rr(r)&&(r.freeBooleanPointer(),s instanceof Hi&&s.invalidateDownstreamBooleanData().recomputeBoolean()),r instanceof $a&&r.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r),this.pathConstraints.removeDependencies(r.uuid)}else if(e.path.length===0&&e.type===9){let r=this.find(e.id);if(r===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(r);let s=r.parent;this.markNeedsRecomputeInstancesForAncessors(s),r.cloner?.resetOnMove(),this.markToExpandCloner(r);let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");o.add(r),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(r),r.invalidateClonerTransform(r),r.updateVisible(),r.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;o.children.splice(a,0,o.children.pop()),Rr(r)&&(r.invalidateUpstreamBooleanData(),Lr(r.parent)?r.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof Hi&&s.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let n of this.children)n instanceof oi&&(n.visible=n.uuid===e,n.visible&&(this.activePage=n,this.activePage.onActive(this)))}updateEntityByOp(e,n,r,s){if(n.type===0){if(("overrides"in n.props||"component"in n.props)&&this.markNeedsRecomputeInstances(),"visible"in n.props&&this.markPenumbraSizeDirty(),n.path.includes("overrides")&&"states"in n.props){let{rest:a}=n.props;n={...n,props:a},this.markNeedsRecomputeInstances()}n.path[0]==="pathSnapping"&&n.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,n.props.pathId)}let o=this.find(e);if(o)try{nO(o,n,r,{scene:this,shared:s}),o instanceof jt&&o.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,n){let r=Object.entries(n.data.lib.components).map((s,o)=>({data:s[1].asset.data,children:s[1].asset.children,id:s[0],fi:o}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:n}),this.add(this.invisibleObjects),this.createChildrenObjects(r,this.invisibleObjects,n),this.createChildrenObjects(e.objects,this,n),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(n,!0),this.traverseEntity(s=>{Lr(s)&&s.recomputeBoolean(),s instanceof Kt&&s.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(n=>{(n.data.type==="Component"||n.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){at.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(n=>{at.is(n)&&n.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,n,r,s,o,a,l){if(e){let u=s.find(e);u&&u!==s&&o.forInstancesRec(c=>{c.data=Aa(c.data,h=>{let d=h.events.data(l.id),f=c.goUp(a);if(f){let p=[...Rg(f.identity),e].join("-"),m=this.entityIdentityToEntity[p];if(m){let g=m.uuid,y=Vn.zoom(d,n);y[r]=g}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,n,r,s,o,a){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...n,l.id],"object",r,s,o,a):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...n,l.id],"object",r,s,o,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof gs&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((n,r)=>{n.data.events.forEach(s=>{if(s.data.type==="GameControl"){let o=!1;if(n.forInstancesRec(a=>{a.data=Aa(a.data,l=>{a.isInstanceRoot||(l.events.delete(s.id),o=!0)}).data}),o===!1)for(let a of Xu.list)this.rewriteActions(s.data.gameActions[a],["gameActions",a],e,n,r,s)}else s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",e,n,r,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",e,n,r,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",e,n,r,s):s.data.condition.type==="Comparison"&&(s.data.condition.lOperand.type==="Property"&&this.relativeizeInner(s.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,n,r,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,n,r,s)),this.rewriteActions(s.data.inActions,["inActions"],e,n,r,s),this.rewriteActions(s.data.outActions,["outActions"],e,n,r,s)):"actions"in s.data&&this.rewriteActions(s.data.actions,["actions"],e,n,r,s)})}),!0})}expandInstances(e,n,r){let s=new Set;this.traverseEntity(o=>{if(o instanceof gs&&o.isInstanceRoot)return o.expandInstanceChildren({scene:this,shared:e,pendingDeletes:s}),n||o.resetBBoxNeedsUpdate(),r&&o.traverseEntity(a=>{r.addClip(a)}),!0});for(let o of s)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),Kv(o)}recomputeInstances(e,n){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(r=>{r instanceof gs&&r.isInstanceRoot&&(r.component=void 0)}),this.expandInstances(e,!1,n))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(n=>{let r=typeof n.identity=="string"?n.identity:n.identity.join("-");this.entityIdentityToEntity[r]===n&&(delete this.entityByUuid[n.uuid],delete this.entityIdentityToEntity[r]),n.dispose()})}clearScene(){for(let e of this.children)at.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,n){this.init(e,n)}raycast(e){return this.raycast1(e,!1)}raycast1(e,n){let r=[],s=o=>{for(let a of o.children){let l=a.cloner;if(at.is(a)&&!a.raycastLock&&(a.visible||l?.object.data.visible))if(n===!0&&a.isInstanceRoot){let u=[];if(e.intersectObject(a,!0,u),u.length){let c=u[0];c.object=a,c.point.applyMatrix4(c.object.matrixWorld);let h=a.matrixWorld.clone().invert();c.point.applyMatrix4(h),r.push(c)}}else(Rr(a)||bp(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),_p(a,e,r)),s(a)}};return s(this),r}raycastWithClones(e){let n=[],r=s=>{for(let o of s.children){let a=o.cloner;at.is(o)&&(o.visible||a?.object.data.visible)&&((Rr(o)||bp(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,n),_p(o,e,n,!0)),r(o))}};return r(this),n}forEachEntity(e){for(let n of this.children)at.is(n)&&e(n)}traverseConcreteEntity(e){for(let n of this.children)at.is(n)&&n.isConcreteEntity&&n.traverseEntity(e)}traverseEntity(e){for(let n of this.children)at.is(n)&&n.traverseEntity(e)}updateFont(e,n){this.traverseEntity(r=>{if(r instanceof jt&&r.data.type==="Mesh"&&r.data.geometry.type==="TextGeometry"&&r.data.geometry.font===e){let s=r.geometry,o=r.data.geometry;s.updateFont(e,n).then(()=>{s.update(o);let a=r.invalidateDownstreamBooleanData();Lr(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let n of this.children)uh.is(n)&&n.traverseObject(e)}traverseVisibleEntity(e){for(let n of this.children)at.is(n)&&n.visible&&n.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,n,r){let s=0;for(let o of e)this.createObject(o.id,o.data,o.children,n,s,r),s+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let n of e.children)this.unregisterObject(n)}createObject(e,n,r,s,o,a){let l={scene:this,shared:a},u=Zv(e,n,l);return u&&(this.entityByUuid[e]=u,s.add(u),s.children.splice(o,0,s.children.pop()),r.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(r,u,a)),u.updateState(n,l),u instanceof jt&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),n.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,n.pathSnapping.pathId)),n.type==="Empty"&&n.animations&&u.traverseEntity(c=>{if(c instanceof jt&&c.isSkinnedMesh){let h=c.dataPatched;if(h.bones&&h.boneInverses){let d=h.bones.map(m=>this.find(m)),f=h.boneInverses.map(m=>new se().fromArray(m)),p=new ca(d,f);c.bind(p,c.bindMatrix)}}else c.matrixAutoUpdate=!0}),u}getCenter(e){let n=[];for(let s=0,o=e.length;s<o;++s){let{id:a,recursive:l}=e[s],u=this.find(a),c=l?u.recursiveBBox:u.singleBBox;n.push(...c.vertices)}let r=new Tt;return r.setFromPoints(n),r.getCenter(aO),aO}copyMatrixWorld(e,n){if(e===null){n.identity();return}let r=this.find(e);r?n.copy(r.matrixWorld):n.identity()}copyParentMatrixWorld(e,n){if(e===null){n.identity();return}let r=this.find(e)?.parent;r?n.copy(r.matrixWorld):n.identity()}traverseMaterial(e){this.traverseEntity(n=>{if(n instanceof Xt)if(Array.isArray(n.material))for(let r=0;r<n.material.length;r++)n.material[r]instanceof ii&&e(n.material[r]);else n.material instanceof ii&&e(n.material)})}updateViewPlaneSize(e,n,r=!1){this.traverseConcreteEntity(s=>{s instanceof Kt&&s.setViewplaneSize(e,n,r)})}};var Tp=(i,t)=>{let e=t.x-i.x,n=t.y-i.y;return Math.sqrt(e*e+n*n)},lO=(i,t)=>{let e=t.x-i.x,n=t.y-i.y;return q9(Math.atan2(n,e))},cO=(i,t,e)=>{let n={x:0,y:0};return e=$v(e),n.x=i.x-t*Math.cos(e),n.y=i.y-t*Math.sin(e),n},$v=i=>i*(Math.PI/180),q9=i=>i*(180/Math.PI),uO=i=>isNaN(i.buttons)?i.pressure!==0:i.buttons!==0,TA=new Map,MA=i=>{TA.has(i)&&clearTimeout(TA.get(i)),TA.set(i,setTimeout(i,100))},bd=(i,t,e)=>{let n=t.split(/[ ,]+/g),r;for(let s=0;s<n.length;s+=1)r=n[s],i.addEventListener?i.addEventListener(r,e,!1):i.attachEvent&&i.attachEvent(r,e)},CA=(i,t,e)=>{let n=t.split(/[ ,]+/g),r;for(let s=0;s<n.length;s+=1)r=n[s],i.removeEventListener?i.removeEventListener(r,e):i.detachEvent&&i.detachEvent(r,e)};var e0=i=>(i.preventDefault(),i.type.match(/^touch/)?i.changedTouches:i),PA=()=>{if(typeof window>"u")return;let i=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:i,y:t}},t0=(i,t)=>{t.top||t.right||t.bottom||t.left?(i.style.top=t.top,i.style.right=t.right,i.style.bottom=t.bottom,i.style.left=t.left):(i.style.left=t.x+"px",i.style.top=t.y+"px")},n0=(i,t,e)=>{let n=dO(i);for(let r in n)if(n.hasOwnProperty(r))if(typeof t=="string")n[r]=t+" "+e;else{let s="";for(let o=0,a=t.length;o<a;o+=1)s+=t[o]+" "+e+", ";n[r]=s.slice(0,-2)}return n},hO=(i,t)=>{let e=dO(i);for(let n in e)e.hasOwnProperty(n)&&(e[n]=t);return e},dO=i=>{let t={};return t[i]="",["webkit","Moz","o"].forEach(function(n){t[n+i.charAt(0).toUpperCase()+i.slice(1)]=""}),t},r0=(i,t)=>{for(let e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},fO=(i,t)=>{let e={};for(let n in i)i.hasOwnProperty(n)&&t.hasOwnProperty(n)?e[n]=t[n]:i.hasOwnProperty(n)&&(e[n]=i[n]);return e},Mp=(i,t)=>{if(i.length)for(let e=0,n=i.length;e<n;e+=1)t(i[e]);else t(i)},pO=(i,t,e)=>({x:Math.min(Math.max(i.x,t.x-e),t.x+e),y:Math.min(Math.max(i.y,t.y-e),t.y+e)});typeof window<"u"&&(mO="ontouchstart"in window,gO=!!window.PointerEvent,yO=!!window.MSPointerEvent);var mO,gO,yO,Cp={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"}},Sd,Pp={};gO?Sd=Cp.pointer:yO?Sd=Cp.MSPointer:mO?(Sd=Cp.touch,Pp=Cp.mouse):Sd=Cp.mouse;function ac(){}ac.prototype.on=function(i,t){var e=this,n=i.split(/[ ,]+/g),r;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)r=n[s],e._handlers_[r]=e._handlers_[r]||[],e._handlers_[r].push(t);return e};ac.prototype.off=function(i,t){var e=this;return e._handlers_=e._handlers_||{},i===void 0?e._handlers_={}:t===void 0?e._handlers_[i]=null:e._handlers_[i]&&e._handlers_[i].indexOf(t)>=0&&e._handlers_[i].splice(e._handlers_[i].indexOf(t),1),e};ac.prototype.trigger=function(i,t){var e=this,n=i.split(/[ ,]+/g),r;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)r=n[s],e._handlers_[r]&&e._handlers_[r].length&&e._handlers_[r].forEach(function(o){o.call(e,{type:r,target:e},t)})};ac.prototype.config=function(i){var t=this;t.options=t.defaults||{},i&&(t.options=fO(t.options,i))};ac.prototype.bindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},bd(i,Sd[t],e._domHandlers_[t]),Pp[t]&&bd(i,Pp[t],e._domHandlers_[t]),e};ac.prototype.unbindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},CA(i,Sd[t],e._domHandlers_[t]),Pp[t]&&CA(i,Pp[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var wd=ac;function er(i,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=i,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=er.id,er.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}er.prototype=new wd;er.constructor=er;er.id=0;er.prototype.buildEl=function(i){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};er.prototype.stylize=function(){if(this.options.dataOnly)return this;var i=this.options.fadeTime+"ms",t=hO("borderRadius","50%"),e=n0("transition","opacity",i),n={};return n.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},n.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},n.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},r0(n.el,e),this.options.shape==="circle"&&r0(n.back,t),r0(n.front,t),this.applyStyles(n),this};er.prototype.applyStyles=function(i){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var e in i[t])this.ui[t].style[e]=i[t][e];return this};er.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};er.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};er.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};er.prototype.show=function(i){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof i=="function"&&i.call(this)},t.options.fadeTime)),t};er.prototype.hide=function(i){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof i=="function"&&i.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,n={};n.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,n.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(i,n)}return t};er.prototype.setPosition=function(i,t){var e=this;e.frontPosition={x:t.x,y:t.y};var n=e.options.fadeTime+"ms",r={};r.front=n0("transition",["top","left"],n);var s={front:{}};s.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(r),e.applyStyles(s),e.restTimeout=setTimeout(function(){typeof i=="function"&&i.call(e),e.restCallback()},e.options.fadeTime)};er.prototype.restCallback=function(){var i=this,t={};t.front=n0("transition","none",""),i.applyStyles(t),i.trigger("rested",i.instance)};er.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};er.prototype.computeDirection=function(i){var t=i.angle.radian,e=Math.PI/4,n=Math.PI/2,r,s,o;if(t>e&&t<e*3&&!i.lockX?r="up":t>-e&&t<=e&&!i.lockY?r="left":t>-e*3&&t<=-e&&!i.lockX?r="down":i.lockY||(r="right"),i.lockY||(t>-n&&t<n?s="left":s="right"),i.lockX||(t>0?o="up":o="down"),i.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var u={};this.direction={x:s,y:o,angle:r},i.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(u[l]=!0);if(u.x&&u.y&&u.angle)return i;(!u.x||!u.y)&&this.trigger("plain",i),u.x||this.trigger("plain:"+s,i),u.y||this.trigger("plain:"+o,i),u.angle||this.trigger("dir dir:"+r,i)}else this.resetDirection();return i};var vO=er;function Pn(i,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=i,e.id=Pn.id,Pn.id+=1,e.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let n=getComputedStyle(e.options.zone.parentElement);return n&&n.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}Pn.prototype=new wd;Pn.constructor=Pn;Pn.id=0;Pn.prototype.prepareNipples=function(){var i=this,t=i.nipples;t.on=i.on.bind(i),t.off=i.off.bind(i),t.options=i.options,t.destroy=i.destroy.bind(i),t.ids=i.ids,t.id=i.id,t.processOnMove=i.processOnMove.bind(i),t.processOnEnd=i.processOnEnd.bind(i),t.get=function(e){if(e===void 0)return t[0];for(var n=0,r=t.length;n<r;n+=1)if(t[n].identifier===e)return t[n];return!1}};Pn.prototype.bindings=function(){var i=this;i.bindEvt(i.options.zone,"start"),i.options.zone.style.touchAction="none",i.options.zone.style.msTouchAction="none"};Pn.prototype.begin=function(){var i=this,t=i.options;if(t.mode==="static"){var e=i.createNipple(t.position,i.manager.getIdentifier());e.add(),i.idles.push(e)}};Pn.prototype.createNipple=function(i,t){var e=this,n=e.manager.scroll,r={},s=e.options,o={x:e.parentIsFlex?n.x:n.x+e.box.left,y:e.parentIsFlex?n.y:n.y+e.box.top};if(i.x&&i.y)r={x:i.x-o.x,y:i.y-o.y};else if(i.top||i.right||i.bottom||i.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=i.top,a.style.right=i.right,a.style.bottom=i.bottom,a.style.left=i.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),r=i,i={x:l.left+n.x,y:l.top+n.y}}var u=new vO(e,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:i,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(t0(u.ui.el,r),t0(u.ui.front,u.frontPosition)),e.nipples.push(u),e.trigger("added "+u.identifier+":added",u),e.manager.trigger("added "+u.identifier+":added",u),e.bindNipple(u),u};Pn.prototype.updateBox=function(){var i=this;i.box=i.options.zone.getBoundingClientRect()};Pn.prototype.bindNipple=function(i){var t=this,e,n=function(r,s){e=r.type+" "+s.id+":"+r.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",n),i.on("dir:up dir:right dir:down dir:left",n),i.on("plain:up plain:right plain:down plain:left",n)};Pn.prototype.pressureFn=function(i,t,e){var n=this,r=0;clearInterval(n.pressureIntervals[e]),n.pressureIntervals[e]=setInterval(function(){var s=i.force||i.pressure||i.webkitForce||0;s!==r&&(t.trigger("pressure",s),n.trigger("pressure "+t.identifier+":pressure",s),r=s)}.bind(n),100)};Pn.prototype.onstart=function(i){var t=this,e=t.options,n=i;i=e0(i),t.updateBox();var r=function(s){t.actives.length<e.maxNumberOfNipples?t.processOnStart(s):n.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(o){if(Object.values(n.touches).findIndex(function(l){return l.identifier===o})<0){var a=[i[0]];a.identifier=o,t.processOnEnd(a)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(s))};return Mp(i,r),t.manager.bindDocument(),!1};Pn.prototype.processOnStart=function(i){var t=this,e=t.options,n,r=t.manager.getIdentifier(i),s=i.force||i.pressure||i.webkitForce||0,o={x:i.pageX,y:i.pageY},a=t.getOrCreate(r,o);a.identifier!==r&&t.manager.removeIdentifier(a.identifier),a.identifier=r;var l=function(c){c.trigger("start",c),t.trigger("start "+c.id+":start",c),c.show(),s>0&&t.pressureFn(i,c,c.identifier),t.processOnMove(i)};if((n=t.idles.indexOf(a))>=0&&t.idles.splice(n,1),t.actives.push(a),t.ids.push(a.identifier),e.mode!=="semi")l(a);else{var u=Tp(o,a.position);if(u<=e.catchDistance)l(a);else{a.destroy(),t.processOnStart(i);return}}return a};Pn.prototype.getOrCreate=function(i,t){var e=this,n=e.options,r;return/(semi|static)/.test(n.mode)?(r=e.idles[0],r?(e.idles.splice(0,1),r):n.mode==="semi"?e.createNipple(t,i):(console.warn("Coudln't find the needed nipple."),!1)):(r=e.createNipple(t,i),r)};Pn.prototype.processOnMove=function(i){var t=this,e=t.options,n=t.manager.getIdentifier(i),r=t.nipples.get(n),s=t.manager.scroll;if(!uO(i)){this.processOnEnd(i);return}if(!r){console.error("Found zombie joystick with ID "+n),t.manager.removeIdentifier(n);return}if(e.dynamicPage){var o=r.el.getBoundingClientRect();r.position={x:s.x+o.left,y:s.y+o.top}}r.identifier=n;var a=r.options.size/2,l={x:i.pageX,y:i.pageY};e.lockX&&(l.y=r.position.y),e.lockY&&(l.x=r.position.x);var u=Tp(l,r.position),c=lO(l,r.position),h=$v(c),d=u/a,f={distance:u,position:l},p,m;if(r.options.shape==="circle"?(p=Math.min(u,a),m=cO(r.position,p,c)):(m=pO(l,r.position,a),p=Tp(m,r.position)),e.follow){if(u>a){let x=l.x-m.x,b=l.y-m.y;r.position.x+=x,r.position.y+=b,r.el.style.top=r.position.y-(t.box.top+s.y)+"px",r.el.style.left=r.position.x-(t.box.left+s.x)+"px",u=Tp(l,r.position)}}else l=m,u=p;var g=l.x-r.position.x,y=l.y-r.position.y;r.frontPosition={x:g,y},e.dataOnly||t0(r.ui.front,r.frontPosition);var v={identifier:r.identifier,position:l,force:d,pressure:i.force||i.pressure||i.webkitForce||0,distance:u,angle:{radian:h,degree:c},vector:{x:g/a,y:-y/a},raw:f,instance:r,lockX:e.lockX,lockY:e.lockY};v=r.computeDirection(v),v.angle={radian:$v(180-c),degree:180-c},r.trigger("move",v),t.trigger("move "+r.id+":move",v)};Pn.prototype.processOnEnd=function(i){var t=this,e=t.options,n=t.manager.getIdentifier(i),r=t.nipples.get(n),s=t.manager.removeIdentifier(r.identifier);!r||(e.dataOnly||r.hide(function(){e.mode==="dynamic"&&(r.trigger("removed",r),t.trigger("removed "+r.id+":removed",r),t.manager.trigger("removed "+r.id+":removed",r),r.destroy())}),clearInterval(t.pressureIntervals[r.identifier]),r.resetDirection(),r.trigger("end",r),t.trigger("end "+r.id+":end",r),t.ids.indexOf(r.identifier)>=0&&t.ids.splice(t.ids.indexOf(r.identifier),1),t.actives.indexOf(r)>=0&&t.actives.splice(t.actives.indexOf(r),1),/(semi|static)/.test(e.mode)?t.idles.push(r):t.nipples.indexOf(r)>=0&&t.nipples.splice(t.nipples.indexOf(r),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[s.id]=s.identifier))};Pn.prototype.onDestroyed=function(i,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};Pn.prototype.destroy=function(){var i=this;i.unbindEvt(i.options.zone,"start"),i.nipples.forEach(function(e){e.destroy()});for(var t in i.pressureIntervals)i.pressureIntervals.hasOwnProperty(t)&&clearInterval(i.pressureIntervals[t]);i.trigger("destroyed",i.nipples),i.manager.unbindDocument(),i.off()};var xO=Pn;function vr(i){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=PA(),t.config(i),t.prepareCollections();var e=function(){var r;t.collections.forEach(function(s){s.forEach(function(o){r=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};if(typeof window>"u")return t.collections;bd(window,"resize",function(){MA(e)});var n=function(){t.scroll=PA()};return bd(window,"scroll",function(){MA(n)}),t.collections}vr.prototype=new wd;vr.constructor=vr;vr.prototype.prepareCollections=function(){var i=this;i.collections.create=i.create.bind(i),i.collections.on=i.on.bind(i),i.collections.off=i.off.bind(i),i.collections.destroy=i.destroy.bind(i),i.collections.get=function(t){var e;return i.collections.every(function(n){return e=n.get(t),!e}),e}};vr.prototype.create=function(i){return this.createCollection(i)};vr.prototype.createCollection=function(i){var t=this,e=new xO(t,i);return t.bindCollection(e),t.collections.push(e),e};vr.prototype.bindCollection=function(i){var t=this,e,n=function(r,s){e=r.type+" "+s.id+":"+r.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",n),i.on("dir:up dir:right dir:down dir:left",n),i.on("plain:up plain:right plain:down plain:left",n)};vr.prototype.bindDocument=function(){var i=this;i.binded||(i.bindEvt(document,"move").bindEvt(document,"end"),i.binded=!0)};vr.prototype.unbindDocument=function(i){var t=this;(!Object.keys(t.ids).length||i===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};vr.prototype.getIdentifier=function(i){var t;return i?(t=i.identifier===void 0?i.pointerId:i.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};vr.prototype.removeIdentifier=function(i){var t={};for(var e in this.ids)if(this.ids[e]===i){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};vr.prototype.onmove=function(i){var t=this;return t.onAny("move",i),!1};vr.prototype.onend=function(i){var t=this;return t.onAny("end",i),!1};vr.prototype.oncancel=function(i){var t=this;return t.onAny("end",i),!1};vr.prototype.onAny=function(i,t){var e=this,n,r="processOn"+i.charAt(0).toUpperCase()+i.slice(1);t=e0(t);var s=function(a,l,u){u.ids.indexOf(l)>=0&&(u[r](a),a._found_=!0)},o=function(a){n=e.getIdentifier(a),Mp(e.collections,s.bind(null,a,n)),a._found_||e.removeIdentifier(n)};return Mp(t,o),!1};vr.prototype.destroy=function(){var i=this;i.unbindDocument(!0),i.ids={},i.index=0,i.collections.forEach(function(t){t.destroy()}),i.off()};vr.prototype.onDestroyed=function(i,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1)};var bO=vr;var SO=new bO,wO={create:function(i){return SO.create(i)},factory:SO};var AO=new Map,Dp=new Map,no=class{constructor(t,e,n,r){this.data=e;let{audio:s,volume:o,delay:a,loop:l}=e;if(!s)throw new Error("Missing property");let u=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new Ho({src:u,volume:o,delay:a,loop:l}),Dp.has(n.uuid)?Dp.get(n.uuid).push(this):Dp.set(n.uuid,[this]),AO.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},Ad=class{constructor(t){this.data=t}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=AO.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=Dp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(n=>n.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(n=>n.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let t=[...Dp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(n=>{n.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(n=>{n.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Ip=class{constructor(t,e,n,r,s){this.data=e;this.shared=r;this.condition=s;if(e.interaction==="play")this.interaction=new no(t,e,n,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Ad(e);else throw new Error("Missing property")}dispatchBasic(){if(zt(this.shared,this.condition)===!1)return!1;this.interaction instanceof no?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(zt(this.shared,this.condition)===!1)return!1;this.interaction instanceof no?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(t){if(zt(this.shared,this.condition)===!1)return!1;this.interaction instanceof no&&(t==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};var Y9="text/plain",X9="us-ascii",EO=(i,t)=>t.some(e=>e instanceof RegExp?e.test(i):e===i),K9=(i,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(i);if(!e)throw new Error(`Invalid URL: ${i}`);let{type:n,data:r,hash:s}=e.groups,o=n.split(";");s=t?"":s;let a=!1;o[o.length-1]==="base64"&&(o.pop(),a=!0);let l=(o.shift()||"").toLowerCase(),c=[...o.map(h=>{let[d,f=""]=h.split("=").map(p=>p.trim());return d==="charset"&&(f=f.toLowerCase(),f===X9)?"":`${d}${f?`=${f}`:""}`}).filter(Boolean)];return a&&c.push("base64"),(c.length>0||l&&l!==Y9)&&c.unshift(l),`data:${c.join(";")},${a?r.trim():r}${s?`#${s}`:""}`};function DA(i,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},i=i.trim(),/^data:/i.test(i))return K9(i,t);if(/^view-source:/i.test(i))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=i.startsWith("//");!e&&/^\.*\//.test(i)||(i=i.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let r=new URL(i);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&r.protocol==="https:"&&(r.protocol="http:"),t.forceHttps&&r.protocol==="http:"&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){let o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let c=o.exec(r.pathname);if(!c)break;let h=c[0],d=c.index,f=r.pathname.slice(a,d);l+=f.replace(/\/{2,}/g,"/"),l+=h,a=d+h.length}let u=r.pathname.slice(a,r.pathname.length);l+=u.replace(/\/{2,}/g,"/"),r.pathname=l}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let o=r.pathname.split("/"),a=o[o.length-1];EO(a,t.removeDirectoryIndex)&&(o=o.slice(0,-1),r.pathname=o.slice(1).join("/")+"/")}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let o of[...r.searchParams.keys()])EO(o,t.removeQueryParameters)&&r.searchParams.delete(o);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let s=i;return i=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!s.endsWith("/")&&r.hash===""&&(i=i.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(i=i.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(i=i.replace(/^http:\/\//,"//")),t.stripProtocol&&(i=i.replace(/^(?:https?:)?\/\//,"")),i}var s0=class{constructor({url:t,context:e},n,r,s){this.controlsManager=n;this.shared=r;this.condition=s;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:DA(t,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=e??"tab"}dispatch(){if(zt(this.shared,this.condition)===!1)return!1;Og?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.controlsManager.orbitControls?.onPointerUp(We[0]),uC())}};var Op=class{constructor(t,e,n,r,s){this.data=t;this.page=e;this.controlsManager=n;this.shared=r;this.condition=s;this.timeoutIdQueue=[];this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)};this.destroyCallback=t=>{this.timeoutIdQueue.shift();let e=this.page.scene.find(t);if(e===void 0)return;let n=this.controlsManager.sharedGameControlGlobals.rapierWorld,r=n?e.dataPatched.physics?.fusedBody:!0;if(e.cloner){for(let s of e.cloner.children)r?(s.playModeVisible=!1,s.rigidBody&&e.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),n.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.bvhGeometry&&(s.bvhGeometry=void 0)):this.clone===void 0||this.clone===s?(s.playModeVisible=!1,s.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),n.removeRigidBody(s.rigidBody),s.rigidBody=void 0)):s.playModeVisible===void 0&&(s.playModeVisible=!0);(r||this.clone===void 0||this.clone===!1)&&(e.visible=!1,e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),n.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0))}else e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),n.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0),e.visible=!1;n===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.rigidBody!==void 0),e.destroyedInAction=!0,this.controlsManager.requestRender()};this.objects=[...t.objects]}dispatch(t){if(zt(this.shared,this.condition)===!1)return!1;this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(zt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};var Rp=class{constructor(t,e,n,r,s){this.data=t;this.page=e;this.shared=n;this.eventManager=r;this.condition=s;this.shared=n}dispatch(){if(zt(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),Ed(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}};var DO={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},LA={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},Q9=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],a0={CSS:{},springs:{}};function ys(i,t,e){return Math.min(Math.max(i,t),e)}function Lp(i,t){return i.indexOf(t)>-1}function IA(i,t){return i.apply(null,t)}var rt={arr:function(i){return Array.isArray(i)},obj:function(i){return Lp(Object.prototype.toString.call(i),"Object")},pth:function(i){return rt.obj(i)&&i.hasOwnProperty("totalLength")},svg:function(i){return i instanceof SVGElement},inp:function(i){return i instanceof HTMLInputElement},dom:function(i){return!("isNode"in i)&&(i.nodeType||rt.svg(i))},str:function(i){return typeof i=="string"},fnc:function(i){return typeof i=="function"},und:function(i){return typeof i>"u"},hex:function(i){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(i)},rgb:function(i){return/^rgb/.test(i)},hsl:function(i){return/^hsl/.test(i)},col:function(i){return rt.hex(i)||rt.rgb(i)||rt.hsl(i)},key:function(i){return!DO.hasOwnProperty(i)&&!LA.hasOwnProperty(i)&&i!=="targets"&&i!=="keyframes"}};function IO(i){var t=/\(([^)]+)\)/.exec(i);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function OO(i,t){var e=IO(i),n=ys(rt.und(e[0])?1:e[0],.1,100),r=ys(rt.und(e[1])?100:e[1],.1,100),s=ys(rt.und(e[2])?10:e[2],.1,100),o=ys(rt.und(e[3])?0:e[3],.1,100),a=Math.sqrt(r/n),l=s/(2*Math.sqrt(r*n)),u=l<1?a*Math.sqrt(1-l*l):0,c=1,h=l<1?(l*a+-o)/u:-o+a;function d(p){var m=t?t*p/1e3:p;return l<1?m=Math.exp(-m*l*a)*(c*Math.cos(u*m)+h*Math.sin(u*m)):m=(c+h*m)*Math.exp(-m*a),p===0||p===1?p:1-m}function f(){var p=a0.springs[i];if(p)return p;for(var m=1/6,g=0,y=0;;)if(g+=m,d(g)===1){if(y++,y>=16)break}else y=0;var v=g*m*1e3;return a0.springs[i]=v,v}return t?d:f}function Z9(i){return i===void 0&&(i=10),function(t){return Math.ceil(ys(t,1e-6,1)*i)*(1/i)}}var J9=function(){var i=11,t=1/(i-1);function e(c,h){return 1-3*h+3*c}function n(c,h){return 3*h-6*c}function r(c){return 3*c}function s(c,h,d){return((e(h,d)*c+n(h,d))*c+r(h))*c}function o(c,h,d){return 3*e(h,d)*c*c+2*n(h,d)*c+r(h)}function a(c,h,d,f,p){var m,g,y=0;do g=h+(d-h)/2,m=s(g,f,p)-c,m>0?d=g:h=g;while(Math.abs(m)>1e-7&&++y<10);return g}function l(c,h,d,f){for(var p=0;p<4;++p){var m=o(h,d,f);if(m===0)return h;var g=s(h,d,f)-c;h-=g/m}return h}function u(c,h,d,f){if(!(0<=c&&c<=1&&0<=d&&d<=1))return;var p=new Float32Array(i);if(c!==h||d!==f)for(var m=0;m<i;++m)p[m]=s(m*t,c,d);function g(y){for(var v=0,x=1,b=i-1;x!==b&&p[x]<=y;++x)v+=t;--x;var w=(y-p[x])/(p[x+1]-p[x]),E=v+w*t,_=o(E,c,d);return _>=.001?l(y,E,c,d):_===0?E:a(y,v,v+t,c,d)}return function(y){return c===h&&d===f||y===0||y===1?y:s(g(y),h,f)}}return u}(),RO=function(){var i={linear:function(){return function(n){return n}}},t={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var r,s=4;n<((r=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((r*3-2)/22-n,2)}},Elastic:function(n,r){n===void 0&&(n=1),r===void 0&&(r=.5);var s=ys(n,1,10),o=ys(r,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},e=["Quad","Cubic","Quart","Quint","Expo"];return e.forEach(function(n,r){t[n]=function(){return function(s){return Math.pow(s,r+2)}}}),Object.keys(t).forEach(function(n){var r=t[n];i["easeIn"+n]=r,i["easeOut"+n]=function(s,o){return function(a){return 1-r(s,o)(1-a)}},i["easeInOut"+n]=function(s,o){return function(a){return a<.5?r(s,o)(a*2)/2:1-r(s,o)(a*-2+2)/2}}}),i}();function NA(i,t){if(rt.fnc(i))return i;var e=i.split("(")[0],n=RO[e],r=IO(i);switch(e){case"spring":return OO(i,t);case"cubicBezier":return IA(J9,r);case"steps":return IA(Z9,r);default:return IA(n,r)}}function LO(i){try{var t=document.querySelectorAll(i);return t}catch{return}}function l0(i,t){for(var e=i.length,n=arguments.length>=2?arguments[1]:void 0,r=[],s=0;s<e;s++)if(s in i){var o=i[s];t.call(n,o,s,i)&&r.push(o)}return r}function c0(i){return i.reduce(function(t,e){return t.concat(rt.arr(e)?c0(e):e)},[])}function _O(i){return rt.arr(i)?i:(rt.str(i)&&(i=LO(i)||i),i instanceof NodeList||i instanceof HTMLCollection?[].slice.call(i):[i])}function BA(i,t){return i.some(function(e){return e===t})}function FA(i){var t={};for(var e in i)t[e]=i[e];return t}function OA(i,t){var e=FA(i);for(var n in i)e[n]=t.hasOwnProperty(n)?t[n]:i[n];return e}function u0(i,t){var e=FA(i);for(var n in t)e[n]=rt.und(i[n])?t[n]:i[n];return e}function $9(i){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(i);return t?"rgba("+t[1]+",1)":i}function eY(i){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=i.replace(t,function(a,l,u,c){return l+l+u+u+c+c}),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),r=parseInt(n[1],16),s=parseInt(n[2],16),o=parseInt(n[3],16);return"rgba("+r+","+s+","+o+",1)"}function tY(i){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(i)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(i),e=parseInt(t[1],10)/360,n=parseInt(t[2],10)/100,r=parseInt(t[3],10)/100,s=t[4]||1;function o(d,f,p){return p<0&&(p+=1),p>1&&(p-=1),p<1/6?d+(f-d)*6*p:p<1/2?f:p<2/3?d+(f-d)*(2/3-p)*6:d}var a,l,u;if(n==0)a=l=u=r;else{var c=r<.5?r*(1+n):r+n-r*n,h=2*r-c;a=o(h,c,e+1/3),l=o(h,c,e),u=o(h,c,e-1/3)}return"rgba("+a*255+","+l*255+","+u*255+","+s+")"}function nY(i){if(rt.rgb(i))return $9(i);if(rt.hex(i))return eY(i);if(rt.hsl(i))return tY(i)}function qo(i){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(i);if(t)return t[1]}function rY(i){if(Lp(i,"translate")||i==="perspective")return"px";if(Lp(i,"rotate")||Lp(i,"skew"))return"deg"}function RA(i,t){return rt.fnc(i)?i(t.target,t.id,t.total):i}function ro(i,t){return i.getAttribute(t)}function kA(i,t,e){var n=qo(t);if(BA([e,"deg","rad","turn"],n))return t;var r=a0.CSS[t+e];if(!rt.und(r))return r;var s=100,o=document.createElement(i.tagName),a=i.parentNode&&i.parentNode!==document?i.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+e;var l=s/o.offsetWidth;a.removeChild(o);var u=l*parseFloat(t);return a0.CSS[t+e]=u,u}function NO(i,t,e){if(t in i.style){var n=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=i.style[t]||getComputedStyle(i).getPropertyValue(n)||"0";return e?kA(i,r,e):r}}function UA(i,t){if(rt.dom(i)&&!rt.inp(i)&&(ro(i,t)||rt.svg(i)&&i[t]))return"attribute";if(rt.dom(i)&&BA(Q9,t))return"transform";if(rt.dom(i)&&t!=="transform"&&NO(i,t))return"css";if(i[t]!=null)return"object"}function BO(i){if(!!rt.dom(i)){for(var t=i.style.transform||"",e=/(\w+)\(([^)]*)\)/g,n=new Map,r;r=e.exec(t);)n.set(r[1],r[2]);return n}}function iY(i,t,e,n){var r=Lp(t,"scale")?1:0+rY(t),s=BO(i).get(t)||r;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),n?kA(i,s,n):s}function VA(i,t,e,n){switch(UA(i,t)){case"transform":return iY(i,t,n,e);case"css":return NO(i,t,e);case"attribute":return ro(i,t);default:return i[t]||0}}function zA(i,t){var e=/^(\*=|\+=|-=)/.exec(i);if(!e)return i;var n=qo(i)||0,r=parseFloat(t),s=parseFloat(i.replace(e[0],""));switch(e[0][0]){case"+":return r+s+n;case"-":return r-s+n;case"*":return r*s+n}}function FO(i,t){if(rt.col(i))return nY(i);if(/\s/g.test(i))return i;var e=qo(i),n=e?i.substr(0,i.length-e.length):i;return t?n+t:n}function GA(i,t){return Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))}function sY(i){return Math.PI*2*ro(i,"r")}function oY(i){return ro(i,"width")*2+ro(i,"height")*2}function aY(i){return GA({x:ro(i,"x1"),y:ro(i,"y1")},{x:ro(i,"x2"),y:ro(i,"y2")})}function kO(i){for(var t=i.points,e=0,n,r=0;r<t.numberOfItems;r++){var s=t.getItem(r);r>0&&(e+=GA(n,s)),n=s}return e}function lY(i){var t=i.points;return kO(i)+GA(t.getItem(t.numberOfItems-1),t.getItem(0))}function UO(i){if(i.getTotalLength)return i.getTotalLength();switch(i.tagName.toLowerCase()){case"circle":return sY(i);case"rect":return oY(i);case"line":return aY(i);case"polyline":return kO(i);case"polygon":return lY(i)}}function cY(i){var t=UO(i);return i.setAttribute("stroke-dasharray",t),t}function uY(i){for(var t=i.parentNode;rt.svg(t)&&rt.svg(t.parentNode);)t=t.parentNode;return t}function VO(i,t){var e=t||{},n=e.el||uY(i),r=n.getBoundingClientRect(),s=ro(n,"viewBox"),o=r.width,a=r.height,l=e.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:n,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function hY(i,t){var e=rt.str(i)?LO(i)[0]:i,n=t||100;return function(r){return{property:r,el:e,svg:VO(e),totalLength:UO(e)*(n/100)}}}function dY(i,t){function e(a){a===void 0&&(a=0);var l=t+a>=1?t+a:0;return i.el.getPointAtLength(l)}var n=VO(i.el,i.svg),r=e(),s=e(-1),o=e(1);switch(i.property){case"x":return(r.x-n.x)*n.w;case"y":return(r.y-n.y)*n.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function TO(i,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,n=FO(rt.pth(i)?i.totalLength:i,t)+"";return{original:n,numbers:n.match(e)?n.match(e).map(Number):[0],strings:rt.str(i)||t?n.split(e):[]}}function zO(i){var t=i?c0(rt.arr(i)?i.map(_O):_O(i)):[];return l0(t,function(e,n,r){return r.indexOf(e)===n})}function GO(i){var t=zO(i);return t.map(function(e,n){return{target:e,id:n,total:t.length,transforms:{list:BO(e)}}})}function fY(i,t){var e=FA(t);if(/^spring/.test(e.easing)&&(e.duration=OO(e.easing)),rt.arr(i)){var n=i.length,r=n===2&&!rt.obj(i[0]);r?i={value:i}:rt.fnc(t.duration)||(e.duration=t.duration/n)}var s=rt.arr(i)?i:[i];return s.map(function(o,a){var l=rt.obj(o)&&!rt.pth(o)?o:{value:o};return rt.und(l.delay)&&(l.delay=a?0:t.delay),rt.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return u0(o,e)})}function pY(i){for(var t=l0(c0(i.map(function(s){return Object.keys(s)})),function(s){return rt.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),e={},n=function(s){var o=t[s];e[o]=i.map(function(a){var l={};for(var u in a)rt.key(u)?u==o&&(l.value=a[u]):l[u]=a[u];return l})},r=0;r<t.length;r++)n(r);return e}function mY(i,t){var e=[],n=t.keyframes;n&&(t=u0(pY(n),t));for(var r in t)rt.key(r)&&e.push({name:r,tweens:fY(t[r],i)});return e}function gY(i,t){var e={};for(var n in i){var r=RA(i[n],t);rt.arr(r)&&(r=r.map(function(s){return RA(s,t)}),r.length===1&&(r=r[0])),e[n]=r}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function yY(i,t){var e;return i.tweens.map(function(n){var r=gY(n,t),s=r.value,o=rt.arr(s)?s[1]:s,a=qo(o),l=VA(t.target,i.name,a,t),u=e?e.to.original:l,c=rt.arr(s)?s[0]:u,h=qo(c)||qo(l),d=a||h;return rt.und(o)&&(o=u),r.from=TO(c,d),r.to=TO(zA(o,c),d),r.start=e?e.end:0,r.end=r.start+r.delay+r.duration+r.endDelay,r.easing=NA(r.easing,r.duration),r.isPath=rt.pth(s),r.isColor=rt.col(r.from.original),r.isColor&&(r.round=1),e=r,r})}var HO={css:function(i,t,e){return i.style[t]=e},attribute:function(i,t,e){return i.setAttribute(t,e)},object:function(i,t,e){return i[t]=e},transform:function(i,t,e,n,r){if(n.list.set(t,e),t===n.last||r){var s="";n.list.forEach(function(o,a){s+=a+"("+o+") "}),i.style.transform=s}}};function jO(i,t){var e=GO(i);e.forEach(function(n){for(var r in t){var s=RA(t[r],n),o=n.target,a=qo(s),l=VA(o,r,a,n),u=a||qo(l),c=zA(FO(s,u),l),h=UA(o,r);HO[h](o,r,c,n.transforms,!0)}})}function vY(i,t){var e=UA(i.target,t.name);if(e){var n=yY(t,i),r=n[n.length-1];return{type:e,property:t.name,animatable:i,tweens:n,duration:r.end,delay:n[0].delay,endDelay:r.endDelay}}}function xY(i,t){return l0(c0(i.map(function(e){return t.map(function(n){return vY(e,n)})})),function(e){return!rt.und(e)})}function WO(i,t){var e=i.length,n=function(s){return s.timelineOffset?s.timelineOffset:0},r={};return r.duration=e?Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return n(s)+o+a+l+s.duration*(s.loop??1)})):t.duration,r.delay=e?Math.min.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.delay})):t.delay,r.endDelay=e?r.duration-Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return n(s)+o+a+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,r}var MO=0;function bY(i){var t=OA(DO,i),e=OA(LA,i),n=mY(e,i),r=GO(i.targets),s=xY(r,n),o=WO(s,e),a=MO;return MO++,u0(t,{id:a,children:[],animatables:r,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:e.startOnceDelay,pingPongDelayCorrection:e.pingPongDelayCorrection,pingPongEndDelayCorrection:e.pingPongEndDelayCorrection})}var Wi=[],CO=[],o0,SY=function(){function i(){o0=requestAnimationFrame(t)}function t(e){var n=Wi.length;if(n){for(var r=0;r<n;){var s=Wi[r];s.paused?(Wi.splice(r,1),n-=1):(s.tick(e),r++)}i()}else o0=cancelAnimationFrame(o0)}return i}();function wY(i){document.hidden?(Wi.forEach(function(t){return t.pause(i.timeStamp)}),CO=Wi.slice(0),Dn.running=Wi=[]):CO.forEach(function(t){return t.play(i.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",wY);function Dn(i){i===void 0&&(i={});var t=0,e=0,n=0,r,s,o=0,a=null;function l(_){var S=window.Promise&&new Promise(function(T){return a=T});return _.finished=S,S}var u=bY(i),c=l(u);function h(){var _=u.direction;_!=="alternate"&&(u.direction=_!=="normal"?"normal":"reverse"),u.reversed=!u.reversed,s.forEach(function(S){(S.loop===1||S.loop%2===0)&&(S.reversed=u.reversed)})}function d(){u.direction="normal",u.reversed=!1,s.forEach(function(_){return _.reversed=!1})}function f(_){return u.reversed?u.duration-_:_}function p(){t=0,e=f(u.currentTime)*(1/Dn.speed)}function m(_,S,T=!1){S&&(u.reversed?S.seek(S.duration*S.loop-(_-S.timelineOffset-S.pingPongDelayCorrection),T):S.seek(_-S.timelineOffset-S.startOnceDelay-S.pingPongDelayCorrection,T))}function g(_,S=!1){if(u.reversed)for(var M=o;M--;)m(_,s[M],S);else for(var T=0;T<o;T++)m(_,s[T],S)}function y(_){var S=0,T=u.animations,M=T.length;for(u.direction!=="alternate"&&u.parent?.direction==="alternate"?u.parent?.rewind===!1&&u.reversePlayback===!0&&u.rewind===!1&&(u.parent?.reversed&&u.direction==="alternate"?_=u.duration-u.delay+u.endDelay-_:_=u.duration+u.delay-u.endDelay-_):w(!1,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)&&(u.parent?.reversed&&u.direction==="alternate"?_=u.duration-u.delay+u.endDelay-_:_=u.duration+u.delay-u.endDelay-_);S<M;){var C=T[S],D=C.animatable,P=C.tweens,I=P.length-1,L=P[I];I&&(L=l0(P,function(W){return _<W.end})[0]||L);let K;u.parent?.reversed&&u.direction==="alternate"?K=ys(_-L.start-L.endDelay,0,L.duration)/L.duration:K=ys(_-L.start-L.delay,0,L.duration)/L.duration;for(var H=isNaN(K)?1:L.easing(K),U=L.to.strings,G=L.round,z=[],V=L.to.numbers.length,$=void 0,F=0;F<V;F++){var j=void 0;let W,ye;u.direction!=="alternate"?u.parent?.rewind===!1&&u.reversePlayback===!0&&u.rewind===!1?(W=L.to.numbers[F],ye=L.from.numbers[F]||0):(ye=L.to.numbers[F],W=L.from.numbers[F]||0):w(!0,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)?(W=L.to.numbers[F],ye=L.from.numbers[F]||0):(ye=L.to.numbers[F],W=L.from.numbers[F]||0),L.isPath?j=dY(L.value,H*ye):j=W+H*(ye-W),G&&(L.isColor&&F>2||(j=Math.round(j*G)/G)),z.push(j)}var X=U.length;if(!X)$=z[0];else{$=U[0];for(var q=0;q<X;q++){var k=U[q],Z=U[q+1],Q=z[q];isNaN(Q)||(Z?$+=Q+Z:$+=Q+" ")}}HO[C.type](D.target,C.property,$,D.transforms),C.currentValue=$,S++}}function v(_){u[_]&&!u.passThrough&&u[_](u)}function x(){u.remaining&&u.remaining!==!0&&u.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 w(_,S,T,M,C){return b[_<<4|S<<3|T<<2|M<<1|C]}function E(_,S=!1){var T=u.duration;let M=u.delay,C=T-u.endDelay;u.parent?.reversed&&u.direction==="alternate"&&(M=u.endDelay,C=T-u.delay);var D=f(_);if(u.progress=ys(D/T*100,0,100),S||(u.reversePlayback=D<u.currentTime),o&&g(D,S),!u.began&&u.currentTime>=0&&(u.began=!0,v("begin")),!u.loopBegan&&u.currentTime>0&&(u.loopBegan=!0,v("loopBegin")),(u.reversed||D>=0)&&D<=M&&u.currentTime!==0&&(y(0),v("change")),(D>=C&&u.currentTime!==T+u.pingPongDelayCorrection||!T)&&(y(T),v("change")),D>M&&D<C?(u.changeBegan||(u.changeBegan=!0,u.changeCompleted=!1,v("changeBegin")),y(D),v("change")):u.changeBegan?(u.changeCompleted=!0,u.changeBegan=!1,v("change"),o&&v("timelineChangeComplete")):u.began&&D>C&&v("changeComplete"),u.currentTime=ys(D,0,T+u.pingPongDelayCorrection),u.began&&v("update"),_>=T)if(x(),!u.remaining)u.paused=!0,u.completed||(u.completed=!0,v("loopComplete"),v("complete"),!u.passThrough&&"Promise"in window&&(a(),c=l(u)));else{o?t+=u.duration/Dn.speed:t+=u.duration;for(let P of s)P.setStartTime(0),P.remaining=P.loop;v("loopComplete"),u.loopBegan=!1,u.direction==="alternate"?h():o&&d()}}return u.reset=function(){var _=u.direction;u.passThrough=!1,u.currentTime=0,u.progress=0,u.paused=!0,u.began=!1,u.loopBegan=!1,u.changeBegan=!1,u.completed=!1,u.changeCompleted=!1,u.reversePlayback=!1,u.reversed=_==="reverse",u.remaining=u.loop,s=u.children,o=s.length;for(var S=o;S--;)u.children[S].reset();(u.reversed&&u.loop!==!0||_==="alternate"&&u.loop===1)&&u.remaining++,y(u.reversed?u.duration:0)},u.setStartTime=function(_){t=_},u.set=function(_,S){return jO(_,S),u},u.tick=function(_){n=_,t||(t=n),E((n+(e-t))*Dn.speed)},u.seek=function(_,S=!1){E(_-t,S)},u.pause=function(_){u.paused=!0,o&&(r=_??performance.now())},u.play=function(_){!u.paused||(u.completed&&u.reset(),u.paused=!1,Wi.push(u),o&&r!==void 0&&(t+=(_??performance.now())-r),o0||SY())},u.reverse=function(){h(),u.completed=!u.reversed,p()},u.restart=function(){u.reset(),u.play()},u.reset(),u.autoplay&&u.play(),u}function PO(i,t){for(var e=t.length;e--;)BA(i,t[e].animatable.target)&&t.splice(e,1)}function AY(i){for(var t=zO(i),e=Wi.length;e--;){var n=Wi[e],r=n.animations,s=n.children;PO(t,r);for(var o=s.length;o--;){var a=s[o],l=a.animations;PO(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!r.length&&!s.length&&n.pause()}}function EY(i,t){t===void 0&&(t={});var e=t.direction||"normal",n=t.easing?NA(t.easing):null,r=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",u=o==="last",c=rt.arr(i),h=parseFloat(c?i[0]:i),d=c?parseFloat(i[1]):0,f=qo(c?i[1]:i)||0,p=t.start||0+(c?h:0),m=[],g=0;return function(y,v,x){if(a&&(o=0),l&&(o=(x-1)/2),u&&(o=x-1),!m.length){for(var b=0;b<x;b++){if(!r)m.push(Math.abs(o-b));else{var w=l?(r[0]-1)/2:o%r[0],E=l?(r[1]-1)/2:Math.floor(o/r[0]),_=b%r[0],S=Math.floor(b/r[0]),T=w-_,M=E-S,C=Math.sqrt(T*T+M*M);s==="x"&&(C=-T),s==="y"&&(C=-M),m.push(C)}g=Math.max.apply(Math,m)}n&&(m=m.map(function(P){return n(P/g)*g})),e==="reverse"&&(m=m.map(function(P){return s?P<0?P*-1:-P:Math.abs(g-P)}))}var D=c?(d-h)/g:h;return p+D*(Math.round(m[v]*100)/100)+f}}function _Y(i){i===void 0&&(i={});var t=Dn(i);return t.duration=0,t.add=function(e,n){var r=Wi.indexOf(t),s=t.children;r>-1&&Wi.splice(r,1);function o(d){d.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=u0(e,OA(LA,i));l.targets=l.targets||i.targets;var u=t.duration;l.autoplay=!1,l.timelineOffset=rt.und(n)?u:zA(n,u),o(t);var c=Dn(l);o(c),s.push(c),c.parent=t;var h=WO(s,i);return t.delay=h.delay,t.endDelay=h.endDelay,t.duration=h.duration,c.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}Dn.version="3.2.0";Dn.speed=1;Dn.running=Wi;Dn.remove=AY;Dn.get=VA;Dn.set=jO;Dn.convertPx=kA;Dn.path=hY;Dn.setDashoffset=cY;Dn.stagger=EY;Dn.timeline=_Y;Dn.easing=NA;Dn.penner=RO;Dn.random=function(i,t){return Math.floor(Math.random()*(t-i+1))+i};var h0=Dn;var qO=new A,YO=new A,XO=new Ye;function KO(i,t,e,n){if(n===0)return e.copy(i);if(n===1)return e.copy(t);let r=i.w*t.w+i.x*t.x+i.y*t.y+i.z*t.z;if(r>=1)return e.copy(i);let s=1-r*r;if(s<=Number.EPSILON){let c=1-n;return e.w=c*i.w+n*t.w,e.x=c*i.x+n*t.x,e.y=c*i.y+n*t.y,e.z=c*i.z+n*t.z,e.normalize(),e}let o=Math.sqrt(s),a=Math.atan2(o,r),l=Math.sin((1-n)*a)/o,u=Math.sin(n*a)/o;return e.w=i.w*l+t.w*u,e.x=i.x*l+t.x*u,e.y=i.y*l+t.y*u,e.z=i.z*l+t.z*u,e}function vs(i,t,e,n,r){let s=e[i]?e[i]:void 0,o=n[i];if(o==null)return;let a=s??t[i],l=o;if(a!==l)return{update:u=>{let c=Te.lerp(a,l,u);r?t[i]=Math.trunc(c):t[i]=c},start:()=>{t[i]=a},end:()=>{t[i]=l}}}function HA(i,t,e,n,r){let s=e[i]?e[i]:void 0,o=n[i];if(!o)return;let a=t[i],l=[...s??a],u=[...o];if(!(l.length!==u.length||Af(l,u)))return{update:c=>{l.forEach((h,d)=>{let f=Te.lerp(h,u[d],c);t[i][d]=r?Math.trunc(f):f})},start:()=>{Object.assign(t[i],l)},end:()=>{Object.assign(t[i],u)}}}function jA(i,t,e,n){let r=e[i]?e[i]:void 0,s=n[i];if(!s)return;let o=t[i],a=r?new A().fromArray(r):o.clone(),l=new A().fromArray(s);if(!a.equals(l))return{update:u=>{o.lerpVectors(a,l,u)},start:()=>{o.copy(a)},end:()=>{o.copy(l)}}}function QO(i,t,e,n){let r=e[i]?e[i]:void 0,s=n[i];if(!s)return;let o=t[i],a=r?new se().fromArray(r):o.clone(),l=new A,u=new Ye,c=new A;a.decompose(l,u,c);let h=new se().fromArray(s),d=new A,f=new Ye,p=new A;if(h.decompose(d,f,p),!a.equals(h))return{update:m=>{XO.slerpQuaternions(u,f,m),qO.lerpVectors(l,d,m),YO.lerpVectors(c,p,m),o.compose(qO,XO,YO)},start:()=>{o.compose(l,u,c)},end:()=>{o.compose(d,f,p)}}}function ZO(i,t,e,n,r){let s=e[i]?e[i]:void 0,o=n[i];if(!o)return;let a=t[i],l=s?typeof s=="string"?r.getColor(s).clone():new Fe().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?r.getColor(o).clone():new Fe().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return t[i]=c,{update:h=>{c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function io(i,t,e,n){if(typeof t[i]=="number")return vs(i,t,e??{},n);if(Array.isArray(t[i]))return HA(i,t,e??{},n)}function JO(i,t,e){let n=[],r=i.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,s=i.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(s!==void 0){let o=r??i.zoom,a=s;o!==a&&n.push({update:l=>{i.zoom=Te.lerp(o,a,l),i.updateProjectionMatrix()},start:()=>{i.zoom=o,i.updateProjectionMatrix()},end:()=>{i.zoom=a,i.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let o=vs("targetOffset",i,t,e);o&&n.push(o)}return n}function TY(i,t,e,n){if(e.scaleBaked===void 0)return;let r=t.scaleBaked??i.data.geometry.scaleBaked,s=e.scaleBaked;if(Ns.isEqual(r,s))return;let o=[];return o.push({update:a=>{i.updateGeometryInteractions({scaleBaked:[Te.lerp(r[0],s[0],a),Te.lerp(r[1],s[1],a),Te.lerp(r[2],s[2],a)]},n),i.invalidateDownstreamBooleanData()},start:()=>{i.updateGeometryInteractions({scaleBaked:r},n),i.invalidateDownstreamBooleanData()},end:()=>{i.updateGeometryInteractions({scaleBaked:s},n),i.invalidateDownstreamBooleanData()}}),o}function MY(i,t,e){if(!e.extrusion)return;let n=i.extrusion,r=t.extrusion??{},s=e.extrusion,o=[];return yS.forEach(a=>{let l=io(a,n,r,s);l&&o.push(l)}),o}function $O(i,t,e,n){let r=[];if(!("geometry"in e))return r;let s=i.geometry.userData.parameters,o="geometry"in t?t.geometry:{},a=e.geometry;if(i instanceof ds){let l=TY(i,o,a,n);l&&r.push(...l)}else{let l={};if(Object.assign(l,xi(s,vS)),vS.forEach(u=>{let c=io(u,l,o,a);c&&r.push(c)}),i instanceof $a){Object.assign(l,{extrusion:{...s.extrusion}});let u=MY(l,o,a);u&&r.push(...u)}r.length&&r.push({update:u=>{i.updateGeometryInteractions(l,n),i.updateGeometryGroupsIfNeeded()},start:u=>{i.updateGeometryInteractions(l,n),i.updateGeometryGroupsIfNeeded()},end:u=>{i.updateGeometryInteractions(l,n),i.updateGeometryGroupsIfNeeded()}})}return r}function eR(i,t,e,n){let r=[];if(e.intensity!==void 0){let s=vs("intensity",i,t,e);s&&r.push(s)}if(e.color!==void 0){let s=ZO("color",i,t,e,n);s&&r.push(s)}return r}function nR(i,t,e,n){let r=[];if(Array.isArray(i.material)){if(!("materials"in e&&e.materials))return r;let s="materials"in t&&t.materials?t.materials:[],o=e.materials;i.material.forEach((a,l)=>{if(!o[l])return;let u=s[l]??{},c=o[l];typeof u=="string"||typeof c=="string"||r.push(...tR(a,u,c,n))})}else{if(!("material"in e&&e.material))return r;let s="material"in t&&t.material?t.material:{},o=e.material;if(typeof s=="string"||typeof o=="string")return r;r.push(...tR(i.material,s,o,n))}return r}function tR(i,t,e,n){let r=[],s=fp(e,n)||!!t.layers&&fp(t,n);r.push(BY(i,s));for(let o of i.layers){let a=t.layers?.data(o.uuid),l=e.layers.data(o.uuid);if(!l||!(o.visible??!0)||!(l.visible??!0))continue;let u=o.getNames().filter(c=>!py.some(h=>c.includes(h)));for(let c of u)try{let h=o.getValue(c),d;if(c==="colors")d=LY(o,a,l,c);else if(Array.isArray(h))c==="steps"&&(d=RY(o,a,l,c));else if(typeof h=="number")d=CY(o,a,l,c);else{if(typeof h=="boolean")continue;h instanceof B?d=PY(o,a,l,c):h instanceof A?d=DY(o,a,l,c):h instanceof hn?d=OY(o,a,l,c,n):h instanceof Fe?d=IY(o,a,l,c,n):"isTexture"in h&&(d=NY(o,a,l,c))}d&&(Array.isArray(d)?r.push(...d):r.push(d))}catch(h){console.error(`lerpMaterial: unexpected material layer for ${c}`,h)}}return r}function CY(i,t,e,n){if(!i.hasValue(n)||!(n in e))return;let r=t?t[n]:i.getValue(n),s=e[n];if(r!==s)return{update:o=>{i.setValue(n,Te.lerp(r,s,o))},start:()=>{i.setValue(n,r)},end:()=>{i.setValue(n,s)}}}function PY(i,t,e,n){if(!i.hasValue(n)||!(n in e))return;let r=i.getValue(n),s=t?new B().fromArray(t[n]):r.clone(),o=new B().fromArray(e[n]);if(!s.equals(o))return{update:a=>{r.lerpVectors(s,o,a)},start:()=>{r.copy(s)},end:()=>{r.copy(o)}}}function DY(i,t,e,n){if(!i.hasValue(n)||!(n in e))return;let r=i.getValue(n),s=t?new A().fromArray(t[n]):r.clone(),o=new A().fromArray(e[n]);if(!s.equals(o))return{update:a=>{r.lerpVectors(s,o,a)},start:()=>{r.copy(s)},end:()=>{r.copy(o)}}}function IY(i,t,e,n,r){if(!i.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=i.getValue(n),l=s?typeof s=="string"?r.getColor(s).clone():new Fe().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?r.getColor(o).clone():new Fe().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return{update:h=>{i.getValue(n)!==c&&i.setValue(n,c),c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function OY(i,t,e,n,r){if(!i.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=i.getValue(n),l=s?typeof s=="string"?r.getColor(s).clone():new Fe().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?r.getColor(o).clone():new hn(o.r,o.g,o.b,o.a);if(l.equals(u))return;let c=a.clone();return{update:h=>{i.getValue(n)!==c&&i.setValue(n,c),c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function RY(i,t,e,n="steps"){if(!i.hasValue(n)||!(n in e))return;let r=[],s=i.getValue(n),o=t?t[n]:s,a=e[n];for(let l=0;l<s.length;++l){let u=o[l],c=a[l];u!==c&&r.push({update:h=>{s[l]=Te.lerp(u,c,h)},start:()=>{s[l]=u},end:()=>{s[l]=c}})}return r.length?r:void 0}function LY(i,t,e,n="colors"){if(!i.hasValue(n)||!(n in e))return;let r=[],s=i.getValue(n),o=t?t[n]:s.map(l=>l.toArray()),a=e[n];for(let l=0;l<s.length;++l){let u=[...o[l]],c=[...a[l]];Lf.isEqual(u,c)||r.push({update:h=>{s[l].fromArray(Lf.lerp(u,c,h))},start:()=>{s[l].fromArray(u)},end:()=>{s[l].fromArray(c)}})}return r.length?r:void 0}function NY(i,t,e,n="texture"){if(!i.hasValue(n)||!(n in e))return;let r=i.getNode("mat");if(!r)return;let s=t?t[n]:r,o=e[n],a=[...s.repeat],l=[...s.offset],u=[...o.repeat],c=[...o.offset];if(!Fl.isEqual(a,u)||!Fl.isEqual(l,c))return{update:h=>{r.repeat=Fl.lerp(a,u,h),r.offset=Fl.lerp(l,c,h),r.updateMatrix()},start:()=>{r.repeat=[...a],r.offset=[...l],r.updateMatrix()},end:()=>{r.repeat=[...u],r.offset=[...c],r.updateMatrix()}}}function BY(i,t){return{update:()=>{i.transparent=t}}}var WA=new A,rR=new qt;function iR(i,t,e,n){let r=[],s,o,a,l,u,c,h={slide:(t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping).slide,offset:(t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping).offset};if(u=vs("slide",h,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping),u&&r.push(u),c=vs("offset",h,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping),c&&r.push(c),!u&&!c&&(s=jA("position",i,t,e),s&&r.push(s),o=jA("scale",i,t,e),o&&r.push(o),a=FY(i,t,e,n),a&&r.push(a),l=QO("hiddenMatrix",i,t,e),l&&r.push(l)),s||o||a||l||u||c){let d=()=>{i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i.parent?.matrixWorldFusedFalse&&(i.matrixWorld.multiplyMatrices(i.parent.matrixWorldFusedFalse,i.matrix),i.matrixWorldNeedsUpdate=!1),Rr(i)&&Lr(i.parent)&&i.invalidateDownstreamBooleanData(!0),i.updatePathSnapping(Object.assign({},t.pathSnapping,h))};r.push({update:d,start:d,end:d})}return r}function FY(i,t,e,n){let r=t?.rotation?t.rotation.map(u=>u*Te.DEG2RAD):void 0,s=e.rotation?.map(u=>u*Te.DEG2RAD);if(!s)return;let o=r?new A().fromArray(r):new A().setFromEuler(i.rotation),a=new A().fromArray(s);if(o.equals(a))return;let l=WA.subVectors(a,o);if(n&&l.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new Ye().setFromEuler(rR.setFromVector3(o)),c=new Ye().setFromEuler(rR.setFromVector3(a));return{update:h=>{KO(u,c,i.quaternion,h)},start:()=>{i.rotation.setFromVector3(o)},end:()=>{i.rotation.setFromVector3(a)}}}else return{update:u=>{WA.lerpVectors(o,a,u),i.rotation.setFromVector3(WA)},start:()=>{i.rotation.setFromVector3(o)},end:()=>{i.rotation.setFromVector3(a)}}}function sR(i,t,e){let n=[];if(!("cloner"in e)||!i.cloner)return n;let r=i.cloner,s="cloner"in t?t.cloner:{},o=e.cloner;lS.forEach(d=>{let f;d==="count"?f=vs("count",r.parameters,s,o,!0):f=io(d,r.parameters,s??{},o),f&&n.push(f)});let a=kY(r,s,o);a?.length&&n.push(...a);let l=UY(r,s,o);l?.length&&n.push(...l);let u=VY(r,s,o);u?.length&&n.push(...u);let c=zY(r,s,o);c?.length&&n.push(...c);let h=GY(r,s,o);return h?.length&&n.push(...h),n.length&&n.push({update:()=>{r.update()}}),n}function kY(i,t,e){if(i.parameters.type!=="radial")return;let n=t.radial,r=e.radial;if(!r)return;let s=i.parameters.radial,o=[];return cS.forEach(a=>{let l=io(a,s,n??{},r);l&&o.push(l)}),o}function UY(i,t,e){if(i.parameters.type!=="linear")return;let n=t.linear,r=e.linear;if(!r)return;let s=[],o=i.parameters.linear;return uS.forEach(a=>{let l=io(a,o,n??{},r);l&&s.push(l)}),s}function VY(i,t,e){if(i.parameters.type!=="grid")return;let n=t.grid,r=e.grid;if(!r)return;let s=[],o=i.parameters.grid;return hS.forEach(a=>{let l;a==="count"?l=HA(a,o,n??{},r,!0):l=io(a,o,n??{},r),l&&s.push(l)}),s}function zY(i,t,e){if(i.parameters.type!=="toObject")return;let n=t.toObject,r=e.toObject;if(!r)return;let s=[],o=i.parameters.toObject;return dS.forEach(a=>{let l;a==="count"?l=vs(a,o,n??{},r,!0):l=io(a,o,n??{},r),l&&s.push(l)}),s}function GY(i,t,e){if(!i.parameters.randomness)return;let n=t.randomnessObject,r=e.randomnessObject;if(!r)return;let s=[],o=i.parameters.randomnessObject;return fS.forEach(a=>{let l=io(a,o,n??{},r);l&&s.push(l)}),s}function qA(i,t,e,n,r){let s=[];return i.data.visible&&s.push(...iR(i,t,e,r)),i.data.visible&&s.push(...sR(i,t,e)),Rr(i)?(i instanceof jt&&i.data.visible&&s.push(...$O(i,t,e,n)),i.data.visible&&s.push(...nR(i,t,e,n))):fI(i)?i.data.visible&&s.push(...eR(i,t,e,n)):dI(i)&&s.push(...JO(i,t,e)),s.length?{update:o=>{s.forEach(a=>a.update(o))},start:o=>{s.forEach(a=>a.start?.(o))},end:o=>{s.forEach(a=>a.end?.(o))}}:void 0}var oR=new A;function Ed(i,t,e=!1){let n=[];i.traverseChildren(r=>{if(e&&(r.rigidBody?.setTranslation(r.position0,!0),r.rigidBody?.setRotation(r.rotation0,!0),r.rigidBody?.setLinvel(oR,!0),r.rigidBody?.setAngvel(oR,!0)),!at.is(r))return;let s=r.uuid,o=r.data;if(delete r.states,r.uuid===Li)return;let a=!1;n.some(l=>i.scene.find(s)?.isDescendantOf(l))?a=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&n.push(s),r.data=o,r.currentState=null,r.reversibleToState=null,r.currentTransitionEvent=null;for(let l of o.states){let u={...l.data};i.data.globalPhysics.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||a)&&(l.data.position!==void 0&&delete u.position,l.data.rotation!==void 0&&delete u.rotation,l.data.hiddenMatrix!==void 0&&delete u.hiddenMatrix),r.states||(r.states={}),r.states[l.id]=No.patch(o,u)}jY(i.scene,r,null,t,o.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0),HY(i)})}function HY(i){i.traverseEntity(t=>{for(let e of t.data.events){let n=[];switch(e.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":n.push(...e.data.actions);break;case"GameControl":for(let r of Object.values(e.data.gameActions))n.push(...r);break;case"DragDrop":n.push(...e.data.dragDropActions.drag,...e.data.dragDropActions.drop);break;case"Conditional":n.push(...e.data.inActions,...e.data.outActions);break}for(let r of n)if(r.data.type==="Create"&&r.data.hideBase==="Yes"){let s=i.scene.find(r.data.object);s&&(s.visible=!1)}}})}function jY(i,t,e,n,r=!1){if(t instanceof jt&&t.removeInteractionGeometry(),t.changeSelectedState(e,{scene:i,shared:n},r),t instanceof jt&&t.updateGeometryGroupsIfNeeded(),t instanceof Kt&&t.updateCameraState(t.dataPatched,{scene:i,shared:n}),t.cloner)for(let s of t.cloner.children)s.playModeVisible=void 0;t.updateVisible()}function YA(i){let t;if(i.easing===5){let{control1:e,control2:n}=i;t=`cubicBezier(
|
|
6238
6238
|
${e[0]}, ${e[1]}, ${n[0]}, ${n[1]}
|
|
6239
|
-
)`}else if(i.easing===6){let{mass:e,stiffness:n,damping:r,velocity:s}=i;t=`spring( ${e}, ${n}, ${r}, ${s} )`}else{let e;switch(i.easing){case 0:e=Ro.linear;break;case 1:e=Ro.ease;break;case 2:e=Ro.easeIn;break;case 3:e=Ro.easeOut;break;case 4:e=Ro.easeInOut;break;default:e=Ro.linear}let[n,r,s,o]=e;t=`cubicBezier( ${n}, ${r}, ${s}, ${o} )`}return{duration:i.duration,easing:t}}function aR(i){let t={delay:0,loop:i.repeat===-1?!0:i.repeat+1};if(i.repeat===0)t.direction="normal",t.rewind=!1;else switch(i.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,i.delayDirection){case"start-once":t.startOnceDelay=i.delay;break;case"start":t.delay=i.delay;break;case"end":t.endDelay=i.delay;break;case"start-end":case void 0:t.delay=i.delay,t.endDelay=i.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,i.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):i.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):i.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var WY={type:"beginState"},qY={type:"completeState",isfromEntity:!1},f0=class{constructor(t,e,n,r,s,o){this.object=t;this.data=r;this.sharedAssets=s;this.allowSlerp=o;this.targets={t:0};this.firstLoop=!0;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))};this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let t=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof Kt&&e.dispatchEvent(WY)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof Kt&&e.dispatchEvent(qY)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=qA(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=d0(this.object,this.object.currentState===n?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=d0(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(n===void 0)throw new Error("Missing property");{let a=d0(this.object,n);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||n===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...aR(r),...YA(r),change:this.onChange},this.callback=qA(this.object,e===void 0?{}:this.from.data,n===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Np=class extends Ht{constructor(e,n,r,s){super();this.data=e;this.page=n;this.shared=r;this.condition=s;this.toggleIsForward=!1;this.timelineNeedsRebuild=!1;this.useToggle=!1;this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,isRebuild:!0}),this.timeline.play())};if(!e.object)throw new Error("Missing property");let o=this.page.scene.find(e.object);if(!o)throw new Error("Missing property");if(!o.states)throw new Error("Missing property");if(this.object=o,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=d0(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,isRebuild:n=!1}={}){try{let r=aR(this.data.tweens[0].data),s=r.loop;n&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=h0.timeline({autoplay:!1,...r,...s===!0||s>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(this.timelineNeedsRebuild=o!==-1&&(s===!0||s>1),r.pingPongDelayCorrection&&n===!1&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let u=this.data.tweens[l],c=this.data.tweens[l+1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Kt&&(this.object.wasMovedByUser=!1)):h=u.data.state===void 0?this.currentState:u.data.state;let d=new f0(this.object,h,c.data.state===void 0?this.currentState:c.data.state,c.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?r.delay:0)+(l===a&&!n?r.pingPongDelayCorrection:0))}this.timeline.duration+=r.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let u=this.data.tweens[l],c=this.data.tweens[l-1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Kt&&(this.object.wasMovedByUser=!1)):h=u.data.state===void 0?this.currentState:u.data.state;let d=new f0(this.object,h,c.data.state===void 0?this.currentState:c.data.state,u.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l-1]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?r.endDelay:0))}this.timeline.duration+=r.delay+(n?0:r.pingPongDelayCorrection)}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(zt(this.shared,this.condition)===!1||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.shared}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(zt(this.shared,this.condition)===!1)return!1;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 d0(i,t){let e,n;if(typeof t=="string"?(e=t,n=i.states?.[e]):t===null&&(e=null,n=i.data),!(e===void 0||n===void 0))return{id:e,data:n}}var YY={type:"beginState"},lR={type:"completeState",isfromEntity:!1},cR={type:"requestRender"},Bp=class extends Ht{constructor(e,n,r,s){super();this.data=e;this.page=n;this.shared=r;this.condition=s;this.toggleIsForward=!1;this.useToggle=!1;this.posStart=new A;this.posEnd=new A;this.qStart=new Ye;this.qEnd=new Ye;this.zoomStart=1;this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let n=this.page.scene.find(this.data.targetCamera);if(!n||!n.visible)throw new ReferenceError("Target camera not founded or not visible");let r={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=h0({targets:r,t:1,...YA(this.data),update:()=>{r.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.uuid)):(this.posEnd.copy(n.position),this.qEnd.copy(n.quaternion),this.zoomEnd=n.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(n.uuid)),this.page.activeCamera.dispatchEvent(YY));let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,r.t),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,r.t),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*r.t,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(cR),r.t===1&&s.dispatchEvent(lR)}})}switchCamera(e){let n=this.page.scene.find(e);if(!n||!n.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(n),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:n})}play(){if(zt(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(zt(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{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.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(lR),this.page.activeCamera.dispatchEvent(cR))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var Fp=class extends Ht{constructor(e,n,r,s,o){super();this.page=n;this.animationControls=r;this.shared=s;this.condition=o;this.startOnceDelay=0;this.toggleIsForward=!1;let a=e.object,l=n.scene.find(e.object);l&&Array.isArray(l.identity)&&(a=l.identity[0]),this.data={...e,object:a};let u=this.animationControls.clipIdToAction[e.clipId+"/"+a];this.duration=u?.getClip()?.duration??1;let c=u?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/c*this.duration,this.rightFrameTime=this.data.crop[1]/c*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(zt(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let n=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let o=r.split("/")[1];this.threeAnimAction!==s&&o===n&&s.isRunning()&&(e?s.fadeOut(.2):s.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Te.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,n=!1){if(zt(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let r=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===r&&o.isRunning()&&(n?o.fadeOut(.2):o.stop())}),n&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}};var kp=class{constructor(t,e,n,r,s){this.data=t;this.page=e;this.eventManager=n;this.shared=r;this.condition=s;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(zt(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(n=>n.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),Ed(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var Up=class{constructor(t,e,n,r){this.data=t;this.page=e;this.shared=n;this.condition=r;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=zt(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=ev(this.data.expression,this.shared,Hr.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};function zt(i,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=ev(t.expression,i,"boolean");return t.negate?!e:!!e}function Qt(i,t,e,n,r,s){let o={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[]},a=l=>({id:u,data:c})=>{try{c.type==="Audio"?Si[i.type].includes("Audio")&&o.Audio.push(new Ip(u,c,s,n,l)):c.type==="Video"?Si[i.type].includes("Video")&&o.Video.push(new Vp(u,c,s,n,l)):c.type==="Link"?Si[i.type].includes("Link")&&o.Link.push(new s0(c,r.controlsManager,n,l)):c.type==="Create"?Si[i.type].includes("Create")&&o.Create.push(new zp(c,e,r.controlsManager,n,l)):c.type==="Destroy"?Si[i.type].includes("Destroy")&&o.Destroy.push(new Op(c,e,r.controlsManager,n,l)):c.type==="Reset"?Si[i.type].includes("Reset")&&o.Reset.push(new Rp(c,e,n,r,l)):c.type==="Transition"?Si[i.type].includes("Transition")&&o.Transition.push(new Np(c,e,n,l)):c.type==="SwitchCamera"?Si[i.type].includes("SwitchCamera")&&o.SwitchCamera.push(new Bp(c,e,n,l)):c.type==="SceneTransition"?Si[i.type].includes("SceneTransition")&&o.SceneTransition.push(new kp(c,e,r,n,l)):c.type==="Animation"?Si[i.type].includes("Animation")&&o.Animation.push(new Fp(c,e,r.animationControls,n,l)):c.type==="SetVariable"?Si[i.type].includes("SetVariable")&&o.SetVariable.push(new Up(c,e,n,l)):c.type==="Conditional"&&Si[i.type].includes("Conditional")&&(c.ifActions.forEach(a({expression:c.condition,negate:!1})),c.elseActions.forEach(a({expression:c.condition,negate:!0})))}catch(h){!1&&console.log(h)}};return t.forEach(a()),o}function Gt(i){Object.values(i).forEach(t=>{t.forEach(e=>{(e instanceof Ip||e instanceof Vp||e instanceof Fp||e instanceof Np||e instanceof zp||e instanceof Op||e instanceof Bp||e instanceof kp||e instanceof Rp||e instanceof Up)&&e.dispose()})})}function uR(i,t){let e;if("material"in i){let n=i.material;Array.isArray(n)?e=i.material[0].layers.find(r=>r.uuid===t):e=i.material.layers.find(r=>r.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var hR=new Map,Gp=new Map,Yo=class{constructor(t,e,n){this.data=e;this.delay=0;this.status="stopped";let{layerId:r,loop:s,volume:o,delay:a}=e;if(this.object=n,r===void 0)throw new Error("Missing property");let l=uR(n,r);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),Gp.has(n.uuid)?Gp.get(n.uuid).push(this):Gp.set(n.uuid,[this]),hR.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let n=this.videoElement.play();n!==void 0&&n.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},_d=class{constructor(t){this.data=t}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=hR.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=Gp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(n=>n[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(n=>n[this.data.interaction]()))}pauseAllVideos(){let t=[...Gp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Vp=class{constructor(t,e,n,r,s){this.data=e;this.shared=r;this.condition=s;if(e.interaction==="play")this.interaction=new Yo(t,e,n);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new _d(e);else throw new Error("Missing property")}dispatchBasic(){if(zt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Yo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(zt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Yo?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var dR=(()=>{let i,t,e,n;function r(a){!i&&!fR()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(i=requestAnimationFrame(s)),a&&(t=a,n=a.requestRender)}function s(a){let l=e?a-e:0,u=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,h=u.length,d=0;for(;d<h;){let f=u[d];f.userData.createdTime===void 0&&(f.userData.createdTime=a),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&a-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&c[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,l/1e3),f.updateMatrix(),n()),d++):(c[f.userData.actionId]>f.userData.quantity&&c[f.userData.actionId]--,u.splice(d,1),f.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(p=>p.bvhGeometry!==void 0)),h--,n())}i=d>0?requestAnimationFrame(s):void 0,e=d>0?a:void 0}function o(){fR()?i&&(cancelAnimationFrame(i),i=void 0,e=void 0):r()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),r})();function fR(){return!!document&&document.hidden}var pR=new Ye,XY=new A,KY=new A,zp=class{constructor(t,e,n,r,s){this.data=t;this.page=e;this.controlsManager=n;this.shared=r;this.condition=s;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=Te.generateUUID();this.dispatch=()=>{if(zt(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()};this.dispatchFromStart=()=>{if(zt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=Vb(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 t=new un(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let n=this.data.coordinateSystem,r=this.page.scene.find(n);r&&(r.updateMatrixWorldSVD(),t.hiddenMatrix.copy(r.matrixWorldRigid))}t.position.fromArray(this.data.position),t.rotation.fromArray(this.data.rotation),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),dR(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof yr)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof un)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof yr)return;t instanceof un?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let n=new A().fromArray(this.data.velocity),r=e.dataPatched;if(!(r.physics.enabled==="visibility"?!r.visible:!r.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(XY,pR,KY),n.applyQuaternion(pR),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(n.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&(t.userData.velocity=n)),e.dataPatched.physics?.fusedBody===!0))return!0};let o=this.page.scene.find(this.data.object);if(!o)throw new Error("Missing Property");if(this.object=o,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");dR(n)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}};var ZA=200,XA=.02,KA=.3,QY=65,r3e=new A,mR=new A,gR=new A,ZY=new A,Xr=new A,ai=new A,el=new A,QA=new se,yR=new se,JY=new se,i3e=new se,xs=new Ye,Xo=new Ye,so=new qt(0,0,0,"YXZ"),$Y=new A(1,0,0),bs=new A(0,1,0),e7=new A(0,0,1),vR=new A(1,1,1),s3e=new ln,t7=1,n7=.025,r7=16e-6,xR=12,i7=20,xr=new Xn,qi=new Tt,s7={type:"requestRender"},o7={type:"updateMatrix"},bR=Math.PI/6,p0=class extends Ht{constructor(e,n,r,s,o,a,l,u,c){super();this.object=e;this.domElement=n;this.data=r;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=u;this.sharedAssets=c;this.enableDamping=!0;this.hiddenMatrix0=new se;this.target0=new A;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=ZA;this.euler0=new qt(0,0,0,"YXZ");this.position0Cam=new A;this.quat0Cam=new Ye;this.scale0Cam=new A;this.hiddenMatrix0Cam=new se;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new Xn(new A(0,-40,0),new A(0,40,0)),matrix:new se,position:new A,rotation:new Ye};this.euler=new qt(0,0,0,"YXZ");this.eulerDelta=new A;this.lastPosition=new A;this.lastCameraQuaternion=new Ye;this.lastCameraPosition=new A;this.PI_2=Math.PI/2;this.prevMouse=new B;this.velocityTarget=new A;this.velocity=new A;this.directionXZ=new A;this.rotVelocityStick=new A;this.rotVelocityTarget=new A;this.rotVelocity=new A;this.rotDirection=new A;this.nonColliderRotOffset=new se;this.nonColliderPosOffset=new se;this.firstPointerId=-1;this.rot=new A;this.path=[];this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0};this.vrEulerYOffset=0;this.onObject=!1;this.actionState={};this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]];this.collisionEnabled=!0;this.offsetMatrix=new se;this.objectToTarget=new A;this.objectToTarget0=new A;this.objectToCamXZ=new A;this.objectToCamXZ0=new A;this.targetToCamera=new A;this.targetToCamera0=new A;this.cameraPolarAxis0=new A;this.targetPos=new A;this.targetQuat=new Ye;this.lerpFactorPos=new A().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new Ye;this.objXZQuatInv=new Ye;this.objXZRotMat=new se;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new A;this.pushedVelocity=new A;this.groundYRotation=0;this.objectRealQuat=new Ye;this.colliderWorldQuat=new Ye;this.groundNormal=new A;this.groundTilt=new Ye;this.groundTiltInv=new Ye;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new A;this.quaternion=new Ye;this.scale=new A;this.initialAction=!0;this.onPointerDown=e=>{e.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Qn&&(!zb||Gb>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let n=e.clientX-this.prevMouse.x,r=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(zb&&Gb<15.5&&!Qn?(this.eulerDelta.y=-n*this.mouseOrbitSensitivity,this.eulerDelta.x=-r*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-n*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-r*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?p0.isLocked=!0:p0.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let n of this.keyAssignments)if(e.key.toUpperCase()===n[1]||e.key===n[1]){this.movementState[n[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let n of this.keyAssignments)if(e.key.toUpperCase()===n[1]||e.key===n[1]||e.code.slice(3,e.code.length).toUpperCase()===n[1]){this.movementState[n[0]]=0;break}};this.copyVRGamePadValues=(e,n)=>{for(let r=2;r<4;r++){let s=e.axes[r];n===0?r===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,r===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(s)>=.3&&(this.vrEulerYOffset+=s<0?1:-1),this.movementState.rotPosY=s):this.moveMode==="fly"&&(this.movementState.moveNegY=s))}};this.sharedGameControlGlobals=o.sharedGameControlGlobals,e===l&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let 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 g=new A(0,0,-1).applyQuaternion(this.camera.quaternion),y=new A().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(y),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v,x;Math.abs(g.y)<1e-6?(y.y=0,g.y=0,x=y.projectOnVector(g)):y.y/g.y>0?x=g.multiplyScalar(y.y/g.y):x=g.multiplyScalar(y.length()),this.targetToCamera0.copy(x).negate(),v=this.camera.position.clone().add(x),this.objectToTarget0.subVectors(v,this.position);let b=new qt().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-b.x,b.x=0,b.z=0,b.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(b)}if(this.object instanceof Kt&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=r.rotByTouch??"joystick",this.rotBy=r.rotBy??"keys",this.rotationMode=r.rotationMode??"normal",this.moveMode=r.moveMode??"walk",this.collisionEnabled=r.collisionEnabled,this.speedTranslate=(r.speedTranslate??250)*t7,this.speedOrbit=(r.speedRotate??100)*n7,this.mouseOrbitSensitivity=(r.speedRotate??100)*r7,this.keyAssignments=r.keyAssignments.map(g=>{let y=[g[0],g[1]];return y[1]==="\u25B2"?y[1]="ArrowUp":y[1]==="\u25C0"?y[1]="ArrowLeft":y[1]==="\u25BC"?y[1]="ArrowDown":y[1]==="\u25B6"?y[1]="ArrowRight":y[1]==="\u21E7"?y[1]="Shift":y[1]==="\u21B5"?y[1]="Enter":y[1]==="Space"?y[1]=" ":y[1]==="\u2318"?y[1]="Meta":y[1]==="Ctrl"?y[1]="Control":y[1]==="Esc"&&(y[1]="Escape"),y}),r.rotBy==="mouse"){let g;g=this.keyAssignments.findIndex(y=>y[0]==="rotNegX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosY"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotNegY"),g!==-1&&(this.keyAssignments[g][1]="")}this.lerpFactorPosStart=1-.02**(1/((r.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((r.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((r.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((r.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((r.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((r.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Oa.defaultData.gravity)*xR,this.usePhysics=this.gloabalPhysics.usePhysics??Oa.defaultData.usePhysics,this.jumpPower=r.jumpPower*i7,this.resetYPosition=this.position.y+Math.abs(r.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=r.alignToGround??!1,this.orientMode=r.autoOrientMove?r.orientMode:"none",this.orientWith=r.orientWith??Ku.defaultDataThirdPerson.orientWith,this.slopeThresh=QY*Math.PI/180,r.collider.type==="capsule"?(this.collider.radius=r.collider.radius,this.collider.segment.start.y=r.collider.height/2-r.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=r.collider.height*XA/this.pixelsPerMeter,this.stepThresh=r.collider.height*KA/this.pixelsPerMeter,this.colliderHeight=r.collider.height):r.collider.type==="sphere"?(this.collider.radius=r.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*r.collider.radius*XA/this.pixelsPerMeter,this.stepThresh=2*r.collider.radius*KA/this.pixelsPerMeter,this.colliderHeight=r.collider.radius*2):(this.offset=r.collider.height*XA/this.pixelsPerMeter,this.stepThresh=r.collider.height*KA/this.pixelsPerMeter,this.colliderHeight=r.collider.height),this.collider.type=r.collider.type;let f=new A().fromArray(r.collider.position),p=new Ye().setFromEuler(new qt().fromArray([...r.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(p),this.collider.matrix.compose(f,p,vR),r.cameraXAxis!==void 0&&(this.cameraXAxis=r.cameraXAxis,this.cameraYAxis=r.cameraYAxis,this.minPolarAngle=r.cameraRotXLimits[0],this.maxPolarAngle=r.cameraRotXLimits[1],this.minAzimuthAngleRel=r.cameraRotYLimits[0],this.maxAzimuthAngleRel=r.cameraRotYLimits[1]),this.forwardDir=r.forwardDirection??"-z",this.runMultiplier=r.runMultiplier??2;let m=r.navmesh.destinationHelperRadius*2;if(m>0){let g=new Re;g.push({fi:0,data:{...dr.defaultData("light","phong"),alpha:0},id:"layer1"}),g.push({fi:0,data:{...dr.defaultData("color"),color:r.navmesh.destinationHelperColor,alpha:r.navmesh.destinationHelperColor.a},id:"layer2"});let y=new Go({layers:g},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Fn(Vy.create({parameters:{width:m,height:m/10,hollow:.7}}),y),this.navMeshPathDest.material.userData.opacity0=r.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let n=new qt().setFromQuaternion(this.quaternion,"YXZ"),r=n.y;this.objectRealQuat.copy(this.quaternion),n.y=0,this.quaternion.setFromEuler(n),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),n.set(0,r,0),this.quaternion.setFromEuler(n),this.rot.setFromEuler(n),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Kt?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,n=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Xu.list.forEach(r=>{this.actions[r]=Qt({...e,disabled:!1,type:"GameControl"},e.gameActions[r],this.page,n,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1),console.log("instantiateActions",this.actions)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),Gt(this.actions.idle),Gt(this.actions.move),Gt(this.actions.run),Gt(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(n=>{n.play()}),this.actions[e].Animation.forEach(n=>{n.play(this.initialAction===!1)}),this.actions[e].Create.forEach(n=>{n.dispatchStart()}),this.actions[e].Audio.forEach(n=>{n.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(n=>{n.dispatchStop()}),this.actions[e].Audio.forEach(n=>{n.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Xr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,n,r){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let s=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let o=s*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let u=ai.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*xR),1)*(this.gravity>0?1:-1):this.velocity.y)*s,0).divideScalar(this.pixelsPerMeter),c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(c){this.onObject=!0,this.groundNormal.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),c.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=c.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(Xr,Xo,ai),this.groundVelocity.subVectors(Xr,d.prevT),this.object.getWorldPosition(ai).add(this.collider.position).sub(Xr),this.groundYRotation=so.setFromQuaternion(Xo).y-d.prevR.y,el.copy(ai).applyAxisAngle(bs,this.groundYRotation),this.groundVelocity.add(el.sub(ai)).divideScalar(s);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*o),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let u=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let c=Xr.subVectors(this.path[1],this.position),h=ai.subVectors(this.path[1],this.path[0]);c.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),u.opacity=u.userData.opacity0}else u.opacity-=.05*u.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**o),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**o),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**o)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let l=ZY.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let u=ai.copy(l);u.y=0,l.set(0,l.y,u.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let u=Xr;this.camera.getWorldDirection(u);let c=el.copy(bs).multiplyScalar(u.dot(bs));u.sub(c);let h=ai.copy(this.directionXZ);h.x*=-1,this.rot.y=u.angleTo(h)*(u.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(so.setFromVector3(this.rot),this.moveMode==="walk"&&(so.x=0),l.applyEuler(so),a&&(Xo.setFromUnitVectors(bs,this.groundNormal),l.applyQuaternion(Xo)),r){let u=so.set(0,this.vrEulerYOffset*bR,0);r.applyEuler(u),l.x+=r.x,l.z+=r.z,this.nonColliderPosOffset.elements[13]+=r.y*s}if(this.usePhysics===!0){let u=ai;this.pushedVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=el.setFromMatrixPosition(c.matrixWorld).sub(c.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),d=c.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),Xr.copy(l).divideScalar(this.pixelsPerMeter),s,!1);h.multiplyScalar(this.pixelsPerMeter);let f=at.is(c)?c:c.object;if(d!==null&&this.lastHitObj!==f){let p;c instanceof un&&(p=c);let m=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(m)for(let g of m)g.data.target==="character"&&(g.dispatch(p),f.dispatchEvent(m0));this.lastHitObj=f}if(d!==null){this.pushedVelocity.copy(h),u.copy(d.normal1).applyQuaternion(c.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let c=u.dot(l);c<0&&l.addScaledVector(u,-c),l.add(this.pushedVelocity)}else l.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(s),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**o):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**o),this.euler.x+=this.rotVelocity.x*s,this.euler.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*s),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(bs,this.euler.y-this.euler0.y);let u=ai.copy(this.objectToCamXZ).normalize(),c=el.copy(l).multiplyScalar(s);c.y=0;let h=c.sub(Xr.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Te.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Te.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Te.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(n?(so.copy(n),so.y=0):(so.copy(this.euler),so.y=0),this.nonColliderRotOffset.makeRotationFromEuler(so)),n&&(this.moveMode==="walk"?(this.rot.y=n.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(n),this.rot.y+=this.vrEulerYOffset*bR),xs.setFromAxisAngle($Y,this.rot.x),Xo.setFromAxisAngle(bs,this.rot.y),Xo.multiply(xs),xs.setFromAxisAngle(e7,this.rot.z),Xo.multiply(xs),this.quaternion.copy(Xo),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let u=ai.copy(l).multiplyScalar(s/this.pixelsPerMeter),c=null;this.didHit=!1;let h=new A;for(let d=0;d<5;d++){let f=u.length(),p=el.copy(u).normalize();if(c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,p,this.object.rigidBody?.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),c!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(c.collider.handle);if(m!==this.lastHitObj&&d===0){this.lastHitObj=m;let x=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(x){for(let b of x)if(b.data.target==="character"){let w=(this.sharedGameControlGlobals.rapierWorld?.getCollider(c.collider.handle))._parent,E;if(m.cloner){for(let _ of m.cloner.children)if(_.rigidBody===w){E=_;break}}b.dispatch(E),m.dispatchEvent(m0)}}}let g=mR.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat),y=gR.copy(p).multiplyScalar(c.toi).dot(g),v=c.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),y>this.offset&&(v=c.toi*(y-this.offset)/y,h.addScaledVector(p,v)),u.copy(p).multiplyScalar(f-v),Math.acos(-g.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),b=el.copy(c.witness2).applyQuaternion(this.colliderWorldQuat);b.y=0;let w=x.add(b);w.y+=this.stepThresh;let E=this.sharedGameControlGlobals.rapierWorld.castShape(w,this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);E!==null&&E.toi===0&&(g.y=0,g.normalize())}u.addScaledVector(g,-u.dot(g))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(u);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(Xr.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(xs.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let u=this.onObject?1:5,c=l.multiplyScalar(s/u);for(let h=0;h<u;h++)this.position.add(c),this.collisionAdjustment(s/u)}else this.position.addScaledVector(l,s);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let u=this.objectToTarget.add(this.position),c=this.targetToCamera.add(u);QA.lookAt(c,u,bs).setPosition(c),QA.decompose(this.targetPos,this.targetQuat,Xr),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**o),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Te.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Te.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(o7),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===null||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(s7),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=xs.setFromAxisAngle(bs,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Te.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let n;this.cameraXAxis==="Limit"?n=Te.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):n=Te.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let r=Xr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&r.applyQuaternion(e);let s=Xo.setFromAxisAngle(r,n);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){bs.angleTo(e)*180/Math.PI<15||bs.angleTo(e)*180/Math.PI>85?xs.identity():xs.setFromUnitVectors(bs,e),this.groundTilt.slerp(xs,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let n=gR.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let r=QA.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Xr,xs,ai).compose(Xr,xs,vR);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;qi.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=yR.copy(a).invert(),u=JY.copy(yR).multiply(r);xr.copy(this.collider.segment),xr.start.applyMatrix4(u),xr.end.applyMatrix4(u);let c=mR.copy(this.position).applyMatrix4(l);qi.expandByPoint(xr.start),qi.expandByPoint(xr.end),qi.min.addScalar(-this.collider.radius),qi.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(xr.end)},intersectsBounds:h=>h.intersectsBox(qi),intersectsTriangle:h=>{let d=Xr,f=ai,p=h.closestPointToSegment(xr,d,f);if(p<this.collider.radius){let m=this.collider.radius-p,g=f.sub(d).normalize(),y=el.copy(c);y.addScaledVector(g,m);let v=y.applyMatrix4(a).sub(this.position);n.add(v),xr.start.addScaledVector(g,m),xr.end.addScaledVector(g,m)}}})}),qi.makeEmpty(),xr.copy(this.collider.segment),xr.start.applyMatrix4(r),xr.end.applyMatrix4(r),qi.expandByPoint(xr.start),qi.expandByPoint(xr.end),qi.min.addScalar(-this.collider.radius),qi.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(xr.end)},intersectsBounds:o=>o.intersectsBox(qi),intersectsTriangle:o=>{let a=Xr,l=ai,u=o.closestPointToSegment(xr,a,l);if(u<this.collider.radius){let c=this.collider.radius-u,h=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),n.addScaledVector(h,c),xr.start.addScaledVector(h,c),xr.end.addScaledVector(h,c)}}}),this.onObject=Math.abs(n.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,n.length()-1e-5);n.normalize().multiplyScalar(s),this.position.add(n)}},Hp=p0;Hp.isLocked=!1;var SR=$o(zS());function Ss(i,t){let e=new Ae;if(!i.getAttribute("position"))return e.setAttribute("position",new be([],3)),e.setIndex([]),e;let{positions:n,triIndices:r}=Yl(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new be(n,3)),e.setIndex(r),t&&e.applyMatrix4(t),e}var a7=new se,l7=new se,oo=[[0,0,0],[0,0,0],[0,0,0]];function JA(i){let t=i.elements;oo[0][0]=t[0],oo[0][1]=t[4],oo[0][2]=t[8],oo[1][0]=t[1],oo[1][1]=t[5],oo[1][2]=t[9],oo[2][0]=t[2],oo[2][1]=t[6],oo[2][2]=t[10];let{u:e,v:n}=(0,SR.SVD)(oo),r=a7.set(e[0][0],e[0][1],e[0][2],0,e[1][0],e[1][1],e[1][2],0,e[2][0],e[2][1],e[2][2],0,0,0,0,1),s=l7.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1);return r.multiply(s.transpose())}var g0=class extends Jc{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,n=[]){return t.forEach(r=>{r.visible&&this.intersectObject(r,e,n)}),n}createRaycastLineHelper(){let t=new Pi({color:65280,linewidth:10}),e=new A(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new A(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new A().addVectors(e,n.multiplyScalar(r)),o=new Ae;return o.setFromPoints([e,s]),new bl(o,t)}};var wR=i=>i instanceof ps||i instanceof gs;function c7(i,t){return i.distance-t.distance}function AR(i,t,e){if(!(!Gs(t)||!t.visible)){Rr(t)&&t.raycast(i,e);for(let n of t.children)AR(i,n,e)}}function Td(i,t,e,n=!1){if(!n&&!e.some(s=>Md(i,s)!==void 0))return[];let r=[];return t.children.forEach(s=>AR(i,s,r)),r.sort(c7),r}function jp(i){let t=[];if(i.length){let e=i[0].object;Gs(e)&&t.push(e);let n=e.parent;for(;n;)wR(n)&&t.push(n),n=n.parent}return t}function Md(i,t){if(Rr(t)){if(t.visible){let e=[];return t.raycast(i,e),e.length?e[0]:void 0}}else if(wR(t))return ER(i,t)}function ER(i,t){if(!(!Gs(t)||!t.visible)){if(Rr(t)){let e=[];if(t.raycast(i,e),e.length)return e[0]}for(let e of t.children){let n=ER(i,e);if(n)return n}}}function u7(i,t,e){return{x:(i-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}var y0=class{constructor(t,e,n,r,s,o,a,l){this.renderer=t;this.publish=e;this.scene=n;this.getCamera=r;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.frame=l;this.raycaster=new g0;this.raycasterNeedsUpdate=!0;this._useWindowEvents=!1;this._useWindowEvents=e.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateRaycaster(t){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:e,pageY:n}=t.touches?.length>0?t.touches[0]:t,r=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(u7(e,n,r),this.getCamera())}};var $A=(a=>(a[a.keydown=0]="keydown",a[a.keyup=1]="keyup",a[a.pointerdown=2]="pointerdown",a[a.pointerup=3]="pointerup",a[a.pointermove=4]="pointermove",a[a.wheel=5]="wheel",a[a.scroll=6]="scroll",a))($A||{}),dn=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var e1=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],_R=i=>e1.find(([t,e])=>e===i)?.[0],ao=i=>e1.find(([t])=>t===i)?.[1],h7=(i,t)=>{let e=_R(i);if(e){let n=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(n,"target",{writable:!1,value:t}),n}},v0=class extends dn{constructor(e){super(e);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let n=this.splineEvents[_R(e.eventName)]?.[e.target.uuid];if(!n)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(n,{deltaY:e.deltaY});let{domElement:r}=this.eventContext;r.dispatchEvent(n)};let{page:n}=this.eventContext;n.traverseEntity(r=>{if(!!r.data?.events.length){for(let[s,o]of e1)if(r.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(r):this.objectsPerEvents.set(s,[r]);let a={id:r.uuid,name:r.name},l=h7(o,a),u=this.splineEvents[s];u?u[r.uuid]=l:this.splineEvents[s]={[r.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.removeEventListener("beginEvent",this.onBeginEvent)})})}};var t1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;this.alreadyPlayedNonTogglingActions=new Set;if(this.useToggle=e.runMode==="Toggle",(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=Qt(e,e.actions,r,s,o,n)}disconnect(){Gt(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()}),this.actions.SwitchCamera.forEach(e=>{e.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(r=>r.playing)||this.actions.Transition.forEach(r=>{this.alreadyPlayedNonTogglingActions.has(r)===!1&&r.play()}),this.actions.SwitchCamera.some(r=>r.playing)||this.actions.SwitchCamera.forEach(r=>{r.play()}),this.actions.Animation.forEach(r=>{r.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch())}},x0=class extends dn{constructor(e,n,r){super(e);this.useForRaycastProperty=r;this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]};this.canvasMouseEvents=[];this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}};this.heldKeys={};this.heldKeysPress={};this._prevObjects=[];this.sceneInterects=null;this.onCanvasRaycast=e=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=Td(n,r,[],!0);this.sceneInterects=s,s.length&&(this.eventContext.sharedAssets.raycastProperty={x:s[0].point.x,y:s[0].point.y,z:s[0].point.z,objX:s[0].object.matrixWorld.elements[12],objY:s[0].object.matrixWorld.elements[13],objZ:s[0].object.matrixWorld.elements[14]})}};this.onCanvasMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&(this.onCanvasRaycast(e),n.dispatch())})};this.onCanvasMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?(this.onCanvasRaycast(e),n.dispatch()):n.data.type==="MousePress"&&n.dispatchRelease()})};this.onMouseDown=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent(r)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{page:s,sharedAssets:o}=this.eventContext;s.traverseEntity(a=>{if(!a.data?.events.length)return;let l=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let u of l){let c=this.eventsPerObjects[u];a.data.events.filter(({data:h})=>h.type===u&&h.disabled!==!0).forEach(({id:h,data:d})=>{try{let f=new t1(h,d,a,s,o,n);f.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(f):c[a.uuid]?c[a.uuid].push(f):c[a.uuid]=[f]}catch(f){!1&&console.log(f)}}),c[a.uuid]?.length&&this.objectsPerTypes[u].push(a)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),e.addEventListener("pointerdown",this.onCanvasMouseDown),e.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([n,r])=>{r.forEach(s=>{s.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(n=>{Object.values(n).forEach(r=>{r.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(n=>{n.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([n,r])=>{r.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:n,raycaster:r,page:s}=this.eventContext,o=this.objectsPerTypes[e];if(!(!o.length&&!this.useForRaycastProperty)){if(n||this.useForRaycastProperty){let a;this.sceneInterects===null?a=Td(r,s,o,this.useForRaycastProperty):(a=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&a.length&&(this.eventContext.sharedAssets.raycastProperty={x:a[0].point.x,y:a[0].point.y,z:a[0].point.z,objX:a[0].object.matrixWorld.elements[12],objY:a[0].object.matrixWorld.elements[13],objZ:a[0].object.matrixWorld.elements[14]}),n&&jp(a).forEach(l=>{this.eventsPerObjects[e][l.uuid]&&this.handleObjectMouseEventDispatch(l,e)})}n||o.forEach(a=>{Md(r,a)&&this.handleObjectMouseEventDispatch(a,e)})}}handleMousePressEvent(e=!1){let n="MousePress",r=this.objectsPerTypes[n],s=[];if(!!r.length){if(!e){let{stopRaycast:o,raycaster:a,page:l}=this.eventContext;if(o){let u=Td(a,l,r);s=jp(u)}else r.forEach(u=>{Md(a,u)&&s.push(u)})}this._prevObjects.length&&this._prevObjects.forEach(o=>{s.includes(o)||this.handleObjectMouseEventDispatchRelease(o,n)}),s.length&&s.forEach(o=>{this.handleObjectMouseEventDispatch(o,n)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(r=>{r.dispatch()})}handleObjectMouseEventDispatchRelease(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(r=>{r.dispatchRelease()})}handleKeyEvent(e,n,r=!1){this.objectsPerTypes[n].forEach(s=>{let o=this.eventsPerObjects[n][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:n}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(r?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,n,r=!1){this.objectsPerTypes[n].forEach(s=>{this.eventsPerObjects[n][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(r)})})}};var d7=new A,f7=new A;var b0=class{constructor(t,e,n,r,s){this.actionsIn=Qt(t,t.inActions,n,r,s,e),this.actionsOut=Qt(t,t.outActions,n,r,s,e)}disconnect(){Gt(this.actionsIn),Gt(this.actionsOut)}};var n1=class extends b0{constructor(e,n,r,s,o,a){super(n,r,s,o,a);this.id=e;this.data=n;this.object=r;this.stage="out";this.objects=[];this.onUpdateMatrixWorld=()=>{for(let s of this.objects)if(!s.visible)return;let e=d7.setFromMatrixPosition(this.objects[0].matrixWorld),n=f7.setFromMatrixPosition(this.objects[1].matrixWorld),r=e.distanceTo(n)<=this.distance?"in":"out";if(this.stage!==r){this.stage=r;let s=r==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Link.forEach(o=>o.dispatch()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.Animation.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),s.SceneTransition.forEach(o=>o.dispatch()),s.SetVariable.forEach(o=>o.checkConditions()),s.SetVariable.forEach(o=>o.dispatch())}};let{distance:l,fromObject:u,toObject:c}=n.condition;this.distance=l;for(let h of[u,c]){if(!h)throw new Error("Missing property");let d=s.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)})}},r1=class extends b0{constructor(e,n,r,s,o,a){super(n,r,s,o,a);this.id=e;this.data=n;this.object=r;this.onBegin=({target:e,state:n})=>{this.toState!==n&&(this.actionsOut.Audio.forEach(r=>r.dispatchConditional()),this.actionsOut.Video.forEach(r=>r.dispatchConditional()),this.actionsOut.Link.forEach(r=>r.dispatch()),this.actionsOut.Create.forEach(r=>r.dispatch()),this.actionsOut.Destroy.forEach(r=>r.dispatch()),this.actionsOut.Reset.forEach(r=>r.dispatch()),this.actionsIn.Transition.forEach(r=>r.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(r=>r.play()),this.actionsOut.Animation.forEach(r=>r.play()),this.actionsIn.SwitchCamera.forEach(r=>r.pause()),this.actionsOut.SwitchCamera.forEach(r=>r.play()),this.actionsOut.SceneTransition.forEach(r=>r.dispatch()),this.actionsOut.SetVariable.forEach(r=>r.checkConditions()),this.actionsOut.SetVariable.forEach(r=>r.dispatch()))};this.onComplete=({target:e,state:n})=>{this.toState===n&&(this.actionsIn.Audio.forEach(r=>r.dispatchConditional()),this.actionsIn.Video.forEach(r=>r.dispatchConditional()),this.actionsIn.Link.forEach(r=>r.dispatch()),this.actionsIn.Create.forEach(r=>r.dispatch()),this.actionsIn.Destroy.forEach(r=>r.dispatch()),this.actionsIn.Reset.forEach(r=>r.dispatch()),this.actionsOut.Transition.forEach(r=>r.pause()),this.actionsOut.Transition.forEach(r=>r.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(r=>r.play()),this.actionsIn.Animation.forEach(r=>r.play()),this.actionsOut.SwitchCamera.forEach(r=>r.pause()),this.actionsIn.SwitchCamera.forEach(r=>r.play()),this.actionsIn.SceneTransition.forEach(r=>r.dispatch()),this.actionsIn.SetVariable.forEach(r=>r.checkConditions()),this.actionsIn.SetVariable.forEach(r=>r.dispatch()))};let{condition:l}=n;if(!l.object)throw new Error("Missing property");let u=s.find(l.object);if(!u)throw new Error("Missing property");if(this.toObject=u,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.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.actionsIn.SetVariable.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.actionsOut.SetVariable.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.actionsIn.SetVariable.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},S0=class extends dn{constructor(e,n){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(o=>{if(!!o.data?.events.length){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="Conditional")try{let u;l.condition.type==="Comparison"||(l.condition.type==="Distance"?u=new n1(a,l,o,r,s,n):l.condition.type==="State"&&(u=new r1(a,l,o,r,s,n))),u&&(this.eventsPerConditions[l.condition.type].push(u),(u.actionsIn.Video.length||u.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(u){!1&&console.log(u)}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.disconnect()))}};var Wp=new A,tl=new A,cc=new A,TR=new En,p7=.01,Ft=new A,tr=new A,MR=new A,uc=new Ye,i1=new qt,m7=new se,s1=new $t,Cd=new A,lo=new A,Pd=.2;function o1(i,t){!t||(t[0]<t[1]&&(i.x=Math.min(Math.max(i.x,t[0]),t[1])),t[2]<t[3]&&(i.y=Math.min(Math.max(i.y,t[2]),t[3])),t[4]<t[5]&&(i.z=Math.min(Math.max(i.z,t[4]),t[5])))}var g7=function(){let i=new se;return(t,e,n)=>{let r=t.obj;i.copy(r.hiddenMatrix),r.parent!==null&&i.premultiply(r.parent.matrixWorld),i.invert(),r.position.copy(e),t.reference==="global"&&o1(r.position,t.limits),r.position.applyMatrix4(i),t.reference==="parent"?o1(r.position,t.limits):t.reference==="local"&&(uc.copy(t.quat0).invert(),r.position.sub(t.position0),r.position.applyQuaternion(uc),o1(r.position,t.limits),uc.invert(),r.position.applyQuaternion(uc),r.position.add(t.position0)),i.multiply(n??r.matrixWorld).decompose(Ft,r.quaternion,tr),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldSVD()),r instanceof Xt&&Lr(r.parent)&&r.invalidateDownstreamBooleanData(!0)}}(),a1=class{constructor(t,e,n,r,s,o){this.object=t;this.data=e;this.dropDestIds=[];this.activeIdx=null;this.wasDragEventTriggered=!1;this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=Qt(e,e.dragDropActions.drag,n,r,s,this.object),this.actionsDrop=Qt(e,e.dragDropActions.drop,n,r,s,this.object);let a=[];this.data.objects.forEach(l=>{let u=n.find(l);!u||u.data.visible!==!1&&(a.push(u),o[u.uuid]&&o[u.uuid].forEach(c=>{let h=n.find(c);!h||h.data.visible!==!1&&a.push(h)}))}),this.data.dropDestinations.forEach(l=>{let u=n.find(l);!u||u.data.visible!==!1&&(this.dropDestIds.push(u.uuid),o[u.uuid]&&o[u.uuid].forEach(c=>{let h=n.find(c);!h||h.data.visible!==!1&&this.dropDestIds.push(h.uuid)}))}),this.dragItems=a.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new A().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new A().setFromMatrixPosition(l.matrixWorld),pointStart:new A,pointEnd:new A,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new A().copy(l.position),quat0:new Ye().copy(l.quaternion),snapped:!1,orientationMatrix:new se,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Gt(this.actionsDrag),Gt(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},w0=class extends dn{constructor(e,n){super(e);this.eventManager=n;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(We.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:u,pointStart:c}of o.dragItems){if(l===s[0].object||l===s[0].object.object||at.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let h=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(Ft,uc,tr),i1.setFromQuaternion(uc),h.prevR===void 0?(h.prevR=i1.clone(),h.prevT=Ft.clone()):(h.prevR.copy(i1),h.prevT.copy(Ft)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.eventManager.controlsManager.usePhysics&&l.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}a++}}this.activeEvent=null};this.onPointerMove=e=>{if(We.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);if(We.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||at.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof ps)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===l.object.uuid||r.scene.find(u).isAncestorOf(l.object.uuid))))[0]),a){let l=MR.copy(a.face.normal).applyMatrix3(s1.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){Ft.copy(l).applyMatrix3(s1.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;Ft.x>Pd?tr.x=-u.recursiveBBox.min.x:Ft.x<-Pd&&(tr.x=-u.recursiveBBox.max.x),Ft.y>Pd?tr.y=-u.recursiveBBox.min.y:Ft.y<-Pd&&(tr.y=-u.recursiveBBox.max.y),Ft.z>Pd?tr.z=-u.recursiveBBox.min.z:Ft.z<-Pd&&(tr.z=-u.recursiveBBox.max.z),tr.applyMatrix3(s1.invert())}else tr.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(tr)}this.activeEvent.data.autoOrient&&(Ft.set(0,1,0).cross(l),Ft.length()<1e-4&&Ft.set(-1,0,0).cross(l),tr.crossVectors(MR,Ft),o.orientationMatrix.makeBasis(Ft,tr,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.stop()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let n=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!n)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&n&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(r=>{r.stop()}),this.activeEvent.actionsDrag.Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(r=>r.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(r=>r.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let r={};e.page.traverseEntity(s=>{s.component&&(r[s.component.uuid]?r[s.component.uuid].push(s.uuid):r[s.component.uuid]=[s.uuid])}),e.page.traverseEntity(s=>{s.data?.events.filter(o=>o.data.type==="DragDrop"&&!o.data.disabled).forEach(o=>{this.events.push(new a1(s,o.data,e.page,e.sharedAssets,n,r))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(n=>n.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let n of e.dragItems)n.paused||this.updateDragItem(n,!0)}calcPlaneIntersectPos(e,n,r,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(tl),tl.negate();let l=uc.identity();switch(s==="parent"?m7.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(Ft,l,tr):s==="local"&&e.matrixWorld.decompose(Ft,l,tr),r){case"x":Ft.set(1,0,0).applyQuaternion(l),Cd.copy(tl).cross(Ft),lo.copy(Ft).cross(Cd);break;case"y":Ft.set(0,1,0).applyQuaternion(l),Cd.copy(tl).cross(Ft),lo.copy(Ft).cross(Cd);break;case"z":Ft.set(0,0,1).applyQuaternion(l),Cd.copy(tl).cross(Ft),lo.copy(Ft).cross(Cd);break;case"xy":lo.set(0,0,1).applyQuaternion(l);break;case"yz":lo.set(1,0,0).applyQuaternion(l);break;case"xz":lo.set(0,1,0).applyQuaternion(l);break;case"adaptive":tl.angleTo(tr.set(0,1,0))>Math.PI/6?(Ft.crossVectors(tr.set(0,1,0),tl),lo.crossVectors(Ft,tr)):lo.set(0,1,0);break;default:lo.copy(tl);break}cc.setFromMatrixPosition(e.matrixWorld);let u=e.userData.lockedPlane?e.userData.worldPosition0:cc;if(TR.setFromNormalAndCoplanarPoint(lo,u),!!a.ray.intersectPlane(TR,n)&&(r==="x"||r==="y"||r==="z")){let c=tr.subVectors(n,u).dot(Ft);n.copy(u).addScaledVector(Ft,c)}}updateDragItem(e,n=!1){cc.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Wp.subVectors(e.fromPosition,cc).divideScalar(e.currentDampingFactor):e.reset==="original"?(Wp.subVectors(e.obj.userData.worldPosition0,cc).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Wp.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(cc).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Wp.length()<p7:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||n)&&g7(e,Wp.add(cc),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var Dd=new A,l1=new A,Ko=new A,Qo=new A,CR=new En,y7=.01,v7={type:"requestRender"},x7=function(){let i=new A,t=new A;return(e,n,r)=>r>0?(i.subVectors(e,n),i.length()<=r?e:t.copy(n).add(i.normalize().multiplyScalar(r))):n}(),PR=function(){let i=new se;return(t,e)=>{t.position.copy(e),t.parent!==null&&(i.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(i)),i.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(i),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Xt&&Lr(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),c1=class{constructor(t,e,n,r,s){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new A;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...sy.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Qt(t,t.actions,n,r,s,e)}},A0=class extends dn{constructor(e,n){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(We.length>1)){this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};let{page:r}=this.eventContext;r.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!r.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new c1(o.data,s,r,e.sharedAssets,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events)if(r.target!==void 0){let s=r.target,o=this.onTargetChange(r);this.pairOfEventListeners.push([s,o]),s.addEventListener("requestRender",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[r,s]of this.pairOfEventListeners)r.removeEventListener("requestRender",s);for(let r of this.events)r.paused=!0,r.isReset=!1,Gt(r.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,n=!1){this.events.forEach(l=>{l.actions.Create.forEach(u=>{u.dispatchThrottled()})});let{plane:r,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(Ko),e.isReset)Qo.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Qo);else{let{getCamera:l,raycaster:u}=this.eventContext;if(r==="custom"?(l().getWorldDirection(l1),l1.negate(),Dd.copy(l1)):r==="xy"?Dd.set(0,0,1):r==="xz"?Dd.set(0,1,0):r==="yz"&&Dd.set(1,0,0),CR.setFromNormalAndCoplanarPoint(Dd,Ko),!u.ray.intersectPlane(CR,Qo))return}if(!e.isReset){if(Qo.distanceTo(e.worldPosition0)>s&&o&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Qo.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&&(Qo.x=Ko.x),e.data.enabledTranslation[1]===!1&&(Qo.y=Ko.y),e.data.enabledTranslation[2]===!1&&(Qo.z=Ko.z);let a=x7(Ko,Qo,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=Dd.subVectors(a,Ko).divideScalar(e.currentDampingFactor);Ko.add(l),n&&PR(e.object,Ko),e.paused=l.length()<y7}else PR(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(v7)}};var qp=new A,E0=new A,Yp=new se,Id=new Ye,nl=new Ye,Xp=new A,Kp=new A,hc=new A,Zo=new A,u1=new En,b7=1e-6,S7={type:"requestRender"},w7={type:"changeRotation"},DR=function(){let i=new se;return function(e,n){e.parent!==null?i.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):i.copy(e.hiddenMatrix),n.premultiply(JA(i).invert()),e.rotation.setFromRotationMatrix(n),e.updateMatrix(),e instanceof Xt&&Lr(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),h1=class{constructor(t,e,n){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new Ye;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...oy.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},_0=class extends dn{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(We.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onScroll=e=>{if(this._lastMouseEvent){let n=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(n)}};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:n,target:r})=>{if(!n||!r)return;let s=ao(n);s&&s==="LookAt"&&this.updateSingleEvent(e)};let{page:n}=this.eventContext;n.traverseEntity(r=>{let s=r.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!n.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new h1(s.data,r,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?n.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events){if(r.target!==void 0){let a=this.onTargetChange(r),l=r.target;this.pairOfEventListeners.push([l,a]),l.addEventListener("requestRender",a)}let s=this.createUserEventListener(r),o=r.object;this.pairOfUserEventListeners.push([o,s]),o.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),n.removeEventListener("scroll",this.onScroll);for(let[r,s]of this.pairOfEventListeners)r.removeEventListener("requestRender",s);for(let[r,s]of this.pairOfUserEventListeners)r.removeEventListener("userEvent",s);for(let r of this.events)r.paused=!0,r.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:n,axis:r,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:u}=e.data,{getCamera:c,raycaster:h}=this.eventContext,{object:d,target:f}=e;if(d.getWorldPosition(Xp),!e.isReset)if(e.target)e.target.getWorldPosition(Kp);else{if(o==="custom"?(c().getWorldDirection(E0),E0.negate(),u1.setFromNormalAndCoplanarPoint(E0,Xp)):(o==="xy"?qp.set(0,0,1):o==="xz"?qp.set(0,1,0):o==="yz"&&qp.set(1,0,0),u1.setFromNormalAndCoplanarPoint(qp,Xp)),!h.ray.intersectPlane(u1,Kp))return;s>0&&(o==="custom"||o===void 0)&&Kp.addScaledVector(E0,s)}if(e.isReset||(f?n==="target"?hc.copy(f.up).applyMatrix4(Yp.extractRotation(f.matrixWorld)).normalize():l.some(p=>p===!1)?(r==="x"?(Zo.set(0,0,1),l[2]===!1&&Zo.set(0,1,0)):r==="y"?(Zo.set(1,0,0),l[0]===!1&&Zo.set(0,0,1)):(Zo.set(0,1,0),l[1]===!1&&Zo.set(1,0,0)),hc.copy(Zo).applyQuaternion(e.worldQuaternion0).normalize()):hc.set(0,1,0):o==="custom"?hc.set(0,1,0):hc.copy(qp)),e.isReset)nl.copy(e.worldQuaternion0);else if(Xp.distanceTo(Kp)>a&&u&&f)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)nl.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;A7(Yp,Kp,Xp,hc,r,Zo),nl.setFromRotationMatrix(Yp),Id.setFromUnitVectors(Zo.applyQuaternion(nl),hc),l.some(p=>p===!1)&&n!=="target"&&nl.premultiply(Id).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),Id.setFromRotationMatrix(JA(d.matrixWorld)),Id.slerp(nl,1/e.currentDampingFactor),DR(d,Yp.makeRotationFromQuaternion(Id)),e.paused=8*(1-Id.dot(nl))<b7):(DR(d,Yp.makeRotationFromQuaternion(nl)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(S7),d.dispatchEvent(w7)}},Yi=new A,nr=new A,In=new A;function A7(i,t,e,n,r,s){let o=i.elements;In.subVectors(t,e),In.lengthSq()===0&&(In.z=1),In.normalize(),nr.crossVectors(n,In),nr.lengthSq()===0&&(Math.abs(n.z)===1?In.x+=1e-4:In.z+=1e-4,In.normalize(),nr.crossVectors(n,In)),nr.normalize(),Yi.crossVectors(In,nr),r==="x"?s.z===1?[nr,Yi,In]=[In,nr,Yi]:(nr.negate(),[nr,In]=[In,nr]):r==="y"?s.x===1?[nr,Yi,In]=[Yi,In,nr]:(nr.negate(),[Yi,In]=[In,Yi]):s.x===1&&(nr.negate(),[nr,Yi]=[Yi,nr]),o[0]=nr.x,o[4]=Yi.x,o[8]=In.x,o[1]=nr.y,o[5]=Yi.y,o[9]=In.y,o[2]=nr.z,o[6]=Yi.z,o[10]=In.z}var d1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;this.actions=Qt(e,e.actions,r,s,o,n)}disconnect(){Gt(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch())}},T0=class extends dn{constructor(e,n){super(e);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{We.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(o=>o.dispatchUserEvent(r)))};let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(o=>{if(!(!o.visible||!o.data?.events.length)){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="MouseHover")try{let u=new d1(a,l,o,r,s,n);this.eventsPerObjects[o.uuid]?this.eventsPerObjects[o.uuid].push(u):this.eventsPerObjects[o.uuid]=[u]}catch(u){!1&&console.log(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(n=>{n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(n=>{n.forEach(r=>{r.disconnect()})}),this.objects.forEach(n=>{n.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let n=[];if(!e){let{stopRaycast:r,raycaster:s,page:o}=this.eventContext;if(r){let a=Td(s,o,this.objects);n=jp(a)}else this.objects.forEach(a=>{Md(s,a)&&n.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(r=>{n.includes(r)||(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(s=>s.dispatchLeave()))}),n.length&&n.forEach(r=>{r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=n}};var f1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.scrollCounter=0;this.actions=Qt(e,e.actions,r,s,o,n)}connect(){this.scrollCounter=0}disconnect(){Gt(this.actions)}dispatch(t){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let n=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(n)),this.actions.Animation.forEach(r=>r.seek(e)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch())}},p1=class{constructor(t,e,n,r,s,o,a){this.id=t;this.data=e;this.object=n;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=Qt(e,e.actions,r,s,a,n)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,n=document.documentElement,r=window.pageYOffset||n.scrollTop||e.scrollTop,s=n.clientTop||e.clientTop||0,o=Math.round(t.top+r-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,l=t.height,u=this.data.enterAnchor,c=u==="top"?a:u==="bottom"?a-l:a-l*.5;this.scrollStart=o-c}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=t,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){Gt(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let n=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(e-this.scrollStart)/n));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch())}dispatch(t){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(t)}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch())}},M0=class extends dn{constructor(e,n){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let n={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:n}),s.forEach(o=>o.dispatch(n))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([n,r])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),r.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}))};let{page:r,sharedAssets:s,domElement:o,isExport:a}=this.eventContext;r.traverseEntity(l=>{if(!!l.data?.events.length){for(let{id:u,data:c}of l.data.events)if(!c.disabled&&c.type==="Scroll")if(c.trigger==="load"||!a){let h=new f1(u,c,l,r,s,n);this.wheelEventsPerObject.has(l)?this.wheelEventsPerObject.get(l)?.push(h):this.wheelEventsPerObject.set(l,[h])}else{let h=new p1(u,c,l,r,s,o,n);this.scrollEventsPerObject.has(l)?this.scrollEventsPerObject.get(l)?.push(h):this.scrollEventsPerObject.set(l,[h])}}}),this.intersectionObserver=new IntersectionObserver(l=>{let u=l[0];u&&(this.isInview=u.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var m1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.actions=Qt(e,e.actions,r,s,o,n)}disconnect(){Gt(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof no?e.interaction.audioPlayer.play():e.interaction instanceof Ad&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let n=e.interaction.data.triggerAfter??"autoplay";n===t&&(e.interaction instanceof Yo?e.interaction.play(n==="autoplay"):e.interaction instanceof _d&&e.interaction.dispatch())})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof no?e.interaction.audioPlayer.play():e.interaction instanceof Ad&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof Yo?e.interaction.play():e.interaction instanceof _d&&e.interaction.dispatch()})}},C0=class extends dn{constructor(e,n){super(e);this.eventManager=n;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:n}=this.eventContext;(n?document:e).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.actions.Audio.forEach(s=>{s.interaction instanceof no&&s.interaction.audioPlayer.play()}),r.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof Yo&&s.interaction.play(o==="autoplay")})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&s==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}),this.eventsAfterPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}))}}connect(){let{sharedAssets:e,page:n}=this.eventContext;if(n.traverseEntity(r=>{if(!!r.data?.events.length)for(let{id:s,data:o}of r.data.events){if(o.disabled||o.type!=="Start")continue;let a=new m1(s,o,r,n,e,this.eventManager);(a.actions.Transition.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length||a.actions.SetVariable.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(a):this.eventsPerObject.set(r,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a]))}}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:s}=this.eventContext,o=s?document:r;o.addEventListener("pointerdown",this.onMouseDown,{once:!0}),o.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),o.addEventListener("pointerdown",this.onAny),o.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,l])=>{a.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(o=>o.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:n}=this.eventContext,r=n?document:e;r.removeEventListener("pointerdown",this.onMouseDown),r.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),r.removeEventListener("pointerdown",this.onAny),r.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,n])=>{e.removeEventListener("userEvent",this.onUserEvent),n.forEach(r=>r.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var P0=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.disabled=!1;this.alreadyPlayedNonTogglingActions=new Set;this.actions=Qt(e,e.actions,r,s,o,n),this.target=e.target,this.useToggle=e.runMode==="Toggle"}disconnect(){Gt(this.actions)}dispatch(t){this.disabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()})):(this.actions.Transition.forEach(e=>{this.alreadyPlayedNonTogglingActions.has(e)===!1&&e.play()}),this.actions.Animation.forEach(e=>{e.play()})),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}};var D0=class extends dn{constructor(e,n,r,s,o){super(e);this.sharedVariables=n;this.eventManager=r;this.needsMouse=s;this.needsRaycast=o;this.dynamicVars=[];this.variablesToWatch=[];this.prevMouseProperty=null;this.prevRaycastProperty=null;this.pauseTime=0;this.events=[];this.onFrame=e=>{this.rafId=window.requestAnimationFrame(this.onFrame);let n=new Date,r=[],s=[];for(let l=0;l<this.propertiesToWatch.length;l++){let{objectId:u,property:c,prevValue:h}=this.propertiesToWatch[l],d=this.eventContext.scene.find(u),f=ly.propertyPaths[c];if(f[0]==="width"||f[0]==="height"||f[0]==="depth")d=d.geometry.userData.parameters[f[0]];else for(let p=0;p<f.length;p++)d=d[f[p]];h!==d&&(h!==null&&s.push({objId:u,property:c}),this.propertiesToWatch[l].prevValue=d)}for(let l=0;l<this.variablesToWatch.length;l++){let{id:u,prevValue:c}=this.variablesToWatch[l],h=this.shared.getVariable(u);h!==c&&(r.push(u),this.variablesToWatch[l].prevValue=h)}for(let l=0;l<this.dynamicVars.length;l++){let{id:u,expectedTime:c,last:h,data:d,timerSeconds:f,startValue:p}=this.dynamicVars[l],m=1e3;if((d.dynamicVariableType==="timer"||d.dynamicVariableType==="stopwatch")&&d.format==="number3decimal"?m=1:d.dynamicVariableType==="counter"?m=d.updateInterval:d.dynamicVariableType==="random"&&(m=d.isStatic?1/0:d.updateInterval),c===-1){this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime=e+m;continue}if(e>=c){if(d.dynamicVariableType==="random"){let g=d.min+Math.random()*(d.max-d.min),y=d.decimals;g=Math.round(g*Math.pow(10,y))/Math.pow(10,y),this.shared.updateVariable(u,g),r.push(u),this.eventManager.requestRender()}else if(d.dynamicVariableType==="counter"){if(d.increment===0)continue;let g=this.shared.getVariable(u);if(d.hasEnd&&(d.increment<0?g<=d.endValue:g>=d.endValue))continue;let y=this.shared.getVariable(u)+d.increment;d.hasEnd&&(y=d.increment>0?Math.min(y,d.endValue):Math.max(y,d.endValue),d.repeat&&y===d.endValue&&(y=p)),this.shared.updateVariable(u,y),r.push(u),this.eventManager.requestRender()}else if(d.dynamicVariableType==="time")this.shared.updateVariable(u,Qw(n,d)),r.push(u),this.eventManager.requestRender();else{let g=Hr.isTextValue(d.endValue)?IR(d.endValue.textValue):d.endValue;if(d.hasEnd&&(d.dynamicVariableType==="timer"?f<=g:f>=g)||d.dynamicVariableType==="timer"&&f===0)continue;let y=f+(e-h)/1e3*(d.dynamicVariableType==="timer"?-1:1);y=Math.max(y,0),d.hasEnd&&(y=d.dynamicVariableType==="timer"?Math.max(y,g):Math.min(y,g),d.repeat&&Math.abs(y-g)<(d.format==="number3decimal"?1e-4:.1)&&(y=p)),this.dynamicVars[l].timerSeconds=y,this.shared.updateVariable(u,wi.getFormattedTimerTime(y,d)),r.push(u),this.eventManager.requestRender()}this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime+=m}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(l=>{l.data.variableId==="mouseProperty"&&(l.dispatch(),this.eventManager.requestRender())}));let o=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,o=!0);let a=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,a=!0),this.events.forEach(l=>{(r.includes(l.data.variableId)||s.find(u=>u.objId===l.data.objectId&&u.property===l.data.property)||l.data.variableId==="mouseProperty"&&o||l.data.variableId==="raycastProperty"&&a)&&(l.dispatch(),this.eventManager.requestRender())})};this.onBlur=()=>{this.pause()};this.onFocus=()=>{this.resume()};e.page.traverseEntity(a=>{a.data?.events.filter(l=>l.data.type==="VariableChange"&&!l.data.disabled).forEach(l=>{this.events.push(new g1(a.uuid,l.data,a,e.page,e.sharedAssets,r))})}),this.propertiesToWatch=this.events.filter(a=>a.data.variableId==="objectProperty"&&a.data.objectId!==null).map(a=>({objectId:a.data.objectId,property:a.data.property,prevValue:null})),this.shared=e.sharedAssets,this.sharedVariables.forEach(({id:a,data:l})=>{if(!("dynamicVariableType"in l)){this.events.find(c=>c.data.variableId===a)&&this.variablesToWatch.push({id:a,prevValue:this.shared.getVariable(a)});return}let u;if(l.dynamicVariableType==="timer"||l.dynamicVariableType==="stopwatch"){let c;if(Hr.isTextValue(l.value)&&Array.isArray(l.value.textValue)){let h=l.value.textValue;h.length===3?c=h[2]+h[1]*60+h[0]*3600:c=h[1]+h[0]*60}else c=l.value;u=c,this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,timerSeconds:c,startValue:u})}else{if(l.dynamicVariableType==="time"&&this.shared.updateVariable(a,Qw(new Date,l)),l.dynamicVariableType==="counter"&&(u=Hr.isTextValue(l.value)?IR(l.value.textValue):l.value),l.dynamicVariableType==="random"){u=l.min+Math.random()*(l.max-l.min);let c=l.decimals;u=Math.round(u*Math.pow(10,c))/Math.pow(10,c),this.shared.updateVariable(a,u)}this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,startValue:u})}})}pause(){this.pauseTime=Date.now()}resume(){let e=Date.now()-this.pauseTime;for(let n=0;n<this.dynamicVars.length;n++)this.dynamicVars[n].last+=e,this.dynamicVars[n].expectedTime+=e}connect(){this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(e=>e.dispose())}},g1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.actions=Qt(e,e.actions,r,s,o,n)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch())}dispose(){Gt(this.actions)}};function IR(i){return i.length===3?i[2]+i[1]*60+i[0]*3600:i[1]+i[0]*60}var RR=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@0.9.458/build/",E7=!1?RR:"https://unpkg.com/@splinetool/navmesh-wasm@0.9.458/build/",_7=`
|
|
6239
|
+
)`}else if(i.easing===6){let{mass:e,stiffness:n,damping:r,velocity:s}=i;t=`spring( ${e}, ${n}, ${r}, ${s} )`}else{let e;switch(i.easing){case 0:e=Ro.linear;break;case 1:e=Ro.ease;break;case 2:e=Ro.easeIn;break;case 3:e=Ro.easeOut;break;case 4:e=Ro.easeInOut;break;default:e=Ro.linear}let[n,r,s,o]=e;t=`cubicBezier( ${n}, ${r}, ${s}, ${o} )`}return{duration:i.duration,easing:t}}function aR(i){let t={delay:0,loop:i.repeat===-1?!0:i.repeat+1};if(i.repeat===0)t.direction="normal",t.rewind=!1;else switch(i.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,i.delayDirection){case"start-once":t.startOnceDelay=i.delay;break;case"start":t.delay=i.delay;break;case"end":t.endDelay=i.delay;break;case"start-end":case void 0:t.delay=i.delay,t.endDelay=i.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,i.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):i.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):i.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var WY={type:"beginState"},qY={type:"completeState",isfromEntity:!1},f0=class{constructor(t,e,n,r,s,o){this.object=t;this.data=r;this.sharedAssets=s;this.allowSlerp=o;this.targets={t:0};this.firstLoop=!0;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))};this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let t=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof Kt&&e.dispatchEvent(WY)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof Kt&&e.dispatchEvent(qY)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=qA(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=d0(this.object,this.object.currentState===n?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=d0(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(n===void 0)throw new Error("Missing property");{let a=d0(this.object,n);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||n===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...aR(r),...YA(r),change:this.onChange},this.callback=qA(this.object,e===void 0?{}:this.from.data,n===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},Np=class extends Ht{constructor(e,n,r,s){super();this.data=e;this.page=n;this.shared=r;this.condition=s;this.toggleIsForward=!1;this.timelineNeedsRebuild=!1;this.useToggle=!1;this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,isRebuild:!0}),this.timeline.play())};if(!e.object)throw new Error("Missing property");let o=this.page.scene.find(e.object);if(!o)throw new Error("Missing property");if(!o.states)throw new Error("Missing property");if(this.object=o,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=d0(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,isRebuild:n=!1}={}){try{let r=aR(this.data.tweens[0].data),s=r.loop;n&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=h0.timeline({autoplay:!1,...r,...s===!0||s>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(this.timelineNeedsRebuild=o!==-1&&(s===!0||s>1),r.pingPongDelayCorrection&&n===!1&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let u=this.data.tweens[l],c=this.data.tweens[l+1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Kt&&(this.object.wasMovedByUser=!1)):h=u.data.state===void 0?this.currentState:u.data.state;let d=new f0(this.object,h,c.data.state===void 0?this.currentState:c.data.state,c.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?r.delay:0)+(l===a&&!n?r.pingPongDelayCorrection:0))}this.timeline.duration+=r.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let u=this.data.tweens[l],c=this.data.tweens[l-1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Kt&&(this.object.wasMovedByUser=!1)):h=u.data.state===void 0?this.currentState:u.data.state;let d=new f0(this.object,h,c.data.state===void 0?this.currentState:c.data.state,u.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l-1]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?r.endDelay:0))}this.timeline.duration+=r.delay+(n?0:r.pingPongDelayCorrection)}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(zt(this.shared,this.condition)===!1||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.shared}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(zt(this.shared,this.condition)===!1)return!1;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 d0(i,t){let e,n;if(typeof t=="string"?(e=t,n=i.states?.[e]):t===null&&(e=null,n=i.data),!(e===void 0||n===void 0))return{id:e,data:n}}var YY={type:"beginState"},lR={type:"completeState",isfromEntity:!1},cR={type:"requestRender"},Bp=class extends Ht{constructor(e,n,r,s){super();this.data=e;this.page=n;this.shared=r;this.condition=s;this.toggleIsForward=!1;this.useToggle=!1;this.posStart=new A;this.posEnd=new A;this.qStart=new Ye;this.qEnd=new Ye;this.zoomStart=1;this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let n=this.page.scene.find(this.data.targetCamera);if(!n||!n.visible)throw new ReferenceError("Target camera not founded or not visible");let r={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=h0({targets:r,t:1,...YA(this.data),update:()=>{r.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.uuid)):(this.posEnd.copy(n.position),this.qEnd.copy(n.quaternion),this.zoomEnd=n.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(n.uuid)),this.page.activeCamera.dispatchEvent(YY));let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,r.t),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,r.t),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*r.t,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(cR),r.t===1&&s.dispatchEvent(lR)}})}switchCamera(e){let n=this.page.scene.find(e);if(!n||!n.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(n),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:n})}play(){if(zt(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(zt(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{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.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(lR),this.page.activeCamera.dispatchEvent(cR))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var Fp=class extends Ht{constructor(e,n,r,s,o){super();this.page=n;this.animationControls=r;this.shared=s;this.condition=o;this.startOnceDelay=0;this.toggleIsForward=!1;let a=e.object,l=n.scene.find(e.object);l&&Array.isArray(l.identity)&&(a=l.identity[0]),this.data={...e,object:a};let u=this.animationControls.clipIdToAction[e.clipId+"/"+a];this.duration=u?.getClip()?.duration??1;let c=u?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/c*this.duration,this.rightFrameTime=this.data.crop[1]/c*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(zt(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let n=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let o=r.split("/")[1];this.threeAnimAction!==s&&o===n&&s.isRunning()&&(e?s.fadeOut(.2):s.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Te.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,n=!1){if(zt(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let r=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===r&&o.isRunning()&&(n?o.fadeOut(.2):o.stop())}),n&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}};var kp=class{constructor(t,e,n,r,s){this.data=t;this.page=e;this.eventManager=n;this.shared=r;this.condition=s;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(zt(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(n=>n.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),Ed(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var Up=class{constructor(t,e,n,r){this.data=t;this.page=e;this.shared=n;this.condition=r;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=zt(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=ev(this.data.expression,this.shared,Hr.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};function zt(i,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=ev(t.expression,i,"boolean");return t.negate?!e:!!e}function Qt(i,t,e,n,r,s){let o={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[]},a=l=>({id:u,data:c})=>{try{c.type==="Audio"?Si[i.type].includes("Audio")&&o.Audio.push(new Ip(u,c,s,n,l)):c.type==="Video"?Si[i.type].includes("Video")&&o.Video.push(new Vp(u,c,s,n,l)):c.type==="Link"?Si[i.type].includes("Link")&&o.Link.push(new s0(c,r.controlsManager,n,l)):c.type==="Create"?Si[i.type].includes("Create")&&o.Create.push(new zp(c,e,r.controlsManager,n,l)):c.type==="Destroy"?Si[i.type].includes("Destroy")&&o.Destroy.push(new Op(c,e,r.controlsManager,n,l)):c.type==="Reset"?Si[i.type].includes("Reset")&&o.Reset.push(new Rp(c,e,n,r,l)):c.type==="Transition"?Si[i.type].includes("Transition")&&o.Transition.push(new Np(c,e,n,l)):c.type==="SwitchCamera"?Si[i.type].includes("SwitchCamera")&&o.SwitchCamera.push(new Bp(c,e,n,l)):c.type==="SceneTransition"?Si[i.type].includes("SceneTransition")&&o.SceneTransition.push(new kp(c,e,r,n,l)):c.type==="Animation"?Si[i.type].includes("Animation")&&o.Animation.push(new Fp(c,e,r.animationControls,n,l)):c.type==="SetVariable"?Si[i.type].includes("SetVariable")&&o.SetVariable.push(new Up(c,e,n,l)):c.type==="Conditional"&&Si[i.type].includes("Conditional")&&(c.ifActions.forEach(a({expression:c.condition,negate:!1})),c.elseActions.forEach(a({expression:c.condition,negate:!0})))}catch(h){!1&&console.log(h)}};return t.forEach(a()),o}function Gt(i){Object.values(i).forEach(t=>{t.forEach(e=>{(e instanceof Ip||e instanceof Vp||e instanceof Fp||e instanceof Np||e instanceof zp||e instanceof Op||e instanceof Bp||e instanceof kp||e instanceof Rp||e instanceof Up)&&e.dispose()})})}function uR(i,t){let e;if("material"in i){let n=i.material;Array.isArray(n)?e=i.material[0].layers.find(r=>r.uuid===t):e=i.material.layers.find(r=>r.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var hR=new Map,Gp=new Map,Yo=class{constructor(t,e,n){this.data=e;this.delay=0;this.status="stopped";let{layerId:r,loop:s,volume:o,delay:a}=e;if(this.object=n,r===void 0)throw new Error("Missing property");let l=uR(n,r);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),Gp.has(n.uuid)?Gp.get(n.uuid).push(this):Gp.set(n.uuid,[this]),hR.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let n=this.videoElement.play();n!==void 0&&n.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},_d=class{constructor(t){this.data=t}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=hR.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=Gp.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(n=>n[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(n=>n[this.data.interaction]()))}pauseAllVideos(){let t=[...Gp.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(n=>{n[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Vp=class{constructor(t,e,n,r,s){this.data=e;this.shared=r;this.condition=s;if(e.interaction==="play")this.interaction=new Yo(t,e,n);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new _d(e);else throw new Error("Missing property")}dispatchBasic(){if(zt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Yo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(zt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Yo?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var dR=(()=>{let i,t,e,n;function r(a){!i&&!fR()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(i=requestAnimationFrame(s)),a&&(t=a,n=a.requestRender)}function s(a){let l=e?a-e:0,u=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,h=u.length,d=0;for(;d<h;){let f=u[d];f.userData.createdTime===void 0&&(f.userData.createdTime=a),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&a-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&c[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,l/1e3),f.updateMatrix(),n()),d++):(c[f.userData.actionId]>f.userData.quantity&&c[f.userData.actionId]--,u.splice(d,1),f.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(p=>p.bvhGeometry!==void 0)),h--,n())}i=d>0?requestAnimationFrame(s):void 0,e=d>0?a:void 0}function o(){fR()?i&&(cancelAnimationFrame(i),i=void 0,e=void 0):r()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),r})();function fR(){return!!document&&document.hidden}var pR=new Ye,XY=new A,KY=new A,zp=class{constructor(t,e,n,r,s){this.data=t;this.page=e;this.controlsManager=n;this.shared=r;this.condition=s;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=Te.generateUUID();this.dispatch=()=>{if(zt(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()};this.dispatchFromStart=()=>{if(zt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=Vb(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 t=new un(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let n=this.data.coordinateSystem,r=this.page.scene.find(n);r&&(r.updateMatrixWorldSVD(),t.hiddenMatrix.copy(r.matrixWorldRigid))}t.position.fromArray(this.data.position),t.rotation.fromArray(this.data.rotation),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),dR(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof yr)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof un)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof yr)return;t instanceof un?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let n=new A().fromArray(this.data.velocity),r=e.dataPatched;if(!(r.physics.enabled==="visibility"?!r.visible:!r.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(XY,pR,KY),n.applyQuaternion(pR),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(n.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&(t.userData.velocity=n)),e.dataPatched.physics?.fusedBody===!0))return!0};let o=this.page.scene.find(this.data.object);if(!o)throw new Error("Missing Property");if(this.object=o,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");dR(n)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}};var ZA=200,XA=.02,KA=.3,QY=65,r3e=new A,mR=new A,gR=new A,ZY=new A,Xr=new A,ai=new A,el=new A,QA=new se,yR=new se,JY=new se,i3e=new se,xs=new Ye,Xo=new Ye,so=new qt(0,0,0,"YXZ"),$Y=new A(1,0,0),bs=new A(0,1,0),e7=new A(0,0,1),vR=new A(1,1,1),s3e=new ln,t7=1,n7=.025,r7=16e-6,xR=12,i7=20,xr=new Xn,qi=new Tt,s7={type:"requestRender"},o7={type:"updateMatrix"},bR=Math.PI/6,p0=class extends Ht{constructor(e,n,r,s,o,a,l,u,c){super();this.object=e;this.domElement=n;this.data=r;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=u;this.sharedAssets=c;this.enableDamping=!0;this.hiddenMatrix0=new se;this.target0=new A;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=ZA;this.euler0=new qt(0,0,0,"YXZ");this.position0Cam=new A;this.quat0Cam=new Ye;this.scale0Cam=new A;this.hiddenMatrix0Cam=new se;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new Xn(new A(0,-40,0),new A(0,40,0)),matrix:new se,position:new A,rotation:new Ye};this.euler=new qt(0,0,0,"YXZ");this.eulerDelta=new A;this.lastPosition=new A;this.lastCameraQuaternion=new Ye;this.lastCameraPosition=new A;this.PI_2=Math.PI/2;this.prevMouse=new B;this.velocityTarget=new A;this.velocity=new A;this.directionXZ=new A;this.rotVelocityStick=new A;this.rotVelocityTarget=new A;this.rotVelocity=new A;this.rotDirection=new A;this.nonColliderRotOffset=new se;this.nonColliderPosOffset=new se;this.firstPointerId=-1;this.rot=new A;this.path=[];this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0};this.vrEulerYOffset=0;this.onObject=!1;this.actionState={};this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]];this.collisionEnabled=!0;this.offsetMatrix=new se;this.objectToTarget=new A;this.objectToTarget0=new A;this.objectToCamXZ=new A;this.objectToCamXZ0=new A;this.targetToCamera=new A;this.targetToCamera0=new A;this.cameraPolarAxis0=new A;this.targetPos=new A;this.targetQuat=new Ye;this.lerpFactorPos=new A().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new Ye;this.objXZQuatInv=new Ye;this.objXZRotMat=new se;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new A;this.pushedVelocity=new A;this.groundYRotation=0;this.objectRealQuat=new Ye;this.colliderWorldQuat=new Ye;this.groundNormal=new A;this.groundTilt=new Ye;this.groundTiltInv=new Ye;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new A;this.quaternion=new Ye;this.scale=new A;this.initialAction=!0;this.onPointerDown=e=>{e.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Qn&&(!zb||Gb>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let n=e.clientX-this.prevMouse.x,r=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(zb&&Gb<15.5&&!Qn?(this.eulerDelta.y=-n*this.mouseOrbitSensitivity,this.eulerDelta.x=-r*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-n*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-r*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?p0.isLocked=!0:p0.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let n of this.keyAssignments)if(e.key.toUpperCase()===n[1]||e.key===n[1]){this.movementState[n[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let n of this.keyAssignments)if(e.key.toUpperCase()===n[1]||e.key===n[1]||e.code.slice(3,e.code.length).toUpperCase()===n[1]){this.movementState[n[0]]=0;break}};this.copyVRGamePadValues=(e,n)=>{for(let r=2;r<4;r++){let s=e.axes[r];n===0?r===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,r===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(s)>=.3&&(this.vrEulerYOffset+=s<0?1:-1),this.movementState.rotPosY=s):this.moveMode==="fly"&&(this.movementState.moveNegY=s))}};this.sharedGameControlGlobals=o.sharedGameControlGlobals,e===l&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let 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 g=new A(0,0,-1).applyQuaternion(this.camera.quaternion),y=new A().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(y),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v,x;Math.abs(g.y)<1e-6?(y.y=0,g.y=0,x=y.projectOnVector(g)):y.y/g.y>0?x=g.multiplyScalar(y.y/g.y):x=g.multiplyScalar(y.length()),this.targetToCamera0.copy(x).negate(),v=this.camera.position.clone().add(x),this.objectToTarget0.subVectors(v,this.position);let b=new qt().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-b.x,b.x=0,b.z=0,b.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(b)}if(this.object instanceof Kt&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=r.rotByTouch??"joystick",this.rotBy=r.rotBy??"keys",this.rotationMode=r.rotationMode??"normal",this.moveMode=r.moveMode??"walk",this.collisionEnabled=r.collisionEnabled,this.speedTranslate=(r.speedTranslate??250)*t7,this.speedOrbit=(r.speedRotate??100)*n7,this.mouseOrbitSensitivity=(r.speedRotate??100)*r7,this.keyAssignments=r.keyAssignments.map(g=>{let y=[g[0],g[1]];return y[1]==="\u25B2"?y[1]="ArrowUp":y[1]==="\u25C0"?y[1]="ArrowLeft":y[1]==="\u25BC"?y[1]="ArrowDown":y[1]==="\u25B6"?y[1]="ArrowRight":y[1]==="\u21E7"?y[1]="Shift":y[1]==="\u21B5"?y[1]="Enter":y[1]==="Space"?y[1]=" ":y[1]==="\u2318"?y[1]="Meta":y[1]==="Ctrl"?y[1]="Control":y[1]==="Esc"&&(y[1]="Escape"),y}),r.rotBy==="mouse"){let g;g=this.keyAssignments.findIndex(y=>y[0]==="rotNegX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosY"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotNegY"),g!==-1&&(this.keyAssignments[g][1]="")}this.lerpFactorPosStart=1-.02**(1/((r.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((r.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((r.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((r.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((r.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((r.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Oa.defaultData.gravity)*xR,this.usePhysics=this.gloabalPhysics.usePhysics??Oa.defaultData.usePhysics,this.jumpPower=r.jumpPower*i7,this.resetYPosition=this.position.y+Math.abs(r.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=r.alignToGround??!1,this.orientMode=r.autoOrientMove?r.orientMode:"none",this.orientWith=r.orientWith??Ku.defaultDataThirdPerson.orientWith,this.slopeThresh=QY*Math.PI/180,r.collider.type==="capsule"?(this.collider.radius=r.collider.radius,this.collider.segment.start.y=r.collider.height/2-r.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=r.collider.height*XA/this.pixelsPerMeter,this.stepThresh=r.collider.height*KA/this.pixelsPerMeter,this.colliderHeight=r.collider.height):r.collider.type==="sphere"?(this.collider.radius=r.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*r.collider.radius*XA/this.pixelsPerMeter,this.stepThresh=2*r.collider.radius*KA/this.pixelsPerMeter,this.colliderHeight=r.collider.radius*2):(this.offset=r.collider.height*XA/this.pixelsPerMeter,this.stepThresh=r.collider.height*KA/this.pixelsPerMeter,this.colliderHeight=r.collider.height),this.collider.type=r.collider.type;let f=new A().fromArray(r.collider.position),p=new Ye().setFromEuler(new qt().fromArray([...r.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(p),this.collider.matrix.compose(f,p,vR),r.cameraXAxis!==void 0&&(this.cameraXAxis=r.cameraXAxis,this.cameraYAxis=r.cameraYAxis,this.minPolarAngle=r.cameraRotXLimits[0],this.maxPolarAngle=r.cameraRotXLimits[1],this.minAzimuthAngleRel=r.cameraRotYLimits[0],this.maxAzimuthAngleRel=r.cameraRotYLimits[1]),this.forwardDir=r.forwardDirection??"-z",this.runMultiplier=r.runMultiplier??2;let m=r.navmesh.destinationHelperRadius*2;if(m>0){let g=new Re;g.push({fi:0,data:{...dr.defaultData("light","phong"),alpha:0},id:"layer1"}),g.push({fi:0,data:{...dr.defaultData("color"),color:r.navmesh.destinationHelperColor,alpha:r.navmesh.destinationHelperColor.a},id:"layer2"});let y=new Go({layers:g},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Fn(Vy.create({parameters:{width:m,height:m/10,hollow:.7}}),y),this.navMeshPathDest.material.userData.opacity0=r.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let n=new qt().setFromQuaternion(this.quaternion,"YXZ"),r=n.y;this.objectRealQuat.copy(this.quaternion),n.y=0,this.quaternion.setFromEuler(n),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),n.set(0,r,0),this.quaternion.setFromEuler(n),this.rot.setFromEuler(n),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Kt?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,n=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Xu.list.forEach(r=>{this.actions[r]=Qt({...e,disabled:!1,type:"GameControl"},e.gameActions[r],this.page,n,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1),console.log("instantiateActions",this.actions)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),Gt(this.actions.idle),Gt(this.actions.move),Gt(this.actions.run),Gt(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(n=>{n.play()}),this.actions[e].Animation.forEach(n=>{n.play(this.initialAction===!1)}),this.actions[e].Create.forEach(n=>{n.dispatchStart()}),this.actions[e].Audio.forEach(n=>{n.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(n=>{n.dispatchStop()}),this.actions[e].Audio.forEach(n=>{n.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Xr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,n,r){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let s=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let o=s*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let u=ai.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*xR),1)*(this.gravity>0?1:-1):this.velocity.y)*s,0).divideScalar(this.pixelsPerMeter),c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(c){this.onObject=!0,this.groundNormal.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),c.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=c.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(Xr,Xo,ai),this.groundVelocity.subVectors(Xr,d.prevT),this.object.getWorldPosition(ai).add(this.collider.position).sub(Xr),this.groundYRotation=so.setFromQuaternion(Xo).y-d.prevR.y,el.copy(ai).applyAxisAngle(bs,this.groundYRotation),this.groundVelocity.add(el.sub(ai)).divideScalar(s);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*o),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let u=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let c=Xr.subVectors(this.path[1],this.position),h=ai.subVectors(this.path[1],this.path[0]);c.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),u.opacity=u.userData.opacity0}else u.opacity-=.05*u.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**o),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**o),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**o)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let l=ZY.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let u=ai.copy(l);u.y=0,l.set(0,l.y,u.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let u=Xr;this.camera.getWorldDirection(u);let c=el.copy(bs).multiplyScalar(u.dot(bs));u.sub(c);let h=ai.copy(this.directionXZ);h.x*=-1,this.rot.y=u.angleTo(h)*(u.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(so.setFromVector3(this.rot),this.moveMode==="walk"&&(so.x=0),l.applyEuler(so),a&&(Xo.setFromUnitVectors(bs,this.groundNormal),l.applyQuaternion(Xo)),r){let u=so.set(0,this.vrEulerYOffset*bR,0);r.applyEuler(u),l.x+=r.x,l.z+=r.z,this.nonColliderPosOffset.elements[13]+=r.y*s}if(this.usePhysics===!0){let u=ai;this.pushedVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=el.setFromMatrixPosition(c.matrixWorld).sub(c.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),d=c.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),Xr.copy(l).divideScalar(this.pixelsPerMeter),s,!1);h.multiplyScalar(this.pixelsPerMeter);let f=at.is(c)?c:c.object;if(d!==null&&this.lastHitObj!==f){let p;c instanceof un&&(p=c);let m=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(m)for(let g of m)g.data.target==="character"&&(g.dispatch(p),f.dispatchEvent(m0));this.lastHitObj=f}if(d!==null){this.pushedVelocity.copy(h),u.copy(d.normal1).applyQuaternion(c.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let c=u.dot(l);c<0&&l.addScaledVector(u,-c),l.add(this.pushedVelocity)}else l.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(s),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**o):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**o),this.euler.x+=this.rotVelocity.x*s,this.euler.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*s),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(bs,this.euler.y-this.euler0.y);let u=ai.copy(this.objectToCamXZ).normalize(),c=el.copy(l).multiplyScalar(s);c.y=0;let h=c.sub(Xr.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Te.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Te.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Te.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(n?(so.copy(n),so.y=0):(so.copy(this.euler),so.y=0),this.nonColliderRotOffset.makeRotationFromEuler(so)),n&&(this.moveMode==="walk"?(this.rot.y=n.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(n),this.rot.y+=this.vrEulerYOffset*bR),xs.setFromAxisAngle($Y,this.rot.x),Xo.setFromAxisAngle(bs,this.rot.y),Xo.multiply(xs),xs.setFromAxisAngle(e7,this.rot.z),Xo.multiply(xs),this.quaternion.copy(Xo),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let u=ai.copy(l).multiplyScalar(s/this.pixelsPerMeter),c=null;this.didHit=!1;let h=new A;for(let d=0;d<5;d++){let f=u.length(),p=el.copy(u).normalize();if(c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,p,this.object.rigidBody?.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),c!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(c.collider.handle);if(m!==this.lastHitObj&&d===0){this.lastHitObj=m;let x=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(x){for(let b of x)if(b.data.target==="character"){let w=(this.sharedGameControlGlobals.rapierWorld?.getCollider(c.collider.handle))._parent,E;if(m.cloner){for(let _ of m.cloner.children)if(_.rigidBody===w){E=_;break}}b.dispatch(E),m.dispatchEvent(m0)}}}let g=mR.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat),y=gR.copy(p).multiplyScalar(c.toi).dot(g),v=c.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),y>this.offset&&(v=c.toi*(y-this.offset)/y,h.addScaledVector(p,v)),u.copy(p).multiplyScalar(f-v),Math.acos(-g.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),b=el.copy(c.witness2).applyQuaternion(this.colliderWorldQuat);b.y=0;let w=x.add(b);w.y+=this.stepThresh;let E=this.sharedGameControlGlobals.rapierWorld.castShape(w,this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);E!==null&&E.toi===0&&(g.y=0,g.normalize())}u.addScaledVector(g,-u.dot(g))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(u);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(Xr.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(xs.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let u=this.onObject?1:5,c=l.multiplyScalar(s/u);for(let h=0;h<u;h++)this.position.add(c),this.collisionAdjustment(s/u)}else this.position.addScaledVector(l,s);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let u=this.objectToTarget.add(this.position),c=this.targetToCamera.add(u);QA.lookAt(c,u,bs).setPosition(c),QA.decompose(this.targetPos,this.targetQuat,Xr),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**o),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Te.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Te.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(o7),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===null||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(s7),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=xs.setFromAxisAngle(bs,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Te.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let n;this.cameraXAxis==="Limit"?n=Te.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):n=Te.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let r=Xr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&r.applyQuaternion(e);let s=Xo.setFromAxisAngle(r,n);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){bs.angleTo(e)*180/Math.PI<15||bs.angleTo(e)*180/Math.PI>85?xs.identity():xs.setFromUnitVectors(bs,e),this.groundTilt.slerp(xs,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let n=gR.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let r=QA.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Xr,xs,ai).compose(Xr,xs,vR);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;qi.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=yR.copy(a).invert(),u=JY.copy(yR).multiply(r);xr.copy(this.collider.segment),xr.start.applyMatrix4(u),xr.end.applyMatrix4(u);let c=mR.copy(this.position).applyMatrix4(l);qi.expandByPoint(xr.start),qi.expandByPoint(xr.end),qi.min.addScalar(-this.collider.radius),qi.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(xr.end)},intersectsBounds:h=>h.intersectsBox(qi),intersectsTriangle:h=>{let d=Xr,f=ai,p=h.closestPointToSegment(xr,d,f);if(p<this.collider.radius){let m=this.collider.radius-p,g=f.sub(d).normalize(),y=el.copy(c);y.addScaledVector(g,m);let v=y.applyMatrix4(a).sub(this.position);n.add(v),xr.start.addScaledVector(g,m),xr.end.addScaledVector(g,m)}}})}),qi.makeEmpty(),xr.copy(this.collider.segment),xr.start.applyMatrix4(r),xr.end.applyMatrix4(r),qi.expandByPoint(xr.start),qi.expandByPoint(xr.end),qi.min.addScalar(-this.collider.radius),qi.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(xr.end)},intersectsBounds:o=>o.intersectsBox(qi),intersectsTriangle:o=>{let a=Xr,l=ai,u=o.closestPointToSegment(xr,a,l);if(u<this.collider.radius){let c=this.collider.radius-u,h=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),n.addScaledVector(h,c),xr.start.addScaledVector(h,c),xr.end.addScaledVector(h,c)}}}),this.onObject=Math.abs(n.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,n.length()-1e-5);n.normalize().multiplyScalar(s),this.position.add(n)}},Hp=p0;Hp.isLocked=!1;var SR=$o(zS());function Ss(i,t){let e=new Ae;if(!i.getAttribute("position"))return e.setAttribute("position",new be([],3)),e.setIndex([]),e;let{positions:n,triIndices:r}=Yl(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new be(n,3)),e.setIndex(r),t&&e.applyMatrix4(t),e}var a7=new se,l7=new se,oo=[[0,0,0],[0,0,0],[0,0,0]];function JA(i){let t=i.elements;oo[0][0]=t[0],oo[0][1]=t[4],oo[0][2]=t[8],oo[1][0]=t[1],oo[1][1]=t[5],oo[1][2]=t[9],oo[2][0]=t[2],oo[2][1]=t[6],oo[2][2]=t[10];let{u:e,v:n}=(0,SR.SVD)(oo),r=a7.set(e[0][0],e[0][1],e[0][2],0,e[1][0],e[1][1],e[1][2],0,e[2][0],e[2][1],e[2][2],0,0,0,0,1),s=l7.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1);return r.multiply(s.transpose())}var g0=class extends Jc{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,n=[]){return t.forEach(r=>{r.visible&&this.intersectObject(r,e,n)}),n}createRaycastLineHelper(){let t=new Pi({color:65280,linewidth:10}),e=new A(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new A(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new A().addVectors(e,n.multiplyScalar(r)),o=new Ae;return o.setFromPoints([e,s]),new bl(o,t)}};var wR=i=>i instanceof ps||i instanceof gs;function c7(i,t){return i.distance-t.distance}function AR(i,t,e){if(!(!Gs(t)||!t.visible)){Rr(t)&&t.raycast(i,e);for(let n of t.children)AR(i,n,e)}}function Td(i,t,e,n=!1){if(!n&&!e.some(s=>Md(i,s)!==void 0))return[];let r=[];return t.children.forEach(s=>AR(i,s,r)),r.sort(c7),r}function jp(i){let t=[];if(i.length){let e=i[0].object;Gs(e)&&t.push(e);let n=e.parent;for(;n;)wR(n)&&t.push(n),n=n.parent}return t}function Md(i,t){if(Rr(t)){if(t.visible){let e=[];return t.raycast(i,e),e.length?e[0]:void 0}}else if(wR(t))return ER(i,t)}function ER(i,t){if(!(!Gs(t)||!t.visible)){if(Rr(t)){let e=[];if(t.raycast(i,e),e.length)return e[0]}for(let e of t.children){let n=ER(i,e);if(n)return n}}}function u7(i,t,e){return{x:(i-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}var y0=class{constructor(t,e,n,r,s,o,a,l){this.renderer=t;this.publish=e;this.scene=n;this.getCamera=r;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.frame=l;this.raycaster=new g0;this.raycasterNeedsUpdate=!0;this._useWindowEvents=!1;this._useWindowEvents=e.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement,this.domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateDomRect(){this.domRect=this.domElement.getBoundingClientRect()}updateRaycaster(t){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:e,pageY:n}=t.touches?.length>0?t.touches[0]:t;this.updateDomRect(),this.raycaster.setFromCamera(u7(e,n,this.domRect),this.getCamera())}};var $A=(a=>(a[a.keydown=0]="keydown",a[a.keyup=1]="keyup",a[a.pointerdown=2]="pointerdown",a[a.pointerup=3]="pointerup",a[a.pointermove=4]="pointermove",a[a.wheel=5]="wheel",a[a.scroll=6]="scroll",a))($A||{}),dn=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var e1=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],_R=i=>e1.find(([t,e])=>e===i)?.[0],ao=i=>e1.find(([t])=>t===i)?.[1],h7=(i,t)=>{let e=_R(i);if(e){let n=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(n,"target",{writable:!1,value:t}),n}},v0=class extends dn{constructor(e){super(e);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let n=this.splineEvents[_R(e.eventName)]?.[e.target.uuid];if(!n)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(n,{deltaY:e.deltaY});let{domElement:r}=this.eventContext;r.dispatchEvent(n)};let{page:n}=this.eventContext;n.traverseEntity(r=>{if(!!r.data?.events.length){for(let[s,o]of e1)if(r.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(r):this.objectsPerEvents.set(s,[r]);let a={id:r.uuid,name:r.name},l=h7(o,a),u=this.splineEvents[s];u?u[r.uuid]=l:this.splineEvents[s]={[r.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(n=>{n.removeEventListener("beginEvent",this.onBeginEvent)})})}};var t1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;this.alreadyPlayedNonTogglingActions=new Set;if(this.useToggle=e.runMode==="Toggle",(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=Qt(e,e.actions,r,s,o,n)}disconnect(){Gt(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()}),this.actions.SwitchCamera.forEach(e=>{e.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(r=>r.playing)||this.actions.Transition.forEach(r=>{this.alreadyPlayedNonTogglingActions.has(r)===!1&&r.play()}),this.actions.SwitchCamera.some(r=>r.playing)||this.actions.SwitchCamera.forEach(r=>{r.play()}),this.actions.Animation.forEach(r=>{r.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch())}},x0=class extends dn{constructor(e,n,r){super(e);this.useForRaycastProperty=r;this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]};this.canvasMouseEvents=[];this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}};this.heldKeys={};this.heldKeysPress={};this._prevObjects=[];this.sceneInterects=null;this.onCanvasRaycast=e=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=Td(n,r,[],!0);this.sceneInterects=s,s.length&&(this.eventContext.sharedAssets.raycastProperty={x:s[0].point.x,y:s[0].point.y,z:s[0].point.z,objX:s[0].object.matrixWorld.elements[12],objY:s[0].object.matrixWorld.elements[13],objZ:s[0].object.matrixWorld.elements[14]})}};this.onCanvasMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&(this.onCanvasRaycast(e),n.dispatch())})};this.onCanvasMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?(this.onCanvasRaycast(e),n.dispatch()):n.data.type==="MousePress"&&n.dispatchRelease()})};this.onMouseDown=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent(r)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{page:s,sharedAssets:o}=this.eventContext;s.traverseEntity(a=>{if(!a.data?.events.length)return;let l=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let u of l){let c=this.eventsPerObjects[u];a.data.events.filter(({data:h})=>h.type===u&&h.disabled!==!0).forEach(({id:h,data:d})=>{try{let f=new t1(h,d,a,s,o,n);f.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(f):c[a.uuid]?c[a.uuid].push(f):c[a.uuid]=[f]}catch(f){!1&&console.log(f)}}),c[a.uuid]?.length&&this.objectsPerTypes[u].push(a)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),e.addEventListener("pointerdown",this.onCanvasMouseDown),e.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([n,r])=>{r.forEach(s=>{s.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(n=>{Object.values(n).forEach(r=>{r.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(n=>{n.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([n,r])=>{r.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:n,raycaster:r,page:s}=this.eventContext,o=this.objectsPerTypes[e];if(!(!o.length&&!this.useForRaycastProperty)){if(n||this.useForRaycastProperty){let a;this.sceneInterects===null?a=Td(r,s,o,this.useForRaycastProperty):(a=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&a.length&&(this.eventContext.sharedAssets.raycastProperty={x:a[0].point.x,y:a[0].point.y,z:a[0].point.z,objX:a[0].object.matrixWorld.elements[12],objY:a[0].object.matrixWorld.elements[13],objZ:a[0].object.matrixWorld.elements[14]}),n&&jp(a).forEach(l=>{this.eventsPerObjects[e][l.uuid]&&this.handleObjectMouseEventDispatch(l,e)})}n||o.forEach(a=>{Md(r,a)&&this.handleObjectMouseEventDispatch(a,e)})}}handleMousePressEvent(e=!1){let n="MousePress",r=this.objectsPerTypes[n],s=[];if(!!r.length){if(!e){let{stopRaycast:o,raycaster:a,page:l}=this.eventContext;if(o){let u=Td(a,l,r);s=jp(u)}else r.forEach(u=>{Md(a,u)&&s.push(u)})}this._prevObjects.length&&this._prevObjects.forEach(o=>{s.includes(o)||this.handleObjectMouseEventDispatchRelease(o,n)}),s.length&&s.forEach(o=>{this.handleObjectMouseEventDispatch(o,n)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(r=>{r.dispatch()})}handleObjectMouseEventDispatchRelease(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(r=>{r.dispatchRelease()})}handleKeyEvent(e,n,r=!1){this.objectsPerTypes[n].forEach(s=>{let o=this.eventsPerObjects[n][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:n}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(r?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,n,r=!1){this.objectsPerTypes[n].forEach(s=>{this.eventsPerObjects[n][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(r)})})}};var d7=new A,f7=new A;var b0=class{constructor(t,e,n,r,s){this.actionsIn=Qt(t,t.inActions,n,r,s,e),this.actionsOut=Qt(t,t.outActions,n,r,s,e)}disconnect(){Gt(this.actionsIn),Gt(this.actionsOut)}};var n1=class extends b0{constructor(e,n,r,s,o,a){super(n,r,s,o,a);this.id=e;this.data=n;this.object=r;this.stage="out";this.objects=[];this.onUpdateMatrixWorld=()=>{for(let s of this.objects)if(!s.visible)return;let e=d7.setFromMatrixPosition(this.objects[0].matrixWorld),n=f7.setFromMatrixPosition(this.objects[1].matrixWorld),r=e.distanceTo(n)<=this.distance?"in":"out";if(this.stage!==r){this.stage=r;let s=r==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Link.forEach(o=>o.dispatch()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.Animation.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),s.SceneTransition.forEach(o=>o.dispatch()),s.SetVariable.forEach(o=>o.checkConditions()),s.SetVariable.forEach(o=>o.dispatch())}};let{distance:l,fromObject:u,toObject:c}=n.condition;this.distance=l;for(let h of[u,c]){if(!h)throw new Error("Missing property");let d=s.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)})}},r1=class extends b0{constructor(e,n,r,s,o,a){super(n,r,s,o,a);this.id=e;this.data=n;this.object=r;this.onBegin=({target:e,state:n})=>{this.toState!==n&&(this.actionsOut.Audio.forEach(r=>r.dispatchConditional()),this.actionsOut.Video.forEach(r=>r.dispatchConditional()),this.actionsOut.Link.forEach(r=>r.dispatch()),this.actionsOut.Create.forEach(r=>r.dispatch()),this.actionsOut.Destroy.forEach(r=>r.dispatch()),this.actionsOut.Reset.forEach(r=>r.dispatch()),this.actionsIn.Transition.forEach(r=>r.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(r=>r.play()),this.actionsOut.Animation.forEach(r=>r.play()),this.actionsIn.SwitchCamera.forEach(r=>r.pause()),this.actionsOut.SwitchCamera.forEach(r=>r.play()),this.actionsOut.SceneTransition.forEach(r=>r.dispatch()),this.actionsOut.SetVariable.forEach(r=>r.checkConditions()),this.actionsOut.SetVariable.forEach(r=>r.dispatch()))};this.onComplete=({target:e,state:n})=>{this.toState===n&&(this.actionsIn.Audio.forEach(r=>r.dispatchConditional()),this.actionsIn.Video.forEach(r=>r.dispatchConditional()),this.actionsIn.Link.forEach(r=>r.dispatch()),this.actionsIn.Create.forEach(r=>r.dispatch()),this.actionsIn.Destroy.forEach(r=>r.dispatch()),this.actionsIn.Reset.forEach(r=>r.dispatch()),this.actionsOut.Transition.forEach(r=>r.pause()),this.actionsOut.Transition.forEach(r=>r.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(r=>r.play()),this.actionsIn.Animation.forEach(r=>r.play()),this.actionsOut.SwitchCamera.forEach(r=>r.pause()),this.actionsIn.SwitchCamera.forEach(r=>r.play()),this.actionsIn.SceneTransition.forEach(r=>r.dispatch()),this.actionsIn.SetVariable.forEach(r=>r.checkConditions()),this.actionsIn.SetVariable.forEach(r=>r.dispatch()))};let{condition:l}=n;if(!l.object)throw new Error("Missing property");let u=s.find(l.object);if(!u)throw new Error("Missing property");if(this.toObject=u,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.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.actionsIn.SetVariable.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.actionsOut.SetVariable.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.actionsIn.SetVariable.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},S0=class extends dn{constructor(e,n){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(o=>{if(!!o.data?.events.length){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="Conditional")try{let u;l.condition.type==="Comparison"||(l.condition.type==="Distance"?u=new n1(a,l,o,r,s,n):l.condition.type==="State"&&(u=new r1(a,l,o,r,s,n))),u&&(this.eventsPerConditions[l.condition.type].push(u),(u.actionsIn.Video.length||u.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(u){!1&&console.log(u)}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.disconnect()))}};var Wp=new A,tl=new A,cc=new A,TR=new En,p7=.01,Ft=new A,tr=new A,MR=new A,uc=new Ye,i1=new qt,m7=new se,s1=new $t,Cd=new A,lo=new A,Pd=.2;function o1(i,t){!t||(t[0]<t[1]&&(i.x=Math.min(Math.max(i.x,t[0]),t[1])),t[2]<t[3]&&(i.y=Math.min(Math.max(i.y,t[2]),t[3])),t[4]<t[5]&&(i.z=Math.min(Math.max(i.z,t[4]),t[5])))}var g7=function(){let i=new se;return(t,e,n)=>{let r=t.obj;i.copy(r.hiddenMatrix),r.parent!==null&&i.premultiply(r.parent.matrixWorld),i.invert(),r.position.copy(e),t.reference==="global"&&o1(r.position,t.limits),r.position.applyMatrix4(i),t.reference==="parent"?o1(r.position,t.limits):t.reference==="local"&&(uc.copy(t.quat0).invert(),r.position.sub(t.position0),r.position.applyQuaternion(uc),o1(r.position,t.limits),uc.invert(),r.position.applyQuaternion(uc),r.position.add(t.position0)),i.multiply(n??r.matrixWorld).decompose(Ft,r.quaternion,tr),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldSVD()),r instanceof Xt&&Lr(r.parent)&&r.invalidateDownstreamBooleanData(!0)}}(),a1=class{constructor(t,e,n,r,s,o){this.object=t;this.data=e;this.dropDestIds=[];this.activeIdx=null;this.wasDragEventTriggered=!1;this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=Qt(e,e.dragDropActions.drag,n,r,s,this.object),this.actionsDrop=Qt(e,e.dragDropActions.drop,n,r,s,this.object);let a=[];this.data.objects.forEach(l=>{let u=n.find(l);!u||u.data.visible!==!1&&(a.push(u),o[u.uuid]&&o[u.uuid].forEach(c=>{let h=n.find(c);!h||h.data.visible!==!1&&a.push(h)}))}),this.data.dropDestinations.forEach(l=>{let u=n.find(l);!u||u.data.visible!==!1&&(this.dropDestIds.push(u.uuid),o[u.uuid]&&o[u.uuid].forEach(c=>{let h=n.find(c);!h||h.data.visible!==!1&&this.dropDestIds.push(h.uuid)}))}),this.dragItems=a.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new A().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new A().setFromMatrixPosition(l.matrixWorld),pointStart:new A,pointEnd:new A,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new A().copy(l.position),quat0:new Ye().copy(l.quaternion),snapped:!1,orientationMatrix:new se,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Gt(this.actionsDrag),Gt(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},w0=class extends dn{constructor(e,n){super(e);this.eventManager=n;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(We.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:u,pointStart:c}of o.dragItems){if(l===s[0].object||l===s[0].object.object||at.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let h=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(Ft,uc,tr),i1.setFromQuaternion(uc),h.prevR===void 0?(h.prevR=i1.clone(),h.prevT=Ft.clone()):(h.prevR.copy(i1),h.prevT.copy(Ft)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.eventManager.controlsManager.usePhysics&&l.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}a++}}this.activeEvent=null};this.onPointerMove=e=>{if(We.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:n,page:r}=this.eventContext,s=r.raycastWithClones(n);if(We.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||at.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof ps)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===l.object.uuid||r.scene.find(u).isAncestorOf(l.object.uuid))))[0]),a){let l=MR.copy(a.face.normal).applyMatrix3(s1.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){Ft.copy(l).applyMatrix3(s1.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;Ft.x>Pd?tr.x=-u.recursiveBBox.min.x:Ft.x<-Pd&&(tr.x=-u.recursiveBBox.max.x),Ft.y>Pd?tr.y=-u.recursiveBBox.min.y:Ft.y<-Pd&&(tr.y=-u.recursiveBBox.max.y),Ft.z>Pd?tr.z=-u.recursiveBBox.min.z:Ft.z<-Pd&&(tr.z=-u.recursiveBBox.max.z),tr.applyMatrix3(s1.invert())}else tr.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(tr)}this.activeEvent.data.autoOrient&&(Ft.set(0,1,0).cross(l),Ft.length()<1e-4&&Ft.set(-1,0,0).cross(l),tr.crossVectors(MR,Ft),o.orientationMatrix.makeBasis(Ft,tr,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.stop()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let n=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!n)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&n&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(r=>{r.stop()}),this.activeEvent.actionsDrag.Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(r=>r.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(r=>r.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let r={};e.page.traverseEntity(s=>{s.component&&(r[s.component.uuid]?r[s.component.uuid].push(s.uuid):r[s.component.uuid]=[s.uuid])}),e.page.traverseEntity(s=>{s.data?.events.filter(o=>o.data.type==="DragDrop"&&!o.data.disabled).forEach(o=>{this.events.push(new a1(s,o.data,e.page,e.sharedAssets,n,r))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(n=>n.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let n of e.dragItems)n.paused||this.updateDragItem(n,!0)}calcPlaneIntersectPos(e,n,r,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(tl),tl.negate();let l=uc.identity();switch(s==="parent"?m7.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(Ft,l,tr):s==="local"&&e.matrixWorld.decompose(Ft,l,tr),r){case"x":Ft.set(1,0,0).applyQuaternion(l),Cd.copy(tl).cross(Ft),lo.copy(Ft).cross(Cd);break;case"y":Ft.set(0,1,0).applyQuaternion(l),Cd.copy(tl).cross(Ft),lo.copy(Ft).cross(Cd);break;case"z":Ft.set(0,0,1).applyQuaternion(l),Cd.copy(tl).cross(Ft),lo.copy(Ft).cross(Cd);break;case"xy":lo.set(0,0,1).applyQuaternion(l);break;case"yz":lo.set(1,0,0).applyQuaternion(l);break;case"xz":lo.set(0,1,0).applyQuaternion(l);break;case"adaptive":tl.angleTo(tr.set(0,1,0))>Math.PI/6?(Ft.crossVectors(tr.set(0,1,0),tl),lo.crossVectors(Ft,tr)):lo.set(0,1,0);break;default:lo.copy(tl);break}cc.setFromMatrixPosition(e.matrixWorld);let u=e.userData.lockedPlane?e.userData.worldPosition0:cc;if(TR.setFromNormalAndCoplanarPoint(lo,u),!!a.ray.intersectPlane(TR,n)&&(r==="x"||r==="y"||r==="z")){let c=tr.subVectors(n,u).dot(Ft);n.copy(u).addScaledVector(Ft,c)}}updateDragItem(e,n=!1){cc.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Wp.subVectors(e.fromPosition,cc).divideScalar(e.currentDampingFactor):e.reset==="original"?(Wp.subVectors(e.obj.userData.worldPosition0,cc).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Wp.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(cc).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Wp.length()<p7:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||n)&&g7(e,Wp.add(cc),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var Dd=new A,l1=new A,Ko=new A,Qo=new A,CR=new En,y7=.01,v7={type:"requestRender"},x7=function(){let i=new A,t=new A;return(e,n,r)=>r>0?(i.subVectors(e,n),i.length()<=r?e:t.copy(n).add(i.normalize().multiplyScalar(r))):n}(),PR=function(){let i=new se;return(t,e)=>{t.position.copy(e),t.parent!==null&&(i.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(i)),i.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(i),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Xt&&Lr(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),c1=class{constructor(t,e,n,r,s){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new A;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...sy.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Qt(t,t.actions,n,r,s,e)}},A0=class extends dn{constructor(e,n){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(We.length>1)){this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};let{page:r}=this.eventContext;r.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!r.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new c1(o.data,s,r,e.sharedAssets,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events)if(r.target!==void 0){let s=r.target,o=this.onTargetChange(r);this.pairOfEventListeners.push([s,o]),s.addEventListener("requestRender",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[r,s]of this.pairOfEventListeners)r.removeEventListener("requestRender",s);for(let r of this.events)r.paused=!0,r.isReset=!1,Gt(r.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,n=!1){this.events.forEach(l=>{l.actions.Create.forEach(u=>{u.dispatchThrottled()})});let{plane:r,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(Ko),e.isReset)Qo.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Qo);else{let{getCamera:l,raycaster:u}=this.eventContext;if(r==="custom"?(l().getWorldDirection(l1),l1.negate(),Dd.copy(l1)):r==="xy"?Dd.set(0,0,1):r==="xz"?Dd.set(0,1,0):r==="yz"&&Dd.set(1,0,0),CR.setFromNormalAndCoplanarPoint(Dd,Ko),!u.ray.intersectPlane(CR,Qo))return}if(!e.isReset){if(Qo.distanceTo(e.worldPosition0)>s&&o&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Qo.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&&(Qo.x=Ko.x),e.data.enabledTranslation[1]===!1&&(Qo.y=Ko.y),e.data.enabledTranslation[2]===!1&&(Qo.z=Ko.z);let a=x7(Ko,Qo,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=Dd.subVectors(a,Ko).divideScalar(e.currentDampingFactor);Ko.add(l),n&&PR(e.object,Ko),e.paused=l.length()<y7}else PR(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(v7)}};var qp=new A,E0=new A,Yp=new se,Id=new Ye,nl=new Ye,Xp=new A,Kp=new A,hc=new A,Zo=new A,u1=new En,b7=1e-6,S7={type:"requestRender"},w7={type:"changeRotation"},DR=function(){let i=new se;return function(e,n){e.parent!==null?i.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):i.copy(e.hiddenMatrix),n.premultiply(JA(i).invert()),e.rotation.setFromRotationMatrix(n),e.updateMatrix(),e instanceof Xt&&Lr(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),h1=class{constructor(t,e,n){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new Ye;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...oy.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=n.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},_0=class extends dn{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(We.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let n of this.events)n.target===void 0&&this.updateSingleEvent(n)}};this.onMouseEnter=e=>{for(let n of this.events)n.target===void 0&&(n.isReset=!1,n.currentDampingFactor=n.data.dampingFactor)};this.onMouseLeave=e=>{for(let n of this.events)n.target===void 0&&(n.data.resetOnPointerLeave&&(n.isReset=!0,n.currentDampingFactor=n.resetDampingFactor),this.updateSingleEvent(n))};this.onScroll=e=>{if(this._lastMouseEvent){let n=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(n)}};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:n,target:r})=>{if(!n||!r)return;let s=ao(n);s&&s==="LookAt"&&this.updateSingleEvent(e)};let{page:n}=this.eventContext;n.traverseEntity(r=>{let s=r.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!n.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new h1(s.data,r,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),n.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?n.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events){if(r.target!==void 0){let a=this.onTargetChange(r),l=r.target;this.pairOfEventListeners.push([l,a]),l.addEventListener("requestRender",a)}let s=this.createUserEventListener(r),o=r.object;this.pairOfUserEventListeners.push([o,s]),o.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),Qn&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),n.removeEventListener("scroll",this.onScroll);for(let[r,s]of this.pairOfEventListeners)r.removeEventListener("requestRender",s);for(let[r,s]of this.pairOfUserEventListeners)r.removeEventListener("userEvent",s);for(let r of this.events)r.paused=!0,r.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:n,axis:r,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:u}=e.data,{getCamera:c,raycaster:h}=this.eventContext,{object:d,target:f}=e;if(d.getWorldPosition(Xp),!e.isReset)if(e.target)e.target.getWorldPosition(Kp);else{if(o==="custom"?(c().getWorldDirection(E0),E0.negate(),u1.setFromNormalAndCoplanarPoint(E0,Xp)):(o==="xy"?qp.set(0,0,1):o==="xz"?qp.set(0,1,0):o==="yz"&&qp.set(1,0,0),u1.setFromNormalAndCoplanarPoint(qp,Xp)),!h.ray.intersectPlane(u1,Kp))return;s>0&&(o==="custom"||o===void 0)&&Kp.addScaledVector(E0,s)}if(e.isReset||(f?n==="target"?hc.copy(f.up).applyMatrix4(Yp.extractRotation(f.matrixWorld)).normalize():l.some(p=>p===!1)?(r==="x"?(Zo.set(0,0,1),l[2]===!1&&Zo.set(0,1,0)):r==="y"?(Zo.set(1,0,0),l[0]===!1&&Zo.set(0,0,1)):(Zo.set(0,1,0),l[1]===!1&&Zo.set(1,0,0)),hc.copy(Zo).applyQuaternion(e.worldQuaternion0).normalize()):hc.set(0,1,0):o==="custom"?hc.set(0,1,0):hc.copy(qp)),e.isReset)nl.copy(e.worldQuaternion0);else if(Xp.distanceTo(Kp)>a&&u&&f)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)nl.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;A7(Yp,Kp,Xp,hc,r,Zo),nl.setFromRotationMatrix(Yp),Id.setFromUnitVectors(Zo.applyQuaternion(nl),hc),l.some(p=>p===!1)&&n!=="target"&&nl.premultiply(Id).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),Id.setFromRotationMatrix(JA(d.matrixWorld)),Id.slerp(nl,1/e.currentDampingFactor),DR(d,Yp.makeRotationFromQuaternion(Id)),e.paused=8*(1-Id.dot(nl))<b7):(DR(d,Yp.makeRotationFromQuaternion(nl)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(S7),d.dispatchEvent(w7)}},Yi=new A,nr=new A,In=new A;function A7(i,t,e,n,r,s){let o=i.elements;In.subVectors(t,e),In.lengthSq()===0&&(In.z=1),In.normalize(),nr.crossVectors(n,In),nr.lengthSq()===0&&(Math.abs(n.z)===1?In.x+=1e-4:In.z+=1e-4,In.normalize(),nr.crossVectors(n,In)),nr.normalize(),Yi.crossVectors(In,nr),r==="x"?s.z===1?[nr,Yi,In]=[In,nr,Yi]:(nr.negate(),[nr,In]=[In,nr]):r==="y"?s.x===1?[nr,Yi,In]=[Yi,In,nr]:(nr.negate(),[Yi,In]=[In,Yi]):s.x===1&&(nr.negate(),[nr,Yi]=[Yi,nr]),o[0]=nr.x,o[4]=Yi.x,o[8]=In.x,o[1]=nr.y,o[5]=Yi.y,o[9]=In.y,o[2]=nr.z,o[6]=Yi.z,o[10]=In.z}var d1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;this.actions=Qt(e,e.actions,r,s,o,n)}disconnect(){Gt(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch())}},T0=class extends dn{constructor(e,n){super(e);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{We.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{We.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(o=>o.dispatchUserEvent(r)))};let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(o=>{if(!(!o.visible||!o.data?.events.length)){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="MouseHover")try{let u=new d1(a,l,o,r,s,n);this.eventsPerObjects[o.uuid]?this.eventsPerObjects[o.uuid].push(u):this.eventsPerObjects[o.uuid]=[u]}catch(u){!1&&console.log(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(n=>{n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Qn&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(n=>{n.forEach(r=>{r.disconnect()})}),this.objects.forEach(n=>{n.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let n=[];if(!e){let{stopRaycast:r,raycaster:s,page:o}=this.eventContext;if(r){let a=Td(s,o,this.objects);n=jp(a)}else this.objects.forEach(a=>{Md(s,a)&&n.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(r=>{n.includes(r)||(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(s=>s.dispatchLeave()))}),n.length&&n.forEach(r=>{r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=n}};var f1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.scrollCounter=0;this.actions=Qt(e,e.actions,r,s,o,n)}connect(){this.scrollCounter=0}disconnect(){Gt(this.actions)}dispatch(t){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let n=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(n)),this.actions.Animation.forEach(r=>r.seek(e)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch())}},p1=class{constructor(t,e,n,r,s,o,a){this.id=t;this.data=e;this.object=n;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=Qt(e,e.actions,r,s,a,n)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,n=document.documentElement,r=window.pageYOffset||n.scrollTop||e.scrollTop,s=n.clientTop||e.clientTop||0,o=Math.round(t.top+r-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,l=t.height,u=this.data.enterAnchor,c=u==="top"?a:u==="bottom"?a-l:a-l*.5;this.scrollStart=o-c}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=t,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){Gt(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let n=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(e-this.scrollStart)/n));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch())}dispatch(t){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(t)}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch())}},M0=class extends dn{constructor(e,n){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let n={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:n}),s.forEach(o=>o.dispatch(n))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([n,r])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),r.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}))};let{page:r,sharedAssets:s,domElement:o,isExport:a}=this.eventContext;r.traverseEntity(l=>{if(!!l.data?.events.length){for(let{id:u,data:c}of l.data.events)if(!c.disabled&&c.type==="Scroll")if(c.trigger==="load"||!a){let h=new f1(u,c,l,r,s,n);this.wheelEventsPerObject.has(l)?this.wheelEventsPerObject.get(l)?.push(h):this.wheelEventsPerObject.set(l,[h])}else{let h=new p1(u,c,l,r,s,o,n);this.scrollEventsPerObject.has(l)?this.scrollEventsPerObject.get(l)?.push(h):this.scrollEventsPerObject.set(l,[h])}}}),this.intersectionObserver=new IntersectionObserver(l=>{let u=l[0];u&&(this.isInview=u.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(r=>r.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var m1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.actions=Qt(e,e.actions,r,s,o,n)}disconnect(){Gt(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof no?e.interaction.audioPlayer.play():e.interaction instanceof Ad&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let n=e.interaction.data.triggerAfter??"autoplay";n===t&&(e.interaction instanceof Yo?e.interaction.play(n==="autoplay"):e.interaction instanceof _d&&e.interaction.dispatch())})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof no?e.interaction.audioPlayer.play():e.interaction instanceof Ad&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof Yo?e.interaction.play():e.interaction instanceof _d&&e.interaction.dispatch()})}},C0=class extends dn{constructor(e,n){super(e);this.eventManager=n;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:n}=this.eventContext;(n?document:e).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.actions.Audio.forEach(s=>{s.interaction instanceof no&&s.interaction.audioPlayer.play()}),r.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof Yo&&s.interaction.play(o==="autoplay")})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(r=>{r.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:n,reverse:r})=>{if(!e||!n)return;let s=ao(e);s&&s==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}),this.eventsAfterPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(r)}))}}connect(){let{sharedAssets:e,page:n}=this.eventContext;if(n.traverseEntity(r=>{if(!!r.data?.events.length)for(let{id:s,data:o}of r.data.events){if(o.disabled||o.type!=="Start")continue;let a=new m1(s,o,r,n,e,this.eventManager);(a.actions.Transition.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length||a.actions.SetVariable.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(a):this.eventsPerObject.set(r,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a]))}}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:s}=this.eventContext,o=s?document:r;o.addEventListener("pointerdown",this.onMouseDown,{once:!0}),o.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),o.addEventListener("pointerdown",this.onAny),o.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,l])=>{a.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(o=>o.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:n}=this.eventContext,r=n?document:e;r.removeEventListener("pointerdown",this.onMouseDown),r.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),r.removeEventListener("pointerdown",this.onAny),r.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,n])=>{e.removeEventListener("userEvent",this.onUserEvent),n.forEach(r=>r.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var P0=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.disabled=!1;this.alreadyPlayedNonTogglingActions=new Set;this.actions=Qt(e,e.actions,r,s,o,n),this.target=e.target,this.useToggle=e.runMode==="Toggle"}disconnect(){Gt(this.actions)}dispatch(t){this.disabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()})):(this.actions.Transition.forEach(e=>{this.alreadyPlayedNonTogglingActions.has(e)===!1&&e.play()}),this.actions.Animation.forEach(e=>{e.play()})),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}};var D0=class extends dn{constructor(e,n,r,s,o){super(e);this.sharedVariables=n;this.eventManager=r;this.needsMouse=s;this.needsRaycast=o;this.dynamicVars=[];this.variablesToWatch=[];this.prevMouseProperty=null;this.prevRaycastProperty=null;this.pauseTime=0;this.events=[];this.onFrame=e=>{this.rafId=window.requestAnimationFrame(this.onFrame);let n=new Date,r=[],s=[];for(let l=0;l<this.propertiesToWatch.length;l++){let{objectId:u,property:c,prevValue:h}=this.propertiesToWatch[l],d=this.eventContext.scene.find(u),f=ly.propertyPaths[c];if(f[0]==="width"||f[0]==="height"||f[0]==="depth")d=d.geometry.userData.parameters[f[0]];else for(let p=0;p<f.length;p++)d=d[f[p]];h!==d&&(h!==null&&s.push({objId:u,property:c}),this.propertiesToWatch[l].prevValue=d)}for(let l=0;l<this.variablesToWatch.length;l++){let{id:u,prevValue:c}=this.variablesToWatch[l],h=this.shared.getVariable(u);h!==c&&(r.push(u),this.variablesToWatch[l].prevValue=h)}for(let l=0;l<this.dynamicVars.length;l++){let{id:u,expectedTime:c,last:h,data:d,timerSeconds:f,startValue:p}=this.dynamicVars[l],m=1e3;if((d.dynamicVariableType==="timer"||d.dynamicVariableType==="stopwatch")&&d.format==="number3decimal"?m=1:d.dynamicVariableType==="counter"?m=d.updateInterval:d.dynamicVariableType==="random"&&(m=d.isStatic?1/0:d.updateInterval),c===-1){this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime=e+m;continue}if(e>=c){if(d.dynamicVariableType==="random"){let g=d.min+Math.random()*(d.max-d.min),y=d.decimals;g=Math.round(g*Math.pow(10,y))/Math.pow(10,y),this.shared.updateVariable(u,g),r.push(u),this.eventManager.requestRender()}else if(d.dynamicVariableType==="counter"){if(d.increment===0)continue;let g=this.shared.getVariable(u);if(d.hasEnd&&(d.increment<0?g<=d.endValue:g>=d.endValue))continue;let y=this.shared.getVariable(u)+d.increment;d.hasEnd&&(y=d.increment>0?Math.min(y,d.endValue):Math.max(y,d.endValue),d.repeat&&y===d.endValue&&(y=p)),this.shared.updateVariable(u,y),r.push(u),this.eventManager.requestRender()}else if(d.dynamicVariableType==="time")this.shared.updateVariable(u,Qw(n,d)),r.push(u),this.eventManager.requestRender();else{let g=Hr.isTextValue(d.endValue)?IR(d.endValue.textValue):d.endValue;if(d.hasEnd&&(d.dynamicVariableType==="timer"?f<=g:f>=g)||d.dynamicVariableType==="timer"&&f===0)continue;let y=f+(e-h)/1e3*(d.dynamicVariableType==="timer"?-1:1);y=Math.max(y,0),d.hasEnd&&(y=d.dynamicVariableType==="timer"?Math.max(y,g):Math.min(y,g),d.repeat&&Math.abs(y-g)<(d.format==="number3decimal"?1e-4:.1)&&(y=p)),this.dynamicVars[l].timerSeconds=y,this.shared.updateVariable(u,wi.getFormattedTimerTime(y,d)),r.push(u),this.eventManager.requestRender()}this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime+=m}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(l=>{l.data.variableId==="mouseProperty"&&(l.dispatch(),this.eventManager.requestRender())}));let o=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,o=!0);let a=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,a=!0),this.events.forEach(l=>{(r.includes(l.data.variableId)||s.find(u=>u.objId===l.data.objectId&&u.property===l.data.property)||l.data.variableId==="mouseProperty"&&o||l.data.variableId==="raycastProperty"&&a)&&(l.dispatch(),this.eventManager.requestRender())})};this.onBlur=()=>{this.pause()};this.onFocus=()=>{this.resume()};e.page.traverseEntity(a=>{a.data?.events.filter(l=>l.data.type==="VariableChange"&&!l.data.disabled).forEach(l=>{this.events.push(new g1(a.uuid,l.data,a,e.page,e.sharedAssets,r))})}),this.propertiesToWatch=this.events.filter(a=>a.data.variableId==="objectProperty"&&a.data.objectId!==null).map(a=>({objectId:a.data.objectId,property:a.data.property,prevValue:null})),this.shared=e.sharedAssets,this.sharedVariables.forEach(({id:a,data:l})=>{if(!("dynamicVariableType"in l)){this.events.find(c=>c.data.variableId===a)&&this.variablesToWatch.push({id:a,prevValue:this.shared.getVariable(a)});return}let u;if(l.dynamicVariableType==="timer"||l.dynamicVariableType==="stopwatch"){let c;if(Hr.isTextValue(l.value)&&Array.isArray(l.value.textValue)){let h=l.value.textValue;h.length===3?c=h[2]+h[1]*60+h[0]*3600:c=h[1]+h[0]*60}else c=l.value;u=c,this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,timerSeconds:c,startValue:u})}else{if(l.dynamicVariableType==="time"&&this.shared.updateVariable(a,Qw(new Date,l)),l.dynamicVariableType==="counter"&&(u=Hr.isTextValue(l.value)?IR(l.value.textValue):l.value),l.dynamicVariableType==="random"){u=l.min+Math.random()*(l.max-l.min);let c=l.decimals;u=Math.round(u*Math.pow(10,c))/Math.pow(10,c),this.shared.updateVariable(a,u)}this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,startValue:u})}})}pause(){this.pauseTime=Date.now()}resume(){let e=Date.now()-this.pauseTime;for(let n=0;n<this.dynamicVars.length;n++)this.dynamicVars[n].last+=e,this.dynamicVars[n].expectedTime+=e}connect(){this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(e=>e.dispose())}},g1=class{constructor(t,e,n,r,s,o){this.id=t;this.data=e;this.object=n;this.actions=Qt(e,e.actions,r,s,o,n)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch())}dispose(){Gt(this.actions)}};function IR(i){return i.length===3?i[2]+i[1]*60+i[0]*3600:i[1]+i[0]*60}var RR=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@0.9.459/build/",E7=!1?RR:"https://unpkg.com/@splinetool/navmesh-wasm@0.9.459/build/",_7=`
|
|
6240
6240
|
(async function() {
|
|
6241
6241
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
6242
6242
|
import('${RR}' + 'navmesh.js'),
|
|
@@ -6302,4 +6302,4 @@ onmessage = function(messageEvent) {
|
|
|
6302
6302
|
<path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
6303
6303
|
</svg>
|
|
6304
6304
|
`),T.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),T.addEventListener("touchend",C=>C.preventDefault()),this.joysticks[p]=[void 0,m];return}let _={zone:m,mode:"static",position:b,size:g};v==="hide"&&(_.restOpacity=0);let S=wO.create(_);S.on("move",(T,M)=>{let C=this.gameControl;f==="pos"?M.force<.2?C.moveForce=0:(C.movementState.movePosZ=Math.sin(-M.angle.radian),C.movementState.movePosX=Math.cos(-M.angle.radian),M.force>1.2?C.movementState.run=1:C.movementState.run=0,M.force<.3?C.moveForce=(M.force-.2)/.1:C.moveForce=1):f==="rot"&&(M.force<.2?C.rotForce=0:(C.movementState.rotPosX=M.vector.y,C.movementState.rotPosY=-M.vector.x,M.force<.3?C.rotForce=(M.force-.2)/.1:C.rotForce=1)),this.requestRender()}),S.on("end",(T,M)=>{let C=this.gameControl;f==="pos"?(C.movementState.movePosZ=0,C.movementState.movePosX=0,C.moveForce=1):f==="rot"&&(C.movementState.rotPosX=0,C.movementState.rotPosY=0,C.rotForce=1)}),this.joysticks[p]=[S,m]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(f=>f.disabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new bt.World(new bt.Vector3(0,this.gravity,0)),this.events=new bt.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let l;if(a instanceof yr)if(a.objectForSample){if(a.objectForSample.dataPatched.physics.fusedBody)return;l=a.object}else return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(a instanceof un)l=a.object;else if(l=a,l.dataPatched.cloner?.disabled===!1&&l.dataPatched.cloner?.hideBase&&l.dataPatched.physics?.fusedBody!==!0)return!0;let u=l.dataPatched,c;for(let y of u.events)y.data.disabled!==!0&&y.data.type==="GameControl"&&(c=y.data);if(!u.physics||(u.physics.enabled==="visibility"?!u.visible:!u.physics.enabled))return!0;a.updateMatrixWorldSVD();let h=Qp(u),d=!1,f=l.userData.hasDestroy,p=l.userData.hasDrag,m=!1;for(let y of u.events)if(y.data.disabled!==!0){if(y.data.type==="Collision"){d=!0;let v=new P0(y.id,y.data,l,this.page,this.sharedAssets,this.eventManager);v.disabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].every(x=>x.id!==y.id)?this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]=[v]}else if(y.data.type==="Follow"){m=!0;let v=y.data.target;a.traverseVisible(x=>{x.userData.isFollowingObj=v})}}u.physics.rigidBody==="dynamic"&&u.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let g=a.geometry;if(c!==void 0){let y=bt.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(Hn,ws,rl),a.position0=Hn.clone().divideScalar(this.pixelsPerMeter),a.rotation0=ws.clone(),Hn.divideScalar(this.pixelsPerMeter),y.setTranslation(Hn.x,Hn.y,Hn.z).setRotation(ws);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(y);a.rigidBody=v;let x;c.collider.type==="sphere"?x=bt.ColliderDesc.ball(c.collider.radius/this.pixelsPerMeter):c.collider.type==="capsule"?x=bt.ColliderDesc.capsule((c.collider.height/2-c.collider.radius)/this.pixelsPerMeter,c.collider.radius/this.pixelsPerMeter):x=bt.ColliderDesc.cuboid(c.collider.width/this.pixelsPerMeter/2,c.collider.height/this.pixelsPerMeter/2,c.collider.depth/this.pixelsPerMeter/2),x.setFrictionCombineRule(bt.CoefficientCombineRule.Average).setRestitutionCombineRule(bt.CoefficientCombineRule.Average).setDensity(u.physics.density).setFriction(u.physics.friction).setRestitution(u.physics.restitution);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(x,v);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,l),Hn.fromArray(c.collider.position).multiply(rl.setFromMatrixScale(l.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(Hn);let w=new Ye().setFromEuler(new qt().setFromVector3(new A().fromArray(c.collider.rotation)));b.setRotationWrtParent(w),b.setActiveEvents(bt.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(l,!0)}else u.physics.rigidBody==="dynamic"||h||m||f||p||d?(this.addRigidBody(a,l,{hasFollow:m,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(l,u.physics.fusedBody)):(g&&t.push(Ss(g,a.matrixWorld)),u.physics.fusedBody&&a.traverseObject((y,v)=>{if(v===0)return;let x;if(y instanceof yr)if(y.objectForSample){if(y.objectForSample.dataPatched.physics.fusedBody)return;x=y.object}else return y.object.dataPatched.physics.fusedBody===!0&&y.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(y instanceof un)x=y.object;else if(x=y,x.dataPatched.cloner?.hideBase)return!0;let b=x.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let w=y.geometry;w?.getAttribute("position")!==void 0&&t.push(Ss(w,y.matrixWorld))}),this.generateSensorColliderDescs(l,u.physics.fusedBody,e));if(u.physics?.fusedBody===!0||c)return!0}),t.length===0)return;let n=rs(t);n.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=bt.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),o=bt.ColliderDesc.trimesh(n.getAttribute("position").array,n.getIndex().array).setFrictionCombineRule(bt.CoefficientCombineRule.Multiply).setRestitutionCombineRule(bt.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(o,s);for(let[a,l]of e){let u=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);this.sensorToTriggerEvent[u.handle]=l}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(e.data.type==="Trigger"&&e.data.disabled!==!0){let n=new Zp(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),r=new se().compose(As.fromArray(e.data.position),Nd.setFromEuler(UR.fromArray(e.data.rotation)),E1);if(e.data.triggerZone==="box"){let s=new Tt;s.min.fromArray(e.data.size).multiplyScalar(-.5),s.max.fromArray(e.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,t,n])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,r,t,n])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(!!this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t,e,n){if(!this.isEnabled)return!0;let r=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(r=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,r=!1):this.initializationCounter===2&&this.gameControl&&(r=!this.gameControl.update(t,e,n)&&r),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let s=.016666666666666666;if(t===0)r=this.stepPhysics()&&r;else{let o=t/1e3;o<s&&o>s*.55&&(o=s),this.accumulator+=o;let a=performance.now(),l=0,u=6;for(;this.accumulator>=s&&l<u&&(r=this.stepPhysics()&&r,this.accumulator-=s,l++,!(performance.now()-a>s*1e3)););this.accumulator=this.accumulator%s}}return r}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(Hn,ws,rl),w1.setFromQuaternion(ws);let n=e;n.prevR===void 0?(n.prevR=w1.clone(),n.prevT=Hn.clone()):(n.prevR.copy(w1),n.prevT.copy(Hn)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation(Hn.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(ws))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,n){let r=(this.sharedGameControlGlobals.rapierWorld?.getCollider(n))._parent,s;if(e.cloner){for(let o of e.cloner.children)if(o.rigidBody===r){s=o;break}}t.dispatch(s),e.dispatchEvent(m0)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,n){let r=VR.copy(t.matrixWorld).invert();t.traverseEntity((s,o)=>{if(e===!1&&o===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let l=new Zp(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager),u;if(a.data.triggerZone==="box"?u=bt.ColliderDesc.cuboid(...a.data.size.map(c=>c/(2*this.pixelsPerMeter))):u=bt.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),u.setDensity(0).setSensor(!0).setActiveEvents(bt.ActiveEvents.COLLISION_EVENTS),As.fromArray(a.data.position),Nd.setFromEuler(UR.fromArray(a.data.rotation)),L0.compose(As,Nd,E1).premultiply(s.matrixWorld),n?(L0.decompose(As,Nd,A1),u.setActiveCollisionTypes(bt.ActiveCollisionTypes.KINEMATIC_FIXED|bt.ActiveCollisionTypes.DYNAMIC_FIXED)):(L0.premultiply(r).decompose(As,Nd,A1),t.rigidBody.bodyType()===bt.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===bt.RigidBodyType.Fixed?u.setActiveCollisionTypes(bt.ActiveCollisionTypes.KINEMATIC_FIXED|bt.ActiveCollisionTypes.DYNAMIC_FIXED):u.setActiveCollisionTypes(bt.ActiveCollisionTypes.KINEMATIC_KINEMATIC|bt.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),As.divideScalar(this.pixelsPerMeter),u.setTranslation(As.x,As.y,As.z),u.setRotation(Nd),n)n.push([u,l]);else{let c=this.sharedGameControlGlobals.rapierWorld.createCollider(u,t.rigidBody);this.sensorToTriggerEvent[c.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[n,r,s,o]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let l=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===l||o.isValidTriggeringObject(at.is(l)?l:l.object)===!1)continue;let u=VR.copy(s.matrixWorld).decompose(As,zR,A1).compose(As,zR,E1).multiply(r),c=L0.copy(l.matrixWorld).invert().multiply(u);n instanceof Tt?t=l.bvhGeometry.boundsTree.intersectsBox(n,c):(_1.radius=n,_1.center.setFromMatrixPosition(c),t=l.bvhGeometry.boundsTree.intersectsSphere(_1)),t?o.currentIntersectedObjects.indexOf(l)===-1&&(o.currentIntersectedObjects.push(l),o.dispatch(),s.dispatchEvent(U7)):o.currentIntersectedObjects=o.currentIntersectedObjects.filter(h=>h!==l)}}}};function HR(i){let t=this._clip.duration,e=this._clip.start??0,n=this.loop,r=this.time+i,s=this._loopCount,o=n===ff;if(i===0)return s===-1?r:o&&(s&1)===1?t-(r-e):r;if(n===fb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:i<0?-1:1})}}else{if(s===-1&&(i>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<e){let a=Math.floor((r-e)/(t-e));r-=(t-e)*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,o||(r=i>0?t:e,this.repetitions===1&&(r=t)),this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:i>0?1:-1});else{if(l===1){let u=i<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-(r-e)}return r}var jR=!1,B0=class{constructor(t,e,n,r){this.scene=t;this.requestRender=e;this.updateDisplayProgress=n;this.animationInspectorState=r;this.clipIdToAction={};this.activeClip=null;this.needsUpdate=!1;this.addClip=t=>{t.data.type==="Empty"&&t.data.animations&&t.data.animations.forEach((e,n)=>{let r=e[0]+"/";if(Array.isArray(t.identity)?r+=t.identity[0]:r+=t.uuid,this.clipIdToAction[r])return;let s=Xc.parse(JSON.parse(e[2]));t.animations[n]=s;let o=this.mixer.clipAction(s,t);jR===!1&&(Object.getPrototypeOf(o)._updateTime=HR,jR=!0),o.clampWhenFinished=!0,this.clipIdToAction[r]=o})};this.mixer=new Qm(t),this.scene.traverseEntity(this.addClip)}deleteClip(t,e){let n=this.scene.find(e);if(!n)return;let r=n.animations.find(o=>o.uuid===t);if(!r)return;let s=this.clipIdToAction[t];!s||(s.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[t],n.animations=n.animations.filter(o=>o.uuid!==t))}get isPlaying(){return Object.values(this.clipIdToAction).some(t=>t.isRunning())}playFromInspector(t){this.mixer.stopAllAction();let e=this.clipIdToAction[t];!e||(e.play(),this.activeClip=e.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(t=>{t.repetitions=1/0,t.loop=pb}),this.mixer.stopAllAction(),this.requestRender()}play(t){let e=t.clipId+"/"+t.object,n=this.clipIdToAction[e];if(!!n)return t&&(t.repeat>=0&&(n.repetitions=t.repeat+1),t.direction==="pingpong"&&t.repeat!==0&&(n.loop=ff)),n.play(),n.paused=!1,this.requestRender(),n}resumeFromInspector(t){let e=this.clipIdToAction[t];!e||(e.play(),e.paused=!1,this.requestRender())}pauseFromInspector(t){let e=this.clipIdToAction[t];!e||(e.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(t){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(t/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*this.maxFrames%this.maxFrames)),this.requestRender()}get maxFrames(){return this.activeClip?.tracks[0]?.times.length??0}setProgressFromInspector(t,e){if(!this.clipIdToAction[e])return;this.activeClip!==this.clipIdToAction[e].getClip()&&this.playFromInspector(e);let n=this.clipIdToAction[e].paused;this.clipIdToAction[e].paused=!1,this.mixer.setTime(Math.min(this.maxFrames?t/this.maxFrames:0,.9999)*this.activeClip.duration),this.requestRender(),n&&(this.clipIdToAction[e].paused=!0)}};var T1=new WeakMap,F0=class extends Kc{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,n,r){let s=new Qc(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,o=>{this.decodeDracoFile(o,e).catch(r)},n,r)}decodeDracoFile(t,e,n,r){let s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n};return this.decodeGeometry(t,s).then(e)}decodeGeometry(t,e){let n=JSON.stringify(e);if(T1.has(t)){let l=T1.get(t);if(l.key===n)return l.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,o=t.byteLength,a=this._getWorker(s,o).then(l=>(r=l,new Promise((u,c)=>{r._callbacks[s]={resolve:u,reject:c},r.postMessage({type:"decode",id:s,taskConfig:e,buffer:t},[t])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),T1.set(t,{key:n,promise:a}),a}_createGeometry(t){let e=new Ae;t.index&&e.setIndex(new Ge(t.index.array,1));for(let n=0;n<t.attributes.length;n++){let r=t.attributes[n],s=r.name,o=r.array,a=r.itemSize;e.setAttribute(s,new Ge(o,a))}return e}_loadLibrary(t,e){let n=new Qc(this.manager);return n.setPath(this.decoderPath),n.setResponseType(e),n.setWithCredentials(this.withCredentials),new Promise((r,s)=>{n.load(t,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(n=>{let r=n[0];t||(this.decoderConfig.wasmBinary=n[1]);let s=V7.toString(),o=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
6305
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let o=s.data;switch(o.type){case"decode":r._callbacks[o.id].resolve(o);break;case"error":r._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function V7(){let i,t;onmessage=function(o){let a=o.data;switch(a.type){case"init":i=a.decoderConfig,t=new Promise(function(c){i.onModuleLoaded=function(h){c({draco:h})},DracoDecoderModule(i)});break;case"decode":let l=a.buffer,u=a.taskConfig;t.then(c=>{let h=c.draco,d=new h.Decoder,f=new h.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let p=e(h,d,f,u),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{h.destroy(f),h.destroy(d)}});break}};function e(o,a,l,u){let c=u.attributeIDs,h=u.attributeTypes,d,f,p=a.GetEncodedGeometryType(l);if(p===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(p===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let m={index:null,attributes:[]};for(let g in c){let y=self[h[g]],v,x;if(u.useUniqueIDs)x=c[g],v=a.GetAttributeByUniqueId(d,x);else{if(x=a.GetAttributeId(d,o[c[g]]),x===-1)continue;v=a.GetAttribute(d,x)}m.attributes.push(r(o,a,d,g,y,v))}return p===o.TRIANGULAR_MESH&&(m.index=n(o,a,d)),o.destroy(d),m}function n(o,a,l){let c=l.num_faces()*3,h=c*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);let f=new Uint32Array(o.HEAPF32.buffer,d,c).slice();return o._free(d),{array:f,itemSize:1}}function r(o,a,l,u,c,h){let d=h.num_components(),p=l.num_points()*d,m=p*c.BYTES_PER_ELEMENT,g=s(o,c),y=o._malloc(m);a.GetAttributeDataArrayForAllPoints(l,h,g,m,y);let v=new c(o.HEAPF32.buffer,y,p).slice();return o._free(y),{name:u,array:v,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var il;function z7(){return il||(il=new F0,il.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),il.decoderPending}async function G7(i){if(il){let t={attributeIDs:il.defaultAttributeIDs,attributeTypes:il.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await il.decodeGeometry(new Int8Array(i).buffer,t)}catch(n){console.error(n)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([n,r])=>({name:n,itemSize:r.itemSize,array:r.array}))}}return null}async function WR(i,t){let[e,n]=Xb(ry.deserialize(new Uint8Array(i)));Ay(e);let r=[];e.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&r.push(o)}),r.length&&await z7();for(let s of r){let o=await G7(vn(s.geometry.data.draco));if(o){o.index&&(s.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:l,array:u,itemSize:c})=>{a[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),s.geometry.data.attributes=a,s.geometry.data.draco=void 0}}return t&&t(e),n.result().data}var M1=class{constructor(t,e,n,r,s,o,a){this.id=t;this.data=e;this.dataEvent=n;this.object=r;this.stage=!1;this.actions=Qt(n,e.actions,s,o,a,r)}disconnect(){Gt(this.actions)}dispatchIn(){this.actions.Audio.forEach(t=>t.dispatchBasic()),this.actions.Video.forEach(t=>t.dispatchBasic()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.Link.forEach(t=>t.dispatch()),this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.actions.Transition.forEach(t=>t.toggle()),this.actions.Animation.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>t.play()),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch())}dispatchOut(){this.actions.Transition.forEach(t=>{t.toggle()})}},k0=class extends dn{constructor(e,n){super(e);this.eventManager=n;this.breakpoints=[];this.helperResize=(e,n)=>{this.breakpoints.forEach(r=>{let s=ay.deviceToSize(r.data.size),o=r.dataEvent.orientation==="horizontal"?e:n,a;switch(r.data.operator){case"<":a=o<s[0];break;case">":a=o>s[0];break;case"<>":a=o>s[0]&&o<s[1];break}r.stage!==a&&(r.stage=a,r.stage?r.dispatchIn():r.dispatchOut())})};this.onResize=()=>{let{innerWidth:e,innerHeight:n}=window;this.helperResize(e,n)};this.onResizeObserver=new ResizeObserver(e=>{for(let n of e){let{width:r,height:s}=n.contentRect;this.helperResize(r,s)}})}connect(){let{page:e,sharedAssets:n,domElement:r,isExport:s,frame:o}=this.eventContext;s?window.addEventListener("resize",this.onResize):o.preset==="fullscreen"?this.onResizeObserver.observe(r):window.addEventListener("resize",this.onResize),e.traverseEntity(a=>{if(!(!a.visible||!a.data?.events.length))for(let{data:l}of a.data.events)l.disabled||l.type==="Resize"&&l.breakpoints.forEach(({data:u,id:c})=>{try{let h=new M1(c,u,l,a,e,n,this.eventManager);this.breakpoints.push(h)}catch(h){!1&&console.log(h)}})})}disconnect(){let{isExport:e,frame:n}=this.eventContext;e?window.removeEventListener("resize",this.onResize):n.preset==="fullscreen"?this.onResizeObserver.disconnect():window.removeEventListener("resize",this.onResize),this.breakpoints.forEach(r=>{r.disconnect()}),this.breakpoints=[]}};var qR=Object.keys($A).filter(i=>isNaN(Number(i))),U0=class{constructor(t,e,n,r,s){this.publish=t;this.controlsManager=e;this.animationControls=n;this.eventContext=r;this.sharedVariables=s;this.isEnabled=!1;this.activateCount=0;this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0};this.onTouchMovePreventScroll=t=>{(t.touches.length>1||this.preventTouchScroll)&&t.preventDefault()};this.onMouseWheelPreventScroll=t=>{this.preventScroll&&t.preventDefault()};this.onMouseMove=t=>{this.eventContext.sharedAssets.mouseProperty={x:t.clientX,y:t.clientY,pressed:t.buttons>0}};this.onMouseDown=t=>{this.eventContext.sharedAssets.mouseProperty={x:t.clientX,y:t.clientY,pressed:!0}};this.onMouseUp=t=>{this.eventContext.sharedAssets.mouseProperty={x:t.clientX,y:t.clientY,pressed:!1}};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=r.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0;let{needsMouse:t,needsRaycast:e}=this.checkForMouseAndRaycastPropertiesInExpressions();t&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new v0(this.eventContext),DynamicVariable:new D0(this.eventContext,this.sharedVariables,this,t,e),["Conditional"]:new S0(this.eventContext,this),["Start"]:new C0(this.eventContext,this),Basic:new x0(this.eventContext,this,e),["MouseHover"]:new T0(this.eventContext,this),["Scroll"]:new M0(this.eventContext,this),["Follow"]:new A0(this.eventContext,this),["DragDrop"]:new w0(this.eventContext,this),["LookAt"]:new _0(this.eventContext),["Resize"]:new k0(this.eventContext,this)};let{page:n,domElement:r,eventElement:s}=this.eventContext;this.hideCursor&&(r.style.cursor="none"),n.traverseEntity(o=>{o.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(o=>o.connect()),qR.forEach(o=>{(Object.values(this.handlers).some(a=>a.domEventsNeeded.has(o))||o==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(r.addEventListener(o,this.onResetRaycaster),s.addEventListener(o,this.onResetRaycaster))}),r.addEventListener("wheel",this.onMouseWheelPreventScroll),r.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:t,domElement:e}=this.eventContext;e.style.cursor="",Object.values(this.handlers).forEach(n=>n.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(n=>{n.removeEventListener("requestRender",this.requestRender),n.destroyedInAction=!1}),qR.forEach(n=>{e.removeEventListener(n,this.onResetRaycaster)}),e.removeEventListener("touchmove",this.onTouchMovePreventScroll),e.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(t){let e=this.isEnabled;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}checkForMouseAndRaycastPropertiesInExpressions(){let t=!1,e=!1;function n(r){for(let s of r)if(s.data.type==="Conditional"||s.data.type==="SetVariable"){for(let o of s.data.type==="Conditional"?s.data.condition:s.data.expression)if("id"in o&&Array.isArray(o.id)&&(o.id[0]==="mouse"&&(t=!0),o.id[0]==="raycast"&&(e=!0)),t&&e)return}}return this.eventContext.page.traverseEntity(r=>{if(!!r.data?.events.length){for(let s of r.data.events)if(!s.data.disabled){if(s.data.type==="VariableChange"&&(s.data.variableId==="mouseProperty"&&(t=!0),s.data.variableId==="raycastProperty"&&(e=!0),t&&e))return!0;if(s.data.type==="Conditional")for(let o of["inActions","outActions"])n(s.data[o]);else if(s.data.type==="DragDrop")for(let o of["drag","drop"])n(s.data.dragDropActions[o]);else if(s.data.type==="GameControl")for(let o of["idle","move","jump","run"])n(s.data.gameActions[o]);else if(s.data.type==="Resize")for(let o of s.data.breakpoints)n(o.data.actions);else s.data.type==="LookAt"||n(s.data.actions);if(t&&e)return!0}}}),{needsMouse:t,needsRaycast:e}}};var V0=class{constructor(t,e,n,r,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new B().copy(n),this._editorSize=new B().copy(r),this._aspect=e.aspect,this._fov=s??e.fov}set frameSize(t){this._frameSize.copy(t)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._frameSize.x,e=this._frameSize.y,n=this._editorSize.y;this._aspect=t/e,e<=n&&(this._camera.zoom*=n/e),this._renderer.setViewport(0,0,t,e)}updateCamera(t=!0){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,n=this._editorSize.y,r=this._fov;if(t&&e>n){let s=H7(e,1080,2160,1,15)/100;r*=e/n,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(t){this._camera=t,this._aspect=t.aspect,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};function H7(i,t,e,n,r){return(i-t)/(e-t)*(r-n)+n}var z0=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new tc(t.shared,e),this.scene=new Ja(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof oi&&t.personalCamera.updateState(t.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof jt&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var G0=class{constructor({x:t=10,y:e=10}){this._startTime=0;let n=document.getElementById("spe-perfs");n?this.element=n:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${t}px`,this.element.style.top=`${e}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function j7(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}function Jp(i){return i instanceof ds?"SubdivObject":i.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function W7(i,t){let e={};return i.traverseEntity(n=>{if(!n.visible||!(n instanceof Xt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let r=n.parent;for(;r;){if(r instanceof Xt&&n.states&&Object.keys(n.states).length)return;r=r.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!Tn.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!Tn.isMergable(u.material))return;s=Tn.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][Jp(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][Jp(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][Jp(n)].push(u)}),e}function q7(i){let t=0;return Object.values(i).forEach(e=>{Object.values(e).forEach(n=>{let r=n.length;r>t&&(t=r)})}),t}function YR(i,t){let e=W7(t,i),n=q7(e),r=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),u=0,c=new Array(n),h=0;for(let[d,f]of Object.entries(e))for(let p of Object.values(f)){if(a=0,u=0,p.forEach(g=>{g instanceof Xt&&(o[a++]=g.geometry.clone(),l[u++]=g)}),u<2)continue;for(let g=0;g<u;g++)l[g].updateWorldMatrix(!0,!1),o[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&j7(o[g]);let m=rs(o.slice(0,a),!1);if(m){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new Fn(m,l[0].material);break}default:{g=new Fn(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{h=0;for(let x of v)x.children&&y(x.children),x instanceof Xt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][Jp(x)]&&e[x.material.uuid][Jp(x)].length>1||(c[h++]=x));for(let x=0;x<h;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),r[s++]=x}}}for(let d=0;d<s;d++)r[d].removeFromParent()}var QR=$o(KR(),1);var X7=new B;function K7(i){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";i.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):i.endsWith(".splinecode")||console.warn(t)}var C1=class{constructor(t,{renderOnDemand:e,renderMode:n="auto"}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._isPaused=!1;this._renderRequested=!1;this._skipRender=!1;this.time=performance.now();this.dt=0;this.currentTAAFrame=0;this.disposed=!1;this._requestRenderAutoMode=()=>{this._skipRender=!1};this.requestRender=()=>{this._renderRequested=!0};this.render=t=>{if(this.time=t,this._lastTime&&(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 e=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=e,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()};this._resize=()=>{if(!!this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=X7.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let t=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(t!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this._requestRenderAutoMode()}};this._debouncedResize=Ol(this._resize,10);this.canvas=t,this.renderMode=e?"auto":n,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new G0({x:10,y:10})),fC(t)}async load(t,e){K7(t),this.disposed=!1;let r=await(await fetch(t,e)).arrayBuffer();await this.start(r)}async start(t,{interactive:e=!0}={}){if(this.disposed)return;let n=await WR(t);this._data=n,n.version&&(0,QR.default)(n.version,"0.9.458")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([mA(n)&&lD(),KD(n)&&tD(),La.physicsEnabled(n.scene.objects)&&bC(),aA(n)&&HD(),v1(n)&&yC()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let r=new z0(n);if(r.resetPersonalCameraFromDocumentData(),this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let a=performance.now();YR(n,r.scene);let l=performance.now();console.log("Merged geometries in ",l-a," ms")}mA(n)&&this._scene.traverse(a=>{Lr(a)&&a.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(a=>{a instanceof yr&&a.pendingMediaLoad&&a.update()})});let s=Object.keys(n.shared.fonts).map(a=>this._sharedAssetsManager.getFont(a).loadingPromise);Promise.all(s).then(()=>{r.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),aA(n)&&GR(n)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),Ed(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new jv({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),n.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData);let o=Object.values(n.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(o.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=o.size[0],this._viewportHeight=o.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new V0(this._renderer,this._camera,new B(this._viewportWidth,this._viewportHeight),new B(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(o.allowResponsive??!1)&&o.preset==="fullscreen"),e){let a=new y0(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,o);this._scene.updateMatrixWorld(!0),this._controls=new N0(a),this._animationControls=new B0(this._scene,this._requestRenderAutoMode),this._eventManager=new U0(n.scene.publish,this._controls,this._animationControls,a,n.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==Li&&!this._scene.isInvisibleObjects(e)&&!(e instanceof oi)){let n=this._createProxyObject(e);n&&t.push(n)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof Ld&&this._controls?.orbitControls.zoomOut(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:n,b:r,a:s}={r:0,g:0,b:0,a:1},o=new hn(e,n,r,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.activePage.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{Ob.unsubscribe(t)}),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),pC(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e;t.traverseAncestors(s=>{s instanceof oi&&(e=s.name)});let n={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,parentUuid:t.parent instanceof oi||t instanceof Ja?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=Ob(n,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,r),r}};
|
|
6305
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let o=s.data;switch(o.type){case"decode":r._callbacks[o.id].resolve(o);break;case"error":r._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function V7(){let i,t;onmessage=function(o){let a=o.data;switch(a.type){case"init":i=a.decoderConfig,t=new Promise(function(c){i.onModuleLoaded=function(h){c({draco:h})},DracoDecoderModule(i)});break;case"decode":let l=a.buffer,u=a.taskConfig;t.then(c=>{let h=c.draco,d=new h.Decoder,f=new h.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let p=e(h,d,f,u),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{h.destroy(f),h.destroy(d)}});break}};function e(o,a,l,u){let c=u.attributeIDs,h=u.attributeTypes,d,f,p=a.GetEncodedGeometryType(l);if(p===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(p===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let m={index:null,attributes:[]};for(let g in c){let y=self[h[g]],v,x;if(u.useUniqueIDs)x=c[g],v=a.GetAttributeByUniqueId(d,x);else{if(x=a.GetAttributeId(d,o[c[g]]),x===-1)continue;v=a.GetAttribute(d,x)}m.attributes.push(r(o,a,d,g,y,v))}return p===o.TRIANGULAR_MESH&&(m.index=n(o,a,d)),o.destroy(d),m}function n(o,a,l){let c=l.num_faces()*3,h=c*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);let f=new Uint32Array(o.HEAPF32.buffer,d,c).slice();return o._free(d),{array:f,itemSize:1}}function r(o,a,l,u,c,h){let d=h.num_components(),p=l.num_points()*d,m=p*c.BYTES_PER_ELEMENT,g=s(o,c),y=o._malloc(m);a.GetAttributeDataArrayForAllPoints(l,h,g,m,y);let v=new c(o.HEAPF32.buffer,y,p).slice();return o._free(y),{name:u,array:v,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var il;function z7(){return il||(il=new F0,il.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),il.decoderPending}async function G7(i){if(il){let t={attributeIDs:il.defaultAttributeIDs,attributeTypes:il.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await il.decodeGeometry(new Int8Array(i).buffer,t)}catch(n){console.error(n)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([n,r])=>({name:n,itemSize:r.itemSize,array:r.array}))}}return null}async function WR(i,t){let[e,n]=Xb(ry.deserialize(new Uint8Array(i)));Ay(e);let r=[];e.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&r.push(o)}),r.length&&await z7();for(let s of r){let o=await G7(pn(s.geometry.data.draco));if(o){o.index&&(s.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:l,array:u,itemSize:c})=>{a[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),s.geometry.data.attributes=a,s.geometry.data.draco=void 0}}return t&&t(e),n.result().data}var M1=class{constructor(t,e,n,r,s,o,a){this.id=t;this.data=e;this.dataEvent=n;this.object=r;this.stage=!1;this.actions=Qt(n,e.actions,s,o,a,r)}disconnect(){Gt(this.actions)}dispatchIn(){this.actions.Audio.forEach(t=>t.dispatchBasic()),this.actions.Video.forEach(t=>t.dispatchBasic()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.Link.forEach(t=>t.dispatch()),this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.actions.Transition.forEach(t=>t.toggle()),this.actions.Animation.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>t.play()),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch())}dispatchOut(){this.actions.Transition.forEach(t=>{t.toggle()})}},k0=class extends dn{constructor(e,n){super(e);this.eventManager=n;this.breakpoints=[];this.helperResize=(e,n)=>{this.breakpoints.forEach(r=>{let s=ay.deviceToSize(r.data.size),o=r.dataEvent.orientation==="horizontal"?e:n,a;switch(r.data.operator){case"<":a=o<s[0];break;case">":a=o>s[0];break;case"<>":a=o>s[0]&&o<s[1];break}r.stage!==a&&(r.stage=a,r.stage?r.dispatchIn():r.dispatchOut())}),this.eventContext.updateDomRect()};this.onResize=()=>{let{innerWidth:e,innerHeight:n}=window;this.helperResize(e,n)};this.onResizeObserver=new ResizeObserver(e=>{for(let n of e){let{width:r,height:s}=n.contentRect;this.helperResize(r,s)}})}connect(){let{page:e,sharedAssets:n,domElement:r,isExport:s,frame:o}=this.eventContext;s?window.addEventListener("resize",this.onResize):o.preset==="fullscreen"?this.onResizeObserver.observe(r):window.addEventListener("resize",this.onResize),e.traverseEntity(a=>{if(!(!a.visible||!a.data?.events.length))for(let{data:l}of a.data.events)l.disabled||l.type==="Resize"&&l.breakpoints.forEach(({data:u,id:c})=>{try{let h=new M1(c,u,l,a,e,n,this.eventManager);this.breakpoints.push(h)}catch(h){!1&&console.log(h)}})})}disconnect(){let{isExport:e,frame:n}=this.eventContext;e?window.removeEventListener("resize",this.onResize):n.preset==="fullscreen"?this.onResizeObserver.disconnect():window.removeEventListener("resize",this.onResize),this.breakpoints.forEach(r=>{r.disconnect()}),this.breakpoints=[]}};var qR=Object.keys($A).filter(i=>isNaN(Number(i))),U0=class{constructor(t,e,n,r,s){this.publish=t;this.controlsManager=e;this.animationControls=n;this.eventContext=r;this.sharedVariables=s;this.isEnabled=!1;this.activateCount=0;this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0};this.onTouchMovePreventScroll=t=>{(t.touches.length>1||this.preventTouchScroll)&&t.preventDefault()};this.onMouseWheelPreventScroll=t=>{this.preventScroll&&t.preventDefault()};this.onMouseMove=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:t.buttons>0}};this.onMouseDown=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!0}};this.onMouseUp=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!1}};this.getMousePosition=t=>{let{domRect:e}=this.eventContext,{pageX:n,pageY:r}=t.touches?.length>0?t.touches[0]:t;return{x:n-(e.left+window.scrollX),y:r-(e.top+window.scrollY)}};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=r.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0;let{needsMouse:t,needsRaycast:e}=this.checkForMouseAndRaycastPropertiesInExpressions();t&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new v0(this.eventContext),DynamicVariable:new D0(this.eventContext,this.sharedVariables,this,t,e),["Conditional"]:new S0(this.eventContext,this),["Start"]:new C0(this.eventContext,this),Basic:new x0(this.eventContext,this,e),["MouseHover"]:new T0(this.eventContext,this),["Scroll"]:new M0(this.eventContext,this),["Follow"]:new A0(this.eventContext,this),["DragDrop"]:new w0(this.eventContext,this),["LookAt"]:new _0(this.eventContext),["Resize"]:new k0(this.eventContext,this)};let{page:n,domElement:r,eventElement:s}=this.eventContext;this.hideCursor&&(r.style.cursor="none"),n.traverseEntity(o=>{o.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(o=>o.connect()),qR.forEach(o=>{(Object.values(this.handlers).some(a=>a.domEventsNeeded.has(o))||o==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(r.addEventListener(o,this.onResetRaycaster),s.addEventListener(o,this.onResetRaycaster))}),r.addEventListener("wheel",this.onMouseWheelPreventScroll),r.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:t,domElement:e}=this.eventContext;e.style.cursor="",Object.values(this.handlers).forEach(n=>n.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(n=>{n.removeEventListener("requestRender",this.requestRender),n.destroyedInAction=!1}),qR.forEach(n=>{e.removeEventListener(n,this.onResetRaycaster)}),e.removeEventListener("touchmove",this.onTouchMovePreventScroll),e.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(t){let e=this.isEnabled;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}checkForMouseAndRaycastPropertiesInExpressions(){let t=!1,e=!1;function n(r){for(let s of r)if(s.data.type==="Conditional"||s.data.type==="SetVariable"){for(let o of s.data.type==="Conditional"?s.data.condition:s.data.expression)if("id"in o&&Array.isArray(o.id)&&(o.id[0]==="mouse"&&(t=!0),o.id[0]==="raycast"&&(e=!0)),t&&e)return}}return this.eventContext.page.traverseEntity(r=>{if(!!r.data?.events.length){for(let s of r.data.events)if(!s.data.disabled){if(s.data.type==="VariableChange"&&(s.data.variableId==="mouseProperty"&&(t=!0),s.data.variableId==="raycastProperty"&&(e=!0),t&&e))return!0;if(s.data.type==="Conditional")for(let o of["inActions","outActions"])n(s.data[o]);else if(s.data.type==="DragDrop")for(let o of["drag","drop"])n(s.data.dragDropActions[o]);else if(s.data.type==="GameControl")for(let o of["idle","move","jump","run"])n(s.data.gameActions[o]);else if(s.data.type==="Resize")for(let o of s.data.breakpoints)n(o.data.actions);else s.data.type==="LookAt"||n(s.data.actions);if(t&&e)return!0}}}),{needsMouse:t,needsRaycast:e}}};var V0=class{constructor(t,e,n,r,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new B().copy(n),this._editorSize=new B().copy(r),this._aspect=e.aspect,this._fov=s??e.fov}set frameSize(t){this._frameSize.copy(t)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._frameSize.x,e=this._frameSize.y,n=this._editorSize.y;this._aspect=t/e,e<=n&&(this._camera.zoom*=n/e),this._renderer.setViewport(0,0,t,e)}updateCamera(t=!0){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,n=this._editorSize.y,r=this._fov;if(t&&e>n){let s=H7(e,1080,2160,1,15)/100;r*=e/n,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(t){this._camera=t,this._aspect=t.aspect,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};function H7(i,t,e,n,r){return(i-t)/(e-t)*(r-n)+n}var z0=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new tc(t.shared,e),this.scene=new Ja(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof oi&&t.personalCamera.updateState(t.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof jt&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var G0=class{constructor({x:t=10,y:e=10}){this._startTime=0;let n=document.getElementById("spe-perfs");n?this.element=n:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${t}px`,this.element.style.top=`${e}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function j7(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}function Jp(i){return i instanceof ds?"SubdivObject":i.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function W7(i,t){let e={};return i.traverseEntity(n=>{if(!n.visible||!(n instanceof Xt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let r=n.parent;for(;r;){if(r instanceof Xt&&n.states&&Object.keys(n.states).length)return;r=r.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!Tn.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!Tn.isMergable(u.material))return;s=Tn.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][Jp(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][Jp(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][Jp(n)].push(u)}),e}function q7(i){let t=0;return Object.values(i).forEach(e=>{Object.values(e).forEach(n=>{let r=n.length;r>t&&(t=r)})}),t}function YR(i,t){let e=W7(t,i),n=q7(e),r=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),u=0,c=new Array(n),h=0;for(let[d,f]of Object.entries(e))for(let p of Object.values(f)){if(a=0,u=0,p.forEach(g=>{g instanceof Xt&&(o[a++]=g.geometry.clone(),l[u++]=g)}),u<2)continue;for(let g=0;g<u;g++)l[g].updateWorldMatrix(!0,!1),o[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&j7(o[g]);let m=rs(o.slice(0,a),!1);if(m){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new Fn(m,l[0].material);break}default:{g=new Fn(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{h=0;for(let x of v)x.children&&y(x.children),x instanceof Xt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][Jp(x)]&&e[x.material.uuid][Jp(x)].length>1||(c[h++]=x));for(let x=0;x<h;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),r[s++]=x}}}for(let d=0;d<s;d++)r[d].removeFromParent()}var QR=$o(KR(),1);var X7=new B;function K7(i){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";i.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):i.endsWith(".splinecode")||console.warn(t)}var C1=class{constructor(t,{renderOnDemand:e,renderMode:n="auto"}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._isPaused=!1;this._renderRequested=!1;this._skipRender=!1;this.time=performance.now();this.dt=0;this.currentTAAFrame=0;this.disposed=!1;this._requestRenderAutoMode=()=>{this._skipRender=!1};this.requestRender=()=>{this._renderRequested=!0};this.render=t=>{if(this.time=t,this._lastTime&&(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 e=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=e,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()};this._resize=()=>{if(!!this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=X7.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let t=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(t!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this._requestRenderAutoMode()}};this._debouncedResize=Ol(this._resize,10);this.canvas=t,this.renderMode=e?"auto":n,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new G0({x:10,y:10})),fC(t)}async load(t,e){K7(t),this.disposed=!1;let r=await(await fetch(t,e)).arrayBuffer();await this.start(r)}async start(t,{interactive:e=!0}={}){if(this.disposed)return;let n=await WR(t);this._data=n,n.version&&(0,QR.default)(n.version,"0.9.459")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([mA(n)&&lD(),KD(n)&&tD(),La.physicsEnabled(n.scene.objects)&&bC(),aA(n)&&HD(),v1(n)&&yC()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let r=new z0(n);if(r.resetPersonalCameraFromDocumentData(),this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let a=performance.now();YR(n,r.scene);let l=performance.now();console.log("Merged geometries in ",l-a," ms")}mA(n)&&this._scene.traverse(a=>{Lr(a)&&a.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(a=>{a instanceof yr&&a.pendingMediaLoad&&a.update()})});let s=Object.keys(n.shared.fonts).map(a=>this._sharedAssetsManager.getFont(a).loadingPromise);Promise.all(s).then(()=>{r.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),aA(n)&&GR(n)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),Ed(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new jv({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),n.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData);let o=Object.values(n.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(o.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=o.size[0],this._viewportHeight=o.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new V0(this._renderer,this._camera,new B(this._viewportWidth,this._viewportHeight),new B(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(o.allowResponsive??!1)&&o.preset==="fullscreen"),e){let a=new y0(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,o);this._scene.updateMatrixWorld(!0),this._controls=new N0(a),this._animationControls=new B0(this._scene,this._requestRenderAutoMode),this._eventManager=new U0(n.scene.publish,this._controls,this._animationControls,a,n.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==Li&&!this._scene.isInvisibleObjects(e)&&!(e instanceof oi)){let n=this._createProxyObject(e);n&&t.push(n)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof Ld&&this._controls?.orbitControls.zoomOut(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:n,b:r,a:s}={r:0,g:0,b:0,a:1},o=new hn(e,n,r,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.activePage.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{Ob.unsubscribe(t)}),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),pC(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e;t.traverseAncestors(s=>{s instanceof oi&&(e=s.name)});let n={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,parentUuid:t.parent instanceof oi||t instanceof Ja?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=Ob(n,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,r),r}};
|