@splinetool/runtime 0.9.272 → 0.9.275
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 +5 -5
- package/build/runtime.js +5 -5
- package/package.json +1 -1
package/build/runtime.js
CHANGED
|
@@ -3135,9 +3135,9 @@ void main() {
|
|
|
3135
3135
|
squared_mean = squared_mean / samples;
|
|
3136
3136
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3137
3137
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3138
|
-
}`;function rN(r,t,e){let n=new Dd,i=new F,s=new F,o=new Qe,a=new Od({depthPacking:m0}),l=new jv,u={},c=e.maxTextureSize,d={[Wr]:bn,[bn]:Wr,[fr]:fr},h=new bt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new F},radius:{value:4}},vertexShader:tN,fragmentShader:nN}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let g=new Te;g.setAttribute("position",new Be(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new Un(g,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Cp,this.render=function(b,w,A){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;let T=r.getRenderTarget(),S=r.getActiveCubeFace(),E=r.getActiveMipmapLevel(),M=r.state;M.setBlending(Ft),M.buffers.color.setClear(1,1,1,1),M.buffers.depth.setTest(!0),M.setScissorTest(!1);for(let I=0,P=b.length;I<P;I++){let C=b[I],D=C.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",C,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;i.copy(D.mapSize);let B=D.getFrameExtents();if(i.multiply(B),s.copy(D.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/B.x),i.x=s.x*B.x,D.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/B.y),i.y=s.y*B.y,D.mapSize.y=s.y)),D.map===null){let X=this.type!==bd?{minFilter:Bt,magFilter:Bt}:{};D.map=new At(i.x,i.y,X),D.map.texture.name=C.name+".shadowMap",D.camera.updateProjectionMatrix()}r.setRenderTarget(D.map),r.clear();let k=D.getViewportCount();for(let X=0;X<k;X++){let W=D.getViewport(X);o.set(s.x*W.x,s.y*W.y,s.x*W.z,s.y*W.w),M.viewport(o),D.updateMatrices(C,X),n=D.getFrustum(),x(w,A,D.camera,C,this.type)}D.isPointLightShadow!==!0&&this.type===bd&&y(D,A),D.needsUpdate=!1}m.needsUpdate=!1,r.setRenderTarget(T,S,E)};function y(b,w){let A=t.update(p);h.defines.VSM_SAMPLES!==b.blurSamples&&(h.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new At(i.x,i.y)),h.uniforms.shadow_pass.value=b.map.texture,h.uniforms.resolution.value=b.mapSize,h.uniforms.radius.value=b.radius,r.setRenderTarget(b.mapPass),r.clear(),r.renderBufferDirect(w,null,A,h,p,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,r.setRenderTarget(b.map),r.clear(),r.renderBufferDirect(w,null,A,f,p,null)}function v(b,w,A,T,S,E){let M=null,I=A.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(I!==void 0)M=I;else if(M=A.isPointLight===!0?l:a,r.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 P=M.uuid,C=w.uuid,D=u[P];D===void 0&&(D={},u[P]=D);let B=D[C];B===void 0&&(B=M.clone(),D[C]=B),M=B}return M.visible=w.visible,M.wireframe=w.wireframe,E===bd?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:d[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,A.isPointLight===!0&&M.isMeshDistanceMaterial===!0&&(M.referencePosition.setFromMatrixPosition(A.matrixWorld),M.nearDistance=T,M.farDistance=S),M}function x(b,w,A,T,S){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&S===bd)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);let I=t.update(b),P=b.material;if(Array.isArray(P)){let C=I.groups;for(let D=0,B=C.length;D<B;D++){let k=C[D],X=P[k.materialIndex];if(X&&X.visible){let W=v(b,X,T,A.near,A.far,S);r.renderBufferDirect(A,null,I,W,b,k)}}}else if(P.visible){let C=v(b,P,T,A.near,A.far,S);r.renderBufferDirect(A,null,I,C,b,null)}}let M=b.children;for(let I=0,P=M.length;I<P;I++)x(M[I],w,A,T,S)}}function iN(r,t,e){let n=e.isWebGL2;function i(){let Y=!1,se=new Qe,ye=null,Ce=new Qe(0,0,0,0);return{setMask:function(Ue){ye!==Ue&&!Y&&(r.colorMask(Ue,Ue,Ue,Ue),ye=Ue)},setLocked:function(Ue){Y=Ue},setClear:function(Ue,tt,$t,Nn,ri){ri===!0&&(Ue*=Nn,tt*=Nn,$t*=Nn),se.set(Ue,tt,$t,Nn),Ce.equals(se)===!1&&(r.clearColor(Ue,tt,$t,Nn),Ce.copy(se))},reset:function(){Y=!1,ye=null,Ce.set(-1,0,0,0)}}}function s(){let Y=!1,se=null,ye=null,Ce=null;return{setTest:function(Ue){Ue?re(2929):Z(2929)},setMask:function(Ue){se!==Ue&&!Y&&(r.depthMask(Ue),se=Ue)},setFunc:function(Ue){if(ye!==Ue){switch(Ue){case LI:r.depthFunc(512);break;case RI:r.depthFunc(519);break;case NI:r.depthFunc(513);break;case Iv:r.depthFunc(515);break;case BI:r.depthFunc(514);break;case FI:r.depthFunc(518);break;case UI:r.depthFunc(516);break;case GI:r.depthFunc(517);break;default:r.depthFunc(515)}ye=Ue}},setLocked:function(Ue){Y=Ue},setClear:function(Ue){Ce!==Ue&&(r.clearDepth(Ue),Ce=Ue)},reset:function(){Y=!1,se=null,ye=null,Ce=null}}}function o(){let Y=!1,se=null,ye=null,Ce=null,Ue=null,tt=null,$t=null,Nn=null,ri=null;return{setTest:function(Ht){Y||(Ht?re(2960):Z(2960))},setMask:function(Ht){se!==Ht&&!Y&&(r.stencilMask(Ht),se=Ht)},setFunc:function(Ht,Is,ii){(ye!==Ht||Ce!==Is||Ue!==ii)&&(r.stencilFunc(Ht,Is,ii),ye=Ht,Ce=Is,Ue=ii)},setOp:function(Ht,Is,ii){(tt!==Ht||$t!==Is||Nn!==ii)&&(r.stencilOp(Ht,Is,ii),tt=Ht,$t=Is,Nn=ii)},setLocked:function(Ht){Y=Ht},setClear:function(Ht){ri!==Ht&&(r.clearStencil(Ht),ri=Ht)},reset:function(){Y=!1,se=null,ye=null,Ce=null,Ue=null,tt=null,$t=null,Nn=null,ri=null}}}let a=new i,l=new s,u=new o,c=new WeakMap,d=new WeakMap,h={},f={},g=new WeakMap,p=[],m=null,y=!1,v=null,x=null,b=null,w=null,A=null,T=null,S=null,E=!1,M=null,I=null,P=null,C=null,D=null,B=r.getParameter(35661),k=!1,X=0,W=r.getParameter(7938);W.indexOf("WebGL")!==-1?(X=parseFloat(/^WebGL (\d)/.exec(W)[1]),k=X>=1):W.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(W)[1]),k=X>=2);let q=null,H={},K=r.getParameter(3088),R=r.getParameter(2978),U=new Qe().fromArray(K),z=new Qe().fromArray(R);function j(Y,se,ye){let Ce=new Uint8Array(4),Ue=r.createTexture();r.bindTexture(Y,Ue),r.texParameteri(Y,10241,9728),r.texParameteri(Y,10240,9728);for(let tt=0;tt<ye;tt++)r.texImage2D(se+tt,0,6408,1,1,0,6408,5121,Ce);return Ue}let G={};G[3553]=j(3553,3553,1),G[34067]=j(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),re(2929),l.setFunc(Iv),me(!1),Me(JS),re(2884),fe(Ft);function re(Y){h[Y]!==!0&&(r.enable(Y),h[Y]=!0)}function Z(Y){h[Y]!==!1&&(r.disable(Y),h[Y]=!1)}function J(Y,se){return f[Y]!==se?(r.bindFramebuffer(Y,se),f[Y]=se,n&&(Y===36009&&(f[36160]=se),Y===36160&&(f[36009]=se)),!0):!1}function V(Y,se){let ye=p,Ce=!1;if(Y)if(ye=g.get(se),ye===void 0&&(ye=[],g.set(se,ye)),Y.isWebGLMultipleRenderTargets){let Ue=Y.texture;if(ye.length!==Ue.length||ye[0]!==36064){for(let tt=0,$t=Ue.length;tt<$t;tt++)ye[tt]=36064+tt;ye.length=Ue.length,Ce=!0}}else ye[0]!==36064&&(ye[0]=36064,Ce=!0);else ye[0]!==1029&&(ye[0]=1029,Ce=!0);Ce&&(e.isWebGL2?r.drawBuffers(ye):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ye))}function pe(Y){return m!==Y?(r.useProgram(Y),m=Y,!0):!1}let ie={[Ol]:32774,[wI]:32778,[AI]:32779};if(n)ie[nw]=32775,ie[rw]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(ie[nw]=Y.MIN_EXT,ie[rw]=Y.MAX_EXT)}let ae={[_I]:0,[TI]:1,[EI]:768,[I1]:770,[OI]:776,[II]:774,[CI]:772,[MI]:769,[D1]:771,[DI]:775,[PI]:773};function fe(Y,se,ye,Ce,Ue,tt,$t,Nn){if(Y===Ft){y===!0&&(Z(3042),y=!1);return}if(y===!1&&(re(3042),y=!0),Y!==SI){if(Y!==v||Nn!==E){if((x!==Ol||A!==Ol)&&(r.blendEquation(32774),x=Ol,A=Ol),Nn)switch(Y){case Nl:r.blendFuncSeparate(1,771,1,771);break;case $S:r.blendFunc(1,1);break;case ew:r.blendFuncSeparate(0,769,0,1);break;case tw:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case Nl:r.blendFuncSeparate(770,771,1,771);break;case $S:r.blendFunc(770,1);break;case ew:r.blendFuncSeparate(0,769,0,1);break;case tw:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}b=null,w=null,T=null,S=null,v=Y,E=Nn}return}Ue=Ue||se,tt=tt||ye,$t=$t||Ce,(se!==x||Ue!==A)&&(r.blendEquationSeparate(ie[se],ie[Ue]),x=se,A=Ue),(ye!==b||Ce!==w||tt!==T||$t!==S)&&(r.blendFuncSeparate(ae[ye],ae[Ce],ae[tt],ae[$t]),b=ye,w=Ce,T=tt,S=$t),v=Y,E=!1}function xe(Y,se){Y.side===fr?Z(2884):re(2884);let ye=Y.side===bn;se&&(ye=!ye),me(ye),Y.blending===Nl&&Y.transparent===!1?fe(Ft):fe(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 Ce=Y.stencilWrite;u.setTest(Ce),Ce&&(u.setMask(Y.stencilWriteMask),u.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),u.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),be(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?re(32926):Z(32926)}function me(Y){M!==Y&&(Y?r.frontFace(2304):r.frontFace(2305),M=Y)}function Me(Y){Y!==xI?(re(2884),Y!==I&&(Y===JS?r.cullFace(1029):Y===bI?r.cullFace(1028):r.cullFace(1032))):Z(2884),I=Y}function Pe(Y){Y!==P&&(k&&r.lineWidth(Y),P=Y)}function be(Y,se,ye){Y?(re(32823),(C!==se||D!==ye)&&(r.polygonOffset(se,ye),C=se,D=ye)):Z(32823)}function Fe(Y){Y?re(3089):Z(3089)}function ht(Y){Y===void 0&&(Y=33984+B-1),q!==Y&&(r.activeTexture(Y),q=Y)}function L(Y,se,ye){ye===void 0&&(q===null?ye=33984+B-1:ye=q);let Ce=H[ye];Ce===void 0&&(Ce={type:void 0,texture:void 0},H[ye]=Ce),(Ce.type!==Y||Ce.texture!==se)&&(q!==ye&&(r.activeTexture(ye),q=ye),r.bindTexture(Y,se||G[Y]),Ce.type=Y,Ce.texture=se)}function O(){let Y=H[q];Y!==void 0&&Y.type!==void 0&&(r.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function ee(){try{r.compressedTexImage2D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function he(){try{r.compressedTexImage3D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ge(){try{r.texSubImage2D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ie(){try{r.texSubImage3D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ge(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function De(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ue(){try{r.texStorage2D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function je(){try{r.texStorage3D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function qe(){try{r.texImage2D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function _e(){try{r.texImage3D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Re(Y){U.equals(Y)===!1&&(r.scissor(Y.x,Y.y,Y.z,Y.w),U.copy(Y))}function Ne(Y){z.equals(Y)===!1&&(r.viewport(Y.x,Y.y,Y.z,Y.w),z.copy(Y))}function pt(Y,se){let ye=d.get(se);ye===void 0&&(ye=new WeakMap,d.set(se,ye));let Ce=ye.get(Y);Ce===void 0&&(Ce=r.getUniformBlockIndex(se,Y.name),ye.set(Y,Ce))}function Nt(Y,se){let Ce=d.get(se).get(Y);c.get(se)!==Ce&&(r.uniformBlockBinding(se,Ce,Y.__bindingPointIndex),c.set(se,Ce))}function gn(){r.disable(3042),r.disable(2884),r.disable(2929),r.disable(32823),r.disable(3089),r.disable(2960),r.disable(32926),r.blendEquation(32774),r.blendFunc(1,0),r.blendFuncSeparate(1,0,1,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(513),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(519,0,4294967295),r.stencilOp(7680,7680,7680),r.clearStencil(0),r.cullFace(1029),r.frontFace(2305),r.polygonOffset(0,0),r.activeTexture(33984),r.bindFramebuffer(36160,null),n===!0&&(r.bindFramebuffer(36009,null),r.bindFramebuffer(36008,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},q=null,H={},f={},g=new WeakMap,p=[],m=null,y=!1,v=null,x=null,b=null,w=null,A=null,T=null,S=null,E=!1,M=null,I=null,P=null,C=null,D=null,U.set(0,0,r.canvas.width,r.canvas.height),z.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:re,disable:Z,bindFramebuffer:J,drawBuffers:V,useProgram:pe,setBlending:fe,setMaterial:xe,setFlipSided:me,setCullFace:Me,setLineWidth:Pe,setPolygonOffset:be,setScissorTest:Fe,activeTexture:ht,bindTexture:L,unbindTexture:O,compressedTexImage2D:ee,compressedTexImage3D:he,texImage2D:qe,texImage3D:_e,updateUBOMapping:pt,uniformBlockBinding:Nt,texStorage2D:ue,texStorage3D:je,texSubImage2D:ge,texSubImage3D:Ie,compressedTexSubImage2D:Ge,compressedTexSubImage3D:De,scissor:Re,viewport:Ne,reset:gn}}function sN(r,t,e,n,i,s,o){let a=i.isWebGL2,l=i.maxTextures,u=i.maxCubemapSize,c=i.maxTextureSize,d=i.maxSamples,h=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),g=new WeakMap,p,m=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(L,O){return y?new OffscreenCanvas(L,O):ap("canvas")}function x(L,O,ee,he){let ge=1;if((L.width>he||L.height>he)&&(ge=he/Math.max(L.width,L.height)),ge<1||O===!0)if(typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&L instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&L instanceof ImageBitmap){let Ie=O?op:Math.floor,Ge=Ie(ge*L.width),De=Ie(ge*L.height);p===void 0&&(p=v(Ge,De));let ue=ee?v(Ge,De):p;return ue.width=Ge,ue.height=De,ue.getContext("2d").drawImage(L,0,0,Ge,De),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+L.width+"x"+L.height+") to ("+Ge+"x"+De+")."),ue}else return"data"in L&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+L.width+"x"+L.height+")."),L;return L}function b(L){return Bv(L.width)&&Bv(L.height)}function w(L){return a?!1:L.wrapS!==hr||L.wrapT!==hr||L.minFilter!==Bt&&L.minFilter!==st}function A(L,O){return L.generateMipmaps&&O&&L.minFilter!==Bt&&L.minFilter!==st}function T(L){r.generateMipmap(L)}function S(L,O,ee,he,ge=!1){if(a===!1)return O;if(L!==null){if(r[L]!==void 0)return r[L];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+L+"'")}let Ie=O;return O===6403&&(ee===5126&&(Ie=33326),ee===5131&&(Ie=33325),ee===5121&&(Ie=33321)),O===33319&&(ee===5126&&(Ie=33328),ee===5131&&(Ie=33327),ee===5121&&(Ie=33323)),O===6408&&(ee===5126&&(Ie=34836),ee===5131&&(Ie=34842),ee===5121&&(Ie=he===Xe&&ge===!1?35907:32856),ee===32819&&(Ie=32854),ee===32820&&(Ie=32855)),(Ie===33325||Ie===33326||Ie===33327||Ie===33328||Ie===34842||Ie===34836)&&t.get("EXT_color_buffer_float"),Ie}function E(L,O,ee){return A(L,ee)===!0||L.isFramebufferTexture&&L.minFilter!==Bt&&L.minFilter!==st?Math.log2(Math.max(O.width,O.height))+1:L.mipmaps!==void 0&&L.mipmaps.length>0?L.mipmaps.length:L.isCompressedTexture&&Array.isArray(L.image)?O.mipmaps.length:1}function M(L){return L===Bt||L===iw||L===Xy?9728:9729}function I(L){let O=L.target;O.removeEventListener("dispose",I),C(O),O.isVideoTexture&&g.delete(O)}function P(L){let O=L.target;O.removeEventListener("dispose",P),B(O)}function C(L){let O=n.get(L);if(O.__webglInit===void 0)return;let ee=L.source,he=m.get(ee);if(he){let ge=he[O.__cacheKey];ge.usedTimes--,ge.usedTimes===0&&D(L),Object.keys(he).length===0&&m.delete(ee)}n.remove(L)}function D(L){let O=n.get(L);r.deleteTexture(O.__webglTexture);let ee=L.source,he=m.get(ee);delete he[O.__cacheKey],o.memory.textures--}function B(L){let O=L.texture,ee=n.get(L),he=n.get(O);if(he.__webglTexture!==void 0&&(r.deleteTexture(he.__webglTexture),o.memory.textures--),L.depthTexture&&L.depthTexture.dispose(),L.isWebGLCubeRenderTarget)for(let ge=0;ge<6;ge++)r.deleteFramebuffer(ee.__webglFramebuffer[ge]),ee.__webglDepthbuffer&&r.deleteRenderbuffer(ee.__webglDepthbuffer[ge]);else{if(r.deleteFramebuffer(ee.__webglFramebuffer),ee.__webglDepthbuffer&&r.deleteRenderbuffer(ee.__webglDepthbuffer),ee.__webglMultisampledFramebuffer&&r.deleteFramebuffer(ee.__webglMultisampledFramebuffer),ee.__webglColorRenderbuffer)for(let ge=0;ge<ee.__webglColorRenderbuffer.length;ge++)ee.__webglColorRenderbuffer[ge]&&r.deleteRenderbuffer(ee.__webglColorRenderbuffer[ge]);ee.__webglDepthRenderbuffer&&r.deleteRenderbuffer(ee.__webglDepthRenderbuffer)}if(L.isWebGLMultipleRenderTargets)for(let ge=0,Ie=O.length;ge<Ie;ge++){let Ge=n.get(O[ge]);Ge.__webglTexture&&(r.deleteTexture(Ge.__webglTexture),o.memory.textures--),n.remove(O[ge])}n.remove(O),n.remove(L)}let k=0;function X(){k=0}function W(){let L=k;return L>=l&&console.warn("THREE.WebGLTextures: Trying to use "+L+" texture units while this GPU supports only "+l),k+=1,L}function q(L){let O=[];return O.push(L.wrapS),O.push(L.wrapT),O.push(L.wrapR||0),O.push(L.magFilter),O.push(L.minFilter),O.push(L.anisotropy),O.push(L.internalFormat),O.push(L.format),O.push(L.type),O.push(L.generateMipmaps),O.push(L.premultiplyAlpha),O.push(L.flipY),O.push(L.unpackAlignment),O.push(L.encoding),O.join()}function H(L,O){let ee=n.get(L);if(L.isVideoTexture&&Fe(L),L.isRenderTargetTexture===!1&&L.version>0&&ee.__version!==L.version){let he=L.image;if(he===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(he.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Z(ee,L,O);return}}e.bindTexture(3553,ee.__webglTexture,33984+O)}function K(L,O){let ee=n.get(L);if(L.version>0&&ee.__version!==L.version){Z(ee,L,O);return}e.bindTexture(35866,ee.__webglTexture,33984+O)}function R(L,O){let ee=n.get(L);if(L.version>0&&ee.__version!==L.version){Z(ee,L,O);return}e.bindTexture(32879,ee.__webglTexture,33984+O)}function U(L,O){let ee=n.get(L);if(L.version>0&&ee.__version!==L.version){J(ee,L,O);return}e.bindTexture(34067,ee.__webglTexture,33984+O)}let z={[Fl]:10497,[hr]:33071,[Lv]:33648},j={[Bt]:9728,[iw]:9984,[Xy]:9986,[st]:9729,[XI]:9985,[Ta]:9987};function G(L,O,ee){if(ee?(r.texParameteri(L,10242,z[O.wrapS]),r.texParameteri(L,10243,z[O.wrapT]),(L===32879||L===35866)&&r.texParameteri(L,32882,z[O.wrapR]),r.texParameteri(L,10240,j[O.magFilter]),r.texParameteri(L,10241,j[O.minFilter])):(r.texParameteri(L,10242,33071),r.texParameteri(L,10243,33071),(L===32879||L===35866)&&r.texParameteri(L,32882,33071),(O.wrapS!==hr||O.wrapT!==hr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(L,10240,M(O.magFilter)),r.texParameteri(L,10241,M(O.minFilter)),O.minFilter!==Bt&&O.minFilter!==st&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let he=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===Bt||O.minFilter!==Xy&&O.minFilter!==Ta||O.type===Zi&&t.has("OES_texture_float_linear")===!1||a===!1&&O.type===Md&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||n.get(O).__currentAnisotropy)&&(r.texParameterf(L,he.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),n.get(O).__currentAnisotropy=O.anisotropy)}}function re(L,O){let ee=!1;L.__webglInit===void 0&&(L.__webglInit=!0,O.addEventListener("dispose",I));let he=O.source,ge=m.get(he);ge===void 0&&(ge={},m.set(he,ge));let Ie=q(O);if(Ie!==L.__cacheKey){ge[Ie]===void 0&&(ge[Ie]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),ge[Ie].usedTimes++;let Ge=ge[L.__cacheKey];Ge!==void 0&&(ge[L.__cacheKey].usedTimes--,Ge.usedTimes===0&&D(O)),L.__cacheKey=Ie,L.__webglTexture=ge[Ie].texture}return ee}function Z(L,O,ee){let he=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(he=35866),O.isData3DTexture&&(he=32879);let ge=re(L,O),Ie=O.source;e.bindTexture(he,L.__webglTexture,33984+ee);let Ge=n.get(Ie);if(Ie.version!==Ge.__version||ge===!0){e.activeTexture(33984+ee),r.pixelStorei(37440,O.flipY),r.pixelStorei(37441,O.premultiplyAlpha),r.pixelStorei(3317,O.unpackAlignment),r.pixelStorei(37443,0);let De=w(O)&&b(O.image)===!1,ue=x(O.image,De,!1,c);ue=ht(O,ue);let je=b(ue)||a,qe=s.convert(O.format,O.encoding),_e=s.convert(O.type),Re=S(O.internalFormat,qe,_e,O.encoding,O.isVideoTexture);G(he,O,je);let Ne,pt=O.mipmaps,Nt=a&&O.isVideoTexture!==!0,gn=Ge.__version===void 0||ge===!0,Y=E(O,ue,je);if(O.isDepthTexture)Re=6402,a?O.type===Zi?Re=36012:O.type===Us?Re=33190:O.type===So?Re=35056:Re=33189:O.type===Zi&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===Aa&&Re===6402&&O.type!==R1&&O.type!==Us&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=Us,_e=s.convert(O.type)),O.format===_o&&Re===6402&&(Re=34041,O.type!==So&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=So,_e=s.convert(O.type))),gn&&(Nt?e.texStorage2D(3553,1,Re,ue.width,ue.height):e.texImage2D(3553,0,Re,ue.width,ue.height,0,qe,_e,null));else if(O.isDataTexture)if(pt.length>0&&je){Nt&&gn&&e.texStorage2D(3553,Y,Re,pt[0].width,pt[0].height);for(let se=0,ye=pt.length;se<ye;se++)Ne=pt[se],Nt?e.texSubImage2D(3553,se,0,0,Ne.width,Ne.height,qe,_e,Ne.data):e.texImage2D(3553,se,Re,Ne.width,Ne.height,0,qe,_e,Ne.data);O.generateMipmaps=!1}else Nt?(gn&&e.texStorage2D(3553,Y,Re,ue.width,ue.height),e.texSubImage2D(3553,0,0,0,ue.width,ue.height,qe,_e,ue.data)):e.texImage2D(3553,0,Re,ue.width,ue.height,0,qe,_e,ue.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Nt&&gn&&e.texStorage3D(35866,Y,Re,pt[0].width,pt[0].height,ue.depth);for(let se=0,ye=pt.length;se<ye;se++)Ne=pt[se],O.format!==oi?qe!==null?Nt?e.compressedTexSubImage3D(35866,se,0,0,0,Ne.width,Ne.height,ue.depth,qe,Ne.data,0,0):e.compressedTexImage3D(35866,se,Re,Ne.width,Ne.height,ue.depth,0,Ne.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Nt?e.texSubImage3D(35866,se,0,0,0,Ne.width,Ne.height,ue.depth,qe,_e,Ne.data):e.texImage3D(35866,se,Re,Ne.width,Ne.height,ue.depth,0,qe,_e,Ne.data)}else{Nt&&gn&&e.texStorage2D(3553,Y,Re,pt[0].width,pt[0].height);for(let se=0,ye=pt.length;se<ye;se++)Ne=pt[se],O.format!==oi?qe!==null?Nt?e.compressedTexSubImage2D(3553,se,0,0,Ne.width,Ne.height,qe,Ne.data):e.compressedTexImage2D(3553,se,Re,Ne.width,Ne.height,0,Ne.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Nt?e.texSubImage2D(3553,se,0,0,Ne.width,Ne.height,qe,_e,Ne.data):e.texImage2D(3553,se,Re,Ne.width,Ne.height,0,qe,_e,Ne.data)}else if(O.isDataArrayTexture)Nt?(gn&&e.texStorage3D(35866,Y,Re,ue.width,ue.height,ue.depth),e.texSubImage3D(35866,0,0,0,0,ue.width,ue.height,ue.depth,qe,_e,ue.data)):e.texImage3D(35866,0,Re,ue.width,ue.height,ue.depth,0,qe,_e,ue.data);else if(O.isData3DTexture)Nt?(gn&&e.texStorage3D(32879,Y,Re,ue.width,ue.height,ue.depth),e.texSubImage3D(32879,0,0,0,0,ue.width,ue.height,ue.depth,qe,_e,ue.data)):e.texImage3D(32879,0,Re,ue.width,ue.height,ue.depth,0,qe,_e,ue.data);else if(O.isFramebufferTexture){if(gn)if(Nt)e.texStorage2D(3553,Y,Re,ue.width,ue.height);else{let se=ue.width,ye=ue.height;for(let Ce=0;Ce<Y;Ce++)e.texImage2D(3553,Ce,Re,se,ye,0,qe,_e,null),se>>=1,ye>>=1}}else if(pt.length>0&&je){Nt&&gn&&e.texStorage2D(3553,Y,Re,pt[0].width,pt[0].height);for(let se=0,ye=pt.length;se<ye;se++)Ne=pt[se],Nt?e.texSubImage2D(3553,se,0,0,qe,_e,Ne):e.texImage2D(3553,se,Re,qe,_e,Ne);O.generateMipmaps=!1}else Nt?(gn&&e.texStorage2D(3553,Y,Re,ue.width,ue.height),e.texSubImage2D(3553,0,0,0,qe,_e,ue)):e.texImage2D(3553,0,Re,qe,_e,ue);A(O,je)&&T(he),Ge.__version=Ie.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function J(L,O,ee){if(O.image.length!==6)return;let he=re(L,O),ge=O.source;e.bindTexture(34067,L.__webglTexture,33984+ee);let Ie=n.get(ge);if(ge.version!==Ie.__version||he===!0){e.activeTexture(33984+ee),r.pixelStorei(37440,O.flipY),r.pixelStorei(37441,O.premultiplyAlpha),r.pixelStorei(3317,O.unpackAlignment),r.pixelStorei(37443,0);let Ge=O.isCompressedTexture||O.image[0].isCompressedTexture,De=O.image[0]&&O.image[0].isDataTexture,ue=[];for(let se=0;se<6;se++)!Ge&&!De?ue[se]=x(O.image[se],!1,!0,u):ue[se]=De?O.image[se].image:O.image[se],ue[se]=ht(O,ue[se]);let je=ue[0],qe=b(je)||a,_e=s.convert(O.format,O.encoding),Re=s.convert(O.type),Ne=S(O.internalFormat,_e,Re,O.encoding),pt=a&&O.isVideoTexture!==!0,Nt=Ie.__version===void 0||he===!0,gn=E(O,je,qe);G(34067,O,qe);let Y;if(Ge){pt&&Nt&&e.texStorage2D(34067,gn,Ne,je.width,je.height);for(let se=0;se<6;se++){Y=ue[se].mipmaps;for(let ye=0;ye<Y.length;ye++){let Ce=Y[ye];O.format!==oi?_e!==null?pt?e.compressedTexSubImage2D(34069+se,ye,0,0,Ce.width,Ce.height,_e,Ce.data):e.compressedTexImage2D(34069+se,ye,Ne,Ce.width,Ce.height,0,Ce.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):pt?e.texSubImage2D(34069+se,ye,0,0,Ce.width,Ce.height,_e,Re,Ce.data):e.texImage2D(34069+se,ye,Ne,Ce.width,Ce.height,0,_e,Re,Ce.data)}}}else{Y=O.mipmaps,pt&&Nt&&(Y.length>0&&gn++,e.texStorage2D(34067,gn,Ne,ue[0].width,ue[0].height));for(let se=0;se<6;se++)if(De){pt?e.texSubImage2D(34069+se,0,0,0,ue[se].width,ue[se].height,_e,Re,ue[se].data):e.texImage2D(34069+se,0,Ne,ue[se].width,ue[se].height,0,_e,Re,ue[se].data);for(let ye=0;ye<Y.length;ye++){let Ue=Y[ye].image[se].image;pt?e.texSubImage2D(34069+se,ye+1,0,0,Ue.width,Ue.height,_e,Re,Ue.data):e.texImage2D(34069+se,ye+1,Ne,Ue.width,Ue.height,0,_e,Re,Ue.data)}}else{pt?e.texSubImage2D(34069+se,0,0,0,_e,Re,ue[se]):e.texImage2D(34069+se,0,Ne,_e,Re,ue[se]);for(let ye=0;ye<Y.length;ye++){let Ce=Y[ye];pt?e.texSubImage2D(34069+se,ye+1,0,0,_e,Re,Ce.image[se]):e.texImage2D(34069+se,ye+1,Ne,_e,Re,Ce.image[se])}}}A(O,qe)&&T(34067),Ie.__version=ge.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function V(L,O,ee,he,ge){let Ie=s.convert(ee.format,ee.encoding),Ge=s.convert(ee.type),De=S(ee.internalFormat,Ie,Ge,ee.encoding);n.get(O).__hasExternalTextures||(ge===32879||ge===35866?e.texImage3D(ge,0,De,O.width,O.height,O.depth,0,Ie,Ge,null):e.texImage2D(ge,0,De,O.width,O.height,0,Ie,Ge,null)),e.bindFramebuffer(36160,L),be(O)?h.framebufferTexture2DMultisampleEXT(36160,he,ge,n.get(ee).__webglTexture,0,Pe(O)):(ge===3553||ge>=34069&&ge<=34074)&&r.framebufferTexture2D(36160,he,ge,n.get(ee).__webglTexture,0),e.bindFramebuffer(36160,null)}function pe(L,O,ee){if(r.bindRenderbuffer(36161,L),O.depthBuffer&&!O.stencilBuffer){let he=33189;if(ee||be(O)){let ge=O.depthTexture;ge&&ge.isDepthTexture&&(ge.type===Zi?he=36012:ge.type===Us&&(he=33190));let Ie=Pe(O);be(O)?h.renderbufferStorageMultisampleEXT(36161,Ie,he,O.width,O.height):r.renderbufferStorageMultisample(36161,Ie,he,O.width,O.height)}else r.renderbufferStorage(36161,he,O.width,O.height);r.framebufferRenderbuffer(36160,36096,36161,L)}else if(O.depthBuffer&&O.stencilBuffer){let he=Pe(O);ee&&be(O)===!1?r.renderbufferStorageMultisample(36161,he,35056,O.width,O.height):be(O)?h.renderbufferStorageMultisampleEXT(36161,he,35056,O.width,O.height):r.renderbufferStorage(36161,34041,O.width,O.height),r.framebufferRenderbuffer(36160,33306,36161,L)}else{let he=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let ge=0;ge<he.length;ge++){let Ie=he[ge],Ge=s.convert(Ie.format,Ie.encoding),De=s.convert(Ie.type),ue=S(Ie.internalFormat,Ge,De,Ie.encoding),je=Pe(O);ee&&be(O)===!1?r.renderbufferStorageMultisample(36161,je,ue,O.width,O.height):be(O)?h.renderbufferStorageMultisampleEXT(36161,je,ue,O.width,O.height):r.renderbufferStorage(36161,ue,O.width,O.height)}}r.bindRenderbuffer(36161,null)}function ie(L,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,L),!(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),H(O.depthTexture,0);let he=n.get(O.depthTexture).__webglTexture,ge=Pe(O);if(O.depthTexture.format===Aa)be(O)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,he,0,ge):r.framebufferTexture2D(36160,36096,3553,he,0);else if(O.depthTexture.format===_o)be(O)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,he,0,ge):r.framebufferTexture2D(36160,33306,3553,he,0);else throw new Error("Unknown depthTexture format")}function ae(L){let O=n.get(L),ee=L.isWebGLCubeRenderTarget===!0;if(L.depthTexture&&!O.__autoAllocateDepthBuffer){if(ee)throw new Error("target.depthTexture not supported in Cube render targets");ie(O.__webglFramebuffer,L)}else if(ee){O.__webglDepthbuffer=[];for(let he=0;he<6;he++)e.bindFramebuffer(36160,O.__webglFramebuffer[he]),O.__webglDepthbuffer[he]=r.createRenderbuffer(),pe(O.__webglDepthbuffer[he],L,!1)}else e.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=r.createRenderbuffer(),pe(O.__webglDepthbuffer,L,!1);e.bindFramebuffer(36160,null)}function fe(L,O,ee){let he=n.get(L);O!==void 0&&V(he.__webglFramebuffer,L,L.texture,36064,3553),ee!==void 0&&ae(L)}function xe(L){let O=L.texture,ee=n.get(L),he=n.get(O);L.addEventListener("dispose",P),L.isWebGLMultipleRenderTargets!==!0&&(he.__webglTexture===void 0&&(he.__webglTexture=r.createTexture()),he.__version=O.version,o.memory.textures++);let ge=L.isWebGLCubeRenderTarget===!0,Ie=L.isWebGLMultipleRenderTargets===!0,Ge=b(L)||a;if(ge){ee.__webglFramebuffer=[];for(let De=0;De<6;De++)ee.__webglFramebuffer[De]=r.createFramebuffer()}else{if(ee.__webglFramebuffer=r.createFramebuffer(),Ie)if(i.drawBuffers){let De=L.texture;for(let ue=0,je=De.length;ue<je;ue++){let qe=n.get(De[ue]);qe.__webglTexture===void 0&&(qe.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&L.samples>0&&be(L)===!1){let De=Ie?O:[O];ee.__webglMultisampledFramebuffer=r.createFramebuffer(),ee.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ee.__webglMultisampledFramebuffer);for(let ue=0;ue<De.length;ue++){let je=De[ue];ee.__webglColorRenderbuffer[ue]=r.createRenderbuffer(),r.bindRenderbuffer(36161,ee.__webglColorRenderbuffer[ue]);let qe=s.convert(je.format,je.encoding),_e=s.convert(je.type),Re=S(je.internalFormat,qe,_e,je.encoding,L.isXRRenderTarget===!0),Ne=Pe(L);r.renderbufferStorageMultisample(36161,Ne,Re,L.width,L.height),r.framebufferRenderbuffer(36160,36064+ue,36161,ee.__webglColorRenderbuffer[ue])}r.bindRenderbuffer(36161,null),L.depthBuffer&&(ee.__webglDepthRenderbuffer=r.createRenderbuffer(),pe(ee.__webglDepthRenderbuffer,L,!0)),e.bindFramebuffer(36160,null)}}if(ge){e.bindTexture(34067,he.__webglTexture),G(34067,O,Ge);for(let De=0;De<6;De++)V(ee.__webglFramebuffer[De],L,O,36064,34069+De);A(O,Ge)&&T(34067),e.unbindTexture()}else if(Ie){let De=L.texture;for(let ue=0,je=De.length;ue<je;ue++){let qe=De[ue],_e=n.get(qe);e.bindTexture(3553,_e.__webglTexture),G(3553,qe,Ge),V(ee.__webglFramebuffer,L,qe,36064+ue,3553),A(qe,Ge)&&T(3553)}e.unbindTexture()}else{let De=3553;(L.isWebGL3DRenderTarget||L.isWebGLArrayRenderTarget)&&(a?De=L.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(De,he.__webglTexture),G(De,O,Ge),V(ee.__webglFramebuffer,L,O,36064,De),A(O,Ge)&&T(De),e.unbindTexture()}L.depthBuffer&&ae(L)}function me(L){let O=b(L)||a,ee=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let he=0,ge=ee.length;he<ge;he++){let Ie=ee[he];if(A(Ie,O)){let Ge=L.isWebGLCubeRenderTarget?34067:3553,De=n.get(Ie).__webglTexture;e.bindTexture(Ge,De),T(Ge),e.unbindTexture()}}}function Me(L){if(a&&L.samples>0&&be(L)===!1){let O=L.isWebGLMultipleRenderTargets?L.texture:[L.texture],ee=L.width,he=L.height,ge=16384,Ie=[],Ge=L.stencilBuffer?33306:36096,De=n.get(L),ue=L.isWebGLMultipleRenderTargets===!0;if(ue)for(let je=0;je<O.length;je++)e.bindFramebuffer(36160,De.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+je,36161,null),e.bindFramebuffer(36160,De.__webglFramebuffer),r.framebufferTexture2D(36009,36064+je,3553,null,0);e.bindFramebuffer(36008,De.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,De.__webglFramebuffer);for(let je=0;je<O.length;je++){Ie.push(36064+je),L.depthBuffer&&Ie.push(Ge);let qe=De.__ignoreDepthValues!==void 0?De.__ignoreDepthValues:!1;if(qe===!1&&(L.depthBuffer&&(ge|=256),L.stencilBuffer&&(ge|=1024)),ue&&r.framebufferRenderbuffer(36008,36064,36161,De.__webglColorRenderbuffer[je]),qe===!0&&(r.invalidateFramebuffer(36008,[Ge]),r.invalidateFramebuffer(36009,[Ge])),ue){let _e=n.get(O[je]).__webglTexture;r.framebufferTexture2D(36009,36064,3553,_e,0)}r.blitFramebuffer(0,0,ee,he,0,0,ee,he,ge,9728),f&&r.invalidateFramebuffer(36008,Ie)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),ue)for(let je=0;je<O.length;je++){e.bindFramebuffer(36160,De.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+je,36161,De.__webglColorRenderbuffer[je]);let qe=n.get(O[je]).__webglTexture;e.bindFramebuffer(36160,De.__webglFramebuffer),r.framebufferTexture2D(36009,36064+je,3553,qe,0)}e.bindFramebuffer(36009,De.__webglMultisampledFramebuffer)}}function Pe(L){return Math.min(d,L.samples)}function be(L){let O=n.get(L);return a&&L.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Fe(L){let O=o.render.frame;g.get(L)!==O&&(g.set(L,O),L.update())}function ht(L,O){let ee=L.encoding,he=L.format,ge=L.type;return L.isCompressedTexture===!0||L.isVideoTexture===!0||L.format===Nv||ee!==jr&&(ee===Xe?a===!1?t.has("EXT_sRGB")===!0&&he===oi?(L.format=Nv,L.minFilter=st,L.generateMipmaps=!1):O=lp.sRGBToLinear(O):(he!==oi||ge!==kt)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ee)),O}this.allocateTextureUnit=W,this.resetTextureUnits=X,this.setTexture2D=H,this.setTexture2DArray=K,this.setTexture3D=R,this.setTextureCube=U,this.rebindTextures=fe,this.setupRenderTarget=xe,this.updateRenderTargetMipmap=me,this.updateMultisampleRenderTarget=Me,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=V,this.useMultisampledRTT=be}function oN(r,t,e){let n=e.isWebGL2;function i(s,o=null){let a;if(s===kt)return 5121;if(s===QI)return 32819;if(s===JI)return 32820;if(s===YI)return 5120;if(s===KI)return 5122;if(s===R1)return 5123;if(s===ZI)return 5124;if(s===Us)return 5125;if(s===Zi)return 5126;if(s===Md)return n?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===$I)return 6406;if(s===oi)return 6408;if(s===eD)return 6409;if(s===tD)return 6410;if(s===Aa)return 6402;if(s===_o)return 34041;if(s===Nv)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===nD)return 6403;if(s===rD)return 36244;if(s===iD)return 33319;if(s===sD)return 33320;if(s===oD)return 36249;if(s===Yy||s===Ky||s===Zy||s===Qy)if(o===Xe)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Yy)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ky)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Zy)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Qy)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Yy)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ky)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Zy)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Qy)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===sw||s===ow||s===aw||s===lw)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===sw)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===ow)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===aw)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===lw)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===aD)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===cw||s===uw)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===cw)return o===Xe?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===uw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===dw||s===hw||s===fw||s===pw||s===mw||s===gw||s===yw||s===vw||s===xw||s===bw||s===Sw||s===ww||s===Aw||s===_w)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===dw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===hw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===fw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===pw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===mw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===gw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===yw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===vw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===xw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===bw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Sw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===ww)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Aw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===_w)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Jy)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===Jy)return o===Xe?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===lD||s===Tw||s===Ew||s===Mw)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===Jy)return a.COMPRESSED_RED_RGTC1_EXT;if(s===Tw)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Ew)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Mw)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===So?n?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}var qv=class extends cn{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},Qi=class extends ut{constructor(){super(),this.isGroup=!0,this.type="Group"}},aN={type:"move"},_d=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Qi,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 Qi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new _,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new _),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Qi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new _,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new _),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 i=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 p of t.hand.values()){let m=e.getJointPose(p,n),y=this._getHandJoint(u,p);m!==null&&(y.matrix.fromArray(m.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=m.radius),y.visible=m!==null}let c=u.joints["index-finger-tip"],d=u.joints["thumb-tip"],h=c.position.distanceTo(d.position),f=.02,g=.005;u.inputState.pinching&&h>f+g?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&h<=f-g&&(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&&(i=e.getPose(t.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(aN)))}return a!==null&&(a.visible=i!==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 Qi;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},Eo=class extends Gt{constructor(t,e,n,i,s,o,a,l,u,c){if(c=c!==void 0?c:Aa,c!==Aa&&c!==_o)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===Aa&&(n=Us),n===void 0&&c===_o&&(n=So),super(null,i,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Bt,this.minFilter=l!==void 0?l:Bt,this.flipY=!1,this.generateMipmaps=!1}},Xv=class extends Wt{constructor(t,e){super();let n=this,i=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,d=null,h=null,f=null,g=null,p=e.getContextAttributes(),m=null,y=null,v=[],x=[],b=new Set,w=new Map,A=new cn;A.layers.enable(1),A.viewport=new Qe;let T=new cn;T.layers.enable(2),T.viewport=new Qe;let S=[A,T],E=new qv;E.layers.enable(1),E.layers.enable(2);let M=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(R){let U=v[R];return U===void 0&&(U=new _d,v[R]=U),U.getTargetRaySpace()},this.getControllerGrip=function(R){let U=v[R];return U===void 0&&(U=new _d,v[R]=U),U.getGripSpace()},this.getHand=function(R){let U=v[R];return U===void 0&&(U=new _d,v[R]=U),U.getHandSpace()};function P(R){let U=x.indexOf(R.inputSource);if(U===-1)return;let z=v[U];z!==void 0&&z.dispatchEvent({type:R.type,data:R.inputSource})}function C(){i.removeEventListener("select",P),i.removeEventListener("selectstart",P),i.removeEventListener("selectend",P),i.removeEventListener("squeeze",P),i.removeEventListener("squeezestart",P),i.removeEventListener("squeezeend",P),i.removeEventListener("end",C),i.removeEventListener("inputsourceschange",D);for(let R=0;R<v.length;R++){let U=x[R];U!==null&&(x[R]=null,v[R].disconnect(U))}M=null,I=null,t.setRenderTarget(m),f=null,h=null,d=null,i=null,y=null,K.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(R){s=R,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(R){a=R,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(R){u=R},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(R){if(i=R,i!==null){if(m=t.getRenderTarget(),i.addEventListener("select",P),i.addEventListener("selectstart",P),i.addEventListener("selectend",P),i.addEventListener("squeeze",P),i.addEventListener("squeezestart",P),i.addEventListener("squeezeend",P),i.addEventListener("end",C),i.addEventListener("inputsourceschange",D),p.xrCompatible!==!0&&await e.makeXRCompatible(),i.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let U={antialias:i.renderState.layers===void 0?p.antialias:!0,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,e,U),i.updateRenderState({baseLayer:f}),y=new At(f.framebufferWidth,f.framebufferHeight,{format:oi,type:kt,encoding:t.outputEncoding,stencilBuffer:p.stencil})}else{let U=null,z=null,j=null;p.depth&&(j=p.stencil?35056:33190,U=p.stencil?_o:Aa,z=p.stencil?So:Us);let G={colorFormat:32856,depthFormat:j,scaleFactor:s};d=new XRWebGLBinding(i,e),h=d.createProjectionLayer(G),i.updateRenderState({layers:[h]}),y=new At(h.textureWidth,h.textureHeight,{format:oi,type:kt,depthTexture:new Eo(h.textureWidth,h.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,U),stencilBuffer:p.stencil,encoding:t.outputEncoding,samples:p.antialias?4:0});let re=t.properties.get(y);re.__ignoreDepthValues=h.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await i.requestReferenceSpace(a),K.setContext(i),K.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function D(R){for(let U=0;U<R.removed.length;U++){let z=R.removed[U],j=x.indexOf(z);j>=0&&(x[j]=null,v[j].disconnect(z))}for(let U=0;U<R.added.length;U++){let z=R.added[U],j=x.indexOf(z);if(j===-1){for(let re=0;re<v.length;re++)if(re>=x.length){x.push(z),j=re;break}else if(x[re]===null){x[re]=z,j=re;break}if(j===-1)break}let G=v[j];G&&G.connect(z)}}let B=new _,k=new _;function X(R,U,z){B.setFromMatrixPosition(U.matrixWorld),k.setFromMatrixPosition(z.matrixWorld);let j=B.distanceTo(k),G=U.projectionMatrix.elements,re=z.projectionMatrix.elements,Z=G[14]/(G[10]-1),J=G[14]/(G[10]+1),V=(G[9]+1)/G[5],pe=(G[9]-1)/G[5],ie=(G[8]-1)/G[0],ae=(re[8]+1)/re[0],fe=Z*ie,xe=Z*ae,me=j/(-ie+ae),Me=me*-ie;U.matrixWorld.decompose(R.position,R.quaternion,R.scale),R.translateX(Me),R.translateZ(me),R.matrixWorld.compose(R.position,R.quaternion,R.scale),R.matrixWorldInverse.copy(R.matrixWorld).invert();let Pe=Z+me,be=J+me,Fe=fe-Me,ht=xe+(j-Me),L=V*J/be*Pe,O=pe*J/be*Pe;R.projectionMatrix.makePerspective(Fe,ht,L,O,Pe,be)}function W(R,U){U===null?R.matrixWorld.copy(R.matrix):R.matrixWorld.multiplyMatrices(U.matrixWorld,R.matrix),R.matrixWorldInverse.copy(R.matrixWorld).invert()}this.updateCamera=function(R){if(i===null)return;E.near=T.near=A.near=R.near,E.far=T.far=A.far=R.far,(M!==E.near||I!==E.far)&&(i.updateRenderState({depthNear:E.near,depthFar:E.far}),M=E.near,I=E.far);let U=R.parent,z=E.cameras;W(E,U);for(let G=0;G<z.length;G++)W(z[G],U);E.matrixWorld.decompose(E.position,E.quaternion,E.scale),R.matrix.copy(E.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale);let j=R.children;for(let G=0,re=j.length;G<re;G++)j[G].updateMatrixWorld(!0);z.length===2?X(E,A,T):E.projectionMatrix.copy(A.projectionMatrix)},this.getCamera=function(){return E},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(R){l=R,h!==null&&(h.fixedFoveation=R),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=R)},this.getPlanes=function(){return b};let q=null;function H(R,U){if(c=U.getViewerPose(u||o),g=U,c!==null){let z=c.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let j=!1;z.length!==E.cameras.length&&(E.cameras.length=0,j=!0);for(let G=0;G<z.length;G++){let re=z[G],Z=null;if(f!==null)Z=f.getViewport(re);else{let V=d.getViewSubImage(h,re);Z=V.viewport,G===0&&(t.setRenderTargetTextures(y,V.colorTexture,h.ignoreDepthValues?void 0:V.depthStencilTexture),t.setRenderTarget(y))}let J=S[G];J===void 0&&(J=new cn,J.layers.enable(G),J.viewport=new Qe,S[G]=J),J.matrix.fromArray(re.transform.matrix),J.projectionMatrix.fromArray(re.projectionMatrix),J.viewport.set(Z.x,Z.y,Z.width,Z.height),G===0&&E.matrix.copy(J.matrix),j===!0&&E.cameras.push(J)}}for(let z=0;z<v.length;z++){let j=x[z],G=v[z];j!==null&&G!==void 0&&G.update(j,U,u||o)}if(q&&q(R,U),U.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:U.detectedPlanes});let z=null;for(let j of b)U.detectedPlanes.has(j)||(z===null&&(z=[]),z.push(j));if(z!==null)for(let j of z)b.delete(j),w.delete(j),n.dispatchEvent({type:"planeremoved",data:j});for(let j of U.detectedPlanes)if(!b.has(j))b.add(j),w.set(j,U.lastChangedTime),n.dispatchEvent({type:"planeadded",data:j});else{let G=w.get(j);j.lastChangedTime>G&&(w.set(j,j.lastChangedTime),n.dispatchEvent({type:"planechanged",data:j}))}}g=null}let K=new U1;K.setAnimationLoop(H),this.setAnimationLoop=function(R){q=R},this.dispose=function(){}}};function lN(r,t){function e(p,m){m.color.getRGB(p.fogColor.value,F1(r)),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function n(p,m,y,v,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?i(p,m):m.isMeshToonMaterial?(i(p,m),c(p,m)):m.isMeshPhongMaterial?(i(p,m),u(p,m)):m.isMeshStandardMaterial?(i(p,m),d(p,m),m.isMeshPhysicalMaterial&&h(p,m,x)):m.isMeshMatcapMaterial?(i(p,m),f(p,m)):m.isMeshDepthMaterial?i(p,m):m.isMeshDistanceMaterial?(i(p,m),g(p,m)):m.isMeshNormalMaterial?i(p,m):m.isLineBasicMaterial?(s(p,m),m.isLineDashedMaterial&&o(p,m)):m.isPointsMaterial?a(p,m,y,v):m.isSpriteMaterial?l(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function i(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.bumpMap&&(p.bumpMap.value=m.bumpMap,p.bumpScale.value=m.bumpScale,m.side===bn&&(p.bumpScale.value*=-1)),m.displacementMap&&(p.displacementMap.value=m.displacementMap,p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap),m.normalMap&&(p.normalMap.value=m.normalMap,p.normalScale.value.copy(m.normalScale),m.side===bn&&p.normalScale.value.negate()),m.specularMap&&(p.specularMap.value=m.specularMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let y=t.get(m).envMap;if(y&&(p.envMap.value=y,p.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap){p.lightMap.value=m.lightMap;let b=r.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=m.lightMapIntensity*b}m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity);let v;m.map?v=m.map:m.specularMap?v=m.specularMap:m.displacementMap?v=m.displacementMap:m.normalMap?v=m.normalMap:m.bumpMap?v=m.bumpMap:m.roughnessMap?v=m.roughnessMap:m.metalnessMap?v=m.metalnessMap:m.alphaMap?v=m.alphaMap:m.emissiveMap?v=m.emissiveMap:m.clearcoatMap?v=m.clearcoatMap:m.clearcoatNormalMap?v=m.clearcoatNormalMap:m.clearcoatRoughnessMap?v=m.clearcoatRoughnessMap:m.iridescenceMap?v=m.iridescenceMap:m.iridescenceThicknessMap?v=m.iridescenceThicknessMap:m.specularIntensityMap?v=m.specularIntensityMap:m.specularColorMap?v=m.specularColorMap:m.transmissionMap?v=m.transmissionMap:m.thicknessMap?v=m.thicknessMap:m.sheenColorMap?v=m.sheenColorMap:m.sheenRoughnessMap&&(v=m.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix));let x;m.aoMap?x=m.aoMap:m.lightMap&&(x=m.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uv2Transform.value.copy(x.matrix))}function s(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity}function o(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function a(p,m,y,v){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*y,p.scale.value=v*.5,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let x;m.map?x=m.map:m.alphaMap&&(x=m.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uvTransform.value.copy(x.matrix))}function l(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let y;m.map?y=m.map:m.alphaMap&&(y=m.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix))}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function c(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function d(p,m){p.roughness.value=m.roughness,p.metalness.value=m.metalness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function h(p,m,y){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),p.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===bn&&p.clearcoatNormalScale.value.negate())),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap)}function f(p,m){m.matcap&&(p.matcap.value=m.matcap)}function g(p,m){p.referencePosition.value.copy(m.referencePosition),p.nearDistance.value=m.nearDistance,p.farDistance.value=m.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:n}}function cN(r,t,e,n){let i={},s={},o=[],a=e.isWebGL2?r.getParameter(35375):0;function l(v,x){let b=x.program;n.uniformBlockBinding(v,b)}function u(v,x){let b=i[v.id];b===void 0&&(g(v),b=c(v),i[v.id]=b,v.addEventListener("dispose",m));let w=x.program;n.updateUBOMapping(v,w);let A=t.render.frame;s[v.id]!==A&&(h(v),s[v.id]=A)}function c(v){let x=d();v.__bindingPointIndex=x;let b=r.createBuffer(),w=v.__size,A=v.usage;return r.bindBuffer(35345,b),r.bufferData(35345,w,A),r.bindBuffer(35345,null),r.bindBufferBase(35345,x,b),b}function d(){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 h(v){let x=i[v.id],b=v.uniforms,w=v.__cache;r.bindBuffer(35345,x);for(let A=0,T=b.length;A<T;A++){let S=b[A];if(f(S,A,w)===!0){let E=S.__offset,M=Array.isArray(S.value)?S.value:[S.value],I=0;for(let P=0;P<M.length;P++){let C=M[P],D=p(C);typeof C=="number"?(S.__data[0]=C,r.bufferSubData(35345,E+I,S.__data)):C.isMatrix3?(S.__data[0]=C.elements[0],S.__data[1]=C.elements[1],S.__data[2]=C.elements[2],S.__data[3]=C.elements[0],S.__data[4]=C.elements[3],S.__data[5]=C.elements[4],S.__data[6]=C.elements[5],S.__data[7]=C.elements[0],S.__data[8]=C.elements[6],S.__data[9]=C.elements[7],S.__data[10]=C.elements[8],S.__data[11]=C.elements[0]):(C.toArray(S.__data,I),I+=D.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(35345,E,S.__data)}}r.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 A=Array.isArray(w)?w:[w],T=[];for(let S=0;S<A.length;S++)T.push(A[S].clone());b[x]=T}return!0}else if(typeof w=="number"){if(b[x]!==w)return b[x]=w,!0}else{let A=Array.isArray(b[x])?b[x]:[b[x]],T=Array.isArray(w)?w:[w];for(let S=0;S<A.length;S++){let E=A[S];if(E.equals(T[S])===!1)return E.copy(T[S]),!0}}return!1}function g(v){let x=v.uniforms,b=0,w=16,A=0;for(let T=0,S=x.length;T<S;T++){let E=x[T],M={boundary:0,storage:0},I=Array.isArray(E.value)?E.value:[E.value];for(let P=0,C=I.length;P<C;P++){let D=I[P],B=p(D);M.boundary+=B.boundary,M.storage+=B.storage}if(E.__data=new Float32Array(M.storage/Float32Array.BYTES_PER_ELEMENT),E.__offset=b,T>0){A=b%w;let P=w-A;A!==0&&P-M.boundary<0&&(b+=w-A,E.__offset=b)}b+=M.storage}return A=b%w,A>0&&(b+=w-A),v.__size=b,v.__cache={},this}function p(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 m(v){let x=v.target;x.removeEventListener("dispose",m);let b=o.indexOf(x.__bindingPointIndex);o.splice(b,1),r.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function y(){for(let v in i)r.deleteBuffer(i[v]);o=[],i={},s={}}return{bind:l,update:u,dispose:y}}function uN(){let r=ap("canvas");return r.style.display="block",r}function v0(r={}){this.isWebGLRenderer=!0;let t=r.canvas!==void 0?r.canvas:uN(),e=r.context!==void 0?r.context:null,n=r.depth!==void 0?r.depth:!0,i=r.stencil!==void 0?r.stencil:!0,s=r.antialias!==void 0?r.antialias:!1,o=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,a=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,l=r.powerPreference!==void 0?r.powerPreference:"default",u=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,c;e!==null?c=e.getContextAttributes().alpha:c=r.alpha!==void 0?r.alpha:!1;let d=null,h=null,f=[],g=[];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=jr,this.physicallyCorrectLights=!1,this.toneMapping=ks,this.toneMappingExposure=1;let p=this,m=!1,y=0,v=0,x=null,b=-1,w=null,A=new Qe,T=new Qe,S=null,E=t.width,M=t.height,I=1,P=null,C=null,D=new Qe(0,0,E,M),B=new Qe(0,0,E,M),k=!1,X=new Dd,W=!1,q=!1,H=null,K=new de,R=new F,U=new _,z={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function j(){return x===null?I:1}let G=e;function re(N,te){for(let oe=0;oe<N.length;oe++){let $=N[oe],ce=t.getContext($,te);if(ce!==null)return ce}return null}try{let N={alpha:!0,depth:n,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ws}`),t.addEventListener("webglcontextlost",Re,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",pt,!1),G===null){let te=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&te.shift(),G=re(te,N),G===null)throw re(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}G.getShaderPrecisionFormat===void 0&&(G.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let Z,J,V,pe,ie,ae,fe,xe,me,Me,Pe,be,Fe,ht,L,O,ee,he,ge,Ie,Ge,De,ue,je;function qe(){Z=new DR(G),J=new TR(G,Z,r),Z.init(J),De=new oN(G,Z,J),V=new iN(G,Z,J),pe=new RR,ie=new q3,ae=new sN(G,Z,V,ie,J,De,pe),fe=new MR(p),xe=new IR(p),me=new HD(G,J),ue=new AR(G,Z,me,J),Me=new OR(G,me,pe,ue),Pe=new UR(G,Me,me,pe),ge=new FR(G,J,ae),O=new ER(ie),be=new j3(p,fe,xe,Z,J,ue,O),Fe=new lN(p,ie),ht=new Y3,L=new eN(Z,J),he=new wR(p,fe,xe,V,Pe,c,o),ee=new rN(p,Pe,J),je=new cN(G,pe,J,V),Ie=new _R(G,Z,pe,J),Ge=new LR(G,Z,pe,J),pe.programs=be.programs,p.capabilities=J,p.extensions=Z,p.properties=ie,p.renderLists=ht,p.shadowMap=ee,p.state=V,p.info=pe}qe();let _e=new Xv(p,G);this.xr=_e,this.getContext=function(){return G},this.getContextAttributes=function(){return G.getContextAttributes()},this.forceContextLoss=function(){let N=Z.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){let N=Z.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(N){N!==void 0&&(I=N,this.setSize(E,M,!1))},this.getSize=function(N){return N.set(E,M)},this.setSize=function(N,te,oe){if(_e.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}E=N,M=te,t.width=Math.floor(N*I),t.height=Math.floor(te*I),oe!==!1&&(t.style.width=N+"px",t.style.height=te+"px"),this.setViewport(0,0,N,te)},this.getDrawingBufferSize=function(N){return N.set(E*I,M*I).floor()},this.setDrawingBufferSize=function(N,te,oe){E=N,M=te,I=oe,t.width=Math.floor(N*oe),t.height=Math.floor(te*oe),this.setViewport(0,0,N,te)},this.getCurrentViewport=function(N){return N.copy(A)},this.getViewport=function(N){return N.copy(D)},this.setViewport=function(N,te,oe,$){N.isVector4?D.set(N.x,N.y,N.z,N.w):D.set(N,te,oe,$),V.viewport(A.copy(D).multiplyScalar(I).floor())},this.getScissor=function(N){return N.copy(B)},this.setScissor=function(N,te,oe,$){N.isVector4?B.set(N.x,N.y,N.z,N.w):B.set(N,te,oe,$),V.scissor(T.copy(B).multiplyScalar(I).floor())},this.getScissorTest=function(){return k},this.setScissorTest=function(N){V.setScissorTest(k=N)},this.setOpaqueSort=function(N){P=N},this.setTransparentSort=function(N){C=N},this.getClearColor=function(N){return N.copy(he.getClearColor())},this.setClearColor=function(){he.setClearColor.apply(he,arguments)},this.getClearAlpha=function(){return he.getClearAlpha()},this.setClearAlpha=function(){he.setClearAlpha.apply(he,arguments)},this.clear=function(N=!0,te=!0,oe=!0){let $=0;N&&($|=16384),te&&($|=256),oe&&($|=1024),G.clear($)},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",Re,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",pt,!1),ht.dispose(),L.dispose(),ie.dispose(),fe.dispose(),xe.dispose(),Pe.dispose(),ue.dispose(),je.dispose(),be.dispose(),_e.dispose(),_e.removeEventListener("sessionstart",Ce),_e.removeEventListener("sessionend",Ue),H&&(H.dispose(),H=null),tt.stop()};function Re(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let N=pe.autoReset,te=ee.enabled,oe=ee.autoUpdate,$=ee.needsUpdate,ce=ee.type;qe(),pe.autoReset=N,ee.enabled=te,ee.autoUpdate=oe,ee.needsUpdate=$,ee.type=ce}function pt(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function Nt(N){let te=N.target;te.removeEventListener("dispose",Nt),gn(te)}function gn(N){Y(N),ie.remove(N)}function Y(N){let te=ie.get(N).programs;te!==void 0&&(te.forEach(function(oe){be.releaseProgram(oe)}),N.isShaderMaterial&&be.releaseShaderCache(N))}this.renderBufferDirect=function(N,te,oe,$,ce,Ze){te===null&&(te=z);let it=ce.isMesh&&ce.matrixWorld.determinant()<0,at=lI(N,te,oe,$,ce);V.setMaterial($,it);let ct=oe.index,wt=1;$.wireframe===!0&&(ct=Me.getWireframeAttribute(oe),wt=2);let mt=oe.drawRange,gt=oe.attributes.position,yn=mt.start*wt,kr=(mt.start+mt.count)*wt;Ze!==null&&(yn=Math.max(yn,Ze.start*wt),kr=Math.min(kr,(Ze.start+Ze.count)*wt)),ct!==null?(yn=Math.max(yn,0),kr=Math.min(kr,ct.count)):gt!=null&&(yn=Math.max(yn,0),kr=Math.min(kr,gt.count));let Ds=kr-yn;if(Ds<0||Ds===1/0)return;ue.setup(ce,$,at,oe,ct);let ma,vn=Ie;if(ct!==null&&(ma=me.get(ct),vn=Ge,vn.setIndex(ma)),ce.isMesh)$.wireframe===!0?(V.setLineWidth($.wireframeLinewidth*j()),vn.setMode(1)):vn.setMode(4);else if(ce.isLine){let yt=$.linewidth;yt===void 0&&(yt=1),V.setLineWidth(yt*j()),ce.isLineSegments?vn.setMode(1):ce.isLineLoop?vn.setMode(2):vn.setMode(3)}else ce.isPoints?vn.setMode(0):ce.isSprite&&vn.setMode(4);if(ce.isInstancedMesh)vn.renderInstances(yn,Ds,ce.count);else if(oe.isInstancedBufferGeometry){let yt=oe._maxInstanceCount!==void 0?oe._maxInstanceCount:1/0,Vy=Math.min(oe.instanceCount,yt);vn.renderInstances(yn,Ds,Vy)}else vn.render(yn,Ds)},this.compile=function(N,te){function oe($,ce,Ze){$.transparent===!0&&$.side===fr&&$.forceSinglePass===!1?($.side=bn,$.needsUpdate=!0,ii($,ce,Ze),$.side=Wr,$.needsUpdate=!0,ii($,ce,Ze),$.side=fr):ii($,ce,Ze)}h=L.get(N),h.init(),g.push(h),N.traverseVisible(function($){$.isLight&&$.layers.test(te.layers)&&(h.pushLight($),$.castShadow&&h.pushShadow($))}),h.setupLights(p.physicallyCorrectLights),N.traverse(function($){let ce=$.material;if(ce)if(Array.isArray(ce))for(let Ze=0;Ze<ce.length;Ze++){let it=ce[Ze];oe(it,N,$)}else oe(ce,N,$)}),g.pop(),h=null};let se=null;function ye(N){se&&se(N)}function Ce(){tt.stop()}function Ue(){tt.start()}let tt=new U1;tt.setAnimationLoop(ye),typeof self<"u"&&tt.setContext(self),this.setAnimationLoop=function(N){se=N,_e.setAnimationLoop(N),N===null?tt.stop():tt.start()},_e.addEventListener("sessionstart",Ce),_e.addEventListener("sessionend",Ue),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(m===!0)return;N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),_e.enabled===!0&&_e.isPresenting===!0&&(_e.cameraAutoUpdate===!0&&_e.updateCamera(te),te=_e.getCamera()),N.isScene===!0&&N.onBeforeRender(p,N,te,x),h=L.get(N,g.length),h.init(),g.push(h),K.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),X.setFromProjectionMatrix(K),q=this.localClippingEnabled,W=O.init(this.clippingPlanes,q),d=ht.get(N,f.length),d.init(),f.push(d),$t(N,te,0,p.sortObjects),d.finish(),p.sortObjects===!0&&d.sort(P,C),W===!0&&O.beginShadows();let oe=h.state.shadowsArray;if(ee.render(oe,N,te),W===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),he.render(d,N),h.setupLights(p.physicallyCorrectLights),te.isArrayCamera){let $=te.cameras;for(let ce=0,Ze=$.length;ce<Ze;ce++){let it=$[ce];Nn(d,N,it,it.viewport)}}else Nn(d,N,te);x!==null&&(ae.updateMultisampleRenderTarget(x),ae.updateRenderTargetMipmap(x)),N.isScene===!0&&N.onAfterRender(p,N,te),ue.resetDefaultState(),b=-1,w=null,g.pop(),g.length>0?h=g[g.length-1]:h=null,f.pop(),f.length>0?d=f[f.length-1]:d=null};function $t(N,te,oe,$){if(N.visible===!1)return;if(N.layers.test(te.layers)){if(N.isGroup)oe=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(te);else if(N.isLight)h.pushLight(N),N.castShadow&&h.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||X.intersectsSprite(N)){$&&U.setFromMatrixPosition(N.matrixWorld).applyMatrix4(K);let it=Pe.update(N),at=N.material;at.visible&&d.push(N,it,at,oe,U.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==pe.render.frame&&(N.skeleton.update(),N.skeleton.frame=pe.render.frame),!N.frustumCulled||X.intersectsObject(N))){$&&U.setFromMatrixPosition(N.matrixWorld).applyMatrix4(K);let it=Pe.update(N),at=N.material;if(Array.isArray(at)){let ct=it.groups;for(let wt=0,mt=ct.length;wt<mt;wt++){let gt=ct[wt],yn=at[gt.materialIndex];yn&&yn.visible&&d.push(N,it,yn,oe,U.z,gt)}}else at.visible&&d.push(N,it,at,oe,U.z,null)}}let Ze=N.children;for(let it=0,at=Ze.length;it<at;it++)$t(Ze[it],te,oe,$)}function Nn(N,te,oe,$){let ce=N.opaque,Ze=N.transmissive,it=N.transparent;h.setupLightsView(oe),W===!0&&O.setGlobalState(p.clippingPlanes,oe),Ze.length>0&&ri(ce,te,oe),$&&V.viewport(A.copy($)),ce.length>0&&Ht(ce,te,oe),Ze.length>0&&Ht(Ze,te,oe),it.length>0&&Ht(it,te,oe),V.buffers.depth.setTest(!0),V.buffers.depth.setMask(!0),V.buffers.color.setMask(!0),V.setPolygonOffset(!1)}function ri(N,te,oe){let $=J.isWebGL2;H===null&&(H=new At(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")?Md:kt,minFilter:Ta,samples:$&&s===!0?4:0})),p.getDrawingBufferSize(R),$?H.setSize(R.x,R.y):H.setSize(op(R.x),op(R.y));let ce=p.getRenderTarget();p.setRenderTarget(H),p.clear();let Ze=p.toneMapping;p.toneMapping=ks,Ht(N,te,oe),p.toneMapping=Ze,ae.updateMultisampleRenderTarget(H),ae.updateRenderTargetMipmap(H),p.setRenderTarget(ce)}function Ht(N,te,oe){let $=te.isScene===!0?te.overrideMaterial:null;for(let ce=0,Ze=N.length;ce<Ze;ce++){let it=N[ce],at=it.object,ct=it.geometry,wt=$===null?it.material:$,mt=it.group;at.layers.test(oe.layers)&&Is(at,te,oe,ct,wt,mt)}}function Is(N,te,oe,$,ce,Ze){N.onBeforeRender(p,te,oe,$,ce,Ze),N.modelViewMatrix.multiplyMatrices(oe.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),ce.onBeforeRender(p,te,oe,$,N,Ze),ce.transparent===!0&&ce.side===fr&&ce.forceSinglePass===!1?(ce.side=bn,ce.needsUpdate=!0,p.renderBufferDirect(oe,te,$,ce,N,Ze),ce.side=Wr,ce.needsUpdate=!0,p.renderBufferDirect(oe,te,$,ce,N,Ze),ce.side=fr):p.renderBufferDirect(oe,te,$,ce,N,Ze),N.onAfterRender(p,te,oe,$,ce,Ze)}function ii(N,te,oe){te.isScene!==!0&&(te=z);let $=ie.get(N),ce=h.state.lights,Ze=h.state.shadowsArray,it=ce.state.version,at=be.getParameters(N,ce.state,Ze,te,oe),ct=be.getProgramCacheKey(at),wt=$.programs;$.environment=N.isMeshStandardMaterial?te.environment:null,$.fog=te.fog,$.envMap=(N.isMeshStandardMaterial?xe:fe).get(N.envMap||$.environment),wt===void 0&&(N.addEventListener("dispose",Nt),wt=new Map,$.programs=wt);let mt=wt.get(ct);if(mt!==void 0){if($.currentProgram===mt&&$.lightsStateVersion===it)return KS(N,at),mt}else at.uniforms=be.getUniforms(N),N.onBuild(oe,at,p),N.onBeforeCompile(at,p),mt=be.acquireProgram(at,ct),wt.set(ct,mt),$.uniforms=at.uniforms;let gt=$.uniforms;(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(gt.clippingPlanes=O.uniform),KS(N,at),$.needsLights=uI(N),$.lightsStateVersion=it,$.needsLights&&(gt.ambientLightColor.value=ce.state.ambient,gt.lightProbe.value=ce.state.probe,gt.directionalLights.value=ce.state.directional,gt.directionalLightShadows.value=ce.state.directionalShadow,gt.spotLights.value=ce.state.spot,gt.spotLightShadows.value=ce.state.spotShadow,gt.rectAreaLights.value=ce.state.rectArea,gt.ltc_1.value=ce.state.rectAreaLTC1,gt.ltc_2.value=ce.state.rectAreaLTC2,gt.pointLights.value=ce.state.point,gt.pointLightShadows.value=ce.state.pointShadow,gt.hemisphereLights.value=ce.state.hemi,gt.directionalShadowMap.value=ce.state.directionalShadowMap,gt.directionalShadowMatrix.value=ce.state.directionalShadowMatrix,gt.spotShadowMap.value=ce.state.spotShadowMap,gt.spotLightMatrix.value=ce.state.spotLightMatrix,gt.spotLightMap.value=ce.state.spotLightMap,gt.pointShadowMap.value=ce.state.pointShadowMap,gt.pointShadowMatrix.value=ce.state.pointShadowMatrix);let yn=mt.getUniforms(),kr=Bl.seqWithValue(yn.seq,gt);return $.currentProgram=mt,$.uniformsList=kr,mt}function KS(N,te){let oe=ie.get(N);oe.outputEncoding=te.outputEncoding,oe.instancing=te.instancing,oe.skinning=te.skinning,oe.morphTargets=te.morphTargets,oe.morphNormals=te.morphNormals,oe.morphColors=te.morphColors,oe.morphTargetsCount=te.morphTargetsCount,oe.numClippingPlanes=te.numClippingPlanes,oe.numIntersection=te.numClipIntersection,oe.vertexAlphas=te.vertexAlphas,oe.vertexTangents=te.vertexTangents,oe.toneMapping=te.toneMapping}function lI(N,te,oe,$,ce){te.isScene!==!0&&(te=z),ae.resetTextureUnits();let Ze=te.fog,it=$.isMeshStandardMaterial?te.environment:null,at=x===null?p.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:jr,ct=($.isMeshStandardMaterial?xe:fe).get($.envMap||it),wt=$.vertexColors===!0&&!!oe.attributes.color&&oe.attributes.color.itemSize===4,mt=!!$.normalMap&&!!oe.attributes.tangent,gt=!!oe.morphAttributes.position,yn=!!oe.morphAttributes.normal,kr=!!oe.morphAttributes.color,Ds=$.toneMapped?p.toneMapping:ks,ma=oe.morphAttributes.position||oe.morphAttributes.normal||oe.morphAttributes.color,vn=ma!==void 0?ma.length:0,yt=ie.get($),Vy=h.state.lights;if(W===!0&&(q===!0||N!==w)){let zr=N===w&&$.id===b;O.setState($,N,zr)}let Bn=!1;$.version===yt.__version?(yt.needsLights&&yt.lightsStateVersion!==Vy.state.version||yt.outputEncoding!==at||ce.isInstancedMesh&&yt.instancing===!1||!ce.isInstancedMesh&&yt.instancing===!0||ce.isSkinnedMesh&&yt.skinning===!1||!ce.isSkinnedMesh&&yt.skinning===!0||yt.envMap!==ct||$.fog===!0&&yt.fog!==Ze||yt.numClippingPlanes!==void 0&&(yt.numClippingPlanes!==O.numPlanes||yt.numIntersection!==O.numIntersection)||yt.vertexAlphas!==wt||yt.vertexTangents!==mt||yt.morphTargets!==gt||yt.morphNormals!==yn||yt.morphColors!==kr||yt.toneMapping!==Ds||J.isWebGL2===!0&&yt.morphTargetsCount!==vn)&&(Bn=!0):(Bn=!0,yt.__version=$.version);let ga=yt.currentProgram;Bn===!0&&(ga=ii($,te,ce));let ZS=!1,ud=!1,Hy=!1,lr=ga.getUniforms(),ya=yt.uniforms;if(V.useProgram(ga.program)&&(ZS=!0,ud=!0,Hy=!0),$.id!==b&&(b=$.id,ud=!0),ZS||w!==N){if(lr.setValue(G,"projectionMatrix",N.projectionMatrix),J.logarithmicDepthBuffer&&lr.setValue(G,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),w!==N&&(w=N,ud=!0,Hy=!0),$.isShaderMaterial||$.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshStandardMaterial||$.envMap){let zr=lr.map.cameraPosition;zr!==void 0&&zr.setValue(G,U.setFromMatrixPosition(N.matrixWorld))}($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial)&&lr.setValue(G,"isOrthographic",N.isOrthographicCamera===!0),($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial||$.isShadowMaterial||ce.isSkinnedMesh)&&lr.setValue(G,"viewMatrix",N.matrixWorldInverse)}if(ce.isSkinnedMesh){lr.setOptional(G,ce,"bindMatrix"),lr.setOptional(G,ce,"bindMatrixInverse");let zr=ce.skeleton;zr&&(J.floatVertexTextures?(zr.boneTexture===null&&zr.computeBoneTexture(),lr.setValue(G,"boneTexture",zr.boneTexture,ae),lr.setValue(G,"boneTextureSize",zr.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 Wy=oe.morphAttributes;if((Wy.position!==void 0||Wy.normal!==void 0||Wy.color!==void 0&&J.isWebGL2===!0)&&ge.update(ce,oe,$,ga),(ud||yt.receiveShadow!==ce.receiveShadow)&&(yt.receiveShadow=ce.receiveShadow,lr.setValue(G,"receiveShadow",ce.receiveShadow)),$.isMeshGouraudMaterial&&$.envMap!==null&&(ya.envMap.value=ct,ya.flipEnvMap.value=ct.isCubeTexture&&ct.isRenderTargetTexture===!1?-1:1),ud&&(lr.setValue(G,"toneMappingExposure",p.toneMappingExposure),yt.needsLights&&cI(ya,Hy),Ze&&$.fog===!0&&Fe.refreshFogUniforms(ya,Ze),Fe.refreshMaterialUniforms(ya,$,I,M,H),Bl.upload(G,yt.uniformsList,ya,ae)),$.isShaderMaterial&&$.uniformsNeedUpdate===!0&&(Bl.upload(G,yt.uniformsList,ya,ae),$.uniformsNeedUpdate=!1),$.isSpriteMaterial&&lr.setValue(G,"center",ce.center),lr.setValue(G,"modelViewMatrix",ce.modelViewMatrix),lr.setValue(G,"normalMatrix",ce.normalMatrix),lr.setValue(G,"modelMatrix",ce.matrixWorld),$.isShaderMaterial||$.isRawShaderMaterial){let zr=$.uniformsGroups;for(let jy=0,dI=zr.length;jy<dI;jy++)if(J.isWebGL2){let QS=zr[jy];je.update(QS,ga),je.bind(QS,ga)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return ga}function cI(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 uI(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,oe){ie.get(N.texture).__webglTexture=te,ie.get(N.depthTexture).__webglTexture=oe;let $=ie.get(N);$.__hasExternalTextures=!0,$.__hasExternalTextures&&($.__autoAllocateDepthBuffer=oe===void 0,$.__autoAllocateDepthBuffer||Z.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),$.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(N,te){let oe=ie.get(N);oe.__webglFramebuffer=te,oe.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(N,te=0,oe=0){x=N,y=te,v=oe;let $=!0,ce=null,Ze=!1,it=!1;if(N){let ct=ie.get(N);ct.__useDefaultFramebuffer!==void 0?(V.bindFramebuffer(36160,null),$=!1):ct.__webglFramebuffer===void 0?ae.setupRenderTarget(N):ct.__hasExternalTextures&&ae.rebindTextures(N,ie.get(N.texture).__webglTexture,ie.get(N.depthTexture).__webglTexture);let wt=N.texture;(wt.isData3DTexture||wt.isDataArrayTexture||wt.isCompressedArrayTexture)&&(it=!0);let mt=ie.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(ce=mt[te],Ze=!0):J.isWebGL2&&N.samples>0&&ae.useMultisampledRTT(N)===!1?ce=ie.get(N).__webglMultisampledFramebuffer:ce=mt,A.copy(N.viewport),T.copy(N.scissor),S=N.scissorTest}else A.copy(D).multiplyScalar(I).floor(),T.copy(B).multiplyScalar(I).floor(),S=k;if(V.bindFramebuffer(36160,ce)&&J.drawBuffers&&$&&V.drawBuffers(N,ce),V.viewport(A),V.scissor(T),V.setScissorTest(S),Ze){let ct=ie.get(N.texture);G.framebufferTexture2D(36160,36064,34069+te,ct.__webglTexture,oe)}else if(it){let ct=ie.get(N.texture),wt=te||0;G.framebufferTextureLayer(36160,36064,ct.__webglTexture,oe||0,wt)}b=-1},this.readRenderTargetPixels=function(N,te,oe,$,ce,Ze,it){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let at=ie.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&it!==void 0&&(at=at[it]),at){V.bindFramebuffer(36160,at);try{let ct=N.texture,wt=ct.format,mt=ct.type;if(wt!==oi&&De.convert(wt)!==G.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let gt=mt===Md&&(Z.has("EXT_color_buffer_half_float")||J.isWebGL2&&Z.has("EXT_color_buffer_float"));if(mt!==kt&&De.convert(mt)!==G.getParameter(35738)&&!(mt===Zi&&(J.isWebGL2||Z.has("OES_texture_float")||Z.has("WEBGL_color_buffer_float")))&&!gt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=N.width-$&&oe>=0&&oe<=N.height-ce&&G.readPixels(te,oe,$,ce,De.convert(wt),De.convert(mt),Ze)}finally{let ct=x!==null?ie.get(x).__webglFramebuffer:null;V.bindFramebuffer(36160,ct)}}},this.copyFramebufferToTexture=function(N,te,oe=0){let $=Math.pow(2,-oe),ce=Math.floor(te.image.width*$),Ze=Math.floor(te.image.height*$);ae.setTexture2D(te,0),G.copyTexSubImage2D(3553,oe,0,0,N.x,N.y,ce,Ze),V.unbindTexture()},this.copyTextureToTexture=function(N,te,oe,$=0){let ce=te.image.width,Ze=te.image.height,it=De.convert(oe.format),at=De.convert(oe.type);ae.setTexture2D(oe,0),G.pixelStorei(37440,oe.flipY),G.pixelStorei(37441,oe.premultiplyAlpha),G.pixelStorei(3317,oe.unpackAlignment),te.isDataTexture?G.texSubImage2D(3553,$,N.x,N.y,ce,Ze,it,at,te.image.data):te.isCompressedTexture?G.compressedTexSubImage2D(3553,$,N.x,N.y,te.mipmaps[0].width,te.mipmaps[0].height,it,te.mipmaps[0].data):G.texSubImage2D(3553,$,N.x,N.y,it,at,te.image),$===0&&oe.generateMipmaps&&G.generateMipmap(3553),V.unbindTexture()},this.copyTextureToTexture3D=function(N,te,oe,$,ce=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Ze=N.max.x-N.min.x+1,it=N.max.y-N.min.y+1,at=N.max.z-N.min.z+1,ct=De.convert($.format),wt=De.convert($.type),mt;if($.isData3DTexture)ae.setTexture3D($,0),mt=32879;else if($.isDataArrayTexture)ae.setTexture2DArray($,0),mt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}G.pixelStorei(37440,$.flipY),G.pixelStorei(37441,$.premultiplyAlpha),G.pixelStorei(3317,$.unpackAlignment);let gt=G.getParameter(3314),yn=G.getParameter(32878),kr=G.getParameter(3316),Ds=G.getParameter(3315),ma=G.getParameter(32877),vn=oe.isCompressedTexture?oe.mipmaps[0]:oe.image;G.pixelStorei(3314,vn.width),G.pixelStorei(32878,vn.height),G.pixelStorei(3316,N.min.x),G.pixelStorei(3315,N.min.y),G.pixelStorei(32877,N.min.z),oe.isDataTexture||oe.isData3DTexture?G.texSubImage3D(mt,ce,te.x,te.y,te.z,Ze,it,at,ct,wt,vn.data):oe.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),G.compressedTexSubImage3D(mt,ce,te.x,te.y,te.z,Ze,it,at,ct,vn.data)):G.texSubImage3D(mt,ce,te.x,te.y,te.z,Ze,it,at,ct,wt,vn),G.pixelStorei(3314,gt),G.pixelStorei(32878,yn),G.pixelStorei(3316,kr),G.pixelStorei(3315,Ds),G.pixelStorei(32877,ma),ce===0&&$.generateMipmaps&&G.generateMipmap(mt),V.unbindTexture()},this.initTexture=function(N){N.isCubeTexture?ae.setTextureCube(N,0):N.isData3DTexture?ae.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?ae.setTexture2DArray(N,0):ae.setTexture2D(N,0),V.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,V.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var Yv=class extends v0{};Yv.prototype.isWebGL1Renderer=!0;var kl=class{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Le(t),this.near=e,this.far=n}clone(){return new kl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},pr=class extends ut{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}},mp=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Rv,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ji()}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 i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[n+i];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=Ji()),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=Ji()),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}}},ur=new _,Ca=class{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}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++)ur.fromBufferAttribute(this,e),ur.applyMatrix4(t),this.setXYZ(e,ur.x,ur.y,ur.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)ur.fromBufferAttribute(this,e),ur.applyNormalMatrix(t),this.setXYZ(e,ur.x,ur.y,ur.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)ur.fromBufferAttribute(this,e),ur.transformDirection(t),this.setXYZ(e,ur.x,ur.y,ur.z);return this}setX(t,e){return this.normalized&&(e=Rt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Rt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Rt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Rt(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=Gs(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Gs(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Gs(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Gs(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Rt(e,this.array),n=Rt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Rt(e,this.array),n=Rt(n,this.array),i=Rt(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Rt(e,this.array),n=Rt(n,this.array),i=Rt(i,this.array),s=Rt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,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 i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new Be(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 Ca(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 i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+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 gp=class extends Be{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}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 ai=class extends Ea{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Le(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(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}},u1=new _,d1=new _,h1=new de,_v=new Ti,Kf=new Sn,Pa=class extends ut{constructor(t=new Te,e=new ai){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 i=1,s=e.count;i<s;i++)u1.fromBufferAttribute(e,i-1),d1.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=u1.distanceTo(d1);t.setAttribute("lineDistance",new we(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,i=this.matrixWorld,s=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Kf.copy(n.boundingSphere),Kf.applyMatrix4(i),Kf.radius+=s,t.ray.intersectsSphere(Kf)===!1)return;h1.copy(i).invert(),_v.copy(t.ray).applyMatrix4(h1);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new _,c=new _,d=new _,h=new _,f=this.isLineSegments?2:1,g=n.index,m=n.attributes.position;if(g!==null){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){let w=g.getX(x),A=g.getX(x+1);if(u.fromBufferAttribute(m,w),c.fromBufferAttribute(m,A),_v.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let S=t.ray.origin.distanceTo(h);S<t.near||S>t.far||e.push({distance:S,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(m.count,o.start+o.count);for(let x=y,b=v-1;x<b;x+=f){if(u.fromBufferAttribute(m,x),c.fromBufferAttribute(m,x+1),_v.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let A=t.ray.origin.distanceTo(h);A<t.near||A>t.far||e.push({distance:A,point:d.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 i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},f1=new _,p1=new _,Mo=class extends Pa{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 i=0,s=e.count;i<s;i+=2)f1.fromBufferAttribute(e,i),p1.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+f1.distanceTo(p1);t.setAttribute("lineDistance",new we(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var yp=class extends Gt{constructor(t,e,n,i,s,o,a,l,u){super(t,e,n,i,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:st,this.magFilter=s!==void 0?s:st,this.generateMipmaps=!1;let c=this;function d(){c.needsUpdate=!0,t.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(d)}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 li=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,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(i),e.push(s),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),i=0,s=n.length,o;e?o=e:o=t*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),u=n[i]-o,u<0)a=i+1;else if(u>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let c=n[i],h=n[i+1]-c,f=(o-c)/h;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new F:new _);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 _,i=[],s=[],o=[],a=new _,l=new de;for(let f=0;f<=t;f++){let g=f/t;i[f]=this.getTangentAt(g,new _)}s[0]=new _,o[0]=new _;let u=Number.MAX_VALUE,c=Math.abs(i[0].x),d=Math.abs(i[0].y),h=Math.abs(i[0].z);c<=u&&(u=c,n.set(1,0,0)),d<=u&&(u=d,n.set(0,1,0)),h<=u&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let g=Math.acos(_n(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,g))}o[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(_n(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let g=1;g<=t;g++)s[g].applyMatrix4(l.makeRotationAxis(i[g],f*g)),o[g].crossVectors(i[g],s[g])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(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}},Ia=class extends li{constructor(t=0,e=0,n=1,i=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=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let n=e||new F,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+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),d=Math.sin(this.aRotation),h=l-this.aX,f=u-this.aY;l=h*c-f*d+this.aX,u=h*d+f*c+this.aY}return n.set(l,u)}copy(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}},Kv=class extends Ia{constructor(t,e,n,i,s,o){super(t,e,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function x0(){let r=0,t=0,e=0,n=0;function i(s,o,a,l){r=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){i(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,d){let h=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+d)+(l-a)/d;h*=c,f*=c,i(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return r+t*s+e*o+n*a}}}var Zf=new _,Tv=new x0,Ev=new x0,Mv=new x0,Zv=class extends li{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new _){let n=e,i=this.points,s=i.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=i[(a-1)%s]:(Zf.subVectors(i[0],i[1]).add(i[0]),u=Zf);let d=i[a%s],h=i[(a+1)%s];if(this.closed||a+2<s?c=i[(a+2)%s]:(Zf.subVectors(i[s-1],i[s-2]).add(i[s-1]),c=Zf),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,g=Math.pow(u.distanceToSquared(d),f),p=Math.pow(d.distanceToSquared(h),f),m=Math.pow(h.distanceToSquared(c),f);p<1e-4&&(p=1),g<1e-4&&(g=p),m<1e-4&&(m=p),Tv.initNonuniformCatmullRom(u.x,d.x,h.x,c.x,g,p,m),Ev.initNonuniformCatmullRom(u.y,d.y,h.y,c.y,g,p,m),Mv.initNonuniformCatmullRom(u.z,d.z,h.z,c.z,g,p,m)}else this.curveType==="catmullrom"&&(Tv.initCatmullRom(u.x,d.x,h.x,c.x,this.tension),Ev.initCatmullRom(u.y,d.y,h.y,c.y,this.tension),Mv.initCatmullRom(u.z,d.z,h.z,c.z,this.tension));return n.set(Tv.calc(l),Ev.calc(l),Mv.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.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 i=this.points[e];t.points.push(i.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 i=t.points[e];this.points.push(new _().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function m1(r,t,e,n,i){let s=(n-t)*.5,o=(i-e)*.5,a=r*r,l=r*a;return(2*e-2*n+s+o)*l+(-3*e+3*n-2*s-o)*a+s*r+e}function dN(r,t){let e=1-r;return e*e*t}function hN(r,t){return 2*(1-r)*r*t}function fN(r,t){return r*r*t}function Td(r,t,e,n){return dN(r,t)+hN(r,e)+fN(r,n)}function pN(r,t){let e=1-r;return e*e*e*t}function mN(r,t){let e=1-r;return 3*e*e*r*t}function gN(r,t){return 3*(1-r)*r*r*t}function yN(r,t){return r*r*r*t}function Ed(r,t,e,n,i){return pN(r,t)+mN(r,e)+gN(r,n)+yN(r,i)}var nr=class extends li{constructor(t=new F,e=new F,n=new F,i=new F){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new F){let n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Ed(t,i.x,s.x,o.x,a.x),Ed(t,i.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}},Da=class extends li{constructor(t=new _,e=new _,n=new _,i=new _){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new _){let n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Ed(t,i.x,s.x,o.x,a.x),Ed(t,i.y,s.y,o.y,a.y),Ed(t,i.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}},rr=class extends li{constructor(t=new F,e=new F){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new F){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 F;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}},Ld=class extends li{constructor(t=new _,e=new _){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new _){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}},qr=class extends li{constructor(t=new F,e=new F,n=new F){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new F){let n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(Td(t,i.x,s.x,o.x),Td(t,i.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}},Qv=class extends li{constructor(t=new _,e=new _,n=new _){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new _){let n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(Td(t,i.x,s.x,o.x),Td(t,i.y,s.y,o.y),Td(t,i.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}},zl=class extends li{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new F){let n=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],u=i[o],c=i[o>i.length-2?i.length-1:o+1],d=i[o>i.length-3?i.length-1:o+2];return n.set(m1(a,l.x,u.x,c.x,d.x),m1(a,l.y,u.y,c.y,d.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new F().fromArray(i))}return this}},vN=Object.freeze({__proto__:null,ArcCurve:Kv,CatmullRomCurve3:Zv,CubicBezierCurve:nr,CubicBezierCurve3:Da,EllipseCurve:Ia,LineCurve:rr,LineCurve3:Ld,QuadraticBezierCurve:qr,QuadraticBezierCurve3:Qv,SplineCurve:zl}),Rd=class extends li{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 rr(e,t))}getPoint(t,e){let n=t*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=n){let o=i[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,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,i=this.curves.length;n<i;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 i=0,s=this.curves;i<s.length;i++){let o=s[i],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 i=t.curves[e];this.curves.push(i.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 i=this.curves[e];t.curves.push(i.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 i=t.curves[e];this.curves.push(new vN[i.type]().fromJSON(i))}return this}},Oa=class extends Rd{constructor(t){super(),this.type="Path",this.currentPoint=new F,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 rr(this.currentPoint.clone(),new F(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){let s=new qr(this.currentPoint.clone(),new F(t,e),new F(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,s,o){let a=new nr(this.currentPoint.clone(),new F(t,e),new F(n,i),new F(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new zl(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,n,i,s,o),this}absarc(t,e,n,i,s,o){return this.absellipse(t,e,n,n,i,s,o),this}ellipse(t,e,n,i,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,n,i,s,o,a,l),this}absellipse(t,e,n,i,s,o,a,l){let u=new Ia(t,e,n,i,s,o,a,l);if(this.curves.length>0){let d=u.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(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}},Vl=class extends Te{constructor(t=[new F(0,-.5),new F(.5,0),new F(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=_n(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,d=new _,h=new F,f=new _,g=new _,p=new _,m=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:m=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-m,f.z=y*0,p.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(p.x,p.y,p.z);break;default:m=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-m,f.z=y*0,g.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),l.push(f.x,f.y,f.z),p.copy(g)}for(let v=0;v<=e;v++){let x=n+v*c*i,b=Math.sin(x),w=Math.cos(x);for(let A=0;A<=t.length-1;A++){d.x=t[A].x*b,d.y=t[A].y,d.z=t[A].x*w,o.push(d.x,d.y,d.z),h.x=v/e,h.y=A/(t.length-1),a.push(h.x,h.y);let T=l[3*A+0]*b,S=l[3*A+1],E=l[3*A+0]*w;u.push(T,S,E)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let b=x+v*t.length,w=b,A=b+t.length,T=b+t.length+1,S=b+1;s.push(w,A,S),s.push(T,S,A)}this.setIndex(s),this.setAttribute("position",new we(o,3)),this.setAttribute("uv",new we(a,2)),this.setAttribute("normal",new we(u,3))}static fromJSON(t){return new Vl(t.points,t.segments,t.phiStart,t.phiLength)}};var La=class extends Te{constructor(t=1,e=1,n=1,i=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;i=Math.floor(i),s=Math.floor(s);let c=[],d=[],h=[],f=[],g=0,p=[],m=n/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new we(d,3)),this.setAttribute("normal",new we(h,3)),this.setAttribute("uv",new we(f,2));function v(){let b=new _,w=new _,A=0,T=(e-t)/n;for(let S=0;S<=s;S++){let E=[],M=S/s,I=M*(e-t)+t;for(let P=0;P<=i;P++){let C=P/i,D=C*l+a,B=Math.sin(D),k=Math.cos(D);w.x=I*B,w.y=-M*n+m,w.z=I*k,d.push(w.x,w.y,w.z),b.set(B,T,k).normalize(),h.push(b.x,b.y,b.z),f.push(C,1-M),E.push(g++)}p.push(E)}for(let S=0;S<i;S++)for(let E=0;E<s;E++){let M=p[E][S],I=p[E+1][S],P=p[E+1][S+1],C=p[E][S+1];c.push(M,I,C),c.push(I,P,C),A+=6}u.addGroup(y,A,0),y+=A}function x(b){let w=g,A=new F,T=new _,S=0,E=b===!0?t:e,M=b===!0?1:-1;for(let P=1;P<=i;P++)d.push(0,m*M,0),h.push(0,M,0),f.push(.5,.5),g++;let I=g;for(let P=0;P<=i;P++){let D=P/i*l+a,B=Math.cos(D),k=Math.sin(D);T.x=E*k,T.y=m*M,T.z=E*B,d.push(T.x,T.y,T.z),h.push(0,M,0),A.x=B*.5+.5,A.y=k*.5*M+.5,f.push(A.x,A.y),g++}for(let P=0;P<i;P++){let C=w+P,D=I+P;b===!0?c.push(D,D+1,C):c.push(D+1,D,C),S+=3}u.addGroup(y,S,b===!0?1:2),y+=S}}static fromJSON(t){return new La(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Hl=class extends La{constructor(t=1,e=1,n=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new Hl(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Wl=class extends Te{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};let s=[],o=[];a(i),u(n),c(),this.setAttribute("position",new we(s,3)),this.setAttribute("normal",new we(s.slice(),3)),this.setAttribute("uv",new we(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new _,b=new _,w=new _;for(let A=0;A<e.length;A+=3)f(e[A+0],x),f(e[A+1],b),f(e[A+2],w),l(x,b,w,v)}function l(v,x,b,w){let A=w+1,T=[];for(let S=0;S<=A;S++){T[S]=[];let E=v.clone().lerp(b,S/A),M=x.clone().lerp(b,S/A),I=A-S;for(let P=0;P<=I;P++)P===0&&S===A?T[S][P]=E:T[S][P]=E.clone().lerp(M,P/I)}for(let S=0;S<A;S++)for(let E=0;E<2*(A-S)-1;E++){let M=Math.floor(E/2);E%2===0?(h(T[S][M+1]),h(T[S+1][M]),h(T[S][M])):(h(T[S][M+1]),h(T[S+1][M+1]),h(T[S+1][M]))}}function u(v){let x=new _;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 _;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=m(v)/2/Math.PI+.5,w=y(v)/Math.PI+.5;o.push(b,1-w)}g(),d()}function d(){for(let v=0;v<o.length;v+=6){let x=o[v+0],b=o[v+2],w=o[v+4],A=Math.max(x,b,w),T=Math.min(x,b,w);A>.9&&T<.1&&(x<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),w<.2&&(o[v+4]+=1))}}function h(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 g(){let v=new _,x=new _,b=new _,w=new _,A=new F,T=new F,S=new F;for(let E=0,M=0;E<s.length;E+=9,M+=6){v.set(s[E+0],s[E+1],s[E+2]),x.set(s[E+3],s[E+4],s[E+5]),b.set(s[E+6],s[E+7],s[E+8]),A.set(o[M+0],o[M+1]),T.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 I=m(w);p(A,M+0,v,I),p(T,M+2,x,I),p(S,M+4,b,I)}}function p(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 m(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 Wl(t.vertices,t.indices,t.radius,t.details)}},jl=class extends Wl{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new jl(t.radius,t.detail)}};var Hs=class extends Oa{constructor(t){super(t),this.uuid=Ji(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,i=this.holes.length;n<i;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 i=t.holes[e];this.holes.push(i.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 i=this.holes[e];t.holes.push(i.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 i=t.holes[e];this.holes.push(new Oa().fromJSON(i))}return this}},xN={triangulate:function(r,t,e=2){let n=t&&t.length,i=n?t[0]*e:r.length,s=H1(r,0,i,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,d,h,f;if(n&&(s=_N(r,t,s,e)),r.length>80*e){a=u=r[0],l=c=r[1];for(let g=e;g<i;g+=e)d=r[g],h=r[g+1],d<a&&(a=d),h<l&&(l=h),d>u&&(u=d),h>c&&(c=h);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return Nd(s,o,e,a,l,f,0),o}};function H1(r,t,e,n,i){let s,o;if(i===NN(r,t,e,n)>0)for(s=t;s<e;s+=n)o=g1(s,r[s],r[s+1],o);else for(s=e-n;s>=t;s-=n)o=g1(s,r[s],r[s+1],o);return o&&Ip(o,o.next)&&(Fd(o),o=o.next),o}function Ra(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(Ip(e,e.next)||Qt(e.prev,e,e.next)===0)){if(Fd(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Nd(r,t,e,n,i,s,o){if(!r)return;!o&&s&&PN(r,n,i,s);let a=r,l,u;for(;r.prev!==r.next;){if(l=r.prev,u=r.next,s?SN(r,n,i,s):bN(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(u.i/e|0),Fd(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=wN(Ra(r),t,e),Nd(r,t,e,n,i,s,2)):o===2&&AN(r,t,e,n,i,s):Nd(Ra(r),t,e,n,i,s,1);break}}}function bN(r){let t=r.prev,e=r,n=r.next;if(Qt(t,e,n)>=0)return!1;let i=t.x,s=e.x,o=n.x,a=t.y,l=e.y,u=n.y,c=i<s?i<o?i:o:s<o?s:o,d=a<l?a<u?a:u:l<u?l:u,h=i>s?i>o?i:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,g=n.next;for(;g!==t;){if(g.x>=c&&g.x<=h&&g.y>=d&&g.y<=f&&Rl(i,a,s,l,o,u,g.x,g.y)&&Qt(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function SN(r,t,e,n){let i=r.prev,s=r,o=r.next;if(Qt(i,s,o)>=0)return!1;let a=i.x,l=s.x,u=o.x,c=i.y,d=s.y,h=o.y,f=a<l?a<u?a:u:l<u?l:u,g=c<d?c<h?c:h:d<h?d:h,p=a>l?a>u?a:u:l>u?l:u,m=c>d?c>h?c:h:d>h?d:h,y=Jv(f,g,t,e,n),v=Jv(p,m,t,e,n),x=r.prevZ,b=r.nextZ;for(;x&&x.z>=y&&b&&b.z<=v;){if(x.x>=f&&x.x<=p&&x.y>=g&&x.y<=m&&x!==i&&x!==o&&Rl(a,c,l,d,u,h,x.x,x.y)&&Qt(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=f&&b.x<=p&&b.y>=g&&b.y<=m&&b!==i&&b!==o&&Rl(a,c,l,d,u,h,b.x,b.y)&&Qt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=p&&x.y>=g&&x.y<=m&&x!==i&&x!==o&&Rl(a,c,l,d,u,h,x.x,x.y)&&Qt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=p&&b.y>=g&&b.y<=m&&b!==i&&b!==o&&Rl(a,c,l,d,u,h,b.x,b.y)&&Qt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function wN(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!Ip(i,s)&&W1(i,n,n.next,s)&&Bd(i,s)&&Bd(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Fd(n),Fd(n.next),n=r=s),n=n.next}while(n!==r);return Ra(n)}function AN(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&ON(o,a)){let l=j1(o,a);o=Ra(o,o.next),l=Ra(l,l.next),Nd(o,t,e,n,i,s,0),Nd(l,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function _N(r,t,e,n){let i=[],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:r.length,u=H1(r,a,l,n,!1),u===u.next&&(u.steiner=!0),i.push(DN(u));for(i.sort(TN),s=0;s<i.length;s++)e=EN(i[s],e);return e}function TN(r,t){return r.x-t.x}function EN(r,t){let e=MN(r,t);if(!e)return t;let n=j1(e,r);return Ra(n,n.next),Ra(e,e.next)}function MN(r,t){let e=t,n=-1/0,i,s=r.x,o=r.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let h=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=s&&h>n&&(n=h,i=e.x<e.next.x?e:e.next,h===s))return i}e=e.next}while(e!==t);if(!i)return null;let a=i,l=i.x,u=i.y,c=1/0,d;e=i;do s>=e.x&&e.x>=l&&s!==e.x&&Rl(o<u?s:n,o,l,u,o<u?n:s,o,e.x,e.y)&&(d=Math.abs(o-e.y)/(s-e.x),Bd(e,r)&&(d<c||d===c&&(e.x>i.x||e.x===i.x&&CN(i,e)))&&(i=e,c=d)),e=e.next;while(e!==a);return i}function CN(r,t){return Qt(r.prev,r,t.prev)<0&&Qt(t.next,r,r.next)<0}function PN(r,t,e,n){let i=r;do i.z===0&&(i.z=Jv(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,IN(i)}function IN(r){let t,e,n,i,s,o,a,l,u=1;do{for(e=r,r=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)?(i=e,e=e.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;e=n}s.nextZ=null,u*=2}while(o>1);return r}function Jv(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function DN(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function Rl(r,t,e,n,i,s,o,a){return(i-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(n-a)}function ON(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!LN(r,t)&&(Bd(r,t)&&Bd(t,r)&&RN(r,t)&&(Qt(r.prev,r,t.prev)||Qt(r,t.prev,t))||Ip(r,t)&&Qt(r.prev,r,r.next)>0&&Qt(t.prev,t,t.next)>0)}function Qt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Ip(r,t){return r.x===t.x&&r.y===t.y}function W1(r,t,e,n){let i=Jf(Qt(r,t,e)),s=Jf(Qt(r,t,n)),o=Jf(Qt(e,n,r)),a=Jf(Qt(e,n,t));return!!(i!==s&&o!==a||i===0&&Qf(r,e,t)||s===0&&Qf(r,n,t)||o===0&&Qf(e,r,n)||a===0&&Qf(e,t,n))}function Qf(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Jf(r){return r>0?1:r<0?-1:0}function LN(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&W1(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Bd(r,t){return Qt(r.prev,r,r.next)<0?Qt(r,t,r.next)>=0&&Qt(r,r.prev,t)>=0:Qt(r,t,r.prev)<0||Qt(r,r.next,t)<0}function RN(r,t){let e=r,n=!1,i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function j1(r,t){let e=new $v(r.i,r.x,r.y),n=new $v(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function g1(r,t,e,n){let i=new $v(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Fd(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function $v(r,t,e){this.i=r,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 NN(r,t,e,n){let i=0;for(let s=t,o=e-n;s<e;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}var ql=class{static area(t){let e=t.length,n=0;for(let i=e-1,s=0;s<e;i=s++)n+=t[i].x*t[s].y-t[s].x*t[i].y;return n*.5}static isClockWise(t){return ql.area(t)<0}static triangulateShape(t,e){let n=[],i=[],s=[];y1(t),v1(n,t);let o=t.length;e.forEach(y1);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,v1(n,e[l]);let a=xN.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function y1(r){let t=r.length;t>2&&r[t-1].equals(r[0])&&r.pop()}function v1(r,t){for(let e=0;e<t.length;e++)r.push(t[e].x),r.push(t[e].y)}var Xl=class extends Wl{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Xl(t.radius,t.detail)}};var Na=class extends Te{constructor(t=1,e=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,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=[],d=new _,h=new _,f=[],g=[],p=[],m=[];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 A=w/e;d.x=-t*Math.cos(i+A*s)*Math.sin(o+x*a),d.y=t*Math.cos(o+x*a),d.z=t*Math.sin(i+A*s)*Math.sin(o+x*a),g.push(d.x,d.y,d.z),h.copy(d).normalize(),p.push(h.x,h.y,h.z),m.push(A+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],A=c[y+1][v+1];(y!==0||o>0)&&f.push(x,b,A),(y!==n-1||l<Math.PI)&&f.push(b,w,A)}this.setIndex(f),this.setAttribute("position",new we(g,3)),this.setAttribute("normal",new we(p,3)),this.setAttribute("uv",new we(m,2))}static fromJSON(t){return new Na(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var Yl=class extends Te{constructor(t=1,e=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);let a=[],l=[],u=[],c=[],d=new _,h=new _,f=new _,g=new _,p=new _,m=new _,y=new _;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,g),m.subVectors(g,f),y.addVectors(g,f),p.crossVectors(m,y),y.crossVectors(p,m),p.normalize(),y.normalize();for(let w=0;w<=i;++w){let A=w/i*Math.PI*2,T=-e*Math.cos(A),S=e*Math.sin(A);d.x=f.x+(T*y.x+S*p.x),d.y=f.y+(T*y.y+S*p.y),d.z=f.z+(T*y.z+S*p.z),l.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),u.push(h.x,h.y,h.z),c.push(x/n),c.push(w/i)}}for(let x=1;x<=n;x++)for(let b=1;b<=i;b++){let w=(i+1)*(x-1)+(b-1),A=(i+1)*x+(b-1),T=(i+1)*x+b,S=(i+1)*(x-1)+b;a.push(w,A,S),a.push(A,T,S)}this.setIndex(a),this.setAttribute("position",new we(l,3)),this.setAttribute("normal",new we(u,3)),this.setAttribute("uv",new we(c,2));function v(x,b,w,A,T){let S=Math.cos(x),E=Math.sin(x),M=w/b*x,I=Math.cos(M);T.x=A*(2+I)*.5*S,T.y=A*(2+I)*E*.5,T.z=A*Math.sin(M)*.5}}static fromJSON(t){return new Yl(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function bo(r,t,e){return q1(r)?new r.constructor(r.subarray(t,e!==void 0?e:r.length)):r.slice(t,e)}function $f(r,t,e){return!r||!e&&r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function q1(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var Kl=class{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],s=e[n-1];n:{e:{let o;t:{r:if(!(t<i)){for(let a=n+2;;){if(i===void 0){if(t<s)break r;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=e[++n],t<i)break e}o=e.length;break t}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(i=s,s=e[--n-1],t>=s)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(i=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i;for(let o=0;o!==i;++o)e[o]=n[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},e0=class extends Kl{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Cw,endingEnd:Cw}}intervalChanged_(t,e,n){let i=this.parameterPositions,s=t-2,o=t+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Pw:s=t,a=2*e-n;break;case Iw:s=i.length-2,a=e+i[s]-i[s+1];break;default:s=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Pw:o=t,l=2*n-e;break;case Iw:o=1,l=n+i[1]-i[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,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,g=(n-e)/(i-e),p=g*g,m=p*g,y=-h*m+2*h*p-h*g,v=(1+h)*m+(-1.5-2*h)*p+(-.5+h)*g+1,x=(-1-f)*m+(1.5+f)*p+.5*g,b=f*m-f*p;for(let w=0;w!==a;++w)s[w]=y*o[c+w]+v*o[u+w]+x*o[l+w]+b*o[d+w];return s}},t0=class extends Kl{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(n-e)/(i-e),d=1-c;for(let h=0;h!==a;++h)s[h]=o[u+h]*d+o[l+h]*c;return s}},n0=class extends Kl{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}},Mi=class{constructor(t,e,n,i){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=$f(e,this.TimeBufferType),this.values=$f(n,this.ValueBufferType),this.setInterpolation(i||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:$f(t.times,Array),values:$f(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new n0(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new t0(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new e0(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case ip:e=this.InterpolantFactoryMethodDiscrete;break;case sp:e=this.InterpolantFactoryMethodLinear;break;case $y: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 ip;case this.InterpolantFactoryMethodLinear:return sp;case this.InterpolantFactoryMethodSmooth:return $y}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){let n=this.times,i=n.length,s=0,o=i-1;for(;s!==i&&n[s]<t;)++s;for(;o!==-1&&n[o]>e;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=bo(n,s,o),this.values=bo(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,i=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(i!==void 0&&q1(i))for(let a=0,l=i.length;a!==l;++a){let u=i[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}return t}optimize(){let t=bo(this.times),e=bo(this.values),n=this.getValueSize(),i=this.getInterpolation()===$y,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(i)l=!0;else{let d=a*n,h=d-n,f=d+n;for(let g=0;g!==n;++g){let p=e[d+g];if(p!==e[h+g]||p!==e[f+g]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let d=a*n,h=o*n;for(let f=0;f!==n;++f)e[h+f]=e[d+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=bo(t,0,o),this.values=bo(e,0,o*n)):(this.times=t,this.values=e),this}clone(){let t=bo(this.times,0),e=bo(this.values,0),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};Mi.prototype.TimeBufferType=Float32Array;Mi.prototype.ValueBufferType=Float32Array;Mi.prototype.DefaultInterpolation=sp;var Ba=class extends Mi{};Ba.prototype.ValueTypeName="bool";Ba.prototype.ValueBufferType=Array;Ba.prototype.DefaultInterpolation=ip;Ba.prototype.InterpolantFactoryMethodLinear=void 0;Ba.prototype.InterpolantFactoryMethodSmooth=void 0;var r0=class extends Mi{};r0.prototype.ValueTypeName="color";var i0=class extends Mi{};i0.prototype.ValueTypeName="number";var s0=class extends Kl{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(i-e),u=t*a;for(let c=u+a;u!==c;u+=4)rt.slerpFlat(s,0,o,u-a,o,u,l);return s}},Ud=class extends Mi{InterpolantFactoryMethodLinear(t){return new s0(this.times,this.values,this.getValueSize(),t)}};Ud.prototype.ValueTypeName="quaternion";Ud.prototype.DefaultInterpolation=sp;Ud.prototype.InterpolantFactoryMethodSmooth=void 0;var Fa=class extends Mi{};Fa.prototype.ValueTypeName="string";Fa.prototype.ValueBufferType=Array;Fa.prototype.DefaultInterpolation=ip;Fa.prototype.InterpolantFactoryMethodLinear=void 0;Fa.prototype.InterpolantFactoryMethodSmooth=void 0;var o0=class extends Mi{};o0.prototype.ValueTypeName="vector";var x1={enabled:!1,files:{},add:function(r,t){this.enabled!==!1&&(this.files[r]=t)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},Gd=class{constructor(t,e,n){let i=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&&i.onStart!==void 0&&i.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,i.onProgress!==void 0&&i.onProgress(c,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(c){i.onError!==void 0&&i.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,d){return u.push(c,d),this},this.removeHandler=function(c){let d=u.indexOf(c);return d!==-1&&u.splice(d,2),this},this.getHandler=function(c){for(let d=0,h=u.length;d<h;d+=2){let f=u[d],g=u[d+1];if(f.global&&(f.lastIndex=0),f.test(c))return g}return null}}},BN=new Gd,Zl=class{constructor(t){this.manager=t!==void 0?t:BN,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(i,s){n.load(t,i,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}},Fs={},a0=class extends Error{constructor(t,e){super(t),this.response=e}},Ql=class extends Zl{constructor(t){super(t)}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=x1.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(Fs[t]!==void 0){Fs[t].push({onLoad:e,onProgress:n,onError:i});return}Fs[t]=[],Fs[t].push({onLoad:e,onProgress:n,onError:i});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=Fs[t],d=u.body.getReader(),h=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=h?parseInt(h):0,g=f!==0,p=0,m=new ReadableStream({start(y){v();function v(){d.read().then(({done:x,value:b})=>{if(x)y.close();else{p+=b.byteLength;let w=new ProgressEvent("progress",{lengthComputable:g,loaded:p,total:f});for(let A=0,T=c.length;A<T;A++){let S=c[A];S.onProgress&&S.onProgress(w)}y.enqueue(b),v()}})}}});return new Response(m)}else throw new a0(`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 d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return u.arrayBuffer().then(g=>f.decode(g))}}}).then(u=>{x1.add(t,u);let c=Fs[t];delete Fs[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=Fs[t];if(c===void 0)throw this.manager.itemError(t),u;delete Fs[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];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 Co=class extends ut{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Le(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}},vp=class extends Co{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Le(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},Cv=new de,b1=new _,S1=new _,kd=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new F(512,512),this.map=null,this.mapPass=null,this.matrix=new de,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Dd,this._frameExtents=new F(1,1),this._viewportCount=1,this._viewports=[new Qe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;b1.setFromMatrixPosition(t.matrixWorld),e.position.copy(b1),S1.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(S1),e.updateMatrixWorld(),Cv.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Cv),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Cv)}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}},l0=class extends kd{constructor(){super(new cn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,n=Pd*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(n!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},xp=class extends Co{constructor(t,e,n=0,i=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new l0}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}},w1=new de,xd=new _,Pv=new _,c0=class extends kd{constructor(){super(new cn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new F(4,2),this._viewportCount=6,this._viewports=[new Qe(2,1,1,1),new Qe(0,1,1,1),new Qe(3,1,1,1),new Qe(1,1,1,1),new Qe(3,0,1,1),new Qe(1,0,1,1)],this._cubeDirections=[new _(1,0,0),new _(-1,0,0),new _(0,0,1),new _(0,0,-1),new _(0,1,0),new _(0,-1,0)],this._cubeUps=[new _(0,1,0),new _(0,1,0),new _(0,1,0),new _(0,1,0),new _(0,0,1),new _(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,i=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),xd.setFromMatrixPosition(t.matrixWorld),n.position.copy(xd),Pv.copy(n.position),Pv.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Pv),n.updateMatrixWorld(),i.makeTranslation(-xd.x,-xd.y,-xd.z),w1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(w1)}},bp=class extends Co{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new c0}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}},u0=class extends kd{constructor(){super(new Ma(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Sp=class extends Co{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.shadow=new u0}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var d0=class extends Te{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}},Jl=class extends Zl{constructor(t){super(t)}load(t,e,n,i){let s=this,o=new Ql(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){i?i(l):console.error(l),s.manager.itemError(t)}},n,i)}parse(t){let e={},n={};function i(f,g){if(e[g]!==void 0)return e[g];let m=f.interleavedBuffers[g],y=s(f,m.buffer),v=If(m.type,y),x=new mp(v,m.stride);return x.uuid=m.uuid,e[g]=x,x}function s(f,g){if(n[g]!==void 0)return n[g];let m=f.arrayBuffers[g],y=new Uint32Array(m).buffer;return n[g]=y,y}let o=t.isInstancedBufferGeometry?new d0:new Te,a=t.data.index;if(a!==void 0){let f=If(a.type,a.array);o.setIndex(new Be(f,1))}let l=t.data.attributes;for(let f in l){let g=l[f],p;if(g.isInterleavedBufferAttribute){let m=i(t.data,g.data);p=new Ca(m,g.itemSize,g.offset,g.normalized)}else{let m=If(g.type,g.array),y=g.isInstancedBufferAttribute?gp:Be;p=new y(m,g.itemSize,g.normalized)}g.name!==void 0&&(p.name=g.name),g.usage!==void 0&&p.setUsage(g.usage),g.updateRange!==void 0&&(p.updateRange.offset=g.updateRange.offset,p.updateRange.count=g.updateRange.count),o.setAttribute(f,p)}let u=t.data.morphAttributes;if(u)for(let f in u){let g=u[f],p=[];for(let m=0,y=g.length;m<y;m++){let v=g[m],x;if(v.isInterleavedBufferAttribute){let b=i(t.data,v.data);x=new Ca(b,v.itemSize,v.offset,v.normalized)}else{let b=If(v.type,v.array);x=new Be(b,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),p.push(x)}o.morphAttributes[f]=p}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let d=t.data.groups||t.data.drawcalls||t.data.offsets;if(d!==void 0)for(let f=0,g=d.length;f!==g;++f){let p=d[f];o.addGroup(p.start,p.count,p.materialIndex)}let h=t.data.boundingSphere;if(h!==void 0){let f=new _;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new Sn(f,h.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var wp=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=A1(),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=A1();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function A1(){return(typeof performance>"u"?Date:performance).now()}var b0="\\[\\]\\.:\\/",FN=new RegExp("["+b0+"]","g"),S0="[^"+b0+"]",UN="[^"+b0.replace("\\.","")+"]",GN=/((?:WC+[\/:])*)/.source.replace("WC",S0),kN=/(WCOD+)?/.source.replace("WCOD",UN),zN=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",S0),VN=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",S0),HN=new RegExp("^"+GN+kN+zN+VN+"$"),WN=["material","materials","bones","map"],h0=class{constructor(t,e,n){let i=n||Mt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].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()}},Mt=class{constructor(t,e,n){this.path=e,this.parsedPath=n||Mt.parseTrackName(e),this.node=Mt.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 Mt.Composite(t,e,n):new Mt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(FN,"")}static parseTrackName(t){let e=HN.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]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);WN.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+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},i=n(t.children);if(i)return i}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 i=0,s=n.length;i!==s;++i)t[e++]=n[i]}_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 i=0,s=n.length;i!==s;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=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,i=e.propertyName,s=e.propertyIndex;if(t||(t=Mt.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[i];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+i+" 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(i==="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=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Mt.Composite=h0;Mt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Mt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Mt.prototype.GetterByBindingType=[Mt.prototype._getValue_direct,Mt.prototype._getValue_array,Mt.prototype._getValue_arrayElement,Mt.prototype._getValue_toArray];Mt.prototype.SetterByBindingTypeAndVersioning=[[Mt.prototype._setValue_direct,Mt.prototype._setValue_direct_setNeedsUpdate,Mt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Mt.prototype._setValue_array,Mt.prototype._setValue_array_setNeedsUpdate,Mt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Mt.prototype._setValue_arrayElement,Mt.prototype._setValue_arrayElement_setNeedsUpdate,Mt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Mt.prototype._setValue_fromArray,Mt.prototype._setValue_fromArray_setNeedsUpdate,Mt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var M6=new Float32Array(1);var Se=class{constructor(t){this.value=t}clone(){return new Se(this.value.clone===void 0?this.value:this.value.clone())}};var $l=class{constructor(t,e,n=0,i=1/0){this.ray=new Ti(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new Id,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 f0(t,this,n,e),n.sort(_1),n}intersectObjects(t,e=!0,n=[]){for(let i=0,s=t.length;i<s;i++)f0(t[i],this,n,e);return n.sort(_1),n}};function _1(r,t){return r.distance-t.distance}function f0(r,t,e,n){if(r.layers.test(t.layers)&&r.raycast(t,e),n===!0){let i=r.children;for(let s=0,o=i.length;s<o;s++)f0(i[s],t,e,!0)}}var zd=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(_n(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var T1=new F,Ap=class{constructor(t=new F(1/0,1/0),e=new F(-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=T1.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 T1.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)}},E1=new _,ep=new _,Cn=class{constructor(t=new _,e=new _){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){E1.subVectors(t,this.start),ep.subVectors(this.end,this.start);let n=ep.dot(ep),s=ep.dot(E1)/n;return e&&(s=_n(s,0,1)),s}closestPointToPoint(t,e,n){let i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).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)}},M1=new _,_p=class extends ut{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Te,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;i.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new we(i,3));let s=new ai({fog:!1,toneMapped:!1});this.cone=new Mo(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),M1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(M1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Tp=class extends Un{constructor(t,e,n){let i=new Na(e,4,2),s=new zs({wireframe:!0,fog:!1,toneMapped:!1});super(i,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 C1=new _,tp=new _,P1=new _,Ep=class extends ut{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 i=new Te;i.setAttribute("position",new we([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new ai({fog:!1,toneMapped:!1});this.lightPlane=new Pa(i,s),this.add(this.lightPlane),i=new Te,i.setAttribute("position",new we([0,0,0,0,0,1],3)),this.targetLine=new Pa(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),C1.setFromMatrixPosition(this.light.matrixWorld),tp.setFromMatrixPosition(this.light.target.matrixWorld),P1.subVectors(tp,C1),this.lightPlane.lookAt(tp),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(tp),this.targetLine.scale.z=P1.length()}},np=new _,en=new Ei,Po=class extends Mo{constructor(t){let e=new Te,n=new ai({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(g,p){l(g),l(p)}function l(g){i.push(0,0,0),s.push(0,0,0),o[g]===void 0&&(o[g]=[]),o[g].push(i.length/3-1)}e.setAttribute("position",new we(i,3)),e.setAttribute("color",new we(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 Le(16755200),c=new Le(16711680),d=new Le(43775),h=new Le(16777215),f=new Le(3355443);this.setColors(u,c,d,h,f)}setColors(t,e,n,i,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,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,n=1,i=1;en.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ln("c",e,t,en,0,0,-1),ln("t",e,t,en,0,0,1),ln("n1",e,t,en,-n,-i,-1),ln("n2",e,t,en,n,-i,-1),ln("n3",e,t,en,-n,i,-1),ln("n4",e,t,en,n,i,-1),ln("f1",e,t,en,-n,-i,1),ln("f2",e,t,en,n,-i,1),ln("f3",e,t,en,-n,i,1),ln("f4",e,t,en,n,i,1),ln("u1",e,t,en,n*.7,i*1.1,-1),ln("u2",e,t,en,-n*.7,i*1.1,-1),ln("u3",e,t,en,0,i*2,-1),ln("cf1",e,t,en,-n,0,1),ln("cf2",e,t,en,n,0,1),ln("cf3",e,t,en,0,-i,1),ln("cf4",e,t,en,0,i,1),ln("cn1",e,t,en,-n,0,-1),ln("cn2",e,t,en,n,0,-1),ln("cn3",e,t,en,0,-i,-1),ln("cn4",e,t,en,0,i,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ln(r,t,e,n,i,s,o){np.set(i,s,o).unproject(n);let a=t[r];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],np.x,np.y,np.z)}}var Io=class extends Mo{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]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Te;s.setIndex(new Be(n,1)),s.setAttribute("position",new we(i,3)),super(s,new ai({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 Mp=class extends Mo{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],i=new Te;i.setAttribute("position",new we(e,3)),i.setAttribute("color",new we(n,3));let s=new ai({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,n){let i=new Le,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ws}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ws);var nc=".",Vd=Symbol("target"),w0=Symbol("unsubscribe");function Hd(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function X1(r){return(typeof r=="object"?r===null:typeof r!="function")||r instanceof RegExp}var Yr=Array.isArray;function Ua(r){return typeof r=="symbol"}var jN={after:(r,t)=>Yr(r)?r.slice(t.length):t===""?r:r.slice(t.length+1),concat:(r,t)=>Yr(r)?(r=[...r],t&&r.push(t),r):t&&t.toString!==void 0?(r!==""&&(r+=nc),Ua(t)?r+t.toString():r+t):r,initial:r=>{if(Yr(r))return r.slice(0,-1);if(r==="")return r;let t=r.lastIndexOf(nc);return t===-1?"":r.slice(0,t)},last:r=>{if(Yr(r))return r[r.length-1]||"";if(r==="")return r;let t=r.lastIndexOf(nc);return t===-1?r:r.slice(t+1)},walk:(r,t)=>{if(Yr(r))for(let e of r)t(e);else if(r!==""){let e=0,n=r.indexOf(nc);if(n===-1)t(r);else for(;e<r.length;)n===-1&&(n=r.length),t(r.slice(e,n)),e=n+1,n=r.indexOf(nc,e)}},get(r,t){return this.walk(t,e=>{r&&(r=r[e])}),r}},mr=jN;function A0(r){return typeof r=="object"&&typeof r.next=="function"}function _0(r,t,e,n,i){let s=r.next;if(t.name==="entries")r.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],t,o.value[0],n),o.value[1]=i(o.value[1],t,o.value[0],n)),o};else if(t.name==="values"){let o=e[Vd].keys();r.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,t,o.next().value,n)),a}}else r.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,t,o.value,n)),o};return r}function Dp(r,t,e){return r.isUnsubscribed||t.ignoreSymbols&&Ua(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var Wd=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),i=n[e];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(t,e),n[e]=i),i}getProxy(t,e,n,i){if(this.isUnsubscribed)return t;let s=t[i],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,mr.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,i,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,i):Reflect.set(t,e,n)}return!0}deleteProperty(t,e,n){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(t);i&&(delete i[e],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(t,e,n){let i=this._getOwnPropertyDescriptor(e,n);return t!==void 0&&i!==void 0&&Object.is(t.value,i.value)&&(t.writable||!1)===(i.writable||!1)&&(t.enumerable||!1)===(i.enumerable||!1)&&(t.configurable||!1)===(i.configurable||!1)&&t.get===i.get&&t.set===i.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 rc(r){return toString.call(r)==="[object Object]"}function ic(){return!0}function Do(r,t){return r.length!==t.length||r.some((e,n)=>t[n]!==e)}var Op=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var qN=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),T0={push:ic,pop:ic,shift:ic,unshift:ic,copyWithin:Do,reverse:Do,sort:Do,splice:Do,flat:Do,fill:Do},Y1=new Set([...Op,...qN,...Object.keys(T0)]);function sc(r,t){if(r.size!==t.size)return!0;for(let e of r)if(!t.has(e))return!0;return!1}var E0=["keys","values","entries"],M0=new Set(["has","toString"]),C0={add:sc,clear:sc,delete:sc,forEach:sc},K1=new Set([...M0,...Object.keys(C0),...E0]);function oc(r,t){if(r.size!==t.size)return!0;let e;for(let[n,i]of r)if(e=t.get(n),e!==i||e===void 0&&!t.has(n))return!0;return!1}var XN=new Set([...M0,"get"]),P0={set:oc,clear:oc,delete:oc,forEach:oc},Z1=new Set([...XN,...Object.keys(P0),...E0]);var zn=class{constructor(t,e,n,i){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return Op.has(t)}_shallowClone(t){let e=t;if(rc(t))e={...t};else if(Yr(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,i]of t.entries())e.set(n,this._shallowClone(i))}return this._clonedCache.add(e),e}preferredThisArg(t,e,n,i){return t?(Yr(i)?this._onIsChanged=T0[e]:i instanceof Set?this._onIsChanged=C0[e]:i instanceof Map&&(this._onIsChanged=P0[e]),i):n}update(t,e,n){let i=mr.after(t,this._path);if(e!=="length"){let s=this.clone;mr.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property: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],mr.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var ac=class extends zn{static isHandledMethod(t){return Y1.has(t)}};var jd=class extends zn{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var lc=class extends zn{static isHandledMethod(t){return K1.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 cc=class extends zn{static isHandledMethod(t){return Z1.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 qd=class extends zn{constructor(t,e,n,i){super(void 0,e,n,i),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 Xd=class extends zn{constructor(t,e,n,i){super(void 0,e,n,i),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 Pi=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return rc(t)||Yr(t)||Hd(t)}static isHandledMethod(t,e){return rc(t)?zn.isHandledMethod(e):Yr(t)?ac.isHandledMethod(e):t instanceof Set?lc.isHandledMethod(e):t instanceof Map?cc.isHandledMethod(e):Hd(t)}get isCloning(){return this._stack.length>0}start(t,e,n){let i=zn;Yr(t)?i=ac:t instanceof Date?i=jd:t instanceof Set?i=lc:t instanceof Map?i=cc:t instanceof WeakSet?i=qd:t instanceof WeakMap&&(i=Xd),this._stack.push(new i(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:i}=t,s=Pi.isHandledMethod(n,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,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 YN={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},I0=(r,t,e={})=>{e={...YN,...e};let n=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=e,l=new Wd(i),u=typeof e.onValidate=="function",c=new Pi(u),d=(v,x,b,w,A)=>!u||c.isCloning||e.onValidate(mr.concat(l.getPath(v),x),b,w,A)===!0,h=(v,x,b,w)=>{!Dp(l,e,x)&&!(o&&l.isDetached(v,r))&&f(l.getPath(v),x,b,w)},f=(v,x,b,w,A)=>{c.isCloning?c.update(v,x,w):t(mr.concat(v,x),b,w,A)},g=v=>v&&(v[n]||v),p=(v,x,b,w)=>X1(v)||b==="constructor"||s&&!Pi.isHandledMethod(x,b)||Dp(l,e,b)||l.isGetInvariant(x,b)||o&&l.isDetached(x,r)?v:(w===void 0&&(w=l.getPath(x)),l.getProxy(v,mr.concat(w,b),m,n)),m={get(v,x,b){if(Ua(x)){if(x===n||x===Vd)return v;if(x===w0&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let w=Hd(v)?Reflect.get(v,x):Reflect.get(v,x,b);return p(w,v,x)},set(v,x,b,w){b=g(b);let A=v[n]||v,T=A[x];if(i(T,b)&&x in v)return!0;let S=d(v,x,b,T);return S&&l.setProperty(A,x,b,w,T)?(h(v,x,v[x],T),!0):!S},defineProperty(v,x,b){if(!l.isSameDescriptor(b,v,x)){let w=v[x];d(v,x,b.value,w)&&l.defineProperty(v,x,b,w)&&h(v,x,b.value,w)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let b=Reflect.get(v,x),w=d(v,x,void 0,b);return w&&l.deleteProperty(v,x,b)?(h(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))&&Pi.isHandledType(w)){let A=mr.initial(l.getPath(v)),T=Pi.isHandledMethod(w,v.name);c.start(w,A,b);let S=Reflect.apply(v,c.preferredThisArg(v,x,w),T?b.map(I=>g(I)):b),E=c.isChanged(w,i),M=c.stop();if(Pi.isHandledType(S)&&T&&(x instanceof Map&&v.name==="get"&&(A=mr.concat(A,b[0])),S=l.getProxy(S,A,m)),E){let I={name:v.name,args:b,result:S},P=c.isCloning?mr.initial(A):A,C=c.isCloning?mr.last(A):"";d(mr.get(r,P),C,w,M,I)?f(P,C,w,M,I):c.undo(w)}return(x instanceof Map||x instanceof Set)&&A0(S)?_0(S,v,x,A,p):S}return Reflect.apply(v,x,b)}},y=l.getProxy(r,e.pathAsArray?[]:"",m);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};I0.target=r=>r&&r[Vd]||r;I0.unsubscribe=r=>r[w0]||r;var D0=I0;var KN=typeof global=="object"&&global&&global.Object===Object&&global,Lp=KN;var ZN=typeof self=="object"&&self&&self.Object===Object&&self,QN=Lp||ZN||Function("return this")(),rn=QN;var JN=rn.Symbol,Vn=JN;var Q1=Object.prototype,$N=Q1.hasOwnProperty,eB=Q1.toString,Yd=Vn?Vn.toStringTag:void 0;function tB(r){var t=$N.call(r,Yd),e=r[Yd];try{r[Yd]=void 0;var n=!0}catch{}var i=eB.call(r);return n&&(t?r[Yd]=e:delete r[Yd]),i}var J1=tB;var nB=Object.prototype,rB=nB.toString;function iB(r){return rB.call(r)}var $1=iB;var sB="[object Null]",oB="[object Undefined]",eA=Vn?Vn.toStringTag:void 0;function aB(r){return r==null?r===void 0?oB:sB:eA&&eA in Object(r)?J1(r):$1(r)}var Kr=aB;function lB(r){return r!=null&&typeof r=="object"}var Jn=lB;var cB="[object Symbol]";function uB(r){return typeof r=="symbol"||Jn(r)&&Kr(r)==cB}var Oo=uB;function dB(r,t){for(var e=-1,n=r==null?0:r.length,i=Array(n);++e<n;)i[e]=t(r[e],e,r);return i}var Rp=dB;var hB=Array.isArray,Pn=hB;var fB=1/0,tA=Vn?Vn.prototype:void 0,nA=tA?tA.toString:void 0;function rA(r){if(typeof r=="string")return r;if(Pn(r))return Rp(r,rA)+"";if(Oo(r))return nA?nA.call(r):"";var t=r+"";return t=="0"&&1/r==-fB?"-0":t}var iA=rA;var pB=/\s/;function mB(r){for(var t=r.length;t--&&pB.test(r.charAt(t)););return t}var sA=mB;var gB=/^\s+/;function yB(r){return r&&r.slice(0,sA(r)+1).replace(gB,"")}var oA=yB;function vB(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}var Hn=vB;var aA=0/0,xB=/^[-+]0x[0-9a-f]+$/i,bB=/^0b[01]+$/i,SB=/^0o[0-7]+$/i,wB=parseInt;function AB(r){if(typeof r=="number")return r;if(Oo(r))return aA;if(Hn(r)){var t=typeof r.valueOf=="function"?r.valueOf():r;r=Hn(t)?t+"":t}if(typeof r!="string")return r===0?r:+r;r=oA(r);var e=bB.test(r);return e||SB.test(r)?wB(r.slice(2),e?2:8):xB.test(r)?aA:+r}var O0=AB;function _B(r){return r}var lA=_B;var TB="[object AsyncFunction]",EB="[object Function]",MB="[object GeneratorFunction]",CB="[object Proxy]";function PB(r){if(!Hn(r))return!1;var t=Kr(r);return t==EB||t==MB||t==TB||t==CB}var Np=PB;var IB=rn["__core-js_shared__"],Bp=IB;var cA=function(){var r=/[^.]+$/.exec(Bp&&Bp.keys&&Bp.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function DB(r){return!!cA&&cA in r}var uA=DB;var OB=Function.prototype,LB=OB.toString;function RB(r){if(r!=null){try{return LB.call(r)}catch{}try{return r+""}catch{}}return""}var js=RB;var NB=/[\\^$.*+?()[\]{}|]/g,BB=/^\[object .+?Constructor\]$/,FB=Function.prototype,UB=Object.prototype,GB=FB.toString,kB=UB.hasOwnProperty,zB=RegExp("^"+GB.call(kB).replace(NB,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function VB(r){if(!Hn(r)||uA(r))return!1;var t=Np(r)?zB:BB;return t.test(js(r))}var dA=VB;function HB(r,t){return r?.[t]}var hA=HB;function WB(r,t){var e=hA(r,t);return dA(e)?e:void 0}var _r=WB;var jB=_r(rn,"WeakMap"),Fp=jB;var fA=Object.create,qB=function(){function r(){}return function(t){if(!Hn(t))return{};if(fA)return fA(t);r.prototype=t;var e=new r;return r.prototype=void 0,e}}(),pA=qB;function XB(r,t,e){switch(e.length){case 0:return r.call(t);case 1:return r.call(t,e[0]);case 2:return r.call(t,e[0],e[1]);case 3:return r.call(t,e[0],e[1],e[2])}return r.apply(t,e)}var mA=XB;function YB(r,t){var e=-1,n=r.length;for(t||(t=Array(n));++e<n;)t[e]=r[e];return t}var gA=YB;var KB=800,ZB=16,QB=Date.now;function JB(r){var t=0,e=0;return function(){var n=QB(),i=ZB-(n-e);if(e=n,i>0){if(++t>=KB)return arguments[0]}else t=0;return r.apply(void 0,arguments)}}var yA=JB;function $B(r){return function(){return r}}var vA=$B;var eF=function(){try{var r=_r(Object,"defineProperty");return r({},"",{}),r}catch{}}(),uc=eF;var tF=uc?function(r,t){return uc(r,"toString",{configurable:!0,enumerable:!1,value:vA(t),writable:!0})}:lA,xA=tF;var nF=yA(xA),bA=nF;function rF(r,t){for(var e=-1,n=r==null?0:r.length;++e<n&&t(r[e],e,r)!==!1;);return r}var SA=rF;var iF=9007199254740991,sF=/^(?:0|[1-9]\d*)$/;function oF(r,t){var e=typeof r;return t=t??iF,!!t&&(e=="number"||e!="symbol"&&sF.test(r))&&r>-1&&r%1==0&&r<t}var dc=oF;function aF(r,t,e){t=="__proto__"&&uc?uc(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[t]=e}var Up=aF;function lF(r,t){return r===t||r!==r&&t!==t}var hc=lF;var cF=Object.prototype,uF=cF.hasOwnProperty;function dF(r,t,e){var n=r[t];(!(uF.call(r,t)&&hc(n,e))||e===void 0&&!(t in r))&&Up(r,t,e)}var fc=dF;function hF(r,t,e,n){var i=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=n?n(e[a],r[a],a,e,r):void 0;l===void 0&&(l=r[a]),i?Up(e,a,l):fc(e,a,l)}return e}var $i=hF;var wA=Math.max;function fF(r,t,e){return t=wA(t===void 0?r.length-1:t,0),function(){for(var n=arguments,i=-1,s=wA(n.length-t,0),o=Array(s);++i<s;)o[i]=n[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=n[i];return a[t]=e(o),mA(r,this,a)}}var AA=fF;var pF=9007199254740991;function mF(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=pF}var pc=mF;function gF(r){return r!=null&&pc(r.length)&&!Np(r)}var Gp=gF;var yF=Object.prototype;function vF(r){var t=r&&r.constructor,e=typeof t=="function"&&t.prototype||yF;return r===e}var mc=vF;function xF(r,t){for(var e=-1,n=Array(r);++e<r;)n[e]=t(e);return n}var _A=xF;var bF="[object Arguments]";function SF(r){return Jn(r)&&Kr(r)==bF}var L0=SF;var TA=Object.prototype,wF=TA.hasOwnProperty,AF=TA.propertyIsEnumerable,_F=L0(function(){return arguments}())?L0:function(r){return Jn(r)&&wF.call(r,"callee")&&!AF.call(r,"callee")},gc=_F;function TF(){return!1}var EA=TF;var PA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,MA=PA&&typeof module=="object"&&module&&!module.nodeType&&module,EF=MA&&MA.exports===PA,CA=EF?rn.Buffer:void 0,MF=CA?CA.isBuffer:void 0,CF=MF||EA,Ga=CF;var PF="[object Arguments]",IF="[object Array]",DF="[object Boolean]",OF="[object Date]",LF="[object Error]",RF="[object Function]",NF="[object Map]",BF="[object Number]",FF="[object Object]",UF="[object RegExp]",GF="[object Set]",kF="[object String]",zF="[object WeakMap]",VF="[object ArrayBuffer]",HF="[object DataView]",WF="[object Float32Array]",jF="[object Float64Array]",qF="[object Int8Array]",XF="[object Int16Array]",YF="[object Int32Array]",KF="[object Uint8Array]",ZF="[object Uint8ClampedArray]",QF="[object Uint16Array]",JF="[object Uint32Array]",zt={};zt[WF]=zt[jF]=zt[qF]=zt[XF]=zt[YF]=zt[KF]=zt[ZF]=zt[QF]=zt[JF]=!0;zt[PF]=zt[IF]=zt[VF]=zt[DF]=zt[HF]=zt[OF]=zt[LF]=zt[RF]=zt[NF]=zt[BF]=zt[FF]=zt[UF]=zt[GF]=zt[kF]=zt[zF]=!1;function $F(r){return Jn(r)&&pc(r.length)&&!!zt[Kr(r)]}var IA=$F;function eU(r){return function(t){return r(t)}}var yc=eU;var DA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Kd=DA&&typeof module=="object"&&module&&!module.nodeType&&module,tU=Kd&&Kd.exports===DA,R0=tU&&Lp.process,nU=function(){try{var r=Kd&&Kd.require&&Kd.require("util").types;return r||R0&&R0.binding&&R0.binding("util")}catch{}}(),qs=nU;var OA=qs&&qs.isTypedArray,rU=OA?yc(OA):IA,kp=rU;var iU=Object.prototype,sU=iU.hasOwnProperty;function oU(r,t){var e=Pn(r),n=!e&&gc(r),i=!e&&!n&&Ga(r),s=!e&&!n&&!i&&kp(r),o=e||n||i||s,a=o?_A(r.length,String):[],l=a.length;for(var u in r)(t||sU.call(r,u))&&!(o&&(u=="length"||i&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||dc(u,l)))&&a.push(u);return a}var zp=oU;function aU(r,t){return function(e){return r(t(e))}}var Vp=aU;var lU=Vp(Object.keys,Object),LA=lU;var cU=Object.prototype,uU=cU.hasOwnProperty;function dU(r){if(!mc(r))return LA(r);var t=[];for(var e in Object(r))uU.call(r,e)&&e!="constructor"&&t.push(e);return t}var RA=dU;function hU(r){return Gp(r)?zp(r):RA(r)}var vc=hU;function fU(r){var t=[];if(r!=null)for(var e in Object(r))t.push(e);return t}var NA=fU;var pU=Object.prototype,mU=pU.hasOwnProperty;function gU(r){if(!Hn(r))return NA(r);var t=mc(r),e=[];for(var n in r)n=="constructor"&&(t||!mU.call(r,n))||e.push(n);return e}var BA=gU;function yU(r){return Gp(r)?zp(r,!0):BA(r)}var xc=yU;var vU=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,xU=/^\w*$/;function bU(r,t){if(Pn(r))return!1;var e=typeof r;return e=="number"||e=="symbol"||e=="boolean"||r==null||Oo(r)?!0:xU.test(r)||!vU.test(r)||t!=null&&r in Object(t)}var FA=bU;var SU=_r(Object,"create"),Xs=SU;function wU(){this.__data__=Xs?Xs(null):{},this.size=0}var UA=wU;function AU(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}var GA=AU;var _U="__lodash_hash_undefined__",TU=Object.prototype,EU=TU.hasOwnProperty;function MU(r){var t=this.__data__;if(Xs){var e=t[r];return e===_U?void 0:e}return EU.call(t,r)?t[r]:void 0}var kA=MU;var CU=Object.prototype,PU=CU.hasOwnProperty;function IU(r){var t=this.__data__;return Xs?t[r]!==void 0:PU.call(t,r)}var zA=IU;var DU="__lodash_hash_undefined__";function OU(r,t){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=Xs&&t===void 0?DU:t,this}var VA=OU;function bc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}bc.prototype.clear=UA;bc.prototype.delete=GA;bc.prototype.get=kA;bc.prototype.has=zA;bc.prototype.set=VA;var N0=bc;function LU(){this.__data__=[],this.size=0}var HA=LU;function RU(r,t){for(var e=r.length;e--;)if(hc(r[e][0],t))return e;return-1}var Lo=RU;var NU=Array.prototype,BU=NU.splice;function FU(r){var t=this.__data__,e=Lo(t,r);if(e<0)return!1;var n=t.length-1;return e==n?t.pop():BU.call(t,e,1),--this.size,!0}var WA=FU;function UU(r){var t=this.__data__,e=Lo(t,r);return e<0?void 0:t[e][1]}var jA=UU;function GU(r){return Lo(this.__data__,r)>-1}var qA=GU;function kU(r,t){var e=this.__data__,n=Lo(e,r);return n<0?(++this.size,e.push([r,t])):e[n][1]=t,this}var XA=kU;function Sc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}Sc.prototype.clear=HA;Sc.prototype.delete=WA;Sc.prototype.get=jA;Sc.prototype.has=qA;Sc.prototype.set=XA;var Ro=Sc;var zU=_r(rn,"Map"),No=zU;function VU(){this.size=0,this.__data__={hash:new N0,map:new(No||Ro),string:new N0}}var YA=VU;function HU(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}var KA=HU;function WU(r,t){var e=r.__data__;return KA(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Bo=WU;function jU(r){var t=Bo(this,r).delete(r);return this.size-=t?1:0,t}var ZA=jU;function qU(r){return Bo(this,r).get(r)}var QA=qU;function XU(r){return Bo(this,r).has(r)}var JA=XU;function YU(r,t){var e=Bo(this,r),n=e.size;return e.set(r,t),this.size+=e.size==n?0:1,this}var $A=YU;function wc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}wc.prototype.clear=YA;wc.prototype.delete=ZA;wc.prototype.get=QA;wc.prototype.has=JA;wc.prototype.set=$A;var ka=wc;var KU="Expected a function";function B0(r,t){if(typeof r!="function"||t!=null&&typeof t!="function")throw new TypeError(KU);var e=function(){var n=arguments,i=t?t.apply(this,n):n[0],s=e.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return e.cache=s.set(i,o)||s,o};return e.cache=new(B0.Cache||ka),e}B0.Cache=ka;var e_=B0;var ZU=500;function QU(r){var t=e_(r,function(n){return e.size===ZU&&e.clear(),n}),e=t.cache;return t}var t_=QU;var JU=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$U=/\\(\\)?/g,eG=t_(function(r){var t=[];return r.charCodeAt(0)===46&&t.push(""),r.replace(JU,function(e,n,i,s){t.push(i?s.replace($U,"$1"):n||e)}),t}),n_=eG;function tG(r){return r==null?"":iA(r)}var r_=tG;function nG(r,t){return Pn(r)?r:FA(r,t)?[r]:n_(r_(r))}var ci=nG;var rG=1/0;function iG(r){if(typeof r=="string"||Oo(r))return r;var t=r+"";return t=="0"&&1/r==-rG?"-0":t}var Fo=iG;function sG(r,t){t=ci(t,r);for(var e=0,n=t.length;r!=null&&e<n;)r=r[Fo(t[e++])];return e&&e==n?r:void 0}var Hp=sG;function oG(r,t){for(var e=-1,n=t.length,i=r.length;++e<n;)r[i+e]=t[e];return r}var Ac=oG;var i_=Vn?Vn.isConcatSpreadable:void 0;function aG(r){return Pn(r)||gc(r)||!!(i_&&r&&r[i_])}var s_=aG;function o_(r,t,e,n,i){var s=-1,o=r.length;for(e||(e=s_),i||(i=[]);++s<o;){var a=r[s];t>0&&e(a)?t>1?o_(a,t-1,e,n,i):Ac(i,a):n||(i[i.length]=a)}return i}var a_=o_;function lG(r){var t=r==null?0:r.length;return t?a_(r,1):[]}var l_=lG;function cG(r){return bA(AA(r,void 0,l_),r+"")}var Wp=cG;var uG=Vp(Object.getPrototypeOf,Object),_c=uG;var dG="[object Object]",hG=Function.prototype,fG=Object.prototype,c_=hG.toString,pG=fG.hasOwnProperty,mG=c_.call(Object);function gG(r){if(!Jn(r)||Kr(r)!=dG)return!1;var t=_c(r);if(t===null)return!0;var e=pG.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&c_.call(e)==mG}var u_=gG;function yG(r,t,e){var n=-1,i=r.length;t<0&&(t=-t>i?0:i+t),e=e>i?i:e,e<0&&(e+=i),i=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(i);++n<i;)s[n]=r[n+t];return s}var d_=yG;function vG(){this.__data__=new Ro,this.size=0}var h_=vG;function xG(r){var t=this.__data__,e=t.delete(r);return this.size=t.size,e}var f_=xG;function bG(r){return this.__data__.get(r)}var p_=bG;function SG(r){return this.__data__.has(r)}var m_=SG;var wG=200;function AG(r,t){var e=this.__data__;if(e instanceof Ro){var n=e.__data__;if(!No||n.length<wG-1)return n.push([r,t]),this.size=++e.size,this;e=this.__data__=new ka(n)}return e.set(r,t),this.size=e.size,this}var g_=AG;function Tc(r){var t=this.__data__=new Ro(r);this.size=t.size}Tc.prototype.clear=h_;Tc.prototype.delete=f_;Tc.prototype.get=p_;Tc.prototype.has=m_;Tc.prototype.set=g_;var Ec=Tc;function _G(r,t){return r&&$i(t,vc(t),r)}var y_=_G;function TG(r,t){return r&&$i(t,xc(t),r)}var v_=TG;var w_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,x_=w_&&typeof module=="object"&&module&&!module.nodeType&&module,EG=x_&&x_.exports===w_,b_=EG?rn.Buffer:void 0,S_=b_?b_.allocUnsafe:void 0;function MG(r,t){if(t)return r.slice();var e=r.length,n=S_?S_(e):new r.constructor(e);return r.copy(n),n}var A_=MG;function CG(r,t){for(var e=-1,n=r==null?0:r.length,i=0,s=[];++e<n;){var o=r[e];t(o,e,r)&&(s[i++]=o)}return s}var __=CG;function PG(){return[]}var jp=PG;var IG=Object.prototype,DG=IG.propertyIsEnumerable,T_=Object.getOwnPropertySymbols,OG=T_?function(r){return r==null?[]:(r=Object(r),__(T_(r),function(t){return DG.call(r,t)}))}:jp,Mc=OG;function LG(r,t){return $i(r,Mc(r),t)}var E_=LG;var RG=Object.getOwnPropertySymbols,NG=RG?function(r){for(var t=[];r;)Ac(t,Mc(r)),r=_c(r);return t}:jp,qp=NG;function BG(r,t){return $i(r,qp(r),t)}var M_=BG;function FG(r,t,e){var n=t(r);return Pn(r)?n:Ac(n,e(r))}var Xp=FG;function UG(r){return Xp(r,vc,Mc)}var Zd=UG;function GG(r){return Xp(r,xc,qp)}var Yp=GG;var kG=_r(rn,"DataView"),Kp=kG;var zG=_r(rn,"Promise"),Zp=zG;var VG=_r(rn,"Set"),Qp=VG;var C_="[object Map]",HG="[object Object]",P_="[object Promise]",I_="[object Set]",D_="[object WeakMap]",O_="[object DataView]",WG=js(Kp),jG=js(No),qG=js(Zp),XG=js(Qp),YG=js(Fp),za=Kr;(Kp&&za(new Kp(new ArrayBuffer(1)))!=O_||No&&za(new No)!=C_||Zp&&za(Zp.resolve())!=P_||Qp&&za(new Qp)!=I_||Fp&&za(new Fp)!=D_)&&(za=function(r){var t=Kr(r),e=t==HG?r.constructor:void 0,n=e?js(e):"";if(n)switch(n){case WG:return O_;case jG:return C_;case qG:return P_;case XG:return I_;case YG:return D_}return t});var Ys=za;var KG=Object.prototype,ZG=KG.hasOwnProperty;function QG(r){var t=r.length,e=new r.constructor(t);return t&&typeof r[0]=="string"&&ZG.call(r,"index")&&(e.index=r.index,e.input=r.input),e}var L_=QG;var JG=rn.Uint8Array,Cc=JG;function $G(r){var t=new r.constructor(r.byteLength);return new Cc(t).set(new Cc(r)),t}var Pc=$G;function ek(r,t){var e=t?Pc(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.byteLength)}var R_=ek;var tk=/\w*$/;function nk(r){var t=new r.constructor(r.source,tk.exec(r));return t.lastIndex=r.lastIndex,t}var N_=nk;var B_=Vn?Vn.prototype:void 0,F_=B_?B_.valueOf:void 0;function rk(r){return F_?Object(F_.call(r)):{}}var U_=rk;function ik(r,t){var e=t?Pc(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.length)}var G_=ik;var sk="[object Boolean]",ok="[object Date]",ak="[object Map]",lk="[object Number]",ck="[object RegExp]",uk="[object Set]",dk="[object String]",hk="[object Symbol]",fk="[object ArrayBuffer]",pk="[object DataView]",mk="[object Float32Array]",gk="[object Float64Array]",yk="[object Int8Array]",vk="[object Int16Array]",xk="[object Int32Array]",bk="[object Uint8Array]",Sk="[object Uint8ClampedArray]",wk="[object Uint16Array]",Ak="[object Uint32Array]";function _k(r,t,e){var n=r.constructor;switch(t){case fk:return Pc(r);case sk:case ok:return new n(+r);case pk:return R_(r,e);case mk:case gk:case yk:case vk:case xk:case bk:case Sk:case wk:case Ak:return G_(r,e);case ak:return new n;case lk:case dk:return new n(r);case ck:return N_(r);case uk:return new n;case hk:return U_(r)}}var k_=_k;function Tk(r){return typeof r.constructor=="function"&&!mc(r)?pA(_c(r)):{}}var z_=Tk;var Ek="[object Map]";function Mk(r){return Jn(r)&&Ys(r)==Ek}var V_=Mk;var H_=qs&&qs.isMap,Ck=H_?yc(H_):V_,W_=Ck;var Pk="[object Set]";function Ik(r){return Jn(r)&&Ys(r)==Pk}var j_=Ik;var q_=qs&&qs.isSet,Dk=q_?yc(q_):j_,X_=Dk;var Ok=1,Lk=2,Rk=4,Y_="[object Arguments]",Nk="[object Array]",Bk="[object Boolean]",Fk="[object Date]",Uk="[object Error]",K_="[object Function]",Gk="[object GeneratorFunction]",kk="[object Map]",zk="[object Number]",Z_="[object Object]",Vk="[object RegExp]",Hk="[object Set]",Wk="[object String]",jk="[object Symbol]",qk="[object WeakMap]",Xk="[object ArrayBuffer]",Yk="[object DataView]",Kk="[object Float32Array]",Zk="[object Float64Array]",Qk="[object Int8Array]",Jk="[object Int16Array]",$k="[object Int32Array]",ez="[object Uint8Array]",tz="[object Uint8ClampedArray]",nz="[object Uint16Array]",rz="[object Uint32Array]",Ut={};Ut[Y_]=Ut[Nk]=Ut[Xk]=Ut[Yk]=Ut[Bk]=Ut[Fk]=Ut[Kk]=Ut[Zk]=Ut[Qk]=Ut[Jk]=Ut[$k]=Ut[kk]=Ut[zk]=Ut[Z_]=Ut[Vk]=Ut[Hk]=Ut[Wk]=Ut[jk]=Ut[ez]=Ut[tz]=Ut[nz]=Ut[rz]=!0;Ut[Uk]=Ut[K_]=Ut[qk]=!1;function Jp(r,t,e,n,i,s){var o,a=t&Ok,l=t&Lk,u=t&Rk;if(e&&(o=i?e(r,n,i,s):e(r)),o!==void 0)return o;if(!Hn(r))return r;var c=Pn(r);if(c){if(o=L_(r),!a)return gA(r,o)}else{var d=Ys(r),h=d==K_||d==Gk;if(Ga(r))return A_(r,a);if(d==Z_||d==Y_||h&&!i){if(o=l||h?{}:z_(r),!a)return l?M_(r,v_(o,r)):E_(r,y_(o,r))}else{if(!Ut[d])return i?r:{};o=k_(r,d,a)}}s||(s=new Ec);var f=s.get(r);if(f)return f;s.set(r,o),X_(r)?r.forEach(function(m){o.add(Jp(m,t,e,m,r,s))}):W_(r)&&r.forEach(function(m,y){o.set(y,Jp(m,t,e,y,r,s))});var g=u?l?Yp:Zd:l?xc:vc,p=c?void 0:g(r);return SA(p||r,function(m,y){p&&(y=m,m=r[y]),fc(o,y,Jp(m,t,e,y,r,s))}),o}var $p=Jp;var iz=1,sz=4;function oz(r){return $p(r,iz|sz)}var Ks=oz;var az="__lodash_hash_undefined__";function lz(r){return this.__data__.set(r,az),this}var Q_=lz;function cz(r){return this.__data__.has(r)}var J_=cz;function em(r){var t=-1,e=r==null?0:r.length;for(this.__data__=new ka;++t<e;)this.add(r[t])}em.prototype.add=em.prototype.push=Q_;em.prototype.has=J_;var $_=em;function uz(r,t){for(var e=-1,n=r==null?0:r.length;++e<n;)if(t(r[e],e,r))return!0;return!1}var eT=uz;function dz(r,t){return r.has(t)}var tT=dz;var hz=1,fz=2;function pz(r,t,e,n,i,s){var o=e&hz,a=r.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var u=s.get(r),c=s.get(t);if(u&&c)return u==t&&c==r;var d=-1,h=!0,f=e&fz?new $_:void 0;for(s.set(r,t),s.set(t,r);++d<a;){var g=r[d],p=t[d];if(n)var m=o?n(p,g,d,t,r,s):n(g,p,d,r,t,s);if(m!==void 0){if(m)continue;h=!1;break}if(f){if(!eT(t,function(y,v){if(!tT(f,v)&&(g===y||i(g,y,e,n,s)))return f.push(v)})){h=!1;break}}else if(!(g===p||i(g,p,e,n,s))){h=!1;break}}return s.delete(r),s.delete(t),h}var tm=pz;function mz(r){var t=-1,e=Array(r.size);return r.forEach(function(n,i){e[++t]=[i,n]}),e}var nT=mz;function gz(r){var t=-1,e=Array(r.size);return r.forEach(function(n){e[++t]=n}),e}var rT=gz;var yz=1,vz=2,xz="[object Boolean]",bz="[object Date]",Sz="[object Error]",wz="[object Map]",Az="[object Number]",_z="[object RegExp]",Tz="[object Set]",Ez="[object String]",Mz="[object Symbol]",Cz="[object ArrayBuffer]",Pz="[object DataView]",iT=Vn?Vn.prototype:void 0,F0=iT?iT.valueOf:void 0;function Iz(r,t,e,n,i,s,o){switch(e){case Pz:if(r.byteLength!=t.byteLength||r.byteOffset!=t.byteOffset)return!1;r=r.buffer,t=t.buffer;case Cz:return!(r.byteLength!=t.byteLength||!s(new Cc(r),new Cc(t)));case xz:case bz:case Az:return hc(+r,+t);case Sz:return r.name==t.name&&r.message==t.message;case _z:case Ez:return r==t+"";case wz:var a=nT;case Tz:var l=n&yz;if(a||(a=rT),r.size!=t.size&&!l)return!1;var u=o.get(r);if(u)return u==t;n|=vz,o.set(r,t);var c=tm(a(r),a(t),n,i,s,o);return o.delete(r),c;case Mz:if(F0)return F0.call(r)==F0.call(t)}return!1}var sT=Iz;var Dz=1,Oz=Object.prototype,Lz=Oz.hasOwnProperty;function Rz(r,t,e,n,i,s){var o=e&Dz,a=Zd(r),l=a.length,u=Zd(t),c=u.length;if(l!=c&&!o)return!1;for(var d=l;d--;){var h=a[d];if(!(o?h in t:Lz.call(t,h)))return!1}var f=s.get(r),g=s.get(t);if(f&&g)return f==t&&g==r;var p=!0;s.set(r,t),s.set(t,r);for(var m=o;++d<l;){h=a[d];var y=r[h],v=t[h];if(n)var x=o?n(v,y,h,t,r,s):n(y,v,h,r,t,s);if(!(x===void 0?y===v||i(y,v,e,n,s):x)){p=!1;break}m||(m=h=="constructor")}if(p&&!m){var b=r.constructor,w=t.constructor;b!=w&&"constructor"in r&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof w=="function"&&w instanceof w)&&(p=!1)}return s.delete(r),s.delete(t),p}var oT=Rz;var Nz=1,aT="[object Arguments]",lT="[object Array]",nm="[object Object]",Bz=Object.prototype,cT=Bz.hasOwnProperty;function Fz(r,t,e,n,i,s){var o=Pn(r),a=Pn(t),l=o?lT:Ys(r),u=a?lT:Ys(t);l=l==aT?nm:l,u=u==aT?nm:u;var c=l==nm,d=u==nm,h=l==u;if(h&&Ga(r)){if(!Ga(t))return!1;o=!0,c=!1}if(h&&!c)return s||(s=new Ec),o||kp(r)?tm(r,t,e,n,i,s):sT(r,t,l,e,n,i,s);if(!(e&Nz)){var f=c&&cT.call(r,"__wrapped__"),g=d&&cT.call(t,"__wrapped__");if(f||g){var p=f?r.value():r,m=g?t.value():t;return s||(s=new Ec),i(p,m,e,n,s)}}return h?(s||(s=new Ec),oT(r,t,e,n,i,s)):!1}var uT=Fz;function dT(r,t,e,n,i){return r===t?!0:r==null||t==null||!Jn(r)&&!Jn(t)?r!==r&&t!==t:uT(r,t,e,n,dT,i)}var hT=dT;function Uz(r,t){return r!=null&&t in Object(r)}var fT=Uz;function Gz(r,t,e){t=ci(t,r);for(var n=-1,i=t.length,s=!1;++n<i;){var o=Fo(t[n]);if(!(s=r!=null&&e(r,o)))break;r=r[o]}return s||++n!=i?s:(i=r==null?0:r.length,!!i&&pc(i)&&dc(o,i)&&(Pn(r)||gc(r)))}var pT=Gz;function kz(r,t){return r!=null&&pT(r,t,fT)}var mT=kz;var zz=function(){return rn.Date.now()},rm=zz;var Vz="Expected a function",Hz=Math.max,Wz=Math.min;function jz(r,t,e){var n,i,s,o,a,l,u=0,c=!1,d=!1,h=!0;if(typeof r!="function")throw new TypeError(Vz);t=O0(t)||0,Hn(e)&&(c=!!e.leading,d="maxWait"in e,s=d?Hz(O0(e.maxWait)||0,t):s,h="trailing"in e?!!e.trailing:h);function f(A){var T=n,S=i;return n=i=void 0,u=A,o=r.apply(S,T),o}function g(A){return u=A,a=setTimeout(y,t),c?f(A):o}function p(A){var T=A-l,S=A-u,E=t-T;return d?Wz(E,s-S):E}function m(A){var T=A-l,S=A-u;return l===void 0||T>=t||T<0||d&&S>=s}function y(){var A=rm();if(m(A))return v(A);a=setTimeout(y,p(A))}function v(A){return a=void 0,h&&n?f(A):(n=i=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,n=l=i=a=void 0}function b(){return a===void 0?o:v(rm())}function w(){var A=rm(),T=m(A);if(n=arguments,i=this,l=A,T){if(a===void 0)return g(l);if(d)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 Qd=jz;function qz(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}var gT=qz;function Xz(r,t){return t.length<2?r:Hp(r,d_(t,0,-1))}var yT=Xz;function Yz(r,t){return hT(r,t)}var Va=Yz;function Kz(r,t){return t=ci(t,r),r=yT(r,t),r==null||delete r[Fo(gT(t))]}var vT=Kz;function Zz(r){return u_(r)?void 0:r}var xT=Zz;var Qz=1,Jz=2,$z=4,eV=Wp(function(r,t){var e={};if(r==null)return e;var n=!1;t=Rp(t,function(s){return s=ci(s,r),n||(n=s.length>1),s}),$i(r,Yp(r),e),n&&(e=$p(e,Qz|Jz|$z,xT));for(var i=t.length;i--;)vT(e,t[i]);return e}),Ic=eV;function tV(r,t,e,n){if(!Hn(r))return r;t=ci(t,r);for(var i=-1,s=t.length,o=s-1,a=r;a!=null&&++i<s;){var l=Fo(t[i]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return r;if(i!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=Hn(c)?c:dc(t[i+1])?[]:{})}fc(a,l,u),a=a[l]}return r}var bT=tV;function nV(r,t,e){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=Hp(r,o);e(a,o)&&bT(s,ci(o,r),a)}return s}var ST=nV;function rV(r,t){return ST(r,t,function(e,n){return mT(r,n)})}var wT=rV;var iV=Wp(function(r,t){return r==null?{}:wT(r,t)}),Uo=iV;var _T,TT=new Promise(r=>{_T=r}),AT=!1;async function ET(){if(AT)return;let r=await import("./physics.js");await r.init(),_T(r),AT=!0}var Ot=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,Ot.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],i;n===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:n};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,Ot.prototype),{data:a,actual:t,reverse:i}}else if(t.type===2){let{id:n}=t,i=e[n];if(i===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,Ot.prototype),delete s[n],{data:s,actual:t,reverse:{type:1,id:n,data:i}}}}return null}};function Jd(r){if(r.deepFreeze!==void 0){r.deepFreeze(r);return}let t=Object.getOwnPropertyNames(r);for(let e of t){let n=r[e];n&&typeof n=="object"&&Jd(n)}return Object.freeze(r)}function MT(r,t){let e=0;for(;e<r.length&&e<t.length;){if(r[e]<t[e])return-1;if(r[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==r.length?1:0}var Dc=class extends Error{};function im(r){let t={...r};return Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}function es(r,t,e){if(r===void 0?t===void 0?(r=0,t=10):r=t-10:t===void 0&&(t=r+10),r>t){let s=r;r=t,t=s}let n=[],i=1/(e+1);for(let s=0;s<e;s++){let o=r+(t-r)*(s+.75+Math.random()*.5)*i;n.push(o)}return n}function Oc(r){return r instanceof Uint8Array||r instanceof Uint16Array||r instanceof Uint32Array||r instanceof Int8Array||r instanceof Int16Array||r instanceof Int32Array||r instanceof Float32Array||r instanceof Float64Array}function CT(){return typeof process<"u"}function PT(r,t){for(let e of r)t(e.id,e.data)!==!0&&PT(e.children,t)}function IT(r,t){if(t(r.id,r.data)!==!0)for(let e of r.children)IT(e,t)}var qt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,qt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Jd(this[e]),e++}fillCaches0(e,n){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,n);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,n){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===n)return!0;e=i}return!1}isDescendantOf(e,n){for(;e;){let i=this.parent(e);if(i===n)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,n){if(e===null)this.traverse(n);else{let i=this.get(e);i&&IT(i,n)}}traverse(e){PT(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 i=e,s=n;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,qt.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 i of n)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:n,fi:i,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:i,id:s,data:o,children:a};return u=[...u,c],u.sort((h,f)=>h.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 i=this.parent(n);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(u=>u.id===n);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:n,fi:i,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 Dc("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],d=this.modifyArrayBy(o,l);o=n,l=d.childrenArray(o);let h=c.fi;return c={...c,fi:i},l=[...l,c],l.sort((f,g)=>f.fi-g.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(o,l),{data:d,actual:e,reverse:{type:9,parent:a,fi:h,id:s}}}previous(e,n){if(n===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(e)){if(s.id===n)return i;i=s.id}return null}traverseSortNext(e){let n=this.parent(e);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===e)+1;if(s<i.length)return i[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 i=this.childrenArray(n),s=i.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(i[s].id):n}}getAllSorted(e){let n=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&n.push({...i,...s})}n.sort((i,s)=>MT(i.sortKey,s.sortKey));for(let i of n)delete i.sortKey;return n}getWithSortKey(e){var n=e;let i=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)i.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:i}}}insertBeforeHelper(e,n,i){return this.insertAfterHelper(e,this.previous(e,n),i)}insertAfterHelper(e,n,i){let s=this.childrenArray(e);if(n===null){if(s.length===0)return es(0,i,i);{let o=s[0].fi;return es(o-i,o,i)}}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 es(l,l+i,i)}else return es(o.fi,a.fi,i)}}};var Lc;(t=>{function r(e,n){if(n.type!==0)return null;if(Array.isArray(e)){let i=n.props,s={},o=[...e],a=!1;if(i)for(let l of Object.keys(i)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=i[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let i=n.props,s={},o={...e},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let u=i[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}t.runOp=r})(Lc||(Lc={}));var He=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,He.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Jd(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,He.prototype);let n=e;return CT()||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:i,data:s}=e,o=this,a={fi:n,id:i,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:i}}}deleteOp(e){let{id:n}=e,i=this,s=i.findIndex(l=>l.id===n);if(s===-1)return null;e.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:n,id:i}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,d)=>c.fi-d.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let i of this){if(i.id===e)return n;n=i.id}return null}insertBeforeHelper(e,n){return this.insertAfterHelper(this.previous(e),n)}insertAfterHelper(e,n){let i=this;if(e===null){if(i.length===0)return es(0,n,n);{let s=i[0].fi;return es(s-n,s,n)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return es(a,a+n,n)}else return es(s.fi,o.fi,n)}}};function Rc(r){return r&&typeof r=="object"&&r instanceof Xt}var Xt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],n=this,i=0,s={};for(;i<t.path.length;){if(e.push(n),n=n===void 0?void 0:n[t.path[i]],n!==void 0&&!Rc(n))return null;i+=1}n=n?im(n):new Xt;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(;i>0;){if(Object.keys(n).length===0){let l=e[i-1];l&&(n=im(l),delete n[t.path[i-1]])}else{let l=e[i-1];if(l){let u=im(l);u[t.path[i-1]]=n,n=u}else{let u=new Xt;u[t.path[i-1]]=n,n=u}}i-=1}let o=Object.setPrototypeOf(n,Xt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},Zs;(n=>{function r(i,s){return $d(i,s)??i}n.apply=r;function t(i,s){return G0(i,s)}n.merge=t;function e(i,s){let o=0,a=s.path,l=i;for(;o<a.length&&l!==void 0;){if(l=gr.zoomOnce(l,a[o]),l===void 0)return s;if(!Rc(l))return;o+=1}if(l===void 0)return s;if(!!Rc(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=U0([s],l);return u?(console.log(u),u):s}else return s}n.filterOp=e})(Zs||(Zs={}));function U0(r,t){if(t===void 0)return;let e=!1,n=r.map(i=>{let s=i.id,o=$d(i.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=i.data),i.children){let a=U0(i.children,t);return a!==void 0?e=!0:a=i.children,{...i,id:s,data:o,children:a}}else return{...i,id:s,data:o}});if(e)return n}function sV(r,t){if(t===void 0)return;let e=!1,n=r.map(i=>{let s=i.id,o=$d(i.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=i.data),{...i,id:s,data:o}});if(e)return Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}function $d(r,t){if(!Rc(t))return t;if(r instanceof qt){let e=U0(r,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}else{if(r instanceof He)return sV(r,t);if(Array.isArray(r)){let e=!1,n=r.map((i,s)=>{let o=$d(i,t[s]);return e=e||o!==void 0,o===void 0&&(o=i),o});return e?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else{if(r instanceof Xt)return G0(r,t);if(r&&typeof r=="object"){let e={},n=!1;for(let[i,s]of Object.entries(r)){let o=$d(s,t[i]);n=n||o!==void 0,o===void 0&&(o=s),e[i]=o}return n?(Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e):void 0}}}}function G0(r,t){if(r===void 0)return t;if(t===void 0)return r;if(!Rc(t))return t;if(!Rc(r))return Zs.apply(r,t);let e=new Set;for(let i of Object.keys(r))e.add(i);for(let i of Object.keys(t))e.add(i);let n=new Xt;for(let i of e){let s=G0(r===void 0?void 0:r[i],t===void 0?void 0:t[i]);n[i]=s}return n}function DT(r,t){let e={cur:[],result:[],len:0};return r=eh(r,t,e)??r,[r,e.result]}function sm(r,t){return r===null?null:(r.cur[r.len]=t,r.len+=1,r)}function om(r){r&&(r.len-=1)}function oV(r){if(r===null)return null;r.result.push(r.cur.slice(0,r.len))}function OT(r,t,e){let n=!1,i=r.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=eh(s.data,t,sm(e,o));om(e),n=n||l!==void 0,l===void 0&&(l=s.data);let u=OT(s.children,t,e);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return i}function aV(r,t,e){let n=!1,i=r.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=eh(s.data,t,sm(e,o));return om(e),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i}function eh(r,t,e){if(r instanceof qt){let n=OT(r,t,e);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}else{if(r instanceof He)return aV(r,t,e);if(Array.isArray(r)){let n=!1,i=r.map((s,o)=>{let a=eh(s,t,sm(e,o));return om(e),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i):void 0}else if(r&&typeof r=="object"&&!Oc(r)){let n={},i=!1;for(let[s,o]of Object.entries(r))if(s!=="name"&&s!=="text"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");i=!0,s=a}let l=eh(o,t,sm(e,s));om(e),i=i||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return i?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else if(typeof r=="string"){let n=t[r];if(n!==void 0){if(r.length!==36)throw new Error("for now you should only call this method when the key is a uuid");oV(e)}return n}else return}}var am;(t=>{function r(e,n){let i=gr.zoom(n,e.path);if(typeof i=="object"){let s={};for(let o of Object.keys(e.props))s[o]=i[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=r})(am||(am={}));var $n;(a=>{function r(l,u){return{...l,path:l.path.slice(u)}}a.drop=r;function t(l,u){return e(l,u)?.data??l}a.applySimple=t;function e(l,u){let c=u.path;for(var d=[];;){let h;if(l instanceof Xt&&u.type===0&&(h=l.runOp({...u,path:c.slice(d.length)}),h===null&&(h=void 0)),d.length===c.length&&(l instanceof qt||l instanceof He||l instanceof Ot?h=l.runOp(u):h=Lc.runOp(l,u)),h!==void 0)if(h!==null){let p=h.data;for(let m=d.length-1;m>=0;m--){let y=c[m],v=d[m];if(v instanceof qt){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof He){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Ot){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Xt){let x={...v,[y]:p};p=Object.setPrototypeOf(x,Xt.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=p;p=[...v],p[y]=x}else p={...v,[y]:p};else return null}return{data:p,actual:{...h.actual,path:c},reverse:{...h.reverse,path:c}}}else return null;let f=c[d.length],g;if(l instanceof qt){if(typeof f=="number")throw new Error("");g=l.get(f)?.data}else if(l instanceof He){if(typeof f=="number")throw new Error("");g=l.get(f)?.data}else l!==null&&(g=l[f]);if(g!==void 0)d.push(l),l=g;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 i(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=i;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&i(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})($n||($n={}));var k0;(l=>{function r(){return[]}l.empty=r;function t(u,c){let d=[];for(let h of u){let[f,...g]=h.path;f===c&&d.push({...h,path:g})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function n(u,c){return[...u,...c]}l.concat=n;function i(u,c){return[...u.filter(h=>!c.some(f=>$n.subsumed(h,f))),...c]}l.compress=i;function s(u,c){return u.every(d=>c.every(h=>$n.commutative(d,h)))}l.commutative=s;function o(u,c){for(let d of c){let h=a(u,d);h!==null&&(u=h.data)}return u}l.applyAll=o;function a(u,c){var d=u;let h=[],f=[];for(let g of c)try{if(g.type===3){let p=gr.zoom(d,[...g.path,g.id]),m=$n.apply(d,{...g,type:2});if(m!==null){d=m.data;let[y,v]=DT(d,{[g.id]:p});d=y;for(let x of v){let b=x[x.length-1];x.splice(x.length-1,1),h.push({type:0,path:x,props:{[b]:p}}),f.push({type:0,path:x,props:{[b]:g.id}})}f.push(m.reverse),h.push(m.actual)}}else{let p=$n.apply(d,g);p!==null&&(h.push(p.actual),d=p.data,f.push(p.reverse))}}catch(p){if(p instanceof Dc)return null;throw p}return{data:d,actual:h,reverse:f.reverse()}}l.apply=a})(k0||(k0={}));var LT=Symbol(),lV=Symbol(),cm=Symbol(),Ha=class{reportOp(t,e,n=[]){let i=this;if(e===null)return;i._current=e.data;let s=n;for(;!(i instanceof lm);){let o=i._path,a=i._current;if(o!==""&&s.splice(0,0,o),i=i._parent,i===null)return;i.update(o,a)}i.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let n=e[cm];n&&n(),delete this._children[t]}}}},V0=class extends Ha{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,Lc.runOp(this._current,t),t.path)}},H0=class extends Ha{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,Ot.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},RT={get(r,t){if(t===cm)return()=>{r._parent=null};if(t===LT)return r._current;if(t===lV)return r;let{_current:e,_children:n}=r;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e[t],o=um(r,t,s);return o!==s?(n===void 0&&(n={},r._children=n),n[t]=o,o):s},has(r,t){return t in r._current},ownKeys(r){return Reflect.ownKeys(r._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(r){return Object.getPrototypeOf(r._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(r,t){let e=r._current,n=Reflect.getOwnPropertyDescriptor(e,t);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:e[t]}}},cV={...RT,set(r,t,e){let n={type:0,props:{[t]:Wn(e)??e}};return r.deleteChildren(t),r.runOp(n),!0},deleteProperty(r,t){let e={type:0,props:{[t]:void 0}};return r.deleteChildren(t),r.runOp(e),!0}},uV={...RT,set(r,t,e){return e===void 0?this.deleteProperty(r,t):(r.deleteChildren(t),r.runOp({type:1,id:t,data:e})),!0},deleteProperty(r,t){return r.runOp({type:2,id:t}),!0}},Nc=class extends Ha{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[cm]=()=>{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,i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=um(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}add(t,e,n,i,s){this.runOp({type:7,parent:t,fi:e,id:n,data:i,children:s})}move(t,e,n){this.runOp({type:9,parent:t,fi:e,id:n})}insertAfter(t,e,n){let i=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,i[s],o.id,o.data,o.children)}}insertBefore(t,e,n){let i=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,i[s],o.id,o.data,o.children)}}moveAfter(t,e,n){let i=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,i[s],o)}}moveBefore(t,e,n){let i=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,i[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)}},Bc=class extends Ha{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[cm]=()=>{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 i=this._current[n].id,s=this._current[n].fi;t(this.data(this._current[n].id),i,s)}}find(t){let e=this.length;for(let n=0;n<e;n++){let i=this._current[n].id;if(t(this.data(i),i))return this.get(i)}}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,i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=um(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 i=0;i<e.length;i++){let s=e[i];this.add(n[i],s.id,s.data)}}insertBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.add(n[i],s.id,s.data)}}moveAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(n[i],s)}}moveBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(n[i],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function z0(r,t,e){if(r.length>0){let n=r[r.length-1];if(n.type===0&&t.type===0&&gr.equal(n.path,e)){Object.assign(n.props,t.props);return}}r.push({...t,path:e})}var lm=class extends Ha{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,i){z0(this.ts,e,t),z0(this.actual,n,t),z0(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function um(r,t,e){return e instanceof qt?new Nc(r,t,e):e instanceof He?new Bc(r,t,e):e instanceof Ot?new Proxy(new H0(r,t,e),uV):e!==null&&typeof e=="object"?Oc(e)?e:new Proxy(new V0(r,t,e),cV):e}function W0(r){let t=new lm(r);return[um(t,"",r),t]}function Fc(r,t){let[e,n]=W0(r);return t(e),n.result()}function Wn(r){return r instanceof Nc||r instanceof Bc?r._current:r!==null&&typeof r=="object"?r[LT]:r}var gr;(i=>{function r(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}i.equal=r;function 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}i.removeOverridden=t;function e(s,o){if((s instanceof qt||s instanceof Nc)&&typeof o=="string")return s.data(o);if((s instanceof He||s instanceof Bc)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}i.zoomOnce=e;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}i.zoom=n})(gr||(gr={}));function NT(r,t){let e=[];if(t.length===r.length)for(var n=0;n<r.length;){if(t[n]==="*")e.push(r[n]);else if(r[n]!==t[n])return null;n+=1}else return null;return e}function Ii(r,t){let e=[];if(t.length<=r.length)for(var n=0;n<t.length;){if(t[n]==="*")e.push(r[n]);else if(r[n]!==t[n])return null;n+=1}else return null;return e}var dm=class{},th=class extends dm{constructor(e){super();this.id=e}},nh=class extends dm{constructor(e){super();this.data=e}};var q0;try{q0=new TextDecoder}catch{}var Oe,ko,Q=0;var HT=[],X0=HT,Y0=0,Tr={},_t,Go,ui=0,ts=0,Zr,Qs,yr=[],Ct,BT={useRecords:!1,mapsAsObjects:!0},rh=class{},Z0=new rh;Z0.name="MessagePack 0xC1";var Uc=!1,ns=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(Oe)return YT(()=>(fm(),this?this.unpack(t,e):ns.prototype.unpack.call(BT,t,e)));ko=e>-1?e:t.length,Q=0,Y0=0,ts=0,Go=null,X0=HT,Zr=null,Oe=t;try{Ct=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw Oe=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 ns){if(Tr=this,this.structures)return _t=this.structures,hm();(!_t||_t.length>0)&&(_t=[])}else Tr=BT,(!_t||_t.length>0)&&(_t=[]);return hm()}unpackMultiple(t,e){let n,i=0;try{Uc=!0;let s=t.length,o=this?this.unpack(t,s):gm.unpack(t,s);if(e){for(e(o);Q<s;)if(i=Q,e(hm())===!1)return}else{for(n=[o];Q<s;)i=Q,n.push(hm());return n}}catch(s){throw s.lastPosition=i,s.values=n,s}finally{Uc=!1,fm()}}_mergeStructures(t,e){t=t||[];for(let n=0,i=t.length;n<i;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 i=t[n],s=e[n];s&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[n]=i),t[n]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function hm(){try{if(!Tr.trusted&&!Uc){let t=_t.sharedLength||0;t<_t.length&&(_t.length=t)}let r=sn();if(Q==ko)_t.restoreStructures&&FT(),_t=null,Oe=null,Qs&&(Qs=null);else if(Q>ko){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Uc)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw _t.restoreStructures&&FT(),fm(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function FT(){for(let r in _t.restoreStructures)_t[r]=_t.restoreStructures[r];_t.restoreStructures=null}function sn(){let r=Oe[Q++];if(r<160)if(r<128){if(r<64)return r;{let t=_t[r&63]||Tr.getStructures&&WT()[r&63];return t?(t.read||(t.read=Q0(t,r&63)),t.read()):r}}else if(r<144)if(r-=128,Tr.mapsAsObjects){let t={};for(let e=0;e<r;e++)t[qT()]=sn();return t}else{let t=new Map;for(let e=0;e<r;e++)t.set(sn(),sn());return t}else{r-=144;let t=new Array(r);for(let e=0;e<r;e++)t[e]=sn();return t}else if(r<192){let t=r-160;if(ts>=Q)return Go.slice(Q-ui,(Q+=t)-ui);if(ts==0&&ko<140){let e=t<16?J0(t):jT(t);if(e!=null)return e}return K0(t)}else{let t;switch(r){case 192:return null;case 193:return Zr?(t=sn(),t>0?Zr[1].slice(Zr.position1,Zr.position1+=t):Zr[0].slice(Zr.position0,Zr.position0-=t)):Z0;case 194:return!1;case 195:return!0;case 196:return j0(Oe[Q++]);case 197:return t=Ct.getUint16(Q),Q+=2,j0(t);case 198:return t=Ct.getUint32(Q),Q+=4,j0(t);case 199:return Wa(Oe[Q++]);case 200:return t=Ct.getUint16(Q),Q+=2,Wa(t);case 201:return t=Ct.getUint32(Q),Q+=4,Wa(t);case 202:if(t=Ct.getFloat32(Q),Tr.useFloat32>2){let e=mm[(Oe[Q]&127)<<1|Oe[Q+1]>>7];return Q+=4,(e*t+(t>0?.5:-.5)>>0)/e}return Q+=4,t;case 203:return t=Ct.getFloat64(Q),Q+=8,t;case 204:return Oe[Q++];case 205:return t=Ct.getUint16(Q),Q+=2,t;case 206:return t=Ct.getUint32(Q),Q+=4,t;case 207:return Tr.int64AsNumber?(t=Ct.getUint32(Q)*4294967296,t+=Ct.getUint32(Q+4)):t=Ct.getBigUint64(Q),Q+=8,t;case 208:return Ct.getInt8(Q++);case 209:return t=Ct.getInt16(Q),Q+=2,t;case 210:return t=Ct.getInt32(Q),Q+=4,t;case 211:return Tr.int64AsNumber?(t=Ct.getInt32(Q)*4294967296,t+=Ct.getUint32(Q+4)):t=Ct.getBigInt64(Q),Q+=8,t;case 212:if(t=Oe[Q++],t==114)return VT(Oe[Q++]&63);{let e=yr[t];if(e)return e.read?(Q++,e.read(sn())):e.noBuffer?(Q++,e()):e(Oe.subarray(Q,++Q));throw new Error("Unknown extension "+t)}case 213:return t=Oe[Q],t==114?(Q++,VT(Oe[Q++]&63,Oe[Q++])):Wa(2);case 214:return Wa(4);case 215:return Wa(8);case 216:return Wa(16);case 217:return t=Oe[Q++],ts>=Q?Go.slice(Q-ui,(Q+=t)-ui):hV(t);case 218:return t=Ct.getUint16(Q),Q+=2,ts>=Q?Go.slice(Q-ui,(Q+=t)-ui):fV(t);case 219:return t=Ct.getUint32(Q),Q+=4,ts>=Q?Go.slice(Q-ui,(Q+=t)-ui):pV(t);case 220:return t=Ct.getUint16(Q),Q+=2,GT(t);case 221:return t=Ct.getUint32(Q),Q+=4,GT(t);case 222:return t=Ct.getUint16(Q),Q+=2,kT(t);case 223:return t=Ct.getUint32(Q),Q+=4,kT(t);default:if(r>=224)return r-256;if(r===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+r)}}}var dV=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Q0(r,t){function e(){if(e.count++>2){let i=r.read=new Function("r","return function(){return {"+r.map(s=>dV.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(sn);return r.highByte===0&&(r.read=UT(t,r.read)),i()}let n={};for(let i=0,s=r.length;i<s;i++){let o=r[i];n[o]=sn()}return n}return e.count=0,r.highByte===0?UT(t,e):e}var UT=(r,t)=>function(){let e=Oe[Q++];if(e===0)return t();let n=r<32?-(r+(e<<5)):r+(e<<5),i=_t[n]||WT()[n];if(!i)throw new Error("Record id is not defined for "+n);return i.read||(i.read=Q0(i,r)),i.read()};function WT(){let r=YT(()=>(Oe=null,Tr.getStructures()));return _t=Tr._mergeStructures(r,_t)}var K0=pm,hV=pm,fV=pm,pV=pm;function pm(r){let t;if(r<16&&(t=J0(r)))return t;if(r>64&&q0)return q0.decode(Oe.subarray(Q,Q+=r));let e=Q+r,n=[];for(t="";Q<e;){let i=Oe[Q++];if((i&128)===0)n.push(i);else if((i&224)===192){let s=Oe[Q++]&63;n.push((i&31)<<6|s)}else if((i&240)===224){let s=Oe[Q++]&63,o=Oe[Q++]&63;n.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Oe[Q++]&63,o=Oe[Q++]&63,a=Oe[Q++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(i);n.length>=4096&&(t+=jn.apply(String,n),n.length=0)}return n.length>0&&(t+=jn.apply(String,n)),t}function GT(r){let t=new Array(r);for(let e=0;e<r;e++)t[e]=sn();return t}function kT(r){if(Tr.mapsAsObjects){let t={};for(let e=0;e<r;e++)t[qT()]=sn();return t}else{let t=new Map;for(let e=0;e<r;e++)t.set(sn(),sn());return t}}var jn=String.fromCharCode;function jT(r){let t=Q,e=new Array(r);for(let n=0;n<r;n++){let i=Oe[Q++];if((i&128)>0){Q=t;return}e[n]=i}return jn.apply(String,e)}function J0(r){if(r<4)if(r<2){if(r===0)return"";{let t=Oe[Q++];if((t&128)>1){Q-=1;return}return jn(t)}}else{let t=Oe[Q++],e=Oe[Q++];if((t&128)>0||(e&128)>0){Q-=2;return}if(r<3)return jn(t,e);let n=Oe[Q++];if((n&128)>0){Q-=3;return}return jn(t,e,n)}else{let t=Oe[Q++],e=Oe[Q++],n=Oe[Q++],i=Oe[Q++];if((t&128)>0||(e&128)>0||(n&128)>0||(i&128)>0){Q-=4;return}if(r<6){if(r===4)return jn(t,e,n,i);{let s=Oe[Q++];if((s&128)>0){Q-=5;return}return jn(t,e,n,i,s)}}else if(r<8){let s=Oe[Q++],o=Oe[Q++];if((s&128)>0||(o&128)>0){Q-=6;return}if(r<7)return jn(t,e,n,i,s,o);let a=Oe[Q++];if((a&128)>0){Q-=7;return}return jn(t,e,n,i,s,o,a)}else{let s=Oe[Q++],o=Oe[Q++],a=Oe[Q++],l=Oe[Q++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){Q-=8;return}if(r<10){if(r===8)return jn(t,e,n,i,s,o,a,l);{let u=Oe[Q++];if((u&128)>0){Q-=9;return}return jn(t,e,n,i,s,o,a,l,u)}}else if(r<12){let u=Oe[Q++],c=Oe[Q++];if((u&128)>0||(c&128)>0){Q-=10;return}if(r<11)return jn(t,e,n,i,s,o,a,l,u,c);let d=Oe[Q++];if((d&128)>0){Q-=11;return}return jn(t,e,n,i,s,o,a,l,u,c,d)}else{let u=Oe[Q++],c=Oe[Q++],d=Oe[Q++],h=Oe[Q++];if((u&128)>0||(c&128)>0||(d&128)>0||(h&128)>0){Q-=12;return}if(r<14){if(r===12)return jn(t,e,n,i,s,o,a,l,u,c,d,h);{let f=Oe[Q++];if((f&128)>0){Q-=13;return}return jn(t,e,n,i,s,o,a,l,u,c,d,h,f)}}else{let f=Oe[Q++],g=Oe[Q++];if((f&128)>0||(g&128)>0){Q-=14;return}if(r<15)return jn(t,e,n,i,s,o,a,l,u,c,d,h,f,g);let p=Oe[Q++];if((p&128)>0){Q-=15;return}return jn(t,e,n,i,s,o,a,l,u,c,d,h,f,g,p)}}}}}function j0(r){return Tr.copyBuffers?Uint8Array.prototype.slice.call(Oe,Q,Q+=r):Oe.subarray(Q,Q+=r)}function Wa(r){let t=Oe[Q++];if(yr[t])return yr[t](Oe.subarray(Q,Q+=r));throw new Error("Unknown extension type "+t)}var zT=new Array(4096);function qT(){let r=Oe[Q++];if(r>=160&&r<192){if(r=r-160,ts>=Q)return Go.slice(Q-ui,(Q+=r)-ui);if(!(ts==0&&ko<180))return K0(r)}else return Q--,sn();let t=(r<<5^(r>1?Ct.getUint16(Q):r>0?Oe[Q]:0))&4095,e=zT[t],n=Q,i=Q+r-3,s,o=0;if(e&&e.bytes==r){for(;n<i;){if(s=Ct.getUint32(n),s!=e[o++]){n=1879048192;break}n+=4}for(i+=3;n<i;)if(s=Oe[n++],s!=e[o++]){n=1879048192;break}if(n===i)return Q=n,e.string;i-=3,n=Q}for(e=[],zT[t]=e,e.bytes=r;n<i;)s=Ct.getUint32(n),e.push(s),n+=4;for(i+=3;n<i;)s=Oe[n++],e.push(s);let a=r<16?J0(r):jT(r);return a!=null?e.string=a:e.string=K0(r)}var VT=(r,t)=>{var e=sn();let n=r;t!==void 0&&(r=r<32?-((t<<5)+r):(t<<5)+r,e.highByte=t);let i=_t[r];return i&&i.isShared&&((_t.restoreStructures||(_t.restoreStructures=[]))[r]=i),_t[r]=e,e.read=Q0(e,n),e.read()},XT=typeof self=="object"?self:global;yr[0]=()=>{};yr[0].noBuffer=!0;yr[101]=()=>{let r=sn();return(XT[r[0]]||Error)(r[1])};yr[105]=r=>{let t=Ct.getUint32(Q-4);Qs||(Qs=new Map);let e=Oe[Q],n;e>=144&&e<160||e==220||e==221?n=[]:n={};let i={target:n};Qs.set(t,i);let s=sn();return i.used?Object.assign(n,s):(i.target=s,s)};yr[112]=r=>{let t=Ct.getUint32(Q-4),e=Qs.get(t);return e.used=!0,e.target};yr[115]=()=>new Set(sn());var $0=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");yr[116]=r=>{let t=r[0],e=$0[t];if(!e)throw new Error("Could not find typed array for code "+t);return new XT[e](Uint8Array.prototype.slice.call(r,1).buffer)};yr[120]=()=>{let r=sn();return new RegExp(r[0],r[1])};yr[98]=r=>{let t=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],e=Q;Q+=t-4,Zr=[sn(),sn()],Zr.position0=0,Zr.position1=0;let n=Q;Q=e;try{return sn()}finally{Q=n}};yr[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function YT(r){let t=ko,e=Q,n=Y0,i=ui,s=ts,o=Go,a=X0,l=Qs,u=Zr,c=new Uint8Array(Oe.slice(0,ko)),d=_t,h=_t.slice(0,_t.length),f=Tr,g=Uc,p=r();return ko=t,Q=e,Y0=n,ui=i,ts=s,Go=o,X0=a,Qs=l,Zr=u,Oe=c,Uc=g,_t=d,_t.splice(0,_t.length,...h),Tr=f,Ct=new DataView(Oe.buffer,Oe.byteOffset,Oe.byteLength),p}function fm(){Oe=null,Qs=null,_t=null}function KT(r){r.unpack?yr[r.type]=r.unpack:yr[r.type]=r}var mm=new Array(147);for(let r=0;r<256;r++)mm[r]=+("1e"+Math.floor(45.15-r*.30103));var gm=new ns({useRecords:!1}),mV=gm.unpack,gV=gm.unpackMultiple,yV=gm.unpack,ym={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},vV=new Float32Array(1),_$=new Uint8Array(vV.buffer,0,4);var vm;try{vm=new TextEncoder}catch{}var xm,tx,bm=typeof Buffer<"u",ex=bm?Buffer.allocUnsafeSlow:Uint8Array,$T=bm?Buffer:Uint8Array,ZT=bm?4294967296:2144337920,le,un,ne=0,rs,is=null,xV=/[\u0080-\uFFFF]/,ih=Symbol("record-id"),ja=class extends ns{constructor(t){super(t),this.offset=0;let e,n,i,s,o,a,l=0,u=$T.prototype.utf8Write?function(S,E,M){return le.utf8Write(S,E,M)}:vm&&vm.encodeInto?function(S,E){return vm.encodeInto(S,le.subarray(E)).written}:!1,c=this;t||(t={});let d=t&&t.sequential,h=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=h?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let g=t.maxOwnStructures;g==null&&(g=h?32:64),d&&!t.saveStructures&&(this.structures=[]);let p=f>32||g+f>64,m=f+64,y=f+g+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,b=0;this.pack=this.encode=function(S,E){if(le||(le=new ex(8192),un=new DataView(le.buffer,0,8192),ne=0),rs=le.length-10,rs-ne<2048?(le=new ex(le.length),un=new DataView(le.buffer,0,le.length),rs=le.length-10,ne=0):ne=ne+7&2147483640,n=ne,a=c.structuredClone?new Map:null,c.bundleStrings?(is=["",""],le[ne++]=214,le[ne++]=98,is.position=ne-n,ne+=4):is=null,i=c.structures,i){i.uninitialized&&(i=c._mergeStructures(c.getStructures()));let M=i.sharedLength||0;if(M>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let I=0;I<M;I++){let P=i[I];if(!P)continue;let C,D=i.transitions;for(let B=0,k=P.length;B<k;B++){let X=P[B];C=D[X],C||(C=D[X]=Object.create(null)),D=C}D[ih]=I+64}l=M}d||(i.nextId=M+64)}s&&(s=!1),o=i||[];try{if(w(S),is){un.setUint32(is.position+n,ne-is.position-n);let M=is;is=null,w(M[0]),w(M[1])}if(c.offset=ne,a&&a.idsToInsert){ne+=a.idsToInsert.length*6,ne>rs&&T(ne),c.offset=ne;let M=SV(le.subarray(n,ne),a.idsToInsert);return a=null,M}return E&tE?(le.start=n,le.end=ne,le):le.subarray(n,ne)}finally{if(i){if(b<10&&b++,x>1e4)i.transitions=null,b=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let M=0,I=v.length;M<I;M++)v[M][ih]=0;v=[]}if(s&&c.saveStructures){let M=i.sharedLength||f;i.length>M&&(i=i.slice(0,M));let I=le.subarray(n,ne);return c.saveStructures(i,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(S)):(l=M,I)}}E&CV&&(ne=n)}};let w=S=>{ne>rs&&(le=T(ne));var E=typeof S,M;if(E==="string"){let I=S.length;if(is&&I>=8&&I<4096){let D=xV.test(S);is[D?0:1]+=S,le[ne++]=193,w(D?-I:I);return}let P;I<32?P=1:I<256?P=2:I<65536?P=3:P=5;let C=I*3;if(ne+C>rs&&(le=T(ne+C)),I<64||!u){let D,B,k,X=ne+P;for(D=0;D<I;D++)B=S.charCodeAt(D),B<128?le[X++]=B:B<2048?(le[X++]=B>>6|192,le[X++]=B&63|128):(B&64512)===55296&&((k=S.charCodeAt(D+1))&64512)===56320?(B=65536+((B&1023)<<10)+(k&1023),D++,le[X++]=B>>18|240,le[X++]=B>>12&63|128,le[X++]=B>>6&63|128,le[X++]=B&63|128):(le[X++]=B>>12|224,le[X++]=B>>6&63|128,le[X++]=B&63|128);M=X-ne-P}else M=u(S,ne+P,C);M<32?le[ne++]=160|M:M<256?(P<2&&le.copyWithin(ne+2,ne+1,ne+1+M),le[ne++]=217,le[ne++]=M):M<65536?(P<3&&le.copyWithin(ne+3,ne+2,ne+2+M),le[ne++]=218,le[ne++]=M>>8,le[ne++]=M&255):(P<5&&le.copyWithin(ne+5,ne+3,ne+3+M),le[ne++]=219,un.setUint32(ne,M),ne+=4),ne+=M}else if(E==="number")if(S>>>0===S)S<64?le[ne++]=S:S<256?(le[ne++]=204,le[ne++]=S):S<65536?(le[ne++]=205,le[ne++]=S>>8,le[ne++]=S&255):(le[ne++]=206,un.setUint32(ne,S),ne+=4);else if(S>>0===S)S>=-32?le[ne++]=256+S:S>=-128?(le[ne++]=208,le[ne++]=S+256):S>=-32768?(le[ne++]=209,un.setInt16(ne,S),ne+=2):(le[ne++]=210,un.setInt32(ne,S),ne+=4);else{let I;if((I=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){le[ne++]=202,un.setFloat32(ne,S);let P;if(I<4||(P=S*mm[(le[ne]&127)<<1|le[ne+1]>>7])>>0===P){ne+=4;return}else ne--}le[ne++]=203,un.setFloat64(ne,S),ne+=8}else if(E==="object")if(!S)le[ne++]=192;else{if(a){let P=a.get(S);if(P){if(!P.id){let C=a.idsToInsert||(a.idsToInsert=[]);P.id=C.push(P)}le[ne++]=214,le[ne++]=112,un.setUint32(ne,P.id),ne+=4;return}else a.set(S,{offset:ne-n})}let I=S.constructor;if(I===Object)A(S,!0);else if(I===Array){M=S.length,M<16?le[ne++]=144|M:M<65536?(le[ne++]=220,le[ne++]=M>>8,le[ne++]=M&255):(le[ne++]=221,un.setUint32(ne,M),ne+=4);for(let P=0;P<M;P++)w(S[P])}else if(I===Map){M=S.size,M<16?le[ne++]=128|M:M<65536?(le[ne++]=222,le[ne++]=M>>8,le[ne++]=M&255):(le[ne++]=223,un.setUint32(ne,M),ne+=4);for(let[P,C]of S)w(P),w(C)}else{for(let P=0,C=xm.length;P<C;P++){let D=tx[P];if(S instanceof D){let B=xm[P];if(B.write){B.type&&(le[ne++]=212,le[ne++]=B.type,le[ne++]=0),w(B.write.call(this,S));return}let k=le,X=un,W=ne;le=null;let q;try{q=B.pack.call(this,S,H=>(le=k,k=null,ne+=H,ne>rs&&T(ne),{target:le,targetView:un,position:ne-H}),w)}finally{k&&(le=k,un=X,ne=W,rs=le.length-10)}q&&(q.length+ne>rs&&T(q.length+ne),ne=bV(q,le,ne,B.type));return}}A(S,!S.hasOwnProperty)}}else if(E==="boolean")le[ne++]=S?195:194;else if(E==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))le[ne++]=211,un.setBigInt64(ne,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)le[ne++]=207,un.setBigUint64(ne,S);else if(this.largeBigIntToFloat)le[ne++]=203,un.setFloat64(ne,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");ne+=8}else if(E==="undefined")this.encodeUndefinedAsNil?le[ne++]=192:(le[ne++]=212,le[ne++]=0,le[ne++]=0);else if(E==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+E)},A=this.useRecords===!1?this.variableMapSize?S=>{let E=Object.keys(S),M=E.length;M<16?le[ne++]=128|M:M<65536?(le[ne++]=222,le[ne++]=M>>8,le[ne++]=M&255):(le[ne++]=223,un.setUint32(ne,M),ne+=4);let I;for(let P=0;P<M;P++)w(I=E[P]),w(S[I])}:(S,E)=>{le[ne++]=222;let M=ne-n;ne+=2;let I=0;for(let P in S)(E||S.hasOwnProperty(P))&&(w(P),w(S[P]),I++);le[M+++n]=I>>8,le[M+n]=I&255}:S=>{let E=Object.keys(S),M,I=o.transitions||(o.transitions=Object.create(null)),P=0;for(let D=0,B=E.length;D<B;D++){let k=E[D];M=I[k],M||(M=I[k]=Object.create(null),P++),I=M}let C=I[ih];if(C)C>=96&&p?(le[ne++]=((C-=96)&31)+96,le[ne++]=C>>5):le[ne++]=C;else{C=o.nextId,C||(C=64),C<m&&this.shouldShareStructure&&!this.shouldShareStructure(E)?(C=o.nextOwnId,C<y||(C=m),o.nextOwnId=C+1):(C>=y&&(C=m),o.nextId=C+1);let D=E.highByte=C>=96&&p?C-96>>5:-1;I[ih]=C,o[C-64]=E,C<m?(E.isShared=!0,o.sharedLength=C-63,s=!0,D>=0?(le[ne++]=(C&31)+96,le[ne++]=D):le[ne++]=C):(D>=0?(le[ne++]=213,le[ne++]=114,le[ne++]=(C&31)+96,le[ne++]=D):(le[ne++]=212,le[ne++]=114,le[ne++]=C),P&&(x+=b*P),v.length>=g&&(v.shift()[ih]=0),v.push(I),w(E))}for(let D=0,B=E.length;D<B;D++)w(S[E[D]])},T=S=>{let E;if(S>16777216){if(S-n>ZT)throw new Error("Packed buffer would be larger than maximum buffer size");E=Math.min(ZT,Math.round(Math.max((S-n)*(S>67108864?1.25:2),4194304)/4096)*4096)}else E=(Math.max(S-n<<2,le.length-1)>>12)+1<<12;let M=new ex(E);return un=new DataView(M.buffer,0,E),le.copy?le.copy(M,0,n,S):M.set(le.slice(n,S)),ne-=n,n=0,rs=M.length-10,le=M}}useBuffer(t){le=t,un=new DataView(le.buffer,le.byteOffset,le.byteLength),ne=0}};tx=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,rh];xm=[{pack(r,t,e){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:i,targetView:s,position:o}=t(6);i[o++]=214,i[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:i,targetView:s,position:o}=t(10);i[o++]=215,i[o++]=255,s.setUint32(o,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:s,position:o}=t(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=t(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,r.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(r,t,e){let n=Array.from(r),{target:i,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),e(n)}},{pack(r,t,e){let{target:n,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=101,n[i++]=0),e([r.name,r.message])}},{pack(r,t,e){let{target:n,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=120,n[i++]=0),e([r.source,r.flags])}},{pack(r,t){this.structuredClone?QT(r,16,t):JT(bm?Buffer.from(r):new Uint8Array(r),t)}},{pack(r,t){let e=r.constructor;e!==$T&&this.structuredClone?QT(r,$0.indexOf(e.name),t):JT(r,t)}},{pack(r,t){let{target:e,position:n}=t(1);e[n]=193}}];function QT(r,t,e,n){let i=r.byteLength;if(i+1<256){var{target:s,position:o}=e(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=e(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=e(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),o)}function JT(r,t){let e=r.byteLength;var n,i;if(e<256){var{target:n,position:i}=t(e+2);n[i++]=196,n[i++]=e}else if(e<65536){var{target:n,position:i}=t(e+3);n[i++]=197,n[i++]=e>>8,n[i++]=e&255}else{var{target:n,position:i,targetView:s}=t(e+5);n[i++]=198,s.setUint32(i,e),i+=4}n.set(r,i)}function bV(r,t,e,n){let i=r.length;switch(i){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:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=n,t.set(r,e),e+=i,e}function SV(r,t){let e,n=t.length*6,i=r.length-n;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;r.copyWithin(s+n,s,i),n-=6;let a=s+n;r[a++]=214,r[a++]=105,r[a++]=o>>24,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=o&255,i=s}return r}function zo(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");tx.unshift(r.Class),xm.unshift(r)}KT(r)}var eE=new ja({useRecords:!1}),wV=eE.pack,AV=eE.pack;var{NEVER:_V,ALWAYS:TV,DECIMAL_ROUND:EV,DECIMAL_FIT:MV}=ym,tE=512,CV=1024;var nE=new ja({structuredClone:!0});zo({Class:Ot.prototype.constructor,type:1,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Ot.prototype),r}});zo({Class:He.prototype.constructor,type:2,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,He.prototype),r}});zo({Class:qt.prototype.constructor,type:3,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,qt.prototype),r}});zo({Class:th.prototype.constructor,type:4,write(r){return r.id},read(r){return new th(r)}});zo({Class:nh.prototype.constructor,type:5,write(r){return r.data},read(r){return new nh(r)}});zo({Class:Xt.prototype.constructor,type:6,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Xt.prototype),r}});function PV(r){var t=0;if(r.length===0)return t;for(let e=0;e<r.length;e++){let n=r[e];t=(t<<5)-t+n,t=t&t}return t}function nx(r){if(Oc(r))return r;if(Array.isArray(r))return r.map(nx);if(typeof r=="object"&&r!==null){let t={};for(let e of Object.keys(r).sort())t[e]=nx(r[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}else return r}var Sm;(n=>{function r(i){return nE.pack(i)}n.serialize=r;function t(i){return nE.unpack(i)}n.deserialize=t;function e(i){return PV(r(nx(i))).toString()}n.checksum=e})(Sm||(Sm={}));var Gc={["LookAt"]:[],["Follow"]:[],["MouseHover"]:["Transition"],["Scroll"]:["Transition"],["Start"]:["Transition","Audio","Video"],["Conditional"]:["Transition","Audio","Video"],["MouseDown"]:["Transition","Audio","Video","Link","Reset"],["MouseUp"]:["Transition","Audio","Video","Link","Reset"],["MousePress"]:["Transition","Audio","Video","Link","Reset"],["KeyDown"]:["Transition","Audio","Video","Link","Reset"],["KeyUp"]:["Transition","Audio","Video","Link","Reset"],["KeyPress"]:["Transition","Audio","Video","Link","Reset"],["GameControl"]:["Transition","Audio"],["Collision"]:["Transition","Audio"]},rE;(e=>{function r(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"}e.is=r;function t(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,disabled:!1,toggle:!1,actions:new He}:{type:n,disabled:!1,key:void 0,toggle:!1,actions:new He}}e.defaultData=t})(rE||(rE={}));var wm;(e=>{function r(n){return{type:"Property",value:[n??null,"position","x"]}}e.propertyDefaultData=r,e.valueDefaultData={type:"Literal",value:0}})(wm||(wm={}));var rx;(n=>{function r(i){return{type:"Comparison",operator:"==",lOperand:wm.propertyDefaultData(i),rOperand:{...wm.valueDefaultData}}}n.comparisonDefaultData=r;function t(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}n.distanceDefaultData=t;function e(i,s){return{type:"State",object:i??null,state:s??null}}n.stateDefaultData=e})(rx||(rx={}));var iE;(e=>{function r(n){return n.type==="Conditional"}e.is=r;function t(n){return{type:"Conditional",disabled:!1,inActions:new He,outActions:new He,condition:rx.distanceDefaultData(n)}}e.defaultData=t})(iE||(iE={}));var Am;(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})(Am||(Am={}));var _m;(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})(_m||(_m={}));var sE;(e=>{function r(n){return n.type==="MouseHover"}e.is=r;function t(){return{type:"MouseHover",disabled:!1,actions:new He}}e.defaultData=t})(sE||(sE={}));var oE;(e=>{function r(n){return n.type==="Scroll"}e.is=r;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new He}}e.defaultData=t})(oE||(oE={}));var aE;(e=>{function r(n){return n.type==="Start"}e.is=r;function t(){return{type:"Start",disabled:!1,actions:new He}}e.defaultData=t})(aE||(aE={}));var lE;(e=>{function r(n){return n.type==="Collision"}e.is=r;function t(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new He}}e.defaultData=t})(lE||(lE={}));var qa;(e=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]}e.isEqual=r;function t(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s]}e.lerp=t})(qa||(qa={}));var ss;(a=>{function r(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}a.isEqual=r;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 i(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=i;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})(ss||(ss={}));var sh;(e=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]&&n[2]===i[2]&&n[3]===i[3]}e.isEqual=r;function t(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s,n[2]+(i[2]-n[2])*s,n[3]+(i[3]-n[3])*s]}e.lerp=t})(sh||(sh={}));var Vo;(i=>{i.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}i.isEqual=t;function e(s){return s??i.identity}i.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}i.applyMatrix4=n})(Vo||(Vo={}));var ir;(u=>{function r(c){return typeof c=="object"&&typeof c.r=="number"&&typeof c.g=="number"&&typeof c.b=="number"}u.isRGB=r,u.white={r:1,g:1,b:1},u.red={r:1,g:0,b:0},u.black={r:0,g:0,b:0};function i(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}u.toRgb255a1=i;function s(c){return{r:c.r,g:c.g,b:c.b}}u.clone=s;function o(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}u.fromHex=o;function a(c,d){return c.r===d.r&&c.g===d.g&&c.b===d.b}u.equals=a;function l(c,d,h){return{r:c.r+(d.r-c.r)*h,g:c.g+(d.g-c.g)*h,b:c.b+(d.b-c.b)*h}}u.lerp=l})(ir||(ir={}));var Er;(a=>{a.white={...ir.white,a:1},a.transparent={...ir.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{...ir.fromHex(l),a:u}}a.fromHexAndA=n;function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=i;function s(l,u){return ir.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})(Er||(Er={}));var Tm;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Tm||(Tm={}));var cE;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(cE||(cE={}));var uE;(t=>t.defaultData={control1:[.5,.05],control2:[.1,.3]})(uE||(uE={}));var Di;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(n){return e.all.includes(n)}e.is=t})(Di||(Di={}));var Xa;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1,autoZoom:!1,autoZoomFrustumSize:790},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=n})(Xa||(Xa={}));var os;(e=>{function r(n,i=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(n[0],n[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[n[0]+n[0]*i,0,0]},grid:{count:[2,2,2],size:n.map(s=>s*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=r;function t(n,i){let s={...n};if(ix.forEach(o=>{Object.assign(s,{[o]:i[o]??n[o]})}),s.radial={...n.radial},i.radial){let o=n.radial,a=i.radial;sx.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...n.linear},i.linear){let o=n.linear,a=i.linear;ox.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...n.grid},i.grid){let o=n.grid,a=i.grid;ax.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...n.toObject},i.toObject){let o=n.toObject,a=i.toObject;lx.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...n.randomnessObject},i.randomnessObject){let o=n.randomnessObject,a=i.randomnessObject;cx.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(os||(os={}));var Em;(n=>{n.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(i,s){let o=[];i.count!==void 0&&o.push({type:0,path:s,props:{count:i.count}});for(let a of t){let l=i[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}n.toOps=e})(Em||(Em={}));var ix=["count"],sx=["radius","start","end","position","scale","rotation"],ox=["position","scale","rotation"],ax=["count","size"],lx=["count","position","scale","rotation"],cx=["strength","scale","rotation","position","movement","seed","freqScale"];var Ya;(e=>{let r={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...r,blendFunction:16,granularity:15},bloom:{...r,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...r,offset:[2,2]},vignette:{...r,darkness:1,offset:0},hueSaturation:{...r,hue:3,saturation:0},brightnessContrast:{...r,brightness:.25,contrast:0},depthOfField:{...r,focalLength:2,focusDistance:2,bokehScale:2},noise:{...r,blendFunction:16}}})(Ya||(Ya={}));var Mm;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(n){return e.all.includes(n)}e.is=t})(Mm||(Mm={}));var Cm;(e=>{function r(n){return t(n)}e.defaultData=r;function t(n){if(n==="PointLight")return{type:n,color:Er.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(n==="SpotLight")return{type:n,color:Er.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(n==="DirectionalLight")return{type:n,color:Er.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Cm||(Cm={}));var ux;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(n,i){return n.castShadow===i.castShadow&&n.receiveShadow===i.receiveShadow}e.equals=t})(ux||(ux={}));var dx;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(n,i){return n.flatShading===i.flatShading&&n.side===i.side&&n.wireframe===i.wireframe}e.equals=t})(dx||(dx={}));var Pm;(t=>t.defaultData={...dx.defaultData,...ux.defaultData})(Pm||(Pm={}));var kc;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(kc||(kc={}));var Im=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],dE=["wrapping","image","video"],vr;(i=>{function r(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}i.patch=r;function t(s,o){return s==="light"&&o?e(o):n(s)}i.defaultData=t;function e(s){switch(s){case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",alpha:.6,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function n(s){switch(s){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"video",projection:0,texture:{video:kc.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:ir.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...ir.fromHex(6710886),a:1},colorB:{...ir.fromHex(6710886),a:1},colorC:{...ir.fromHex(16777215),a:1},colorD:{...ir.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:Er.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Er.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:Er.fromHexAndA(0,1),contourColor:Er.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(vr||(vr={}));var qn;(l=>{function r(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}l.isMergable=r;function t(u){let c="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([h,f])=>{c+=`${h}${f}`,Array.isArray(f)?f.forEach(g=>c+=`${g}`):typeof f=="object"?Object.values(f).forEach(g=>{typeof g=="number"?c+=`${g.toFixed(4)}`:c+=`${g}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new He}}l.defaultEmptyData=e;function n(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=n;function i(u,c){return{...u,name:c}}l.withName=i;function s(u,c="layer1",d="layer2"){let h=new He;return h.push({fi:0,data:vr.defaultData("light",u),id:c}),h.push({fi:1,data:vr.defaultData("color"),id:d}),{layers:h}}l.defaultTwoLayerData=s;function o(u,c="phong",d="layer1",h="layer2"){let f=vr.defaultData("texture");Object.assign(f.texture,{image:u});let g=new He;return g.push({fi:0,data:f,id:d}),g.push({fi:1,data:vr.defaultData("light",c),id:h}),{layers:g}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",d="layer1",h="layer2"){let f=vr.defaultData("video");Object.assign(f.texture,{video:u});let g=new He;return g.push({fi:0,data:f,id:d}),g.push({fi:1,data:vr.defaultData("light",c),id:h}),{layers:g}}l.defaultTwoLayerVideoTextureData=a})(qn||(qn={}));var zc;(t=>{function r(){return{points:new He,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=r})(zc||(zc={}));var Vc;(t=>{function r(){return{points:new He,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=r})(Vc||(Vc={}));var hx={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0};var Dm;(t=>{function r(e,n){let i={...e};return fx.forEach(s=>{Object.assign(i,{[s]:n[s]??e[s]})}),i}t.merge=r})(Dm||(Dm={}));var Om={shape:hx,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},fx=["depth","offset","angle","twist","startScale","endScale"];var oh;(t=>{function r(e){return e==="PolygonGeometry"||e==="RectangleGeometry"||e==="StarGeometry"||e==="TriangleGeometry"||e==="EllipseGeometry"}t.is2DParametricMesh=r})(oh||(oh={}));var Lm;(t=>{function r(e,n){let i={...e};return Object.assign(i,n),i.type==="PathGeometry"&&"extrusion"in n&&n.extrusion&&(i.extrusion={...e.extrusion},Object.assign(i.extrusion,Dm.merge(i.extrusion,n.extrusion))),i}t.merge=r})(Lm||(Lm={}));var Ho;(t=>{function r(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:Vc.defaultData(),extrusion:Om};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:zc.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:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};throw new Error("not implemented")}t.defaultData=r})(Ho||(Ho={}));var px=["width","height","depth"];var hE;(e=>{function r(n){return n==="Component"||n==="Instance"}e.isComponentRelated=r;function t(n){return n==="Empty"||n==="Instance"}e.isEmptyOrComponent=t})(hE||(hE={}));var Hc;(i=>{i.identity={...Tm.identity,hiddenMatrix:Vo.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.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}}i.merge=e;function n(s,o){return{position:ss.isEqual(s.position,o.position)?null:o.position,rotation:ss.isEqual(s.rotation,o.rotation)?null:o.rotation,scale:ss.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:Vo.isEqual(s.hiddenMatrix,o.hiddenMatrix)?null:o.hiddenMatrix}}i.diff=n})(Hc||(Hc={}));var mx;(t=>t.defaultData={fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(mx||(mx={}));var Qr;(t=>t.defaultData={states:new He,events:new He,visible:!0,raycastLock:!1,physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Hc.identity,cloner:null})(Qr||(Qr={}));var fE;(t=>t.defaultData={type:"Empty",...Qr.defaultData})(fE||(fE={}));var pE;(t=>t.defaultData={type:"Component",...Qr.defaultData})(pE||(pE={}));var Ka;(t=>t.defaultData={type:"Mesh",...Qr.defaultData,...Pm.defaultData})(Ka||(Ka={}));var Wc;(t=>t.defaultData={...Qr.defaultData,...Hc.identity,...Xa.defaultData})(Wc||(Wc={}));var Rm;(t=>{function r(e){return{...Qr.defaultData,...Cm.defaultData(e)}}t.defaultData=r})(Rm||(Rm={}));var jc;(e=>{function r(n,i,s=0){for(;s<i.length;){let o=n?n[i[s]]:void 0;if(i.length===s+1)return o;if(o)n=o.descendants,s+=1;else return}}e.resolveWithDes=r;function t(n,i,s=0){let o=r(n,i,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(jc||(jc={}));var Wo;(s=>{s.rootOverrideProps=["physics"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function n(o,a){return{...Qr.defaultData,...a,component:o,overrides:new Xt,physics:void 0,type:"Instance"}}s.ofComponent=n;function i(o){let a=Hc.fromObject(o.data);return n(o.id,a)}s.fromComponentData=i})(Wo||(Wo={}));var Nm;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Vo.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:mx.defaultData,states:new He,events:new He,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Xa.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",...Qr.defaultData,...Ka.defaultData,geometry:Ho.defaultData("RectangleGeometry"),material:qn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Qr.defaultData,...Ka.defaultData,geometry:Ho.defaultData("BooleanGeometry"),material:qn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Qr.defaultData,...Ka.defaultData,geometry:Ho.defaultData("TextGeometry"),material:qn.defaultTwoLayerData("phong","layer1","layer2")}))(Nm||(Nm={}));var Js;(i=>{function r(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Xt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Xt})))):Di.is(s.type)&&(a.perspective={},a.orthographic={}),a}i.newEmpty=r;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Fc(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let d=l.layers.data(u);d&&vr.patch(d,c)}}).data),a.materials&&o.materials&&(a.materials=Fc(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[d,h]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&vr.patch(f,h)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(d,h){for(let[f,g]of Object.entries(h.layers)){let{texture:p,...m}=g;if(p!==void 0&&Object.keys(p).length>0){let y={path:[...d,"layers",f,"texture"],props:p,type:0};l.push(y)}if(Object.keys(m).length>0){let y={path:[...d,"layers",f],props:m,type:0};l.push(y)}}}for(let[d,h]of Object.entries(o))if(d!=="name")if(d==="cloner")l.push(...Em.toOps(h,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:h.slide,offset:h.offset},type:0});else if(d==="material")c(["material"],h);else if(d==="materials")for(let[f,g]of Object.entries(h))c(["materials",f],g);else if(u[d]===0){if(d==="geometry"&&h.extrusion!==void 0){let f={path:[d,"extrusion"],props:h.extrusion,type:0};l.push(f),h={...h},delete h.extrusion}if(Object.keys(h).length>0){let f={path:[d],props:h,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[d]=h;return l}i.toOps=e;function n(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,Hc.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})}),Di.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:Lm.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:os.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:os.merge(a.cloner,o.cloner)});else if(Mm.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=ir.clone(l.color))}return a}i.patch=n})(Js||(Js={}));var lh;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:ir.white,near:.1,far:2e3})(lh||(lh={}));var qc;(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,autoZoom:!1})(qc||(qc={}));var $s;(t=>t.defaultData={orbitControls:qc.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:typeof window<"u"?Math.floor(window.devicePixelRatio):1,stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((e,n)=>{let i=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?i=30:(n===4||n===11||n===9)&&(i=-30),[120,[i,s],"show"]}),gameControlObject:null})($s||($s={}));function Oi(r,t){return Object.setPrototypeOf(r,t),r}var IV=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),DV=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),OV=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Za&&"ontouchend"in document,LV=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,RV=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,NV=()=>{if(typeof window>"u")return!1;let r=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(r)&&/Apple Computer/.test(t)},BV=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},ste=IV(),Za=DV(),ch=OV(),mE=LV(),In=RV(),gx=NV(),yx=Number(BV());function Bm(r){return Array.isArray(r)?r:[r]}function gE(r,t){let e=0;for(;e<r.length&&e<t.length;){if(r[e]<t[e])return-1;if(r[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==r.length?1:0}function uh(r){return Za?r.metaKey:r.ctrlKey}var Je=[],Um={},dh={},Fm={};function yE(r){Je.includes(r)||Je.push(r)}function Xc(r){delete Um[r.pointerId];for(let t=0;t<Je.length;t++)if(Je[t].pointerId===r.pointerId){Je.splice(t,1);break}}function vE(){Je.splice(0,Je.length)}function Gm(r){if(r.pointerType!=="touch")return;let t=Um[r.pointerId];t===void 0&&(t={x:0,y:0},Um[r.pointerId]=t),t.x=r.pageX,t.y=r.pageY}function km(r){let t=r.pointerId===Je[0].pointerId?Je[1]:Je[0];return Um[t.pointerId]}function xE(r){dh[r.key]=!0,Fm[r.key]=Fm[r.key]===void 0?1:Fm[r.key]+1}function bE(r){if(Za&&dh.Meta)for(let t in dh)dh[t]=!1;else dh[r.key]=!1;Fm={}}function SE(r){r.addEventListener("pointerdown",yE,!0),r.addEventListener("pointerdown",Gm,!0),r.addEventListener("pointermove",Gm,!0),r.addEventListener("pointerup",Xc,!0),r.addEventListener("pointercancel",Xc,!0),r.addEventListener("pointerleave",Xc,!0),window.addEventListener("keydown",xE,!0),window.addEventListener("keyup",bE,!0)}function wE(r){r.removeEventListener("pointerdown",yE,!0),r.removeEventListener("pointerdown",Gm,!0),r.removeEventListener("pointermove",Gm,!0),r.removeEventListener("pointerup",Xc,!0),r.removeEventListener("pointercancel",Xc,!0),r.removeEventListener("pointerleave",Xc,!0),window.removeEventListener("keydown",xE,!0),window.removeEventListener("keyup",bE,!0)}var xr;(t=>t.defaultData={ambientLight:{enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!0,softShadowQuality:"low"},usePhysics:!1,gravity:-10,pixelsPerMeter:200,skinWidthRelative:.02,stepThreshRelative:.3,slopeThresh:65})(xr||(xr={}));var zm;(o=>{o.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(a={withLight:!0,withSquare:!0}){let l=new qt,u=Nm.defaultMeshObject;return a.withLight===!0&&l.push({fi:-1,data:{...Rm.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),a.withSquare===!0&&l.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:u,children:[]}),l}o.defaultData={backgroundColor:Er.fromHexAndA(1908256,1),postprocessing:Ya.defaultData,fog:lh.defaultData,objects:t(),environment:xr.defaultData,publish:$s.defaultData},o.emptyData=function(a){return{backgroundColor:Er.fromHexAndA(1908256,1),postprocessing:Ya.defaultData,fog:lh.defaultData,objects:a?t(a):new qt,environment:xr.defaultData,publish:$s.defaultData}};function i(a){return{...o.defaultData,objects:Oi(a,qt.prototype)}}o.withObjs=i;function s(a,l){return i([{id:a,data:l,children:[],fi:0}])}o.withObj=s})(zm||(zm={}));var Yc;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(Yc||(Yc={}));var Kc;(n=>{function r(){let i={};return i["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Oi(i,Ot.prototype)}n.defaultColors=r;function t(i){let s={};return i?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Yc.emptyImage,name:"AI generated image"}),Oi(s,Ot.prototype)}n.defaultImages=t;function e(){return{materials:new Ot,images:new Ot,videos:new Ot,colors:new Ot,audios:new Ot,fonts:new Ot,penumbraSize:[.5,.5,.5]}}n.emptyData=e})(Kc||(Kc={}));function AE(r){r.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,n=t.colorB,i=[[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++)i.push(i[1]),s.push(1);let o={...Uo(Wn(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:i,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={...Wn(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Vm(r,t){Object.values(r.shared.materials).forEach(e=>t(e))}function Hm(r,t){r.scene.objects.traverse((e,n)=>{"materials"in n?n.materials.forEach(i=>{typeof i!="string"&&t(i)}):"material"in n&&typeof n.material!="string"&&t(n.material)})}function FV(r){Object.assign(r.scene.publish,{orbitControls:{...qc.defaultData,...Wn(r.scene.publish.orbitControls)}})}function UV(r){Object.assign(r.scene.publish.settings,{video:{...$s.defaultData.settings.video,...Wn(r.scene.publish.settings.video)}})}function GV(r){function t(e){if(e.layers){for(let n of Object.values(e.layers))if(n){for(let[i,s]of Object.entries(n))if((Im.includes(i)||typeof s=="boolean")&&delete n[i],i==="texture")for(let[o,a]of Object.entries(s))(dE.includes(o)||typeof a=="boolean")&&delete s[o]}}}r.scene.objects.traverse((e,n)=>{n.states.forEach(i=>{let s=i;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function kV(r){r.scene.publish.withBackground=!0}function zV(r){r.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function VV(r){r.scene.objects.traverse((t,e)=>{let n=e.cloner;n&&(n.radial.scale=n.radial.scale.map(i=>i+1),n.linear.scale=n.linear.scale.map(i=>i+1))})}function HV(r){r.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function WV(r){r.scene.objects.traverse((t,e)=>{let n=r.scene.objects.unproxy().parent(t);if(n){let i=Wn(r.scene.objects.data(n));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Wn(e).booleanExclude!==!0)}})}function jV(r){r.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 qV(r){function t(n){Object.setPrototypeOf(n,Xt.prototype),n.texture&&Object.setPrototypeOf(n.texture,Xt.prototype)}function e(n){Object.setPrototypeOf(n,Xt.prototype);for(let i in n)t(n[i])}r.scene.objects.traverse((n,i)=>{i.states.forEach(s=>{let o=s;if(o.material){let a=Wn(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=Wn(l).layers;e(u),l.layers=u}})})}function _E(r){r.layers===void 0&&Object.assign(r,qn.defaultTwoLayerData("lambert"))}function vx(r){!r.layers||r.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 i={...Wn(t),colors:e,steps:n};Object.assign(t,i)}})}function XV(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function TE(r){r.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(n=>{typeof n!="string"&&vx(n)}):"material"in e&&typeof e.material!="string"&&vx(e.material)}),Object.values(r.shared.materials).forEach(t=>vx(t))}function YV(r){r.scene.environment.ambientLight.softShadows=!1,r.scene.environment.ambientLight.softShadowQuality="low",r.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),r.shared.penumbraSize=new Array(5).fill(.5)}function KV(r){r.shared.audios=Oi({},Ot.prototype)}function ZV(r){r.shared.videos=Oi({},Ot.prototype)}function QV(r){let t=r.shared.materials;Object.entries(t).forEach(([e,n])=>{if(!n.layers){let i={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:i})}})}function JV(r){Object.entries(Wn(r.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.images[n]}),Object.entries(Wn(r.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.audios[n]})}function $V(r){r.scene.publish.settings.web.preload=!1}function EE(r){r.layers&&r.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 e4(r){r.shared.fonts=Oi({},Ot.prototype)}function t4(r){return r.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function n4(r){let t=[];r.scene.objects.traverse((e,n)=>{let i=n;if(i.type==="TextFrame"){let s=qn.defaultTwoLayerData("phong"),o=typeof i.color=="string"?r.shared.colors[i.color]:i.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=i.alpha;let a=t4(i.font);r.shared.fonts[a]===void 0&&(r.shared.fonts[a]={name:a});let l={name:i.name,...Qr.defaultData,...Ka.defaultData,flatShading:!1,wireframe:!1,geometry:{...Ho.defaultData("TextGeometry"),width:i.width,height:i.height,font:a,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Wn(i.states),events:Wn(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},u=Wn(r.scene.objects).parent(e);r.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{r.scene.objects.delete(e)})}function r4(r){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};r.scene.objects.traverse((e,n)=>{n.events.forEach(i=>{if(!!t[Number(i.type)])if(Object.assign(i,{type:t[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new He,move:new He,jump:new He}});else{let s=new He;Object.assign(i,{actions:s}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&s.push({fi:0,id:Ve.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,Uo(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let d={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},h={state:o.state,...d,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new He({fi:0,id:Ve.generateUUID(),data:u},{fi:1,id:Ve.generateUUID(),data:h})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function i4(r){r.scene.objects.traverse((t,e)=>{function n(i,s){let o=new He,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let d;a.push(u),l.interaction==="play"?d={...Uo(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(d={...Uo(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&o.push({fi:c,id:u,data:d})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:Ve.generateUUID(),data:{type:i,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}function ME(r){let t=r.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=vr.defaultData("light","phong"),n=t;Object.assign(n,e),n.visible=!1}}function CE(r){Vm(r,ME),Hm(r,ME)}function s4(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function o4(r){r.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 a4(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=qn.defaultTwoLayerData("phong"))})}function l4(r){r.scene.publish.orbitControls.autoZoom===void 0&&(r.scene.publish.orbitControls.autoZoom=!1),r.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 c4(r){r.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 u4(r){r.scene.publish.mouseEventTarget===void 0&&(r.scene.publish.mouseEventTarget="canvas"),r.scene.publish.settings.web.hint===void 0&&(r.scene.publish.settings.web.hint=!1)}function d4(r){let{video:t}=r.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function h4(r){r.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.resetYPosition=Math.abs(n.resetYPosition-e.position[1]))})})}var PE=36;function IE(r){let t=r.schema??0;t!==PE&&(console.warn("updating from ",t,"to ",PE),t<1&&(Hm(r,AE),Vm(r,AE),r.schema=1),t<2&&(FV(r),r.schema=2),t<3&&(GV(r),r.schema=3),t<4&&(kV(r),r.schema=4),t<5&&(zV(r),r.schema=5),t<6&&(VV(r),r.schema=6),t<7&&(HV(r),r.schema=7),t<8&&(r.schema=8),t<9&&(TE(r),r.schema=9),t<10&&(XV(r),r.schema=10),t<11&&(YV(r),r.schema=11),t<12&&(TE(r),r.schema=12),t<13&&(KV(r),r.schema=13),t<14&&(QV(r),r.schema=14),t<15&&(JV(r),r.schema=15),t<16&&($V(r),r.schema=16),t<17&&(Hm(r,EE),Vm(r,EE),r.schema=17),t<18&&(Hm(r,_E),Vm(r,_E),r.schema=18),t<19&&(UV(r),r.schema=19),t<20&&(e4(r),n4(r),r.schema=20),t<21&&(r4(r),i4(r),r.schema=21),t<22&&(CE(r),r.schema=22),t<23&&(s4(r),r.schema=23),t<24&&(o4(r),r.schema=24),(t<25||r.shared.videos===void 0)&&(ZV(r),t<25&&(r.schema=25)),t<26&&(WV(r),r.schema=26),t<27&&(jV(r),r.schema=27),t<28&&(CE(r),r.schema=28),t<29&&(qV(r),r.schema=29),t<30&&(a4(r),r.schema=30),t<31&&(l4(r),r.schema=31),t<33&&(c4(r),r.schema=33),t<34&&(u4(r),r.schema=34),t<35&&(d4(r),r.schema=35),t<36&&(h4(r),r.schema=36))}function eo(r,t=!1){let e=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new Te,u=0;for(let c=0;c<r.length;++c){let d=r[c],h=0;if(e!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in d.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(d.attributes[f]),h++}if(h!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in d.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(d.morphAttributes[f])}if(t){let f;if(e)f=d.index.count;else if(d.attributes.position!==void 0)f=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,f,c),u+=f}}if(e){let c=0,d=[];for(let h=0;h<r.length;++h){let f=r[h].index;for(let g=0;g<f.count;++g)d.push(f.getX(g)+c);c+=r[h].attributes.position.count}l.setIndex(d)}for(let c in s){let d=DE(s[c]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,d)}for(let c in o){let d=o[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let h=0;h<d;++h){let f=[];for(let p=0;p<o[c].length;++p)f.push(o[c][p][h]);let g=DE(f);if(!g)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(g)}}return l}function DE(r){let t,e,n,i=0;for(let a=0;a<r.length;++a){let l=r[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(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;i+=l.array.length}let s=new t(i),o=0;for(let a=0;a<r.length;++a)s.set(r[a].array,o),o+=r[a].array.length;return new Be(s,e,n)}var Wm;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",speedTranslate:1e3,speedRotate:100,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new He,move:new He,jump:new He}}))(Wm||(Wm={}));var OE=Math.pow(2,-24);var Qa=class{constructor(){}};function di(r,t,e){return e.min.x=t[r],e.min.y=t[r+1],e.min.z=t[r+2],e.max.x=t[r+3],e.max.y=t[r+4],e.max.z=t[r+5],e}function xx(r){let t=-1,e=-1/0;for(let n=0;n<3;n++){let i=r[n+3]-r[n];i>e&&(e=i,t=n)}return t}function bx(r,t){t.set(r)}function Sx(r,t,e){let n,i;for(let s=0;s<3;s++){let o=s+3;n=r[s],i=t[s],e[s]=n<i?n:i,n=r[o],i=t[o],e[o]=n>i?n:i}}function hh(r,t,e){for(let n=0;n<3;n++){let i=t[r+2*n],s=t[r+2*n+1],o=i-s,a=i+s;o<e[n]&&(e[n]=o),a>e[n+3]&&(e[n+3]=a)}}function Qc(r){let t=r[3]-r[0],e=r[4]-r[1],n=r[5]-r[2];return 2*(t*e+e*n+n*t)}function m4(r,t){if(!r.index){let e=r.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;e>65535?i=new Uint32Array(new n(4*e)):i=new Uint16Array(new n(2*e)),r.setIndex(new Be(i,1));for(let s=0;s<e;s++)i[s]=s}}function g4(r){if(!r.groups||!r.groups.length)return[{offset:0,count:r.index.count/3}];let t=[],e=new Set;for(let i of r.groups)e.add(i.start),e.add(i.start+i.count);let n=Array.from(e.values()).sort((i,s)=>i-s);for(let i=0;i<n.length-1;i++){let s=n[i],o=n[i+1];t.push({offset:s/3,count:(o-s)/3})}return t}function Ax(r,t,e,n,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,d=1/0,h=1/0,f=1/0,g=-1/0,p=-1/0,m=-1/0,y=i!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let b=r[v+0],w=r[v+1],A=b-w,T=b+w;A<s&&(s=A),T>l&&(l=T),y&&b<d&&(d=b),y&&b>g&&(g=b);let S=r[v+2],E=r[v+3],M=S-E,I=S+E;M<o&&(o=M),I>u&&(u=I),y&&S<h&&(h=S),y&&S>p&&(p=S);let P=r[v+4],C=r[v+5],D=P-C,B=P+C;D<a&&(a=D),B>c&&(c=B),y&&P<f&&(f=P),y&&P>m&&(m=P)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,y&&(i[0]=d,i[1]=h,i[2]=f,i[3]=g,i[4]=p,i[5]=m)}function y4(r,t,e,n){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,d=(t+e)*6;c<d;c+=6){let h=r[c+0];h<i&&(i=h),h>a&&(a=h);let f=r[c+2];f<s&&(s=f),f>l&&(l=f);let g=r[c+4];g<o&&(o=g),g>u&&(u=g)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function v4(r,t,e,n,i){let s=e,o=e+n-1,a=i.pos,l=i.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=r[s*3+u];r[s*3+u]=r[o*3+u],r[o*3+u]=c;let d=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=d;let h=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=h}s++,o--}else return s}}var to=32,x4=(r,t)=>r.candidate-t.candidate,jo=new Array(to).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),jm=new Float32Array(6);function b4(r,t,e,n,i,s){let o=-1,a=0;if(s===0)o=xx(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=xx(r),o!==-1&&(a=S4(e,n,i,o));else if(s===2){let l=Qc(r),u=1.25*i,c=n*6,d=(n+i)*6;for(let h=0;h<3;h++){let f=t[h],m=(t[h+3]-f)/to;if(i<to/4){let y=[...jo];y.length=i;let v=0;for(let b=c;b<d;b+=6,v++){let w=y[v];w.candidate=e[b+2*h],w.count=0;let{bounds:A,leftCacheBounds:T,rightCacheBounds:S}=w;for(let E=0;E<3;E++)S[E]=1/0,S[E+3]=-1/0,T[E]=1/0,T[E+3]=-1/0,A[E]=1/0,A[E+3]=-1/0;hh(b,e,A)}y.sort(x4);let x=i;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<d;b+=6){let w=e[b+2*h];for(let A=0;A<x;A++){let T=y[A];w>=T.candidate?hh(b,e,T.rightCacheBounds):(hh(b,e,T.leftCacheBounds),T.count++)}}for(let b=0;b<x;b++){let w=y[b],A=w.count,T=i-w.count,S=w.leftCacheBounds,E=w.rightCacheBounds,M=0;A!==0&&(M=Qc(S)/l);let I=0;T!==0&&(I=Qc(E)/l);let P=1+1.25*(M*A+I*T);P<u&&(o=h,u=P,a=w.candidate)}}else{for(let x=0;x<to;x++){let b=jo[x];b.count=0,b.candidate=f+m+x*m;let w=b.bounds;for(let A=0;A<3;A++)w[A]=1/0,w[A+3]=-1/0}for(let x=c;x<d;x+=6){let A=~~((e[x+2*h]-f)/m);A>=to&&(A=to-1);let T=jo[A];T.count++,hh(x,e,T.bounds)}let y=jo[to-1];bx(y.bounds,y.rightCacheBounds);for(let x=to-2;x>=0;x--){let b=jo[x],w=jo[x+1];Sx(b.bounds,w.rightCacheBounds,b.rightCacheBounds)}let v=0;for(let x=0;x<to-1;x++){let b=jo[x],w=b.count,A=b.bounds,S=jo[x+1].rightCacheBounds;w!==0&&(v===0?bx(A,jm):Sx(A,jm,jm)),v+=w;let E=0,M=0;v!==0&&(E=Qc(jm)/l);let I=i-v;I!==0&&(M=Qc(S)/l);let P=1+1.25*(E*v+M*I);P<u&&(o=h,u=P,a=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function S4(r,t,e,n){let i=0;for(let s=t,o=t+e;s<o;s++)i+=r[s*6+n*2];return i/e}function w4(r,t){let e=r.attributes.position,n=e.array,i=r.index.array,s=i.length/3,o=new Float32Array(s*6),a=e.offset||0,l=3;e.isInterleavedBufferAttribute&&(l=e.data.stride);for(let u=0;u<s;u++){let c=u*3,d=u*6,h=i[c+0]*l+a,f=i[c+1]*l+a,g=i[c+2]*l+a;for(let p=0;p<3;p++){let m=n[h+p],y=n[f+p],v=n[g+p],x=m;y<x&&(x=y),v<x&&(x=v);let b=m;y>b&&(b=y),v>b&&(b=v);let w=(b-x)/2,A=p*2;o[d+A+0]=x+w,o[d+A+1]=w+(Math.abs(x)+w)*OE,x<t[p]&&(t[p]=x),b>t[p+3]&&(t[p+3]=b)}}return o}function A4(r,t){function e(y){h&&h(y/f)}function n(y,v,x,b=null,w=0){if(!g&&w>=l&&(g=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(r))),x<=c||w>=l)return e(v+x),y.offset=v,y.count=x,y;let A=b4(y.boundingData,b,o,v,x,d);if(A.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let T=v4(a,o,v,x,A);if(T===v||T===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=A.axis;let S=new Qa,E=v,M=T-v;y.left=S,S.boundingData=new Float32Array(6),Ax(o,E,M,S.boundingData,s),n(S,E,M,s,w+1);let I=new Qa,P=T,C=x-M;y.right=I,I.boundingData=new Float32Array(6),Ax(o,P,C,I.boundingData,s),n(I,P,C,s,w+1)}return y}m4(r,t);let i=new Float32Array(6),s=new Float32Array(6),o=w4(r,i),a=r.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,d=t.strategy,h=t.onProgress,f=r.index.count/3,g=!1,p=[],m=g4(r);if(m.length===1){let y=m[0],v=new Qa;v.boundingData=i,y4(o,y.offset,y.count,s),n(v,y.offset,y.count,s),p.push(v)}else for(let y of m){let v=new Qa;v.boundingData=new Float32Array(6),Ax(o,y.offset,y.count,v.boundingData,s),n(v,y.offset,y.count,s),p.push(v)}return p}function NE(r,t){let e=A4(r,t),n,i,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let d=e[c],h=l(d),f=new a(32*h);n=new Float32Array(f),i=new Uint32Array(f),s=new Uint16Array(f),u(0,d),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,d){let h=c/4,f=c/2,g=!!d.count,p=d.boundingData;for(let m=0;m<6;m++)n[h+m]=p[m];if(g){let m=d.offset,y=d.count;return i[h+6]=m,s[f+14]=y,s[f+15]=65535,c+32}else{let m=d.left,y=d.right,v=d.splitAxis,x;if(x=u(c+32,m),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[h+6]=x/4,x=u(x,y),i[h+7]=v,x}}}var Mr=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}setFromPoints(t,e){let n=1/0,i=-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,i=l>i?l:i}this.min=n,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}};Mr.prototype.setFromBox=function(){let r=new _;return function(e,n){let i=n.min,s=n.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){r.x=i.x*l+s.x*(1-l),r.y=i.y*u+s.y*(1-u),r.z=i.z*c+s.z*(1-c);let d=e.dot(r);o=Math.min(d,o),a=Math.max(d,a)}this.min=o,this.max=a}}();var _ne=function(){let r=new Mr;return function(e,n){let i=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 d=o[c],h=s[c];if(r.setFromPoints(h,a),d.isSeparated(r))return!1}for(let c=0;c<3;c++){let d=u[c],h=l[c];if(r.setFromPoints(h,i),d.isSeparated(r))return!1}}}();var _4=function(){let r=new _,t=new _,e=new _;return function(i,s,o){let a=i.start,l=r,u=s.start,c=t;e.subVectors(a,u),r.subVectors(i.end,s.start),t.subVectors(s.end,s.start);let d=e.dot(c),h=c.dot(l),f=c.dot(c),g=e.dot(l),m=l.dot(l)*f-h*h,y,v;m!==0?y=(d*h-g*f)/m:y=0,v=(d+y*h)/f,o.x=y,o.y=v}}(),fh=function(){let r=new F,t=new _,e=new _;return function(i,s,o,a){_4(i,s,r);let l=r.x,u=r.y;if(l>=0&&l<=1&&u>=0&&u<=1){i.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let d;u<0?d=s.start:d=s.end;let h=t,f=e;if(i.closestPointToPoint(d,!0,t),s.closestPointToPoint(c,!0,e),h.distanceToSquared(d)<=f.distanceToSquared(c)){o.copy(h),a.copy(d);return}else{o.copy(c),a.copy(f);return}}}}(),BE=function(){let r=new _,t=new _,e=new Tn,n=new Cn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:d}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=u,n.end=d,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=c,n.end=d,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;let p=o.getPlane(e);if(Math.abs(p.distanceToPoint(l))<=a){let y=p.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var T4=1e-15;function Jc(r){return Math.abs(r)<T4}var Cr=class extends tn{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new _),this.satBounds=new Array(4).fill().map(()=>new Mr),this.points=[this.a,this.b,this.c],this.sphere=new Sn,this.plane=new Tn,this.needsUpdate=!0}intersectsSphere(t){return BE(t,this)}update(){let t=this.a,e=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,i);let d=s[2],h=o[2];d.subVectors(e,n),h.setFromPoints(d,i);let f=s[3],g=o[3];f.subVectors(n,t),g.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};Cr.prototype.closestPointToSegment=function(){let r=new _,t=new _,e=new Cn;return function(i,s=null,o=null){let{start:a,end:l}=i,u=this.points,c,d=1/0;for(let h=0;h<3;h++){let f=(h+1)%3;e.start.copy(u[h]),e.end.copy(u[f]),fh(e,i,r,t),c=r.distanceToSquared(t),c<d&&(d=c,s&&s.copy(r),o&&o.copy(t))}return this.closestPointToPoint(a,r),c=a.distanceToSquared(r),c<d&&(d=c,s&&s.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),c=l.distanceToSquared(r),c<d&&(d=c,s&&s.copy(r),o&&o.copy(l)),Math.sqrt(d)}}();Cr.prototype.intersectsTriangle=function(){let r=new Cr,t=new Array(3),e=new Array(3),n=new Mr,i=new Mr,s=new _,o=new _,a=new _,l=new _,u=new Cn,c=new Cn,d=new Cn;return function(f,g=null){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(r.copy(f),r.update(),f=r);let p=this.plane,m=f.plane;if(Math.abs(p.normal.dot(m.normal))>1-1e-10){let y=this.satBounds,v=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let w=0;w<4;w++){let A=y[w],T=v[w];if(n.setFromPoints(T,e),A.isSeparated(n))return!1}let x=f.satBounds,b=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let A=x[w],T=b[w];if(n.setFromPoints(T,t),A.isSeparated(n))return!1}for(let w=0;w<4;w++){let A=v[w];for(let T=0;T<4;T++){let S=b[T];if(s.crossVectors(A,S),n.setFromPoints(s,t),i.setFromPoints(s,e),n.isSeparated(i))return!1}}return g&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),g.start.set(0,0,0),g.end.set(0,0,0)),!0}else{let y=this.points,v=!1,x=0;for(let C=0;C<3;C++){let D=y[C],B=y[(C+1)%3];u.start.copy(D),u.end.copy(B),u.delta(o);let k=v?c.start:c.end,X=Jc(m.distanceToPoint(D));if(Jc(m.normal.dot(o))&&X){c.copy(u),x=2;break}if((m.intersectLine(u,k)||X)&&!Jc(k.distanceTo(B))){if(x++,v)break;v=!0}}if(x===1&&this.containsPoint(c.start))return g&&(g.start.copy(c.start),g.end.copy(c.start)),!0;if(x!==2)return!1;let b=f.points,w=!1,A=0;for(let C=0;C<3;C++){let D=b[C],B=b[(C+1)%3];u.start.copy(D),u.end.copy(B),u.delta(a);let k=w?d.start:d.end,X=Jc(p.distanceToPoint(D));if(Jc(p.normal.dot(a))&&X){d.copy(u),A=2;break}if((p.intersectLine(u,k)||X)&&!Jc(k.distanceTo(B))){if(A++,w)break;w=!0}}if(A===1&&this.containsPoint(d.start))return g&&(g.start.copy(d.start),g.end.copy(d.start)),!0;if(A!==2)return!1;if(c.delta(o),d.delta(a),o.dot(a)<0){let C=d.start;d.start=d.end,d.end=C}let T=c.start.dot(o),S=c.end.dot(o),E=d.start.dot(o),M=d.end.dot(o),I=S<E,P=T<M;return T!==M&&E!==S&&I===P?!1:(g&&(l.subVectors(c.start,d.start),l.dot(o)>0?g.start.copy(c.start):g.start.copy(d.start),l.subVectors(c.end,d.end),l.dot(o)<0?g.end.copy(c.end):g.end.copy(d.end)),!0)}}}();Cr.prototype.distanceToPoint=function(){let r=new _;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();Cr.prototype.distanceToTriangle=function(){let r=new _,t=new _,e=["a","b","c"],n=new Cn,i=new Cn;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let d=0;d<3;d++){let h,f=e[d],g=o[f];this.closestPointToPoint(g,r),h=g.distanceToSquared(r),h<c&&(c=h,a&&a.copy(r),l&&l.copy(g));let p=this[f];o.closestPointToPoint(p,r),h=p.distanceToSquared(r),h<c&&(c=h,a&&a.copy(p),l&&l.copy(r))}for(let d=0;d<3;d++){let h=e[d],f=e[(d+1)%3];n.set(this[h],this[f]);for(let g=0;g<3;g++){let p=e[g],m=e[(g+1)%3];i.set(o[p],o[m]),fh(n,i,r,t);let y=r.distanceToSquared(t);y<c&&(c=y,a&&a.copy(r),l&&l.copy(t))}}return Math.sqrt(c)}}();var Pr=class extends xt{constructor(...t){super(...t),this.isOrientedBox=!0,this.matrix=new de,this.invMatrix=new de,this.points=new Array(8).fill().map(()=>new _),this.satAxes=new Array(3).fill().map(()=>new _),this.satBounds=new Array(3).fill().map(()=>new Mr),this.alignedSatBounds=new Array(3).fill().map(()=>new Mr),this.needsUpdate=!1}set(t,e,n){super.set(t,e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){super.copy(t),this.matrix.copy(t.matrix),this.needsUpdate=!0}};Pr.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,i=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let d=0;d<=1;d++){let h=1*u|2*c|4*d,f=i[h];f.x=u?n.x:e.x,f.y=c?n.y:e.y,f.z=d?n.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=i[0];for(let u=0;u<3;u++){let c=o[u],d=s[u],h=1<<u,f=i[h];c.subVectors(a,f),d.setFromPoints(c,i)}let l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Pr.prototype.intersectsBox=function(){let r=new Mr;return function(e){this.needsUpdate&&this.update();let n=e.min,i=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,a[0].isSeparated(r)||(r.min=n.y,r.max=i.y,a[1].isSeparated(r))||(r.min=n.z,r.max=i.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(r.setFromBox(u,e),c.isSeparated(r))return!1}return!0}}();Pr.prototype.intersectsTriangle=function(){let r=new Cr,t=new Array(3),e=new Mr,n=new Mr,i=new _;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let h=0;h<3;h++){let f=a[h],g=l[h];if(e.setFromPoints(g,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,d=this.points;for(let h=0;h<3;h++){let f=u[h],g=c[h];if(e.setFromPoints(g,d),f.isSeparated(e))return!1}for(let h=0;h<3;h++){let f=l[h];for(let g=0;g<4;g++){let p=c[g];if(i.crossVectors(f,p),e.setFromPoints(i,t),n.setFromPoints(i,d),e.isSeparated(n))return!1}}return!0}}();Pr.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}}();Pr.prototype.distanceToPoint=function(){let r=new _;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();Pr.prototype.distanceToBox=function(){let r=["x","y","z"],t=new Array(12).fill().map(()=>new Cn),e=new Array(12).fill().map(()=>new Cn),n=new _,i=new _;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),u&&u.copy(i)),0;let c=a*a,d=o.min,h=o.max,f=this.points,g=1/0;for(let m=0;m<8;m++){let y=f[m];i.copy(y).clamp(d,h);let v=y.distanceToSquared(i);if(v<g&&(g=v,l&&l.copy(y),u&&u.copy(i),v<c))return Math.sqrt(v)}let p=0;for(let m=0;m<3;m++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(m+1)%3,b=(m+2)%3,w=y<<x|v<<b,A=1<<m|y<<x|v<<b,T=f[w],S=f[A];t[p].set(T,S);let M=r[m],I=r[x],P=r[b],C=e[p],D=C.start,B=C.end;D[M]=d[M],D[I]=y?d[I]:h[I],D[P]=v?d[P]:h[I],B[M]=h[M],B[I]=y?d[I]:h[I],B[P]=v?d[P]:h[I],p++}for(let m=0;m<=1;m++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){i.x=m?h.x:d.x,i.y=y?h.y:d.y,i.z=v?h.z:d.z,this.closestPointToPoint(i,n);let x=i.distanceToSquared(n);if(x<g&&(g=x,l&&l.copy(n),u&&u.copy(i),x<c))return Math.sqrt(x)}for(let m=0;m<12;m++){let y=t[m];for(let v=0;v<12;v++){let x=e[v];fh(y,x,n,i);let b=n.distanceToSquared(i);if(b<g&&(g=b,l&&l.copy(n),u&&u.copy(i),b<c))return Math.sqrt(b)}}return Math.sqrt(g)}}();var Xm=new _,Ym=new _,Km=new _,FE=new F,UE=new F,GE=new F,kE=new _;function E4(r,t,e,n,i,s){let o;return s===bn?o=r.intersectTriangle(n,e,t,!0,i):o=r.intersectTriangle(t,e,n,s!==fr,i),o===null?null:{distance:r.origin.distanceTo(i),point:i.clone()}}function M4(r,t,e,n,i,s,o){Xm.fromBufferAttribute(t,n),Ym.fromBufferAttribute(t,i),Km.fromBufferAttribute(t,s);let a=E4(r,Xm,Ym,Km,kE,o);if(a){e&&(FE.fromBufferAttribute(e,n),UE.fromBufferAttribute(e,i),GE.fromBufferAttribute(e,s),a.uv=tn.getUV(kE,Xm,Ym,Km,FE,UE,GE,new F));let l={a:n,b:i,c:s,normal:new _,materialIndex:0};tn.getNormal(Xm,Ym,Km,l.normal),a.face=l,a.faceIndex=n}return a}function Tx(r,t,e,n,i){let s=n*3,o=r.index.getX(s),a=r.index.getX(s+1),l=r.index.getX(s+2),u=M4(e,r.attributes.position,r.attributes.uv,o,a,l,t);return u?(u.faceIndex=n,i&&i.push(u),u):null}function zE(r,t,e,n,i,s){for(let o=n,a=n+i;o<a;o++)Tx(r,t,e,o,s)}function VE(r,t,e,n,i){let s=1/0,o=null;for(let a=n,l=n+i;a<l;a++){let u=Tx(r,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Ex(r,t,e){return r===null||(r.point.applyMatrix4(t.matrixWorld),r.distance=r.point.distanceTo(e.ray.origin),r.object=t,r.distance<e.near||r.distance>e.far)?null:r}function hi(r,t,e,n){let i=r.a,s=r.b,o=r.c,a=t,l=t+1,u=t+2;e&&(a=e.getX(t),l=e.getX(t+1),u=e.getX(t+2)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function Mx(r,t,e,n,i,s,o){let a=e.index,l=e.attributes.position;for(let u=r,c=t+r;u<c;u++)if(hi(o,u*3,a,l),o.needsUpdate=!0,n(o,u,i,s))return!0;return!1}var $c=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 no(r,t){return t[r+15]===65535}function Ja(r,t){return t[r+6]}function eu(r,t){return t[r+14]}function tu(r){return r+8}function nu(r,t){return t[r+6]}function HE(r,t){return t[r+7]}var ru=new xt,Qm=new _,P4=["x","y","z"];function Jm(r,t,e,n,i){let s=r*2,o=iu,a=qo,l=Xo;if(no(s,a)){let c=Ja(r,l),d=eu(s,a);zE(t,e,n,c,d,i)}else{let c=tu(r);eg(c,o,n,Qm)&&Jm(c,t,e,n,i);let d=nu(r,l);eg(d,o,n,Qm)&&Jm(d,t,e,n,i)}}function $m(r,t,e,n){let i=r*2,s=iu,o=qo,a=Xo;if(no(i,o)){let u=Ja(r,a),c=eu(i,o);return VE(t,e,n,u,c)}else{let u=HE(r,a),c=P4[u],h=n.direction[c]>=0,f,g;h?(f=tu(r),g=nu(r,a)):(f=nu(r,a),g=tu(r));let m=eg(f,s,n,Qm)?$m(f,t,e,n):null;if(m){let x=m.point[c];if(h?x<=s[g+u]:x>=s[g+u+3])return m}let v=eg(g,s,n,Qm)?$m(g,t,e,n):null;return m&&v?m.distance<=v.distance?m:v:m||v||null}}var WE=function(){let r,t,e=[],n=new $c(()=>new xt);return function(...o){r=n.getPrimitive(),t=n.getPrimitive(),e.push(r,t);let a=i(...o);n.releasePrimitive(r),n.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],r=e[l-2]),a};function i(s,o,a,l,u=null,c=0,d=0){function h(x){let b=x*2,w=qo,A=Xo;for(;!no(b,w);)x=tu(x),b=x*2;return Ja(x,A)}function f(x){let b=x*2,w=qo,A=Xo;for(;!no(b,w);)x=nu(x,A),b=x*2;return Ja(x,A)+eu(b,w)}let g=s*2,p=iu,m=qo,y=Xo;if(no(g,m)){let x=Ja(s,y),b=eu(g,m);return di(s,p,r),l(x,b,!1,d,c+s,r)}else{let x=tu(s),b=nu(s,y),w=x,A=b,T,S,E,M;if(u&&(E=r,M=t,di(w,p,E),di(A,p,M),T=u(E),S=u(M),S<T)){w=b,A=x;let X=T;T=S,S=X,E=M}E||(E=r,di(w,p,E));let I=no(w*2,m),P=a(E,I,T,d+1,c+w),C;if(P===2){let X=h(w),q=f(w)-X;C=l(X,q,!0,d+1,c+w,E)}else C=P&&i(w,o,a,l,u,c,d+1);if(C)return!0;M=t,di(A,p,M);let D=no(A*2,m),B=a(M,D,S,d+1,c+A),k;if(B===2){let X=h(A),q=f(A)-X;k=l(X,q,!0,d+1,c+A,M)}else k=B&&i(A,o,a,l,u,c,d+1);return!!k}}}(),jE=function(){let r=new Cr,t=new Cr,e=new de,n=new Pr,i=new Pr;return function s(o,a,l,u,c=null){let d=o*2,h=iu,f=qo,g=Xo;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),no(d,f)){let m=a,y=m.index,v=m.attributes.position,x=l.index,b=l.attributes.position,w=Ja(o,g),A=eu(d,f);if(e.copy(u).invert(),l.boundsTree)return di(o,h,i),i.matrix.copy(e),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>i.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(u),S.b.applyMatrix4(u),S.c.applyMatrix4(u),S.needsUpdate=!0;for(let E=w*3,M=(A+w)*3;E<M;E+=3)if(hi(t,E,y,v),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let T=w*3,S=A+w*3;T<S;T+=3){hi(r,T,y,v),r.a.applyMatrix4(e),r.b.applyMatrix4(e),r.c.applyMatrix4(e),r.needsUpdate=!0;for(let E=0,M=x.count;E<M;E+=3)if(hi(t,E,x,b),t.needsUpdate=!0,r.intersectsTriangle(t))return!0}}else{let m=o+8,y=g[o+6];return di(m,h,ru),!!(c.intersectsBox(ru)&&s(m,a,l,u,c)||(di(y,h,ru),c.intersectsBox(ru)&&s(y,a,l,u,c)))}}}();function eg(r,t,e,n){return di(r,t,ru),e.intersectBox(ru,n)}var Cx=[],Zm,iu,qo,Xo;function su(r){Zm&&Cx.push(Zm),Zm=r,iu=new Float32Array(r),qo=new Uint16Array(r),Xo=new Uint32Array(r)}function ph(){Zm=null,iu=null,qo=null,Xo=null,Cx.length&&su(Cx.pop())}var Px=Symbol("skip tree generation"),Ix=new xt,Dx=new xt,ou=new de,$a=new Pr,mh=new Pr,gh=new _,tg=new _,I4=new _,D4=new _,O4=new _,qE=new xt,as=new $c(()=>new Cr),on=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."),on.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let n=t.geometry,i=t._roots,s=n.getIndex(),o;return e.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,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."),on.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:i,roots:s}=t,o=new on(e,{...n,[Px]:!0});if(o._roots=s,n.setIndex){let a=e.getIndex();if(a===null){let l=new Be(t.index,1,!1);e.setIndex(l)}else a.array!==i&&(a.array.set(i),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,[Px]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[Px]||(this._roots=NE(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new xt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,i=e.attributes.position,s=i.array,o=i.offset||0,a=3;i.isInterleavedBufferAttribute&&(a=i.data.stride);let l,u,c,d,h=0,f=this._roots;for(let p=0,m=f.length;p<m;p++)l=f[p],u=new Uint32Array(l),c=new Uint16Array(l),d=new Float32Array(l),g(0,h),h+=l.byteLength;function g(p,m,y=!1){let v=p*2;if(c[v+15]===65535){let b=u[p+6],w=c[v+14],A=1/0,T=1/0,S=1/0,E=-1/0,M=-1/0,I=-1/0;for(let P=3*b,C=3*(b+w);P<C;P++){let D=n[P]*a+o,B=s[D+0],k=s[D+1],X=s[D+2];B<A&&(A=B),B>E&&(E=B),k<T&&(T=k),k>M&&(M=k),X<S&&(S=X),X>I&&(I=X)}return d[p+0]!==A||d[p+1]!==T||d[p+2]!==S||d[p+3]!==E||d[p+4]!==M||d[p+5]!==I?(d[p+0]=A,d[p+1]=T,d[p+2]=S,d[p+3]=E,d[p+4]=M,d[p+5]=I,!0):!1}else{let b=p+8,w=u[p+6],A=b+m,T=w+m,S=y,E=!1,M=!1;t?S||(E=t.has(A),M=t.has(T),S=!E&&!M):(E=!0,M=!0);let I=S||E,P=S||M,C=!1;I&&(C=g(b,m,S));let D=!1;P&&(D=g(w,m,S));let B=C||D;if(B)for(let k=0;k<3;k++){let X=b+k,W=w+k,q=d[X],H=d[X+3],K=d[W],R=d[W+3];d[p+k]=q<K?q:K,d[p+k+3]=H>R?H:R}return B}}}traverse(t,e=0){let n=this._roots[e],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let d=i[a+6],h=s[u+14];t(l,c,new Float32Array(n,a*4,6),d,h)}else{let d=a+32/4,h=i[a+6],f=i[a+7];t(l,c,new Float32Array(n,a*4,6),f)||(o(d,l+1),o(h,l+1))}}}raycast(t,e=Wr){let n=this._roots,i=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=i.groups,u=o?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=a?e[l[c].materialIndex].side:u,f=s.length;if(su(n[c]),Jm(0,i,h,t,s),ph(),a){let g=l[c].materialIndex;for(let p=f,m=s.length;p<m;p++)s[p].face.materialIndex=g}}return s}raycastFirst(t,e=Wr){let n=this._roots,i=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=i.groups,u=s?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=o?e[l[c].materialIndex].side:u;su(n[c]);let f=$m(0,i,h,t);ph(),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,i=!1;for(let s of this._roots)if(su(s),i=jE(0,n,t,e),ph(),i)break;return i}shapecast(t,e,n){let i=this.geometry;if(t instanceof Function){if(e){let h=e;e=(f,g,p,m)=>{let y=g*3;return h(f,y,y+1,y+2,p,m)}}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=as.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let h=l;l=(f,g,p,m,y)=>h(f,g,p,m,y)?!0:Mx(f,g,i,u,p,m,s)}else l||(u?l=(h,f,g,p)=>Mx(h,f,i,u,g,p,s):l=(h,f,g)=>g);let c=!1,d=0;for(let h of this._roots){if(su(h),c=WE(0,i,a,l,o,d),ph(),c)break;d+=h.byteLength}return as.releasePrimitive(s),c}bvhcast(t,e,n){let{intersectsRanges:i,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;ou.copy(e).invert();let c=as.getPrimitive(),d=as.getPrimitive();if(s){let f=function(g,p,m,y,v,x,b,w){for(let A=m,T=m+y;A<T;A++){hi(d,A*3,l,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let S=g,E=g+p;S<E;S++)if(hi(c,S*3,o,a),c.needsUpdate=!0,s(c,d,S,A,v,x,b,w))return!0}return!1};if(i){let g=i;i=function(p,m,y,v,x,b,w,A){return g(p,m,y,v,x,b,w,A)?!0:f(p,m,y,v,x,b,w,A)}}else i=f}t.getBoundingBox(Dx),Dx.applyMatrix4(e);let h=this.shapecast({intersectsBounds:f=>Dx.intersectsBox(f),intersectsRange:(f,g,p,m,y,v)=>(Ix.copy(v),Ix.applyMatrix4(ou),t.shapecast({intersectsBounds:x=>Ix.intersectsBox(x),intersectsRange:(x,b,w,A,T)=>i(f,g,x,b,m,y,A,T)}))});return as.releasePrimitive(c),as.releasePrimitive(d),h}intersectsBox(t,e){return $a.set(t.min,t.max,e),$a.needsUpdate=!0,this.shapecast({intersectsBounds:n=>$a.intersectsBox(n),intersectsTriangle:n=>$a.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},i={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),$a.set(t.boundingBox.min,t.boundingBox.max,e),$a.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,d=t.index,h=as.getPrimitive(),f=as.getPrimitive(),g=tg,p=I4,m=null,y=null;i&&(m=D4,y=O4);let v=1/0,x=null,b=null;return ou.copy(e).invert(),mh.matrix.copy(ou),this.shapecast({boundsTraverseOrder:w=>$a.distanceToBox(w),intersectsBounds:(w,A,T)=>T<v&&T<o?(A&&(mh.min.copy(w.min),mh.max.copy(w.max),mh.needsUpdate=!0),!0):!1,intersectsRange:(w,A)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:T=>mh.distanceToBox(T),intersectsBounds:(T,S,E)=>E<v&&E<o,intersectsRange:(T,S)=>{for(let E=T*3,M=(T+S)*3;E<M;E+=3){hi(f,E,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let I=w*3,P=(w+A)*3;I<P;I+=3){hi(h,I,u,l),h.needsUpdate=!0;let C=h.distanceToTriangle(f,g,m);if(C<v&&(p.copy(g),y&&y.copy(m),v=C,x=I/3,b=E/3),C<s)return!0}}}});{let T=d?d.count:c.count;for(let S=0,E=T;S<E;S+=3){hi(f,S,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let M=w*3,I=(w+A)*3;M<I;M+=3){hi(h,M,u,l),h.needsUpdate=!0;let P=h.distanceToTriangle(f,g,m);if(P<v&&(p.copy(g),y&&y.copy(m),v=P,x=M/3,b=S/3),P<s)return!0}}}}}),as.releasePrimitive(h),as.releasePrimitive(f),v===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=v,n.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(ou),p.applyMatrix4(ou),i.distance=p.sub(i.point).length(),i.faceIndex=b),n)}closestPointToPoint(t,e={},n=0,i=1/0){let s=n*n,o=i*i,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(gh.copy(t).clamp(c.min,c.max),gh.distanceToSquared(t)),intersectsBounds:(c,d,h)=>h<a&&h<o,intersectsTriangle:(c,d)=>{c.closestPointToPoint(t,gh);let h=t.distanceToSquared(gh);return h<a&&(tg.copy(gh),a=h,l=d),h<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(tg):e.point=tg.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{di(0,new Float32Array(n),qE),t.union(qE)}),t}},XE=on.prototype.raycast;on.prototype.raycast=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[t,e,n,i]=r;return XE.call(this,n,t.material).forEach(o=>{o=Ex(o,t,e),o&&i.push(o)}),i}else return XE.apply(this,r)};var YE=on.prototype.raycastFirst;on.prototype.raycastFirst=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[t,e,n]=r;return Ex(YE.call(this,n,t.material),t,e)}else return YE.apply(this,r)};var KE=on.prototype.closestPointToPoint;on.prototype.closestPointToPoint=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),r.unshift();let t=r[1],e={};return r[1]=e,KE.apply(this,r),t&&t.copy(e.point),e.distance}else return KE.apply(this,r)};var ZE=on.prototype.closestPointToGeometry;on.prototype.closestPointToGeometry=function(...r){let t=r[2],e=r[3];if(t&&t.isVector3||e&&e.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let n={},i={},s=r[1];return r[2]=n,r[3]=i,ZE.apply(this,r),t&&t.copy(n.point),e&&e.copy(i.point).applyMatrix4(s),n.distance}else return ZE.apply(this,r)};var QE=on.prototype.refit;on.prototype.refit=function(...r){let t=r[0],e=r[1];if(e&&(e instanceof Set||Array.isArray(e))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let n=new Set;e.forEach(i=>n.add(i)),t&&t.forEach(i=>n.add(i)),QE.call(this,n)}else QE.apply(this,r)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(r=>{let t=on.prototype[r];on.prototype[r]=function(...e){return(e[0]===null||e[0].isMesh)&&(e.shift(),console.warn(`MeshBVH: The function signature for "${r}" has changed and no longer takes Mesh. See docs for new signature.`)),t.apply(this,e)}});var Fu=dd($E());var L4=.5*(Math.sqrt(3)-1),yh=(3-Math.sqrt(3))/6,R4=1/3,ls=1/6,vre=(Math.sqrt(5)-1)/4,xre=(5-Math.sqrt(5))/20,vh=r=>Math.floor(r)|0,eM=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]),Lx=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 ng(r=Math.random){let t=nM(r),e=new Float64Array(t).map(i=>eM[i%12*2]),n=new Float64Array(t).map(i=>eM[i%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*L4,d=vh(s+c),h=vh(o+c),f=(d+h)*yh,g=d-f,p=h-f,m=s-g,y=o-p,v,x;m>y?(v=1,x=0):(v=0,x=1);let b=m-v+yh,w=y-x+yh,A=m-1+2*yh,T=y-1+2*yh,S=d&255,E=h&255,M=.5-m*m-y*y;if(M>=0){let C=S+t[E],D=e[C],B=n[C];M*=M,a=M*M*(D*m+B*y)}let I=.5-b*b-w*w;if(I>=0){let C=S+v+t[E+x],D=e[C],B=n[C];I*=I,l=I*I*(D*b+B*w)}let P=.5-A*A-T*T;if(P>=0){let C=S+1+t[E+1],D=e[C],B=n[C];P*=P,u=P*P*(D*A+B*T)}return 70*(a+l+u)}}function tM(r=Math.random){let t=nM(r),e=new Float64Array(t).map(s=>Lx[s%12*3]),n=new Float64Array(t).map(s=>Lx[s%12*3+1]),i=new Float64Array(t).map(s=>Lx[s%12*3+2]);return function(o,a,l){let u,c,d,h,f=(o+a+l)*R4,g=vh(o+f),p=vh(a+f),m=vh(l+f),y=(g+p+m)*ls,v=g-y,x=p-y,b=m-y,w=o-v,A=a-x,T=l-b,S,E,M,I,P,C;w>=A?A>=T?(S=1,E=0,M=0,I=1,P=1,C=0):w>=T?(S=1,E=0,M=0,I=1,P=0,C=1):(S=0,E=0,M=1,I=1,P=0,C=1):A<T?(S=0,E=0,M=1,I=0,P=1,C=1):w<T?(S=0,E=1,M=0,I=0,P=1,C=1):(S=0,E=1,M=0,I=1,P=1,C=0);let D=w-S+ls,B=A-E+ls,k=T-M+ls,X=w-I+2*ls,W=A-P+2*ls,q=T-C+2*ls,H=w-1+3*ls,K=A-1+3*ls,R=T-1+3*ls,U=g&255,z=p&255,j=m&255,G=.6-w*w-A*A-T*T;if(G<0)u=0;else{let V=U+t[z+t[j]];G*=G,u=G*G*(e[V]*w+n[V]*A+i[V]*T)}let re=.6-D*D-B*B-k*k;if(re<0)c=0;else{let V=U+S+t[z+E+t[j+M]];re*=re,c=re*re*(e[V]*D+n[V]*B+i[V]*k)}let Z=.6-X*X-W*W-q*q;if(Z<0)d=0;else{let V=U+I+t[z+P+t[j+C]];Z*=Z,d=Z*Z*(e[V]*X+n[V]*W+i[V]*q)}let J=.6-H*H-K*K-R*R;if(J<0)h=0;else{let V=U+1+t[z+1+t[j+1]];J*=J,h=J*J*(e[V]*H+n[V]*K+i[V]*R)}return 32*(u+c+d+h)}}function nM(r){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 i=n+~~(r()*(256-n)),s=e[n];e[n]=e[i],e[i]=s}for(let n=256;n<512;n++)e[n]=e[n-256];return e}var Li=new tn,rg=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 i=0;i<t.count;i+=3){let s=1;Li.a.fromBufferAttribute(t,i),Li.b.fromBufferAttribute(t,i+1),Li.c.fromBufferAttribute(t,i+2),s*=Li.getArea(),e[i/3]=s}this.distribution=new Float32Array(t.count/3);let n=0;for(let i=0;i<e.length;i++)n+=e[i],this.distribution[i]=n;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let n=this.distribution[this.distribution.length-1],i=this.binarySearch(this.randomFunction()*n);return this.sampleFace(i,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,n=0,i=e.length-1,s=-1;for(;n<=i;){let o=Math.ceil((n+i)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?i=o-1:n=o+1}return s}sampleFace(t,e,n){let i=this.randomFunction(),s=this.randomFunction();return i+s>1&&(i=1-i,s=1-s),Li.a.fromBufferAttribute(this.positionAttribute,t*3),Li.b.fromBufferAttribute(this.positionAttribute,t*3+1),Li.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Li.a,i).addScaledVector(Li.b,s).addScaledVector(Li.c,1-(i+s)),Li.getNormal(n),this}};var iM=dd(Rx()),N4=new de,B4=new de,F4=new de,xh;(t=>{function r(e){return e&&e.__isSPEObject}t.is=r})(xh||(xh={}));var au=r=>class extends r{constructor(){super(...arguments);this.hiddenMatrix=new de;this.matrixWorldRigid=new de;this.shearScale=new de;this.shearScaleInv=new de}get __isSPEObject(){return!0}isDescendantOf(n){n instanceof ut&&(n=n.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===n)return!0;i=i.parent}return!1}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);for(let i of this.children)i.updateMatrixWorld(n)}updateWorldMatrix(n,i){let s=this.parent;if(n&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseObject(n,i=0){if(n(this,i)!==!0)for(let o of this.children)xh.is(o)&&o.traverseObject(n,i+1)}updateMatrixWorldSVD(){let n=this.matrixWorld.elements,i=[[n[0],n[4],n[8]],[n[1],n[5],n[9]],[n[2],n[6],n[10]]],{u:s,v:o,q:a}=(0,iM.SVD)(i),l=N4.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=B4.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=F4.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),a.every(d=>Math.abs(a[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(n,i){this.updateWorldMatrix(!0,!1);let s=new de().copy(this.matrixWorld).invert();return n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),s.multiply(n.parent.matrixWorld)),"hiddenMatrix"in n&&n.hiddenMatrix instanceof de?n.hiddenMatrix.premultiply(s):n.applyMatrix4(s),n.updateWorldMatrix(!1,!1),this.add(n),i!==void 0&&(this.children.pop(),this.children.splice(i,0,n)),this}};var Nx=class extends au(ut){},U4=r=>r.type==="Mesh",fi=class extends Nx{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1}expand(){let e=0,n=this.object.entityChildren(e);for(;n;){let i=this.children[e];i?.object!==n&&(i&&this.remove(i),i=new fi(n),this.add(i),i.matrixAutoUpdate=!1,i.matrix=n.matrix,i.hiddenMatrix=n.hiddenMatrix),i.expand(),e+=1,n=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return 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 U4(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 el=new _,tl=new _,lu=new de,oM=[new _(-1,1,1),new _(-1,-1,1),new _(1,-1,1),new _(1,1,1),new _(-1,1,-1),new _(-1,-1,-1),new _(1,-1,-1),new _(1,1,-1)],G4=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],k4=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],sM=(r,t,e)=>{r.updateEntityBoxSize(el,tl),lu.copy(t).multiply(r.matrixWorld),tl.x===0&&tl.y===0&&tl.z===0?e.push(new _(el.x,el.y,el.z).applyMatrix4(lu)):oM.forEach(n=>{e.push(n.clone().multiply(tl).add(el).applyMatrix4(lu))})},bh=class extends xt{constructor(){super(...arguments);this.matrix=new de;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 i=new de().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,n)}expandByObjectSize(e,n,i=!1){let s=[];return i===!0?e.traverseEntity(o=>{(o.visible||o.cloner&&o.data.visible)&&sM(o,n,s)}):sM(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(lu.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(tl).multiplyScalar(.5),this.getCenter(el),lu.copy(this.matrix).setPosition(el),this.vertices=oM.map(e=>e.clone().multiply(tl).applyMatrix4(lu))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=G4.map(([e,n])=>new Cn(this.vertices[e],this.vertices[n])),this.centerEdges=this.edges.map(e=>e.getCenter(new _))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=k4.map(([e,n])=>this.vertices[e].clone().add(this.vertices[n]).multiplyScalar(.5))}};var Ri={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var Fx=class extends Rd{constructor(){super()}getPoints(t=12){let e=[],n,i=this.getCurveLengths(),o=i[i.length-1]/i.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?i[a]:i[a]-i[a-1],d=Math.ceil(t*c/o),h=u.getPoints(d);for(let f=0;f<h.length;f++){let g=h[f];n&&n.equals(g)||(e.push(g),n=g)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var Ux=.001;function Gx(r,t,e){return t.clone().sub(r).cross(t.clone().sub(e)).length()<=Ux}function Bx(r,t){let e=new _(...r.position),n=new _(...r.controlNext.position),i=new _(...t.controlPrevious.position),s=new _(...t.position);return Gx(e,n,s)&&Gx(e,i,s)}function sg(r){let t=r.points.map(c=>new _(...c.data.position)),e=[r.points[0]],n=new _(...e[0].data.position);for(let c=0;c<r.points.length-1;c++)Gx(n,t[c],t[c+1])||(e.push(r.points[c]),n=t[c]);e.push(r.points[r.points.length-1]);let i=r.isClosed,s=e.length-(i?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let d=e[c].data,h=new _(...d.position),f=new _(...d.controlPrevious.position),g=new _(...d.controlNext.position),p={position:h,baseRoundness:d.roundness,controlPrevious:f,controlNext:g};if(d.roundness===0||!r.isClosed&&(c===0||c===o-1)){a[c]={...p,removedLength:0};continue}let m=i&&c==0?o-1:c-1,y=i&&c==o-1?0:c+1,v=e[m].data,x=e[y].data,b=new _(...v.position),w=new _(...x.position),A=b.clone().sub(h).normalize(),T=w.clone().sub(h).normalize();Object.assign(p,{prevDir:A,nextDir:T});let S=Bx(v,d),E=Bx(d,x);if(!S||!E)a[c]={...p,removedLength:0};else{let M=A.clone().add(T).normalize(),I=M.clone().cross(A).length()/A.dot(M);a[c]={...p,tan:I,removedLength:d.roundness/I}}}for(let c=0;c<s;c++){let d=c,h=i&&c===o-1?0:c+1,f=a[d],g=a[h];if(f.removedLength!==0||g.removedLength!==0){let p=f.position.distanceTo(g.position);f.removedLength=Math.min(f.removedLength,p/2),g.removedLength=Math.min(g.removedLength,p/2)}}let l=[];for(let c=0;c<s;c++){let d=c,h=i&&c===o-1?0:c+1,f=a[d],g=a[h],p=null;if(!Bx(e[d].data,e[h].data))f.position.distanceTo(g.position)>Ux&&(p=new Da(f.position,f.controlNext,g.controlPrevious,g.position));else{let m=f.position.clone(),y=g.position.clone();(f.removedLength!==0||g.removedLength!==0)&&(f.nextDir&&m.add(f.nextDir.clone().setLength(f.removedLength)),g.prevDir&&y.add(g.prevDir.clone().setLength(g.removedLength))),m.distanceTo(y)>Ux&&(p=new Da(m,m.clone().lerp(y,.3),y.clone().lerp(m,.3),y))}l[2*c+1]=p}for(let c=0;c<o;c++){let d=a[c];if(d.removedLength===0){l[2*c]=null;continue}let h=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(h),g=d.nextDir.clone().multiplyScalar(d.removedLength).add(h),p=d.tan*d.removedLength,m=d.prevDir.clone().add(d.nextDir).normalize(),y=f.clone().lerp(g,.5),v=f.distanceTo(g)/2,x=m.clone().multiplyScalar(Math.sqrt(Math.pow(p,2)-Math.pow(v,2))).add(y),b=m.clone().multiplyScalar(-p).add(x),w=h.distanceTo(b)/h.distanceTo(y),A=d.prevDir.clone().multiplyScalar(w*h.distanceTo(f)).add(h),T=A.clone().lerp(b,2),S=f.clone().lerp(A,4/3),E=g.clone().lerp(T,4/3);l[2*c]=new Da(f,S,E,g)}let u=new Fx;return l.forEach(c=>{c&&u.add(c)}),u}var Pt;(t=>{function r(e){return e&&e.__isEntity}t.is=r})(Pt||(Pt={}));var ro=r=>Pt.is(r),z4={type:"completeState",isfromEntity:!0},og=r=>class extends au(r){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new bh;this._recursiveBBox=new bh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(n){let i=this.children[n];if(Pt.is(i))return i}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let n=this;for(;n.data.type!=="Instance";){let i=n.parent;if(Pt.is(i))n=i;else return}return n}forInstancesRec(n){this.instances.forEach(i=>{i.disposed||n(i),i.forInstancesRec(n)})}super_Entity(n,i){typeof n=="string"&&(this.uuid=n),this.identity=n,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(n,i,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)Js.toOps(this.data,o.data).forEach(l=>{let u=am.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,i)});if(n!==null){let o=this.data.states.data(n);o&&(this.dataPatched=Js.patch(this.data,o),Js.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,i)}))}s&&this.updateTransformState(this.dataPatched),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,i){n.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(n=>{ro(n)&&n.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(n=>{n.resetBBoxNeedsUpdateSelf()})}find(n){let i;return this.traverseEntity(s=>{s.uuid===n&&(i=s)}),i}traverseSortNextHelper(){let n=this.parent;if(n){let i=n.children,s=i.indexOf(this)+1;if(Pt.is(i[s]))return i[s];if(Pt.is(n))return n.traverseSortNextHelper()}}sortNext(){let n=this.children;return this.children.length>0&&Pt.is(this.children[0])?n[0]:this.traverseSortNextHelper()}goUp(n){let i=this;for(;n>0&&i!==null;)i=i.parent,n-=1;return i}hasAnccestorOrSelf(n){return this===n||this.hasAnccestor(n)}hasAnccestor(n){let i=this.parent;for(;i;){if(n===i)return!0;i=i.parent}return!1}countToAccestor(n){let i=0,s=this;for(;s!==n;){if(s===null)return-1;s=s.parent,i+=1}return i}forEachEntity(n){for(let i of this.children)ro(i)&&n(i)}traverseEntityAncestors(n){this.traverseAncestors(i=>{Pt.is(i)&&n(i)})}traverseEntity(n,i=0){if(n(this,i)!==!0)for(let o of this.children)ro(o)&&o.traverseEntity(n,i+1)}traverseVisibleEntity(n){n(this);for(let i of this.children)ro(i)&&i.visible&&i.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(n,i=!0){return super.copy(n,!1),this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),this}hasEntityChild(){return this.children.some(n=>ro(n))}isAncestorOf(n){if(this.uuid===n)return!1;let i=!1;return this.traverseEntity(s=>{s.uuid===n&&(i=!0)}),i}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Ic(i,n)}updateTransformState(n){let i=!1;return n.position&&(this.position.fromArray(n.position),i=!0),n.rotation&&(this.rotation.fromArray(n.rotation),i=!0),n.scale&&(i=!0,this.scale.fromArray(n.scale)),n.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(n.hiddenMatrix??Vo.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),n.position&&n.rotation&&n.scale&&n.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let n of this.children)Pt.is(n)&&n.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(n=>{Pt.is(n)&&n.disposeRecursively()})}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return Ic(i,n)}updateByOp(n,i,s,o){let a=this.data;this.data=i;let l=n,u=Ii(n.path,["states","*"]);if(u!==null){if(n.type===0){let[c]=u;if(this?.stateSelection===c){let d={...n.props};if(Object.values(n.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let f=gr.zoom(h,n.path.slice(2));if(f)for(let g in n.props)n.props[g]===void 0&&g in f&&(d[g]=f[g])}}l={...n,props:d,path:n.path.slice(2)}}}}else if(n.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(n.props.name!==void 0&&c.name){let{name:h,...f}=c;c=f}if(n.props.material!==void 0&&"material"in c){let{material:h,...f}=c;c=f}let d=gr.removeOverridden(n.path,n.props,c);l={...n,props:d}}}if(this.updateByPatchedOpBase(l,Js.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Ii(n.path,["overrides"])){let c=[],d=[...n.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(n.type===0)for(let h of Object.keys(n.props)){c[c.length-1]=h;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=n.props[h],f.updateState(Zs.apply(f.component.data,f.overrideData),s))}}else{let h=s.scene.findInstance([this.uuid,...c]);if(h){let f=gr.zoom(h.component.data,d);if(n={...n,path:d},n.type===0){let g=n.props;if(f)for(let[p,m]of Object.entries(n.props))m===void 0&&(g===n.props&&(g={...n.props}),g[p]=f[p]);n={...n,props:g}}h.overrideData=jc.resolve(i.overrides,c),h.updateByOp(n,$n.applySimple(h.data,n),s,!1)}}}else if(this.instances.length>0){let c;if(n.path.length===0&&n.type===0){let d;for(let h of Wo.rootOverrideProps)h in n.props&&(d===void 0&&(d={}),d[h]=n.props[h]);d&&(c={...n,props:d})}else for(let d of Wo.rootOverrideProps)if(Ii(n.path,[d])){c=n;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let h=Zs.filterOp(d.overrideData,c);h&&d.updateByOp(h,$n.applySimple(d.data,h),s,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let h=Zs.filterOp(d.overrideData,n);if(h){let f;a===d.data&&n===h?f=i:f=$n.applySimple(d.data,h),d.updateByOp(h,f,s,!0)}}})}}updateByPatchedOpBase(n,i,s){if(this.dataPatched=i,n.path.length===0&&n.type===0)n.props.type!==void 0&&!Di.is(n.props.type)&&Ri.changeEntityProptotype(this,i,s);else if(n.path.length===1&&n.path[0]==="geometry"&&n.type===0&&"type"in n.props){Ri.changeEntityProptotype(this,i,s);for(let o of this.children)Pt.is(o)&&o.updateVisible()}this.updateByPatchedOp(n,i,s)}updateByPatchedOp(n,i,s){if(n.path.length===0&&n.type===0&&this.updateState(n.props,s),Ii(n.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Ii(n.path,["cloner"])!==null){let o=$n.drop(n,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(i.cloner,s.scene):(this.setFromClonerState(i.cloner,s),this.expandCloner(s.scene)),this.updateVisible()}}updatePathSnapping(n){this._updatedPathSnapping=n,this._needApplyPathSnapping=!0}applyPathSnapping(n){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let l=n.find(i);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data,c=sg(u.geometry.path),d=(s+o)%1,h=c.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new de;l.updateMatrixWorld();let g=new de().multiplyMatrices(f.clone().invert(),l.matrixWorld);h.applyMatrix4(g);let p={position:h.toArray(),rotation:u.rotation};if(a==="tangential"){let m=new de().extractRotation(l.matrixWorld),y=c.getTangentAt(d).applyMatrix4(m).add(h),v=new de().lookAt(h,y,new _(0,1,0)),x=new jt().setFromRotationMatrix(v);p={...p,rotation:[x.x,x.y,x.z]}}this.updateTransformState(p),this.traverseEntity(m=>{m._cameraType&&m.dispatchEvent(z4)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(n,i){n.name!==void 0&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),"cloner"in n&&n.cloner!==void 0&&(this.setFromClonerState(n.cloner,i),this.updateVisible()),this.updateTransformState(n)}get attachedSurfaceCloners(){return this.children.filter(n=>n instanceof Ri.Cloner&&n.parameters.type==="toObject")}setFromClonerState(n,i){this.disposed||(n===null||n.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):(this.cloner===void 0&&(this.cloner=new Ri.Cloner(this,n),i.scene.addPendingExpandCloner(this)),this.cloner.updateState(n,i.scene)))}expandCloner(n){!this.disposed&&this.cloner&&this.cloner.expandClones(n)}invalidateClonerTransform(n){this.cloner&&this.cloner.invalidateTransform(n)}};var lM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},r.parameters),n=e.width/2,i=e.radiusTop??n,s=e.radiusBottom??n;return i===s?(i=n,s=n):i>s?(i=n,s=s*n/i):(i=i*n/s,s=n),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:i,radiusBottom:s})}}static build(r){let{width:t,depth:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:h,hollow:f}=r.parameters,g;return d||f?g=new Sh(u,c,n,i,s,o,a,l*Math.PI/180,d,d,h,f):g=new La(u,c,n,i,s,o,a,l*Math.PI/180),g.scale(1,1,e/t),Object.assign(g,{userData:{...r,type:"CylinderGeometry"}})}};function Yo(r,t,e){e.x=r.x*t.x,e.y=r.y,e.z=r.x*t.y}function aM(r){return new F(r.y,-r.x)}var Sh=class extends Te{constructor(t,e,n,i,s,o,a,l,u,c,d,h,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,n=n||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let g=[],p=[],m=[],y=[],v=0,x=n/2,b=new _,w=new _;f&&t==0&&(t=u),f&&e==0&&(e=c);let A=new F(t,x),T=new F(e,-x),S=null,E=null,M=null,I=null,P=A.clone().sub(T),C=0,D=0,B=0;h>0&&(C=Math.min(t,e)*(1-h),D=t-C,B=e-C);let k=A.clone();k.x-=C;let X=Math.PI-P.angle(),W=P.angle(),q=Math.tan(W/2),H=Math.tan(X/2),K=q+H,R=h?K:H,U=h?K:q;if(u=Math.min(u,(t-D)/R,P.length()/K),c=Math.min(c,(e-B)/U,P.length()/K),u>0){let J=u/q;S=A.clone().sub(new F(J,u)),h&&(M=S.clone(),M.x-=C-K*u),A.sub(P.clone().setLength(J))}if(c>0){let J=c/H;E=T.clone().sub(new F(J,-c)),T.add(P.clone().setLength(J)),h&&(I=E.clone(),I.x-=C-K*c,k.sub(P.clone().setLength(J)))}P=A.clone().sub(T);let z=P.length()<.5,j=[];for(let J=0;J<=i;J++){let V=[],pe=J/i,ie=pe*l+a,ae=new F(Math.sin(ie),Math.cos(ie));I&&E?(G(V,pe,ae,X,c,I,-1,!0),G(V,pe,ae,W,c,E,-1,!1)):E?(re(V,ae,E.x,0,-1),G(V,pe,ae,W,c,E,-1,!1)):o||re(V,ae,e,B,-1);let fe=aM(P).normalize();if(Yo(fe,ae,b),!z)for(let xe=0;xe<=s;xe++){let me=xe/s,Me=P.clone().multiplyScalar(me).add(T);Yo(Me,ae,w),p.push(w.x,w.y,w.z),m.push(b.x,b.y,b.z),y.push(pe,.5+w.y/n),V.push(v++)}if(M&&S?(G(V,pe,ae,X,u,S,1,!1),G(V,pe,ae,W,u,M,1,!0)):S?(G(V,pe,ae,X,u,S,1,!1),re(V,ae,S.x,0,1)):o||re(V,ae,t,D,1),h&&!z){let xe=aM(P).multiplyScalar(-1).normalize();Yo(xe,ae,b);for(let me=0;me<=s;me++){let Me=me/s,Pe=P.clone().multiplyScalar(-Me).add(k);Yo(Pe,ae,w),p.push(w.x,w.y,w.z),m.push(b.x,b.y,b.z),y.push(pe,.5+w.y/n),V.push(v++)}}h&&!o&&V.push(V[0]),j.push(V)}for(let J=0;J<j.length-1;J++)for(let V=0;V<j[0].length-1;V++){if(o&&h&&V==s)continue;let pe=j[J][V],ie=j[J+1][V],ae=j[J+1][V+1],fe=j[J][V+1],xe=p[ae*3+0],me=p[ae*3+2];g.push(pe,ie,fe),(xe!=0||me!=0)&&g.push(ie,ae,fe)}l<Math.PI*2&&(Z(-1,j[0],a),Z(1,j[j.length-1],a+l)),this.setIndex(g),this.setAttribute("position",new we(p,3)),this.setAttribute("normal",new we(m,3)),this.setAttribute("uv",new we(y,2));function G(J,V,pe,ie,ae,fe,xe,me){for(let Me=0;Me<d+1;Me++){let Pe=Me/d,be=xe<0?Pe:1-Pe;me&&(be-=1),be*=ie;let Fe=new F(Math.sin(be),Math.cos(be)*xe),ht=Fe.clone().multiplyScalar(ae).add(fe);Yo(ht,pe,w),p.push(w.x,w.y,w.z),Yo(Fe,pe,b),m.push(b.x,b.y,b.z),y.push(V,.5+w.y/n),J.push(v++)}}function re(J,V,pe,ie,ae){let fe=new _,xe=new F,me=[pe,ie];ae<0&&me.reverse();for(let Me of me)xe.set(Me,x*ae),Yo(xe,V,fe),p.push(fe.x,fe.y,fe.z),m.push(0,ae,0),y.push(.5,.5),J.push(v++)}function Z(J,V,pe){let ie=new F(Math.sin(pe),Math.cos(pe)),ae=new F(-Math.cos(pe),Math.sin(pe)),fe=new _,xe=J<0?(Pe,be,Fe)=>g.push(Pe,be,Fe):(Pe,be,Fe)=>g.push(Pe,Fe,be),me=new F((t+e+D+B)/4,0);Yo(me,ie,fe),p.push(fe.x,fe.y,fe.z),m.push(ae.x,0,ae.y),y.push(.5,.5);let Me=v++;for(let Pe of V){let be=p.slice(Pe*3,Pe*3+3);p.push(...be),m.push(ae.x,0,ae.y);let Fe=y.slice(Pe*2,Pe*2+2);y.push(...Fe),v++}for(let Pe=Me+1;Pe<v-1;Pe++)xe(Me,Pe,Pe+1);xe(Me,v-1,Me+1)}}};var cM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,depth:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=r.parameters,h;return u>0||c>0||l<360?h=new Sh(0,t/2,n,i,s,o,a,l*Math.PI/180,u,c,d,0,!0):h=new Hl(t/2,n,i,s,o),h.scale(1,1,e/t),Object.assign(h,{userData:{...r,type:"ConeGeometry"}})}};var uM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},r.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(r){let{width:t,height:e,depth:n,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=r.parameters,u;return a==0?u=new Gn(t,e,n,i,s,o):u=new zx(t,e,n,i,s,o,a,l),Object.assign(u,{userData:{...r,type:"CubeGeometry"}})}},kx=Math.PI/2,zx=class extends Te{constructor(t=1,e=1,n=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,n/2);let c=[],d=[],h=[],f=[],g=0,p=0;m("z","y","x",-1,-1,n,e,t,o,s,0),m("z","y","x",1,-1,n,e,-t,o,s,1),m("x","z","y",1,1,t,n,e,i,o,2),m("x","z","y",1,-1,t,n,-e,i,o,3),m("x","y","z",1,-1,t,e,n,i,s,4),m("x","y","z",-1,-1,t,e,-n,i,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,i,0),y("x","y","z",1,-1,1,t,e,n,i,1),y("x","y","z",-1,1,1,t,e,n,i,0),y("x","y","z",1,1,-1,t,e,n,i,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 we(d,3)),this.setAttribute("normal",new we(h,3)),this.setAttribute("uv",new we(f,2));function m(x,b,w,A,T,S,E,M,I,P,C){let D=(S-2*a)/I,B=(E-2*a)/P,k=S/2-a,X=E/2-a,W=M/2,q=I+1,H=P+1,K=0,R=0,U=new _;for(let z=0;z<H;z++){let j=z*B-X;for(let G=0;G<q;G++){let re=G*D-k;U[x]=re*A,U[b]=j*T,U[w]=W,d.push(U.x,U.y,U.z),U[x]=0,U[b]=0,U[w]=M>0?1:-1,h.push(U.x,U.y,U.z),f.push(G/I),f.push(1-z/P),K+=1}}for(let z=0;z<P;z++)for(let j=0;j<I;j++){let G=g+j+q*z,re=g+j+q*(z+1),Z=g+(j+1)+q*(z+1),J=g+(j+1)+q*z;c.push(G,re,J),c.push(re,Z,J),R+=6}u.addGroup(p,R,C),p+=R,g+=K}function y(x,b,w,A,T,S,E,M,I,P,C){let D=(E-2*a)/P,B=E/2-a,k=M/2-a,X=I/2,W=P+1,q=0,H=0,K=new _,R=new _;for(let U=0;U<l+1;U++){let z=U/l*kx,j=Math.sin(z)*a,G=(1-Math.cos(z))*a,re=Math.sin(z),Z=Math.cos(z);K[b]=(k+j)*T,K[w]=(X-G)*S,R[x]=0,R[b]=re*Math.sign(K[b]),R[w]=Z*Math.sign(K[w]);for(let J=0;J<W;J++){let V=J*D-B;K[x]=V*A,d.push(K.x,K.y,K.z),h.push(R.x,R.y,R.z),f.push(J/P),f.push(0),q+=1}}for(let U=0;U<l;U++)for(let z=0;z<P;z++){let j=g+z+W*U,G=g+z+W*(U+1),re=g+(z+1)+W*(U+1),Z=g+(z+1)+W*U;c.push(j,G,Z),c.push(G,re,Z),H+=6}u.addGroup(p,H,C),p+=H,g+=q}function v(x,b,w){let A=new _,T=new _(t/2,e/2,n/2);T.subScalar(a);let S=[],E=x*b*w>0?(I,P,C)=>c.push(I,P,C):(I,P,C)=>c.push(I,C,P);for(let I=0;I<=l;I++){let P=[],C=kx*(1-I/l),D=Math.cos(C),B=Math.sin(C),k=0;for(let X=0;X<=I;X++){let W=Math.cos(k),q=Math.sin(k);A.x=D*W,A.y=B,A.z=D*q;let H=T.clone().addScaledVector(A,a);d.push(x*H.x,b*H.y,w*H.z),h.push(x*A.x,b*A.y,w*A.z),f.push(0,0),P.push(g++),k+=kx/I}S.push(P)}let M=S.length-1;for(let I=0;I<M;I++){let P=S[I],C=S[I+1],D=P.length-1;E(P[0],C[1],C[0]);for(let B=1;B<=D;B++)E(P[B-1],P[B],C[B]),E(P[B],C[B+1],C[B])}}}};var Ko=class extends Te{constructor(t=[],e=[],n="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),d(),this.setAttribute("position",new we(a,3)),this.setAttribute("normal",new we(u,3)),this.setAttribute("uv",new we(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],g=new _,p=g.clone(),m=new tn,y=s*i,v=i-y,x=o+1,b=new _,w=(q,H)=>b.subVectors(q,H).normalize(),A=(q,H)=>Array(q).fill(void 0).map(H),T=A(t.length/3,(q,H)=>new _().fromArray(t,H*3).setLength(i)),S=[],E=1e6;for(let q=0;q<T.length;q++){let H=T[q],K=[],R,U,z,j=1e10,G=-1;for(;(G=e.indexOf(q,G+1))!=-1;){let V=G-G%3;R=e[V+(G+1)%3],U=e[V+(G+2)%3],z=H.distanceToSquared(T[R]),j=Math.min(j,z),K.push([R,U,z])}j+=1e-6;let re=[],Z=0,J=K.length;for(let V=0;V<J;V++){[R,U,z]=K[Z];let pe=S[R]?.includes(q)==!0;z<=j&&re.push(R+ +pe*E),Z=K.findIndex(ie=>ie[0]==U)}S.push(re)}let M=[];{let q=0,H=0,K,R,U=f==3;for(let z=0;z<=o;z++){K=z*(z+1)/2,R=(z+1)*(z+2)/2;for(let j=0;j<o-z;j++)[q,H]=[K+j+z+2,R+j+z+3],M.push(K,R,...U?[H,K]:[q,R],H,q),[K,R]=[q,H];M.push(K,R,K+o+2)}}let I=g.clone(),P=g.clone(),C=g.clone(),D=g.clone(),B=g.clone(),k=[],X=A(T.length,()=>A(f,()=>g.clone()));for(let q=0;q<T.length;q++){g.copy(T[q]).normalize(),I.copy(g).multiplyScalar(v);let H=S[q];for(let re=0;re<H.length;re++){let Z=H[re],J=H[(re+1)%f];m.setFromPointsAndIndices(T,q,Z%E,J%E),m.b.sub(m.a).setLength(1e10).add(m.a),m.c.sub(m.a).setLength(1e10).add(m.a),m.closestPointToPoint(I,X[q][re])}let K=[],R=[],U=[],z=new _;o==0&&[...X[q]].reduce((re,Z)=>re.add(Z),z).multiplyScalar(1/f);for(let re=0;re<f;re++){let Z=[],J=(re-1+f)%f,V=X[q][J],pe=X[q][re];g.copy(V).sub(I),p.copy(pe).sub(I);let ie=I.angleTo(g),ae=g.angleTo(p),fe=Math.cos(ie)*y;o==0?P.copy(z):P.copy(I).setLength(v+fe),R.push(fe);let xe=[P,V,pe];for(let me=0;me<2;me++){let Me=xe[me],Pe=xe[me+1];D.subVectors(Me,I),B.subVectors(Pe,I),C.crossVectors(D,B).normalize();for(let be=0;be<x;be++){let Fe=[ie,ae][me]*be/x;g.copy(D).applyAxisAngle(C,Fe).add(I),K.push(g.clone()),me&&(w(g,I),Z.push([be==0?Me:g.clone(),b.clone()]))}me&&(w(Pe,I),Z.push([Pe,b.clone()]))}U.push(Z)}k.push(U);let j=2*x,G=2;for(let re=0;re<f;re++){let Z=j*re,J=j*((re+1)%f),V=[K[Z]];for(let ie=1;ie<x;ie++){D=K[Z+ie],B=K[J+ie],V.push(D);for(let ae=1,fe=ie-G+1;ae<=fe;ae++)g.lerpVectors(D,B,ae/(fe+1)),g.sub(I).setLength(R[re]).add(I),V.push(g.clone());V.push(B)}for(let ie=0;ie<x;ie++)V.push(K[ie+x+Z]);V.push(K[J+x]);let pe=M.map(ie=>V[ie]);a.push(...pe.map(ie=>[ie.x,ie.y,ie.z]).flat()),u.push(...pe.map(ie=>(w(ie,I),[b.x,b.y,b.z])).flat())}}let W=[];for(let q=0;q<S.length;q++)for(let H=0;H<f;H++){let K=S[q][H];if(K<E){let R=S[K].findIndex(j=>j%E==q),U=k[q][H],z=k[K][R];for(let j=0;j<x;j++){let G=U[j],re=z[x-j],Z=U[j+1],J=z[x-(j+1)];[G,re,Z,Z,re,J].forEach(V=>{a.push(V[0].x,V[0].y,V[0].z),u.push(V[1].x,V[1].y,V[1].z)})}W.push(U[0][0],z[x][0],U[x][0],z[0][0])}}for(;W.length;){let q,H,K,R;[q,H]=W.splice(0,2);let U=[q];for(;q!=H;)U.push(H),K=W.indexOf(H),R=K%2,H=W.splice(K-R,2)[1-R];b.subVectors(U[0],U[1]).cross(g.subVectors(U[0],U[2])).normalize();let z=b.dot(U[0])<0;z&&b.negate();for(let j=1;j<=U.length-2;j++)[U[j+ +z],U[j+1-+z],U[0]].forEach(G=>{a.push(G.x,G.y,G.z),u.push(b.x,b.y,b.z)})}}function d(){let h=new _;for(let T=0;T<a.length;T+=3){h.x=a[T+0],h.y=a[T+1],h.z=a[T+2];let S=w(h)/2/Math.PI+.5,E=A(h)/Math.PI+.5;l.push(S,1-E)}let f=new _,g=new _,p=new _,m=new _,y=new F,v=new F,x=new F,b=(T,S,E,M)=>{M<0&&T.x===1&&(l[S]=T.x-1),E.x===0&&E.z===0&&(l[S]=M/2/Math.PI+.5)};for(let T=0,S=0;T<a.length;T+=9,S+=6){f.set(a[T+0],a[T+1],a[T+2]),g.set(a[T+3],a[T+4],a[T+5]),p.set(a[T+6],a[T+7],a[T+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]),m.copy(f).add(g).add(p).divideScalar(3);let E=w(m);b(y,S+0,f,E),b(v,S+2,g,E),b(x,S+4,p,E)}for(let T=0;T<l.length;T+=6){let S=l[T+0],E=l[T+2],M=l[T+4],I=Math.max(S,E,M),P=Math.min(S,E,M);I>.9&&P<.1&&(S<.2&&(l[T+0]+=1),E<.2&&(l[T+2]+=1),M<.2&&(l[T+4]+=1))}function w(T){return Math.atan2(T.z,-T.x)}function A(T){return Math.atan2(-T.y,Math.sqrt(T.x*T.x+T.z*T.z))}}}static fromJSON(t){return new Ko(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var dM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.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(r){let{width:t,height:e,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new wh(t*.5,s,o):new jl(t*.5,i);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...r,type:"DodecahedronGeometry"}})}},wh=class extends Ko{constructor(t=1,e=.2,n=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,n),this.type=l}static fromJSON(t){return new wh(t.radius,t.corner,t.cornerSides)}};var Ah=1e-12,cu=class{constructor(t){this.position=new F;this.startPosition=new F;this.uuid=Ve.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 cu(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},uu=class extends cu{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new uu(this.parent).copy(this)}},Ni=class extends cu{constructor(e,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new uu(this),new uu(this))}static create(e,n){let i=new Ni(e,new F(...n.position));return i.controls[0].position.set(...n.controlPrevious.position),i.controls[1].position.set(...n.controlNext.position),i.roundness=n.roundness,i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,i}getOppositeControl(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 i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(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 Ni(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 F,n=new F){let[i,s]=this.computeTangents();return i&&s&&(hM(i,e),hM(s,n)),[e,n]}computeTangent(e=new F){let[n,i]=this.computeTangents();return n&&i&&e.copy(n).add(i).normalize(),e}computeNormal(e=new F){let[n,i]=this.computeNormals();return e.copy(n).add(i).normalize(),e}};function hM(r,t=new F){let e=r.length();return t.set(-r.y/e,r.x/e)}var Hx=r=>r,du=new F,ag=new F,V4=new F,H4=new F,W4=new F,j4=new F,pM=new _,mM=new _;function gM(r){let t=new F;t.addVectors(r.v0,du.subVectors(r.v1,r.v0).multiplyScalar(2/3));let e=new F;return e.addVectors(r.v2,ag.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new nr(r.v0,t,e,r.v2)}function _h(r,t,e=Number.EPSILON){return Math.abs(r-t)<e}function q4(r,t,e=Number.EPSILON){return r.distanceTo(t)<e}function X4(r,t,e=Number.EPSILON){return r.distanceTo(t)<e}function Wx(r,t,e){let n=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2));return Math.acos((i*i+n*n-s*s)/(2*i*n))}function yM(r,t,e){return fM(r,t)&&fM(t,e)&&Vx(r.position,t.position,e.position)}function Vx(r,t,e){return du.copy(t).sub(r).cross(ag.copy(e).sub(r))===0}function vM(r,t,e,n,i){let s=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),o=(r.y+t.y)/2,a=(r.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(r.y-t.y)/s,u=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-r.x)/s;return n.set(a+l,o+u),i.set(a-l,o-u),[n,i]}function xM(r,t,e){let n=r.distanceTo(e),i=t.distanceTo(e);return n<i?t:r}function bM(r,t,e,n,i,s){let o=t.x-r.x,a=t.y-r.y,l=e.x-r.x,u=e.y-r.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),d;return Wx(t,r,e)>Math.PI&&(c*=-1),_h(u,a)?d=(a+u)*(n/c-.5)*8/3/(o-l):d=(o+l)*(n/c-.5)*8/3/(u-a),i.set(t.x-d*a,t.y+d*o),s.set(e.x+d*u,e.y-d*l),[i,s]}function jx(r,t){return r.position.equals(r.controls[1].position)&&t.position.equals(t.controls[0].position)}function fM(r,t){return Vx(r.position,r.controls[1].position,t.position)&&Vx(r.position,t.controls[0].position,t.position)}function SM(r,t,e,n,i=.5){let s=du.subVectors(t,r).multiplyScalar(i).add(r),o=ag.subVectors(e,t).multiplyScalar(i).add(t),a=V4.subVectors(n,e).multiplyScalar(i).add(e),l=s,u=H4.subVectors(o,s).multiplyScalar(i).add(s),c=W4.subVectors(a,o).multiplyScalar(i).add(o),d=a,h=j4.subVectors(c,u).multiplyScalar(i).add(u);return[r.x,r.y,l.x,l.y,u.x,u.y,h.x,h.y,c.x,c.y,d.x,d.y,n.x,n.y]}function wM(r,t,e=12,n=!0){let i=mM.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=Hx(t[l]),c=du,d=Zo(u,e);a.push(d);for(let h=0;h<=d;h++)if(u instanceof nr||u instanceof qr||u instanceof rr){if(u.getPoint(h/d,c),i.set(c.x,c.y,0),s!==void 0&&X4(s,i))continue;s===void 0&&(s=pM),s.copy(i),r.setXYZ(o,i.x,i.y,i.z),o++}}return n&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),r}function AM(r,t,e,n=12,i=!0){let s=mM.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=Hx(t[l]),d=du,h=Zo(c,n);a.push(h);for(let f=0;f<=h;f++)if(c instanceof nr||c instanceof qr||c instanceof rr){if(c.getPoint(f/h,d),s.set(d.x,d.y,0),u?.equals(s))continue;u===void 0?u=pM:(r.setXYZ(o,u.x,u.y,u.z),o++,r.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return i&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),a}function qx(r,t=12,e=!1){let n=[];for(let i=0,s=r.length;i<s;i++){let o=r[i],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=Zo(o.roundedCurveCorner,t)*.5;i>0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Zo(o.curveAfter,t)),n.push(a)}return r.length>0&&e&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=Zo(r[0].roundedCurveCorner,t)*.5),n}function Zo(r,t=12){return r&&r instanceof Ia?t*2:r&&(r instanceof rr||r instanceof Ld)?1:r&&r instanceof zl?t*r.points.length:t}function _M(r,t,e=12,n=!0){let i,s=0;for(let o=0;o<t.length;o++){let a=Hx(t[o]),l=Zo(a,e),u=du;for(let c=0;c<=l;c++)if(a instanceof nr||a instanceof qr||a instanceof rr){if(a.getPoint(c/l,u),i!==void 0&&q4(i,u,Ah))continue;i===void 0&&(i=ag),i.copy(u),r.push(u.x,u.y),s++}}return _h(r[0],r[r.length-2],Ah)&&_h(r[1],r[r.length-1],Ah)&&(r.pop(),r.pop()),n&&s>1&&!(_h(r[s-1],r[1],Ah)&&_h(r[s-2],r[0],Ah))&&(r.push(r[0],r[1]),s++),r}var Xx=new F,Y4=new F,K4=new F,Z4=new F,Q4=new F,J4=new F,St=class extends Hs{constructor(e=100,n=100){super();this.points=[];this.shapeHoles=[];this.plane=new Tn(new _(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=Ve.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=n}static createFromState(e,n,i){let s=new St;return s.isClosed=e.isClosed,s.points=e.points.map(o=>Ni.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>St.createFromState(o)),n!==void 0&&i!==void 0&&s.applySize(n,i),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let n=0,i=this.points.length;n<i;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,i=this.points.findIndex(s=>s.uuid===e);if(i<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(e);if(c<0)s+=u;else return c+s}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let n=this.points.length;for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],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 i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],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 i=Xx.set(e,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,n);this._update()}createPoint(e,n=0,i=Ve.generateUUID()){let s;e instanceof F?s=e:s=new F(e,n);let o=new Ni(i,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,i=this.points.length;n<i;n++){let s=this.points[n];if(s.uuid===e)return s}for(let n=0,i=this.shapeHoles.length;n<i;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(i=>i.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,i=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=i?this.roundedCurveDivisions:this.curveDivisions;return wM(e,i?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=qx(this.points,e,!1),this.roundedCurveDivisions=qx(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,n,i=12){return AM(e,this.curves,n,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),_M(e,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(e,n=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=Zo(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<i+c)return[l,(a-i+1)/c];i+=c}return[0,1]}getCurveT(e,n,i){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(jx(s,o)){let d=s.position.distanceTo(o.position);return s.position.distanceTo(Xx.set(i.x,i.y))/d}let u=0;for(let d=0;d<e;d++)u+=a[d];return(n-u)/l}dispose(){}_applyCurveForPoint(e,n){jx(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 i=this.curves[this.curves.length-1];e.curveBefore=i,n.curveAfter=i;let s=i.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,i=this.points.length;n<i;n++){let s=this.points[n];if(n===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[n-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let n=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(n,i)}if(this.points.length>2){let n=0;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i],a=this.points[i-1]??this.points[this.points.length-1],l=this.points[i+1]??this.points[0],u=o.roundness,c=a&&l&&yM(a,o,l);if(!o.controlsMoved()&&u>0&&!c){let d=o.curveBefore,h=o.curveAfter;if(d===void 0||h===void 0)continue;let f=o.roundedCurveBefore,g=o.roundedCurveAfter,p=d.getLength(),m=h.getLength(),y=Math.min(u,p*.499),v=Math.min(u,m*.499),x=Math.min(y,v),b=1-x/p,w=x/m,A=d.getPointAt(b,Xx),T=h.getPointAt(w,Y4);this._subSplitCurve(d,f,b,A,void 0),this._subSplitCurve(h,g,w,void 0,T);let S;if(this.useCubicForRoundedCorners){let E=Wx(A,o.position,T)/2,M=Math.tan(E)*A.distanceTo(o.position),[I,P]=vM(A,T,M,K4,Z4),C=xM(I,P,o.position),[D,B]=bM(C,A,T,M,Q4,J4);S=new nr(A.clone(),D.clone(),B.clone(),T.clone())}else S=new qr(A.clone(),o.position.clone(),T.clone());o.roundedCurveCorner=S,this.roundedCurves.splice(i+n,0,S),n++}}}}_subSplitCurve(e,n,i,s,o){if(e instanceof rr)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=e,l=n,u=a.getUtoTmapping(i,0),c=SM(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 St(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 i=0;i<n;i++){let s=i*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],d=e.points[s+5],h=e.points[s+6],f=new Ni(Ve.generateUUID(),new F(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=h,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let s=new St;return s.fromJSON(i),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let n=(s,o)=>{o instanceof nr&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},i=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof qr&&(s[a]=gM(s[a]));for(a=0,l=s.length;a<l;a++){let d=s[a],h=a>0?s[a-1]:null,f;d instanceof nr?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof rr&&(f=this.createPoint(d.v1)),f!==void 0&&(h!==null&&n(f,h),o.push(f))}let u=s[s.length-1],c=!1;return u instanceof nr?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof rr&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=i(e.curves),e instanceof Hs&&(this.shapeHoles=e.holes.map(s=>{let o=new St;return o.fromShape(s),o})),this.update(),this}updatePoint(e,n){let i=this.getPointByUuid(e);i&&(n.position!==void 0&&i.position.fromArray(n.position),n.roundness!==void 0&&(i.roundness=n.roundness),n.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(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 Kx=Math.PI*2;function Yx({x:r,y:t},e,n,i,s){return{x:r*e+i,y:t*n+s}}function $4(r,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),n=Math.cos(r),i=Math.sin(r),s=Math.cos(r+t),o=Math.sin(r+t);return[{x:n-i*e,y:i+n*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function TM(r,t,e,n){let i=r*n-t*e<0?-1:1,s=Math.min(1,Math.max(-1,r*e+t*n));return i*Math.acos(s)}function eH(r,t,e,n,i,s,o,a,l,u){let c=Math.pow(i,2),d=Math.pow(s,2),h=Math.pow(o,2),f=Math.pow(a,2),g=c*d-c*f-d*h;g<0&&(g=0),g/=c*f+d*h,g=Math.sqrt(g)*(l===u?-1:1);let p=g*i/s*a,m=g*-s/i*o,y=p+(r+e)/2,v=m+(t+n)/2,x=(o-p)/i,b=(a-m)/s,w=(-o-p)/i,A=(-a-m)/s,T=TM(1,0,x,b),S=TM(x,b,w,A);return!u&&S>0&&(S-=Kx),u&&S<0&&(S+=Kx),{centerx:y,centery:v,ang1:T,ang2:S}}function EM({px:r,py:t,cx:e,cy:n,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let u=(r-e)/2,c=(t-n)/2;if(u===0&&c===0)return[];i=Math.abs(i),s=Math.abs(s);let d=Math.pow(u,2)/Math.pow(i,2)+Math.pow(c,2)/Math.pow(s,2);d>1&&(i*=Math.sqrt(d),s*=Math.sqrt(d));let h=eH(r,t,e,n,i,s,u,c,o,a),{ang1:f,ang2:g}=h,{centerx:p,centery:m}=h,y=Math.abs(g)/(Kx/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);g/=v;for(let x=0;x<v;x++)l.push($4(f,g)),f+=g;return l.map(x=>{let{x:b,y:w}=Yx(x[0],i,s,p,m),{x:A,y:T}=Yx(x[1],i,s,p,m),{x:S,y:E}=Yx(x[2],i,s,p,m);return{x1:b,y1:w,x2:A,y2:T,x:S,y:E}})}var ft;(function(r){r[r.ODD=0]="ODD",r[r.NONZERO=1]="NONZERO",r[r.POSITIVE=2]="POSITIVE",r[r.NEGATIVE=3]="NEGATIVE",r[r.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(ft||(ft={}));var Jt;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Jt||(Jt={}));function Ye(r,t){if(!r)throw t||"Assertion Failed!"}var ke=function(){function r(){}return r.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},r.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},r.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},r.edgeGoesLeft=function(t){return r.vertLeq(t.Dst,t.Org)},r.edgeGoesRight=function(t){return r.vertLeq(t.Org,t.Dst)},r.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},r.edgeEval=function(t,e,n){Ye(r.vertLeq(t,e)&&r.vertLeq(e,n));var i=e.s-t.s,s=n.s-e.s;return i+s>0?i<s?e.t-t.t+(t.t-n.t)*(i/(i+s)):e.t-n.t+(n.t-t.t)*(s/(i+s)):0},r.edgeSign=function(t,e,n){Ye(r.vertLeq(t,e)&&r.vertLeq(e,n));var i=e.s-t.s,s=n.s-e.s;return i+s>0?(e.t-n.t)*i+(e.t-t.t)*s:0},r.transEval=function(t,e,n){Ye(r.transLeq(t,e)&&r.transLeq(e,n));var i=e.t-t.t,s=n.t-e.t;return i+s>0?i<s?e.s-t.s+(t.s-n.s)*(i/(i+s)):e.s-n.s+(n.s-t.s)*(s/(i+s)):0},r.transSign=function(t,e,n){Ye(r.transLeq(t,e)&&r.transLeq(e,n));var i=e.t-t.t,s=n.t-e.t;return i+s>0?(e.s-n.s)*i+(e.s-t.s)*s:0},r.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},r.interpolate=function(t,e,n,i){return t=t<0?0:t,n=n<0?0:n,t<=n?n===0?(e+i)/2:e+(i-e)*(t/(t+n)):i+(e-i)*(n/(t+n))},r.intersect=function(t,e,n,i,s){var o,a,l;r.vertLeq(t,e)||(l=t,t=e,e=l),r.vertLeq(n,i)||(l=n,n=i,i=l),r.vertLeq(t,n)||(l=t,t=n,n=l,l=e,e=i,i=l),r.vertLeq(n,e)?r.vertLeq(e,i)?(o=r.edgeEval(t,n,e),a=r.edgeEval(n,e,i),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,e.s)):(o=r.edgeSign(t,n,e),a=-r.edgeSign(t,i,e),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,i.s)):s.s=(n.s+e.s)/2,r.transLeq(t,e)||(l=t,t=e,e=l),r.transLeq(n,i)||(l=n,n=i,i=l),r.transLeq(t,n)||(l=t,t=n,n=l,l=e,e=i,i=l),r.transLeq(n,e)?r.transLeq(e,i)?(o=r.transEval(t,n,e),a=r.transEval(n,e,i),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,e.t)):(o=r.transSign(t,n,e),a=-r.transSign(t,i,e),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,i.t)):s.t=(n.t+e.t)/2},r}(),Th=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return r}(),lg=function(){function r(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(r.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),r}(),hu=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return r}(),MM=function(){function r(){var t=new hu,e=new Th,n=new lg(0),i=new lg(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,n.next=n,n.Sym=i,i.next=i,i.Sym=n,this.vHead=t,this.fHead=e,this.eHead=n,this.eHeadSym=i}return r.prototype.makeEdge_=function(t){var e=new lg(0),n=new lg(1);t.Sym.side<t.side&&(t=t.Sym);var i=t.Sym.next;return n.next=i,i.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},r.prototype.splice_=function(t,e){var n=t.Onext,i=e.Onext;n.Sym.Lnext=e,i.Sym.Lnext=t,t.Onext=i,e.Onext=n},r.prototype.makeVertex_=function(t,e,n){var i=t;Ye(i,"Vertex can't be null!");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=e;var o=e;do o.Org=i,o=o.Onext;while(o!==e)},r.prototype.makeFace_=function(t,e,n){var i=t;Ye(i,"Face can't be null");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=e,i.trail=null,i.marked=!1,i.inside=n.inside;var o=e;do o.Lface=i,o=o.Lnext;while(o!==e)},r.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},r.prototype.killVertex_=function(t,e){var n=t.anEdge,i=n;do i.Org=e,i=i.Onext;while(i!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},r.prototype.killFace_=function(t,e){var n=t.anEdge,i=n;do i.Lface=e,i=i.Lnext;while(i!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},r.prototype.makeEdge=function(){var t=new hu,e=new hu,n=new Th,i=this.makeEdge_(this.eHead);return this.makeVertex_(t,i,this.vHead),this.makeVertex_(e,i.Sym,this.vHead),this.makeFace_(n,i,this.fHead),i},r.prototype.splice=function(t,e){var n=!1,i=!1;if(t!==e){if(e.Org!==t.Org&&(i=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!i){var s=new hu;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!n){var o=new Th;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},r.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 i=new Th;this.makeFace_(i,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)},r.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),n=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var i=new hu;return this.makeVertex_(i,n,e.Org),e.Lface=n.Lface=t.Lface,e},r.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},r.prototype.connect=function(t,e){var n=!1,i=this.makeEdge_(t),s=i.Sym;if(e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(i,t.Lnext),this.splice_(s,e),i.Org=t.Dst,s.Org=e.Org,i.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!n){var o=new Th;this.makeFace_(o,i,t.Lface)}return i},r.prototype.zapFace=function(t){var e=t.anEdge,n,i,s,o,a;i=e.Lnext;do n=i,i=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},r.prototype.countFaceVerts_=function(t){var e=t.anEdge,n=0;do n++,e=e.Lnext;while(e!==t.anEdge);return n},r.prototype.mergeConvexFaces=function(t){var e,n,i,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;i=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&ke.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&ke.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=i;return!0},r.prototype.check=function(){var t=this.fHead,e=this.vHead,n=this.eHead,i,s,o,a,l,u;for(s=t,s=t;(i=s.next)!==t;s=i){Ye(i.prev===s),l=i.anEdge;do Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l),Ye(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(Ye(i.prev===s&&i.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){Ye(o.prev===a),l=o.anEdge;do Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l),Ye(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(Ye(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)Ye(l.Sym.next===u.Sym),Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Org!==null),Ye(l.Dst!==null),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l);Ye(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},r}(),CM=function(){function r(){this.handle=null}return r}(),PM=function(){function r(){this.key=null,this.node=0}return r}(),tH=function(){function r(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 CM,this.handles[n]=new PM;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return r.prototype.floatDown_=function(t){var e=this.nodes,n=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(n[e[o+1].handle].key,n[e[o].handle].key)&&++o,Ye(o<=this.max),s=e[o].handle,o>this.size||this.leq(n[i].key,n[s].key)){e[t].handle=i,n[i].node=t;break}e[t].handle=s,n[s].node=t,t=o}},r.prototype.floatUp_=function(t){var e=this.nodes,n=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(n[s].key,n[i].key)){e[t].handle=i,n[i].node=t;break}e[t].handle=s,n[s].node=t,t=o}},r.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},r.prototype.min=function(){return this.handles[this.nodes[1].handle].key},r.prototype.insert=function(t){var e,n;if(e=++this.size,e*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new CM;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new PM}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},r.prototype.extractMin=function(){var t=this.nodes,e=this.handles,n=t[1].handle,i=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)),i},r.prototype.delete=function(t){var e=this.nodes,n=this.handles,i;Ye(t>=1&&t<=this.max&&n[t].key!==null),i=n[t].node,e[i].handle=e[this.size].handle,n[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(n[e[i>>1].handle].key,n[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),n[t].key=null,n[t].node=this.freeList,this.freeList=t},r}(),Zx=function(){function r(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return r}(),IM=function(){function r(){this.key=null,this.next=null,this.prev=null}return r}(),nH=function(){function r(t,e){this.frame=t,this.leq=e,this.head=new IM,this.head.next=this.head,this.head.prev=this.head}return r.prototype.min=function(){return this.head.next},r.prototype.max=function(){return this.head.prev},r.prototype.insert=function(t){return this.insertBefore(this.head,t)},r.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},r.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var n=new IM;return n.key=e,n.next=t.next,t.next.prev=n,n.prev=t,t.next=n,n},r.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},r}(),rH=function(){function r(){}return r.regionBelow=function(t){return t.nodeUp.prev.key},r.regionAbove=function(t){return t.nodeUp.next.key},r.debugEvent=function(t){},r.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},r.edgeLeq=function(t,e,n){var i=t.event,s=e.eUp,o=n.eUp;if(s.Dst===i)return o.Dst===i?ke.vertLeq(s.Org,o.Org)?ke.edgeSign(o.Dst,s.Org,o.Org)<=0:ke.edgeSign(s.Dst,o.Org,s.Org)>=0:ke.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return ke.edgeSign(s.Dst,i,s.Org)>=0;var a=ke.edgeEval(s.Dst,i,s.Org),l=ke.edgeEval(o.Dst,i,o.Org);return a>=l},r.deleteRegion=function(t,e){e.fixUpperEdge&&Ye(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},r.fixUpperEdge=function(t,e,n){Ye(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=n,n.activeRegion=e},r.topLeftRegion=function(t,e){var n=e.eUp.Org,i;do e=r.regionAbove(e);while(e.eUp.Org===n);if(e.fixUpperEdge){if(i=t.mesh.connect(r.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;r.fixUpperEdge(t,e,i),e=r.regionAbove(e)}return e},r.topRightRegion=function(t){var e=t.eUp.Dst;do t=r.regionAbove(t);while(t.eUp.Dst===e);return t},r.addRegionBelow=function(t,e,n){var i=new Zx;return i.eUp=n,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,n.activeRegion=i,i},r.isWindingInside=function(t,e){switch(t.windingRule){case ft.ODD:return(e&1)!==0;case ft.NONZERO:return e!==0;case ft.POSITIVE:return e>0;case ft.NEGATIVE:return e<0;case ft.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},r.computeWinding=function(t,e){e.windingNumber=r.regionAbove(e).windingNumber+e.eUp.winding,e.inside=r.isWindingInside(t,e.windingNumber)},r.finishRegion=function(t,e){var n=e.eUp,i=n.Lface;i.inside=e.inside,i.anEdge=n,r.deleteRegion(t,e)},r.finishLeftRegions=function(t,e,n){for(var i,s=null,o=e,a=e.eUp;o!==n;){if(o.fixUpperEdge=!1,s=r.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){r.finishRegion(t,o);break}i=t.mesh.connect(a.Lprev,i.Sym),r.fixUpperEdge(t,s,i)}a.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(a,i)),r.finishRegion(t,o),a=s.eUp,o=s}return a},r.addRightEdges=function(t,e,n,i,s,o){var a,l,u,c,d=!0;u=n;do Ye(ke.vertLeq(u.Org,u.Dst)),r.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==i);for(s===null&&(s=r.regionBelow(e).eUp.Rprev),l=e,c=s;a=r.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=r.isWindingInside(t,a.windingNumber),l.dirty=!0,!d&&r.checkForRightSplice(t,l)&&(r.addWinding(u,c),r.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=a,c=u;l.dirty=!0,Ye(l.windingNumber-u.winding===a.windingNumber),o&&r.walkDirtyRegions(t,l)},r.spliceMergeVertices=function(t,e,n){t.mesh.splice(e,n)},r.vertexWeights=function(t,e,n){var i=ke.vertL1dist(e,t),s=ke.vertL1dist(n,t),o=.5*s/(i+s),a=.5*i/(i+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]},r.getIntersectData=function(t,e,n,i,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,r.vertexWeights(e,n,i),r.vertexWeights(e,s,o)},r.checkForRightSplice=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp;if(ke.vertLeq(i.Org,s.Org)){if(ke.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;ke.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(t.pq.delete(i.Org.pqHandle),r.spliceMergeVertices(t,s.Oprev,i)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(i,s.Oprev),e.dirty=n.dirty=!0)}else{if(ke.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;r.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Oprev,i)}return!0},r.checkForLeftSplice=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp,o;if(Ye(!ke.vertEq(i.Dst,s.Dst)),ke.vertLeq(i.Dst,s.Dst)){if(ke.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;r.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(i),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(ke.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;e.dirty=n.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},r.checkForIntersect=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp,o=i.Org,a=s.Org,l=i.Dst,u=s.Dst,c,d,h=new hu,f,g;if(Ye(!ke.vertEq(u,l)),Ye(ke.edgeSign(l,t.event,o)<=0),Ye(ke.edgeSign(u,t.event,a)>=0),Ye(o!==t.event&&a!==t.event),Ye(!e.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),d=Math.max(a.t,u.t),c>d))return!1;if(ke.vertLeq(o,a)){if(ke.edgeSign(u,o,a)>0)return!1}else if(ke.edgeSign(l,a,o)<0)return!1;return r.debugEvent(t),ke.intersect(l,o,u,a,h),Ye(Math.min(o.t,l.t)<=h.t),Ye(h.t<=Math.max(a.t,u.t)),Ye(Math.min(u.s,l.s)<=h.s),Ye(h.s<=Math.max(a.s,o.s)),ke.vertLeq(h,t.event)&&(h.s=t.event.s,h.t=t.event.t),f=ke.vertLeq(o,a)?o:a,ke.vertLeq(f,h)&&(h.s=f.s,h.t=f.t),ke.vertEq(h,o)||ke.vertEq(h,a)?(r.checkForRightSplice(t,e),!1):!ke.vertEq(l,t.event)&&ke.edgeSign(l,t.event,h)>=0||!ke.vertEq(u,t.event)&&ke.edgeSign(u,t.event,h)<=0?u===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Sym,i),e=r.topLeftRegion(t,e),i=r.regionBelow(e).eUp,r.finishLeftRegions(t,r.regionBelow(e),n),r.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(i.Lnext,s.Oprev),n=e,e=r.topRightRegion(e),g=r.regionBelow(e).eUp.Rprev,n.eUp=s.Oprev,s=r.finishLeftRegions(t,n,null),r.addRightEdges(t,e,s.Onext,i.Rprev,g,!0),!0):(ke.edgeSign(l,t.event,h)>=0&&(r.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),ke.edgeSign(u,t.event,h)<=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(i.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,i),i.Org.s=h.s,i.Org.t=h.t,i.Org.pqHandle=t.pq.insert(i.Org),r.getIntersectData(t,i.Org,o,l,a,u),r.regionAbove(e).dirty=e.dirty=n.dirty=!0,!1)},r.walkDirtyRegions=function(t,e){for(var n=r.regionBelow(e),i,s;;){for(;n.dirty;)e=n,n=r.regionBelow(n);if(!e.dirty&&(n=e,e=r.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,s=n.eUp,i.Dst!==s.Dst&&r.checkForLeftSplice(t,e)&&(n.fixUpperEdge?(r.deleteRegion(t,n),t.mesh.delete(s),n=r.regionBelow(e),s=n.eUp):e.fixUpperEdge&&(r.deleteRegion(t,e),t.mesh.delete(i),e=r.regionAbove(n),i=e.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!e.fixUpperEdge&&!n.fixUpperEdge&&(i.Dst===t.event||s.Dst===t.event)){if(r.checkForIntersect(t,e))return}else r.checkForRightSplice(t,e);i.Org===s.Org&&i.Dst===s.Dst&&(r.addWinding(s,i),r.deleteRegion(t,e),t.mesh.delete(i),e=r.regionAbove(n))}},r.connectRightVertex=function(t,e,n){var i,s=n.Onext,o=r.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&r.checkForIntersect(t,e),ke.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=r.topLeftRegion(t,e),s=r.regionBelow(e).eUp,r.finishLeftRegions(t,r.regionBelow(e),o),u=!0),ke.vertEq(l.Org,t.event)&&(t.mesh.splice(n,l.Oprev),n=r.finishLeftRegions(t,o,null),u=!0),u){r.addRightEdges(t,e,n.Onext,s,s,!0);return}ke.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=t.mesh.connect(n.Lprev,i),r.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,r.walkDirtyRegions(t,e)},r.connectLeftDegenerate=function(t,e,n){var i,s,o,a,l;if(i=e.eUp,ke.vertEq(i.Org,n)){Ye(!1),r.spliceMergeVertices(t,i,n.anEdge);return}if(!ke.vertEq(i.Dst,n)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(n.anEdge,i),r.sweepEvent(t,n);return}Ye(!1),e=r.topRightRegion(e),l=r.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(Ye(s!==o),r.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(n.anEdge,o),ke.edgeGoesLeft(s)||(s=null),r.addRightEdges(t,e,o.Onext,a,s,!0)},r.connectLeftVertex=function(t,e){var n,i,s,o,a,l,u=new Zx;if(u.eUp=e.anEdge.Sym,n=t.dict.search(u).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,ke.edgeSign(o.Dst,e,o.Org)===0){r.connectLeftDegenerate(t,n,e);return}if(s=ke.vertLeq(a.Dst,o.Dst)?n:i,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?r.fixUpperEdge(t,s,l):r.computeWinding(t,r.addRegionBelow(t,n,l)),r.sweepEvent(t,e)}else r.addRightEdges(t,n,e.anEdge,e.anEdge,null,!0)}},r.sweepEvent=function(t,e){t.event=e,r.debugEvent(t);for(var n=e.anEdge;n.activeRegion===null;)if(n=n.Onext,n===e.anEdge){r.connectLeftVertex(t,e);return}var i=r.topLeftRegion(t,n.activeRegion);Ye(i!==null);var s=r.regionBelow(i),o=s.eUp,a=r.finishLeftRegions(t,s,null);a.Onext===o?r.connectRightVertex(t,i,a):r.addRightEdges(t,i,a.Onext,o,o,!0)},r.addSentinel=function(t,e,n,i){var s=new Zx,o=t.mesh.makeEdge();o.Org.s=n,o.Org.t=i,o.Dst.s=e,o.Dst.t=i,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)},r.initEdgeDict=function(t){t.dict=new nH(t,r.edgeLeq);var e=t.bmax[0]-t.bmin[0],n=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-n,a=t.bmax[1]+n;r.addSentinel(t,i,s,o),r.addSentinel(t,i,s,a)},r.doneEdgeDict=function(t){for(var e,n=0;(e=t.dict.min().key)!==null;)e.sentinel||(Ye(e.fixUpperEdge),Ye(++n===1)),Ye(e.windingNumber===0),r.deleteRegion(t,e)},r.removeDegenerateEdges=function(t){var e,n,i,s=t.mesh.eHead;for(e=s.next;e!==s;e=n)n=e.next,i=e.Lnext,ke.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(r.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===n||i===n.Sym)&&(n=n.next),t.mesh.delete(i)),(e===n||e===n.Sym)&&(n=n.next),t.mesh.delete(e))},r.initPriorityQ=function(t){var e,n,i,s=0;for(i=t.mesh.vHead,n=i.next;n!==i;n=n.next)s++;for(s+=8,e=t.pq=new tH(s,ke.vertLeq),i=t.mesh.vHead,n=i.next;n!==i;n=n.next)n.pqHandle=e.insert(n);return n!==i?!1:(e.init(),!0)},r.donePriorityQ=function(t){t.pq=null},r.removeDegenerateFaces=function(t,e){var n,i,s;for(n=e.fHead.next;n!==e.fHead;n=i)i=n.next,s=n.anEdge,Ye(s.Lnext!==s),s.Lnext.Lnext===s&&(r.addWinding(s.Onext,s),t.mesh.delete(s));return!0},r.computeInterior=function(t,e){e===void 0&&(e=!0);var n,i;if(r.removeDegenerateEdges(t),!r.initPriorityQ(t))return!1;for(r.initEdgeDict(t);(n=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!ke.vertEq(i,n));)i=t.pq.extractMin(),r.spliceMergeVertices(t,n.anEdge,i.anEdge);r.sweepEvent(t,n)}return t.event=t.dict.min().key.eUp.Org,r.debugEvent(t),r.doneEdgeDict(t),r.donePriorityQ(t),r.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},r}(),iH=function(){function r(){this.mesh=new MM,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=ft.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return r.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},r.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},r.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},r.prototype.computeNormal_=function(t){var e,n,i,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],h=[0,0,0],f=[null,null,null],g=[null,null,null],p=this.mesh.vHead;e=p.next;for(var m=0;m<3;++m)s=e.coords[m],u[m]=s,g[m]=e,l[m]=s,f[m]=e;for(e=p.next;e!==p;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<u[y]&&(u[y]=s,g[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=g[v],i=f[v],c[0]=n.coords[0]-i.coords[0],c[1]=n.coords[1]-i.coords[1],c[2]=n.coords[2]-i.coords[2],e=p.next;e!==p;e=e.next)d[0]=e.coords[0]-i.coords[0],d[1]=e.coords[1]-i.coords[1],d[2]=e.coords[2]-i.coords[2],h[0]=c[1]*d[2]-c[2]*d[1],h[1]=c[2]*d[0]-c[0]*d[2],h[2]=c[0]*d[1]-c[1]*d[0],o=h[0]*h[0]+h[1]*h[1]+h[2]*h[2],o>a&&(a=o,t[0]=h[0],t[1]=h[1],t[2]=h[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},r.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,n=this.mesh.vHead,i,s=0,o=t.next;o!==t;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(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]}},r.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],n,i,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,i=this.tUnit;var o=this.longAxis_(e);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=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,i);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))},r.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},r.prototype.tessellateMonoRegion_=function(t,e){var n,i;if(n=e.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;ke.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;ke.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(ke.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(ke.edgeGoesLeft(i.Lnext)||ke.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=t.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==n&&(ke.edgeGoesRight(n.Lprev)||ke.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=t.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(i.Lnext===n)throw"Mono region invalid";for(;i.Lnext.Lnext!==n;)s=t.connect(i.Lnext,i),i=s.Sym;return!0},r.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},r.prototype.discardExterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)e=n.next,n.inside||t.zapFace(n)},r.prototype.setWindingNumber_=function(t,e,n){for(var i,s=t.eHead.next;s!==t.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:n?t.delete(s):s.winding=0},r.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},r.prototype.outputPolymesh_=function(t,e,n,i){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===Jt.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*i;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],i>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var h=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[h++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[h++]=-1;if(e===Jt.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[h++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var g=l;g<n;++g)this.elements[h++]=-1}}},r.prototype.outputContours_=function(t,e){var n,i,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){i=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*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,i=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!==i);this.elements[c++]=s,this.elements[c++]=o,s+=o}},r.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new MM),t<2&&(t=2),t>3&&(t=3);for(var n=null,i=0;i<e.length;i+=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[i+0],n.Org.coords[1]=e[i+1],t>2?n.Org.coords[2]=e[i+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},r.prototype.tesselate=function(t,e,n,i,s,o){if(t===void 0&&(t=ft.ODD),e===void 0&&(e=Jt.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,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),rH.computeInterior(this,o);var a=this.mesh;return e===Jt.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===Jt.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,n,i),!0},r}();function Bi(r){var t=r.windingRule,e=t===void 0?ft.ODD:t,n=r.elementType,i=n===void 0?Jt.POLYGONS:n,s=r.polySize,o=s===void 0?3:s,a=r.vertexSize,l=a===void 0?2:a,u=r.normal,c=u===void 0?[0,0,1]:u,d=r.contours,h=d===void 0?[]:d,f=r.strict,g=f===void 0?!0:f,p=r.debug,m=p===void 0?!1:p;if(!h&&g)throw new Error("Contours can't be empty");if(!!h){var y=new iH;r.edgeCreateCallback&&(y.edgeCreateCallback=r.edgeCreateCallback),r.vertexIdCallback&&(y.vertexIdCallback=r.vertexIdCallback);for(var v=0;v<h.length;v++)y.addContour(l||2,h[v]);return y.tesselate(e,i,o,l,c,g),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:m?y.mesh:void 0}}}var Fie=ft.ODD,Uie=ft.NONZERO,Gie=ft.POSITIVE,kie=ft.NEGATIVE,zie=ft.ABS_GEQ_TWO,Vie=Jt.POLYGONS,Hie=Jt.CONNECTED_POLYGONS,Wie=Jt.BOUNDARY_CONTOURS;var cg=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*cg.eSize;this.buffer=new ArrayBuffer(n);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*i,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*cg.eSize,i=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*t);o+=3*t;let l=new Float32Array(i,o*s,3*t);o+=3*t;let u=new Float32Array(i,o*s,2*t);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}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)}},Eh=cg;Eh.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Mh={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Jx={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},$x={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},Qx=(r,t)=>([e,n])=>(n<e&&(n+=t),(r>=e?r:r+t)<=n),fu=class extends Te{constructor(e,n,i=0,s=12,o=3,a=ft.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=n,this._bevel=i,this._curveSegments=s,this._bevelSegmentsInput=o,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,n/2-1e-12),this._bevelSegments=Math.floor(o));let l=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(T=>{let S=T.extractShapePointsToFlatArray([],s),E=[];for(let M=S.length-1;M>=1;M-=2){let I=S[M-1],P=S[M-0];E.push(I,P)}return E}),c;try{c=Bi({windingRule:a,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]})}catch{c=Mh}let d;try{d=Bi({windingRule:ft.ODD,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{d=Jx}if(!c)throw new Error("error generating geometry");let h=c.elementCount;if(d){c.elementCount+=d.elementCount;for(let T=0;T<d.elements.length;T++){let S=d.elements[T],E=T%2===0?c.vertexCount:0;c.elements.push(S+E)}for(let T=0;T<d.vertexIndices.length;T++){let S=d.vertexIndices[T],E=c.vertexCount;c.vertexIndices.push(S+E)}for(let T=0;T<d.vertices.length;T++){let S=d.vertices[T];c.vertices.push(S)}}let f=1/0,g=-1/0,p=1/0,m=-1/0;for(let T=0,S=c.vertexCount;T<S;T++){let E=T*2,M=c.vertices[E+0],I=c.vertices[E+1];M<f&&(f=M),M>g&&(g=M),I<p&&(p=I),I>m&&(m=I)}this._minX=f,this._minY=p,this._width=g-f,this._height=m-p,this._buffer=new Eh(this._computeBufferEstimatedSize(c));let y=[],v=[];for(let T=c.elementCount-1;T>=0;T--){let S=T>=h,E=T*2,M=c.elements[E+0],I=c.elements[E+1],P=M+I,C={start:M,count:I,normals:[],continuous:[],concave:[]},D=M,B=P-1,k=M+1,X=this._shape.roundedCurves.length;do{let K=D-M,R=c.vertices[B*2+0],U=c.vertices[B*2+1],z=c.vertices[D*2+0],j=c.vertices[D*2+1],G=c.vertices[k*2+0],re=c.vertices[k*2+1],Z=z-R,J=j-U,V=Math.sqrt(Z*Z+J*J);Z/=V,J/=V;let pe=z-G,ie=j-re,ae=Math.sqrt(pe*pe+ie*ie);pe/=ae,ie/=ae,C.normals[K*2+0]=-ie,C.normals[K*2+1]=pe,C.concave[K]=Z*ie-J*pe>0;let fe=c.vertexIndices[D];if(Array.isArray(fe))C.continuous[K]=!1;else{let[xe,me]=this._shape.getCurveIndexFromVertexId(fe-1,!0);if(me>0&&me<1)C.continuous[K]=!0;else{let Me=me===1?xe+1:xe-1;Me=(Me+X)%X;let Pe=me===1?0:1,be=this._shape.roundedCurves[xe].getTangent(me),Fe=this._shape.roundedCurves[Me].getTangent(Pe);C.continuous[K]=be.dot(Fe)>.95}}S&&(C.normals[K*2+0]*=-1,C.normals[K*2+1]*=-1),[B,D,k]=[D,k,k+1],k>=P&&(k-=I)}while(k!==M+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(M*2,P*2),vertexCount:I,vertexIndices:new Array(I).fill(!0).map((K,R)=>[R,R]),elements:[0,I],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(M*2,P*2)});for(let K=1;K<=this._bevelSegments;K++){let R=K/this._bevelSegments*Math.PI/2,U=(1-Math.cos(R))*this._bevelSize,z=[],j=[],G=[],re=[],Z=0;for(let V=0;V<I;V++){let pe=V*2,ie=(V-1+I)%I*2,ae=c.vertices[C.start*2+pe+0],fe=c.vertices[C.start*2+pe+1],xe=-C.normals[ie+0]*U,me=-C.normals[ie+1]*U,Me=-C.normals[pe+0]*U,Pe=-C.normals[pe+1]*U;if(C.concave[V]||!C.concave[V]&&S){let be=Math.atan2(me,xe),Fe=Math.atan2(Pe,Me);Fe>be&&(Fe-=Math.PI*2);let ht=Fe-be;if(C.continuous[V]||S){let L=be+ht/2,O=Math.cos(L)*U,ee=Math.sin(L)*U;z[2*Z+0]=ae+O*(S?-1:1),z[2*Z+1]=fe+ee*(S?-1:1),re[Z]=V,Z++}else{let L=Math.max(1,Math.floor(s/4*Math.abs(ht)/Math.PI));for(let O=0;O<=L;O++){let ee=be+ht*(O/L),he=Math.cos(ee)*U,ge=Math.sin(ee)*U;z[2*Z+0]=ae+he,z[2*Z+1]=fe+ge,re[Z]=V,Z++}}}else z[2*Z+0]=ae+xe,z[2*Z+1]=fe+me,re[Z]=V,j[V]=Z,Z++,z[2*Z+0]=ae,z[2*Z+1]=fe,re[Z]=V,Z++,z[2*Z+0]=ae+Me,z[2*Z+1]=fe+Pe,re[Z]=V,G[V]=Z,Z++}let J=Bi({windingRule:ft.POSITIVE,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[z],edgeCreateCallback:V=>{let ie=V.Org.idx,ae=re[ie],fe=re[(ie+1)%re.length];V.idx=[ae,fe],V.Sym.idx=[fe,ae]},vertexIdCallback:V=>{let pe=V.Lprev.idx;return[pe?pe[1]:0,V.idx?V.idx[0]:0]}});if(!J)throw console.log("Error"),new Error(`error generating bevel geometry for ${K}'th loop`);if(!J.vertexCount)break;for(let V=0;V<J.vertexIndices.length;V++){let[pe,ie]=J.vertexIndices[V];if(pe===ie)continue;let ae=ie;ie<pe&&(ae+=I);for(let fe=pe;fe<ae;fe++){let xe=fe%I,me=(fe+1)%I;if(!C.continuous[xe]||!C.continuous[me]){J.vertexIndices[V]=[pe,xe],J.vertexIndices.splice(V+1,0,[me,ie]),J.vertices.splice((V+1)*2,0,J.vertices[V*2],J.vertices[V*2+1]);break}}}W.push({bevelI:K,angle:R,size:U,boundary:J,reverseMap:re,insetPoints:z})}let q=(K,R,U)=>{let z=0,j=K.boundary.vertexIndices.length;for(;z<j&&U(K.boundary.vertexIndices[R]);)R=(R+1)%j,z++;return z},H=y.length;for(let K=1;K<W.length;K++){let R=W[K-1],U=W[K],z=R.boundary.vertexIndices.length,j=U.boundary.vertexIndices.length;if(!z||!j)break;let G=C.concave.length,re=0,Z=Qx(re,I);for(;!R.boundary.vertexIndices.filter(Z).length||!U.boundary.vertexIndices.filter(Z).length;)re++,Z=Qx(re,I);let J=R.boundary.vertexIndices.findIndex(Z),V=U.boundary.vertexIndices.findIndex(Z);do J=(J+1)%z;while(Z(R.boundary.vertexIndices[J]));do V=(V+1)%j;while(Z(U.boundary.vertexIndices[V]));re=(re+1)%I;let pe=re,ie=this._buildBevelVert(C,R,(J-1+z)%z),ae=this._buildBevelVert(C,U,(V-1+j)%j),fe=ie,xe=ae,me,Me,Pe=!1;do{Z=Qx(re,I);let be=q(R,J,Z),Fe=q(U,V,Z),ht=Pe;if(Pe=!1,be&&!Fe){for(let L=0;L<be;L++)me=this._buildBevelVert(C,R,(J+L)%z,L/(be-1)),y.push(fe.topN,me.topP,xe.topN),y.push(me.bottomP,fe.bottomN,xe.bottomN),fe=me;Pe=!0}else if(!be&&Fe)for(let L=0;L<Fe;L++)Me=this._buildBevelVert(C,U,(V+L)%j,L/(Fe-1)),y.push(xe.topN,fe.topP,Me.topP),y.push(fe.bottomP,xe.bottomN,Me.bottomP),xe=Me;else if(be&&Fe)if(me=this._buildBevelVert(C,R,J,0),Me=this._buildBevelVert(C,U,V,0),ht?(y.push(fe.topN,Me.topP,xe.topN),y.push(fe.topN,me.topP,Me.topP),y.push(Me.bottomP,fe.bottomN,xe.bottomN),y.push(Me.bottomP,me.bottomP,fe.bottomN)):(y.push(xe.topN,fe.topN,me.topP),y.push(xe.topN,me.topP,Me.topP),y.push(me.bottomP,fe.bottomN,xe.bottomN),y.push(me.bottomP,xe.bottomN,Me.bottomP)),fe=me,xe=Me,be===Fe)for(let L=1;L<be;L++)me=this._buildBevelVert(C,R,(J+L)%z,L/(be-1)),Me=this._buildBevelVert(C,U,(V+L)%j,L/(Fe-1)),y.push(fe.topN,me.topP,xe.topN),y.push(xe.topN,me.topP,Me.topP),y.push(me.bottomP,fe.bottomN,xe.bottomN),y.push(me.bottomP,xe.bottomN,Me.bottomP),fe=me,xe=Me;else if(be>Fe){let L=be/Fe,O=0;for(let ee=1;ee<be;ee++)me=this._buildBevelVert(C,R,(J+ee)%z,ee/(be-1)),y.push(fe.topN,me.topP,xe.topN),y.push(me.bottomP,fe.bottomN,xe.bottomN),fe=me,ee>(O+1)*L&&(O++,Me=this._buildBevelVert(C,U,(V+O)%j,O/(Fe-1)),y.push(xe.topN,me.topP,Me.topP),y.push(me.bottomP,xe.bottomN,Me.bottomP),xe=Me)}else{let L=Fe/be,O=0;for(let ee=1;ee<Fe;ee++)Me=this._buildBevelVert(C,U,(V+ee)%j,ee/(Fe-1)),y.push(xe.topN,me.topP,Me.topP),y.push(me.bottomP,xe.bottomN,Me.bottomP),xe=Me,ee>(O+1)*L&&(O++,me=this._buildBevelVert(C,R,(J+O)%z,O/(be-1)),y.push(fe.topN,me.topP,xe.topN),y.push(me.bottomP,fe.bottomN,xe.bottomN),fe=me)}J=(J+be)%z,V=(V+Fe)%j,re=(re+1)%G}while(re!==pe)}if(this._buildWall(W,C,y),S){let K=[];for(let R=y.length-1;R>=H+2;R-=3){let U=y[R-2],z=y[R-1],j=y[R-0];K.push(j,z,U)}y.splice(H,y.length-H,...K)}if(S){let K=[];for(let R=W[W.length-1].boundary.vertices.length-1;R>=1;R-=2){let U=W[W.length-1].boundary.vertices[R-1],z=W[W.length-1].boundary.vertices[R-0];K.push(U,z)}v.push(K)}if(!S){let K=W[W.length-1],R;try{R=Bi({windingRule:W.length>1?ft.POSITIVE:ft.ODD,elementType:Jt.POLYGONS,vertexSize:2,strict:!0,contours:[K.insetPoints,...v]})}catch{R=$x}if(!R)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:y.length});for(let U=0;U<R.elementCount*3;U+=3){let z=this._buildSurfaceVert(R,R.elements[U+0]),j=this._buildSurfaceVert(R,R.elements[U+1]),G=this._buildSurfaceVert(R,R.elements[U+2]);y.push(z.top,j.top,G.top),y.push(G.bottom,j.bottom,z.bottom)}}this.vertexCache={}}this._buffer.shrink();let x=new Be(Uint32Array.from(y),1),b=new Be(this._buffer.positions,3),w=new Be(this._buffer.normals,3),A=new Be(this._buffer.uvs,2);b.needsUpdate=!0,w.needsUpdate=!0,A.needsUpdate=!0,x.needsUpdate=!0,this.setAttribute("position",b),this.setAttribute("normal",w),this.setAttribute("uv",A),this.setIndex(x)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,i){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);i.push(u.topP,l.topN,l.bottomN),i.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,n){let i=n.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=e.vertices[n*2+0],o=e.vertices[n*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,u=this._buffer.get(2),c=u*3,d=u*2,h={top:u+0,bottom:u+1};return this._buffer.positions[c+0]=s,this._buffer.positions[c+1]=o,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[d+0]=a,this._buffer.uvs[d+1]=l,this._buffer.positions[c+3]=s,this._buffer.positions[c+4]=o,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[d+2]=a,this._buffer.uvs[d+3]=l,this.vertexCache[i]=h,h}_buildBevelVert(e,n,i,s=1){let o=`${n.bevelI}:${i}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=n.boundary.vertexIndices[i],u,c,d,h;a!==l?(c=a,u=l,h=!1,d=e.continuous[c]&&e.continuous[u]):(u=a,c=(u-1+e.count)%e.count,h=e.concave[u]&&n.bevelI>0,d=e.continuous[u]||h);let f=Math.cos(n.angle),g=Math.sin(n.angle),p=i*2,m=u*2,y=c*2,v=n.boundary.vertices[p+0],x=n.boundary.vertices[p+1],b=(1-g)*this._bevelSize,w=(v-this._minX)/this._width,A=(x-this._minY)/this._height,T=e.normals[m+0],S=e.normals[m+1],E=e.normals[y+0],M=e.normals[y+1];if(h){let B=E-T,k=M-S;T=T+B*(1-s),S=S+k*(1-s);let X=Math.sqrt(T*T+S*S);T/=X,S/=X}let I=this._buffer.get(d?2:4),P=I*3,C=I*2,D={i,fi:u,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1};return this._buffer.positions[P+0]=v,this._buffer.positions[P+1]=x,this._buffer.positions[P+2]=this._depth-b,this._buffer.normals[P+0]=T*f,this._buffer.normals[P+1]=S*f,this._buffer.normals[P+2]=g,this._buffer.uvs[C+0]=w,this._buffer.uvs[C+1]=A,this._buffer.positions[P+3]=v,this._buffer.positions[P+4]=x,this._buffer.positions[P+5]=b,this._buffer.normals[P+3]=T*f,this._buffer.normals[P+4]=S*f,this._buffer.normals[P+5]=-g,this._buffer.uvs[C+2]=A,this._buffer.uvs[C+3]=w,d||(I+=2,P+=6,C+=4,D.topP=I+0,D.bottomP=I+1,this._buffer.positions[P+0]=v,this._buffer.positions[P+1]=x,this._buffer.positions[P+2]=this._depth-b,this._buffer.normals[P+0]=E*f,this._buffer.normals[P+1]=M*f,this._buffer.normals[P+2]=g,this._buffer.uvs[C+0]=w,this._buffer.uvs[C+1]=A,this._buffer.positions[P+3]=v,this._buffer.positions[P+4]=x,this._buffer.positions[P+5]=b,this._buffer.normals[P+3]=E*f,this._buffer.normals[P+4]=M*f,this._buffer.normals[P+5]=-g,this._buffer.uvs[C+2]=A,this._buffer.uvs[C+3]=w),this.vertexCache[o]=D,D}clone(){let e=new fu(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Ks(this.userData),e}};var pu=class extends Te{constructor(e,n=12,i={}){super();this.type="ShapeGeometry";this.windingRule=ft.ODD;this.elementType=Jt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:ft.ODD,elementType:Jt.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(g=>g.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,d;for(let g=0,p=s.length/2;g<p;g++){let m=g*2,y=s[m+0],v=s[m+1];if(c!==void 0&&y!==c&&(l=!1),d!==void 0&&v!==d&&(u=!1),c=y,d=v,!l&&!u)break}if(!l&&!u)try{a=Bi({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=Mh}let h=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Be(new Float32Array(h*3),3),this._normalAttribute=new Be(new Float32Array(h*3),3),this._uvAttribute=new Be(new Float32Array(h*2),2),this._indexAttribute=new Be(new Uint32Array(f*3),1),a){let g=1/0,p=-1/0,m=1/0,y=-1/0;for(let b=0,w=h;b<w;b++){let A=b*2,T=a.vertices[A+0],S=a.vertices[A+1];T<g&&(g=T),T>p&&(p=T),S<m&&(m=S),S>y&&(y=S)}let v=p-g,x=y-m;for(let b=0,w=h;b<w;b++){let A=b*2,T=a.vertices[A+0],S=a.vertices[A+1],E=(T-g)/v,M=(S-m)/x;this._positionAttribute.setXYZ(b,T,S,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,E,M)}for(let b=0,w=f;b<w;b++){let A=b*3,T=a.elements[A+0],S=a.elements[A+1],E=a.elements[A+2];this._indexAttribute.setX(A+0,T),this._indexAttribute.setX(A+1,S),this._indexAttribute.setX(A+2,E)}}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 pu(this._shape,this._curveSegments);return e.userData=Ks(this.userData),e}};var mu=class extends fu{constructor(e,n,i=0,s=12,o=3,a=ft.ODD){super(e,n,i,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,i){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);i.push(u.topP,l.topN,l.bottomN),i.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new mu(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Ks(this.userData),e}};var Ir=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:ft.ODD},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=r.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof St?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new St(n,i).fromJSON(o),r.parameters?.roundness!==void 0&&r.parameters?.roundness>0&&o.update());let l=o??new St(n,i);return{parameters:Object.assign(e,{width:n,height:i,depth:s,roundness:a}),shape:l}}static build(r){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:n,subdivisions:i,roundness:s,windingRule:o}=r.parameters;r.shape.roundness=s;let a;return t<=0?a=new pu(r.shape,i,{windingRule:o}):a=new mu(r.shape,t,e,i,n,o),Object.assign(a,{userData:{...r,type:"VectorGeometry"}})}};var OM=Math.PI*2,yu=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof St?r.shape:new St,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,spikes:n,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u=r.shape,c=t*.5,d=e*.5,h=sH(u,c,d,i*Math.PI/180,n,s);u.isClosed=!0,u.update();let f=Ir.create({shape:u,parameters:{subdivisions:h,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...r,type:"EllipseGeometry"}})}};function sH(r,t,e,n,i,s){if(n>=OM)return i>30||i%4===0?(aH(r,t,e,s),Math.round(i/4)):DM(r,n,i,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=EM({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:n>Math.PI,sweepFlag:!0});return i>30||i%u.length===0?oH(r,o.x,o.y,u,i,t,e,s):DM(r,n,i,t,e,s)}function oH(r,t,e,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint(gu(t,e));for(let u=0,c=n.length;u<c;u++){let d=n[u],h=r.points[u],f=gu(d.x,d.y);h.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),r.addPoint(f)}return a>0?LM(r,s,o,a):r.addPoint(gu(0,0)),l}function DM(r,t,e,n,i,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)*i;r.addPoint(gu(u,c))}return t<OM?s>0?LM(r,n,i,s):r.addPoint(gu(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&RM(r,n,i,s)),1}function aH(r,t,e,n=0,i=0,s=0){let o=.5522847498,a=t*o,l=e*o;r.addPoint(ug(i-t,s,i-t,s-l,i-t,s+l)),r.addPoint(ug(i,s+e,i-a,s+e,i+a,s+e)),r.addPoint(ug(i+t,s,i+t,s+l,i+t,s-l)),r.addPoint(ug(i,s-e,i+a,s-e,i-a,s-e)),n>0&&RM(r,t,e,n)}function gu(r,t){return new Ni(Ve.generateUUID(),new F(r,t))}function ug(r,t,e,n,i,s){let o=gu(r,t);return o.controls[0].position.set(e,n),o.controls[1].position.set(i,s),o}function LM(r,t,e,n){NM(r,t,e,n).forEach(s=>r.addPoint(s))}function RM(r,t,e,n){let i=NM(r,t,e,n),s=new St;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function NM(r,t,e,n){let i=n*t/100,s=i*(Math.abs(e)/Math.abs(t)),o=new F(i/t,s/e),a=r.points.map(l=>{let u=l.clone();return u.uuid=Ve.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 BM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},r.parameters),n=Math.abs(e.width),i=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:i,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(r){let{width:t,height:e,depth:n,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=r.parameters,h=new nl(!1,t,e,n,i,s,o,a,l,u,c,d);return Object.assign(h,{userData:{...r,type:"HelixGeometry"}})}},nl=class extends Te{constructor(t=!0,e=1,n=1,i=1,s=1,o=1,a=1,l=1,u=1,c=1,d=1,h=1,f=!1){super();let g=t&&o===1;g&&(h=0),d>100&&(d=100);let p=()=>new _,m=new _,y=p(),v=p(),x=p(),b,w,A,T,S,E,M,I,P=p(),C=p(),D=p(),B=p(),k=p(),X=p(),W=p(),q=p(),H=n-2*l+.001,K=H/o,R=Math.ceil(a*o),U=R+1,z=H/R,j=-H/2,G=c+1,re=2*Math.PI/c,Z=Math.PI/2/h,J=.01,V=Math.min((1-d/100)*l,l-J),pe=l-V,ie=0,ae=2,fe=h*ae+ae,xe=G*fe/ae,me=xe+G*U,Me=G*(U+fe),[Pe,be,Fe]=[3,3,2].map(_e=>Array(Me*_e).fill(0)),ht=[],L=s-l;function O(_e,Re){let Ne=Math.PI/2;E=Re*z,I=2*Math.PI*(E%K)/K+Ne,E+=j,M=Math.sin(I)*L,S=Math.cos(I)*L,t?_e.set(S,M,E):_e.set(S,E,M)}O(m,-1e-10),O(y,0),P.copy(m),O(m,1);let ee=m.distanceTo(y),he=g?0:pe+V,ge=ee*R+2*he,Ie=V,Ge=ge-he;for(let _e=0;_e<=R;_e++){O(v,_e),q.subVectors(v,P).normalize(),P.copy(v),X.copy(v).setComponent(+t+1,0).normalize(),W.crossVectors(q,X).normalize();let Re=_e===0,Ne=_e===R,pt=Re?3*Math.PI/2:Z,Nt=Re?Ie:Ge,gn=Re?G:me,Y=Re?0:Me-G,se=q.clone().multiplyScalar(Re?-pe:pe).add(v),ye=q.clone().multiplyScalar(Re?-1:1).normalize();for(let Ce=0;Ce<G;Ce++){let Ue=Ce*re;if(C.addVectors(m.copy(X).multiplyScalar(l*Math.cos(Ue)),y.copy(W).multiplyScalar(l*Math.sin(Ue))),D.copy(C).normalize(),Re||Ne){g||(ie=Y+Ce,[0,1,2].forEach(tt=>{Pe[ie*3+tt]=se.getComponent(tt),be[ie*3+tt]=ye.getComponent(tt)}),Fe[ie*2]=+Ne,Fe[ie*2+1]=Ce/c),y.copy(D).multiplyScalar(V),x.addVectors(v,y);for(let tt=0;tt<h;tt++){let $t=tt*Z+pt;B.addVectors(m.copy(q).multiplyScalar(pe*Math.sin($t)),y.copy(D).multiplyScalar(pe*Math.cos($t))),k.copy(B).normalize(),y.addVectors(x,B),B.normalize(),ie=gn+tt*G+Ce,[0,1,2].forEach(ri=>{Pe[ie*3+ri]=y.getComponent(ri),be[ie*3+ri]=k.getComponent(ri)});let Nn=+Re+Math.sin($t);Fe[ie*2]=(Nt+pe*Nn)/ge,Fe[ie*2+1]=Ce/c}}y.addVectors(v,C),ie=xe+_e*G+Ce,[0,1,2].forEach(tt=>{Pe[ie*3+tt]=y.getComponent(tt),be[ie*3+tt]=D.getComponent(tt)}),Fe[ie*2]=(he+_e*ee)/ge,Fe[ie*2+1]=Ce/c}}let De=U+2*h+ae,ue=1,[je,qe]=[+g,De-1];f&&(qe-=1);for(let _e=je;_e<=qe-1;_e++){let Re=g&&_e===qe-1;for(let Ne=0;Ne<G-1;Ne++)b=_e*G+Ne,w=b+1,A=(Re?Ne:b)+G,T=(Re?Ne+1:w)+G,_e===0?ht.push(w,T,A):_e===De-2?ht.push(b,w,A):ht.push(b,w,A,w,T,A)}this.setIndex(ht),this.setAttribute("position",new we(Pe,3)),this.setAttribute("normal",new we(be,3)),this.setAttribute("uv",new we(Fe,2))}};var FM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.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(r){let{width:t,height:e,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new Ch(t*.5,s,o):new Xl(t*.5,i);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...r,type:"IcosahedronGeometry"}})}},Ch=class extends Ko{constructor(t=1,e=.2,n=4){let i=(1+Math.sqrt(5))/2,s=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,n),this.type=a}static fromJSON(t){return new Ch(t.radius,t.corner,t.cornerSides)}};var UM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){(r.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}]},r.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(r){let{points:t,segments:e,verticalSegments:n}=r.parameters,i=new Hs;i.moveTo(t[0].x,t[0].y),i.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new Vl(i.extractPoints(n).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...r,type:"LatheGeometry"}})}};var cs=new de,eb=new ut,dg=new _,Qo=class extends Wt{constructor(){super(),this.uuid=Ve.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 nn().getNormalMatrix(t);for(let n=0,i=this.vertices.length;n<i;n++)this.vertices[n].applyMatrix4(t);for(let n=0,i=this.faces.length;n<i;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 cs.makeRotationX(t),this.applyMatrix4(cs),this}rotateY(t){return cs.makeRotationY(t),this.applyMatrix4(cs),this}rotateZ(t){return cs.makeRotationZ(t),this.applyMatrix4(cs),this}translate(t,e,n){return cs.makeTranslation(t,e,n),this.applyMatrix4(cs),this}scale(t,e,n){return cs.makeScale(t,e,n),this.applyMatrix4(cs),this}lookAt(t){return eb.lookAt(t),eb.updateMatrix(),this.applyMatrix4(eb.matrix),this}fromBufferGeometry(t){let e=this,n=t.index!==null?t.index:void 0,i=t.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,u=i.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let h=0;h<s.count;h++)e.vertices.push(new _().fromBufferAttribute(s,h)),a!==void 0&&e.colors.push(new Le().fromBufferAttribute(a,h));function c(h,f,g,p){let m=a===void 0?[]:[e.colors[h].clone(),e.colors[f].clone(),e.colors[g].clone()],y=o===void 0?[]:[new _().fromBufferAttribute(o,h),new _().fromBufferAttribute(o,f),new _().fromBufferAttribute(o,g)],v=new vu(h,f,g,y,m,p);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new F().fromBufferAttribute(l,h),new F().fromBufferAttribute(l,f),new F().fromBufferAttribute(l,g)]),u!==void 0&&e.faceVertexUvs[1].push([new F().fromBufferAttribute(u,h),new F().fromBufferAttribute(u,f),new F().fromBufferAttribute(u,g)])}let d=t.groups;if(d.length>0)for(let h=0;h<d.length;h++){let f=d[h],g=f.start,p=f.count;for(let m=g,y=g+p;m<y;m+=3)n!==void 0?c(n.getX(m),n.getX(m+1),n.getX(m+2),f.materialIndex):c(m,m+1,m+2,f.materialIndex)}else if(n!==void 0)for(let h=0;h<n.count;h+=3)c(n.getX(h),n.getX(h+1),n.getX(h+2));else for(let h=0;h<s.count;h+=3)c(h,h+1,h+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(dg).negate(),this.translate(dg.x,dg.y,dg.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,n=e===0?1:1/e,i=new de;return i.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(i),this}computeFaceNormals(){let t=new _,e=new _;for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];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,i=this.vertices.length;n<i;n++)e[n]=new _;if(t){let n=new _,i=new _;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];n.subVectors(c,u),i.subVectors(l,u),n.cross(i),e[a.a].add(n),e[a.b].add(n),e[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,i=this.faces.length;n<i;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,i=this.vertices.length;n<i;n++)e[n].normalize();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(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],i=n.vertexNormals;i.length===3?(i[0].copy(n.normal),i[1].copy(n.normal),i[2].copy(n.normal)):(i[0]=n.normal.clone(),i[1]=n.normal.clone(),i[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,n=this.faces.length;e<n;e++){let i=this.faces[e];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let t=new Qo;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 _,c={a:new _,b:new _,c:new _};s.push(u),o.push(c)}}let i=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=i.faceNormals[s],u=i.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let e=0,n=this.faces.length;e<n;e++){let i=this.faces[e];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new xt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Sn),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 i,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(i=new nn().getNormalMatrix(e));for(let h=0,f=a.length;h<f;h++){let p=a[h].clone();e!==void 0&&p.applyMatrix4(e),o.push(p)}for(let h=0,f=d.length;h<f;h++)c.push(d[h].clone());for(let h=0,f=u.length;h<f;h++){let g=u[h],p,m,y=g.vertexNormals,v=g.vertexColors,x=new vu(g.a+s,g.b+s,g.c+s);x.normal.copy(g.normal),i!==void 0&&x.normal.applyMatrix3(i).normalize();for(let b=0,w=y.length;b<w;b++)p=y[b].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),x.vertexNormals.push(p);x.color.copy(g.color);for(let b=0,w=v.length;b<w;b++)m=v[b],x.vertexColors.push(m.clone());x.materialIndex=g.materialIndex+n,l.push(x)}for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let g=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,m=g.length;p<m;p++){let y=g[p],v=[];for(let x=0,b=y.length;x<b;x++)v.push(y[x].clone());this.faceVertexUvs[h].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=[],i=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[d]===void 0?(e[d]=l,n.push(this.vertices[l]),i[l]=n.length-1):i[l]=i[e[d]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=i[c.a],c.b=i[c.b],c.c=i[c.c];let d=[c.a,c.b,c.c];for(let h=0;h<3;h++)if(d[h]===d[(h+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(t){this.vertices=[];for(let e=0,n=t.length;e<n;e++){let i=t[e];this.vertices.push(new _(i.x,i.y,i.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 i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(i[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 g=this.parameters;for(let p in g)g[p]!==void 0&&(t[p]=g[p]);return t}let e=[];for(let g=0;g<this.vertices.length;g++){let p=this.vertices[g];e.push(p.x,p.y,p.z)}let n=[],i=[],s={},o=[],a={},l=[],u={};for(let g=0;g<this.faces.length;g++){let p=this.faces[g],m=!0,y=!1,v=this.faceVertexUvs[0][g]!==void 0,x=p.normal.length()>0,b=p.vertexNormals.length>0,w=p.color.r!==1||p.color.g!==1||p.color.b!==1,A=p.vertexColors.length>0,T=0;if(T=c(T,0,0),T=c(T,1,m),T=c(T,2,y),T=c(T,3,v),T=c(T,4,x),T=c(T,5,b),T=c(T,6,w),T=c(T,7,A),n.push(T),n.push(p.a,p.b,p.c),n.push(p.materialIndex),v){let S=this.faceVertexUvs[0][g];n.push(f(S[0]),f(S[1]),f(S[2]))}if(x&&n.push(d(p.normal)),b){let S=p.vertexNormals;n.push(d(S[0]),d(S[1]),d(S[2]))}if(w&&n.push(h(p.color)),A){let S=p.vertexColors;n.push(h(S[0]),h(S[1]),h(S[2]))}}function c(g,p,m){return m?g|1<<p:g&~(1<<p)}function d(g){let p=g.x.toString()+g.y.toString()+g.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(g.x,g.y,g.z)),s[p]}function h(g){let p=g.r.toString()+g.g.toString()+g.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(g.getHex())),a[p]}function f(g){let p=g.x.toString()+g.y.toString();return u[p]!==void 0||(u[p]=l.length/2,l.push(g.x,g.y)),u[p]}return t.data={},t.data.vertices=e,t.data.normals=i,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=n,t}clone(){return new Qo().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 h=0,f=e.length;h<f;h++)this.vertices.push(e[h].clone());let n=t.colors;for(let h=0,f=n.length;h<f;h++)this.colors.push(n[h].clone());let i=t.faces;for(let h=0,f=i.length;h<f;h++)this.faces.push(i[h].clone());for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let g=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,m=g.length;p<m;p++){let y=g[p],v=[];for(let x=0,b=y.length;x<b;x++){let w=y[x];v.push(w.clone())}this.faceVertexUvs[h].push(v)}}let s=t.morphTargets;for(let h=0,f=s.length;h<f;h++){let g={};if(g.name=s[h].name,s[h].vertices!==void 0){g.vertices=[];for(let p=0,m=s[h].vertices.length;p<m;p++)g.vertices.push(s[h].vertices[p].clone())}if(s[h].normals!==void 0){g.normals=[];for(let p=0,m=s[h].normals.length;p<m;p++)g.normals.push(s[h].normals[p].clone())}this.morphTargets.push(g)}let o=t.morphNormals;for(let h=0,f=o.length;h<f;h++){let g={};if(o[h].vertexNormals!==void 0){g.vertexNormals=[];for(let p=0,m=o[h].vertexNormals.length;p<m;p++){let y=o[h].vertexNormals[p],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),g.vertexNormals.push(v)}}if(o[h].faceNormals!==void 0){g.faceNormals=[];for(let p=0,m=o[h].faceNormals.length;p<m;p++)g.faceNormals.push(o[h].faceNormals[p].clone())}this.morphNormals.push(g)}let a=t.skinWeights;for(let h=0,f=a.length;h<f;h++)this.skinWeights.push(a[h].clone());let l=t.skinIndices;for(let h=0,f=l.length;h<f;h++)this.skinIndices.push(l[h].clone());let u=t.lineDistances;for(let h=0,f=u.length;h<f;h++)this.lineDistances.push(u[h]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.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 tb().fromGeometry(this),e=new Te,n=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",hg.call(new Be(n,3),t.vertices)),t.normals.length>0){let i=new Float32Array(t.normals.length*3);e.setAttribute("normal",hg.call(new Be(i,3),t.normals))}if(t.colors.length>0){let i=new Float32Array(t.colors.length*3);e.setAttribute("color",GM.call(new Be(i,3),t.colors))}if(t.uvs.length>0){let i=new Float32Array(t.uvs.length*2);e.setAttribute("uv",kM.call(new Be(i,2),t.uvs))}if(t.uvs2.length>0){let i=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",kM.call(new Be(i,2),t.uvs2))}e.groups=t.groups;for(let i in t.morphTargets){let s=[],o=t.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new we(u.data.length*3,3);c.name=u.name,s.push(hg.call(c,u.data))}e.morphAttributes[i]=s}if(t.skinIndices.length>0){let i=new we(t.skinIndices.length*4,4);e.setAttribute("skinIndex",zM.call(i,t.skinIndices))}if(t.skinWeights.length>0){let i=new we(t.skinWeights.length*4,4);e.setAttribute("skinWeight",zM.call(i,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 Te,n=t.geometry;if(t.isPoints||t.isLine){let i=new we(n.vertices.length*3,3),s=new we(n.colors.length*3,3);if(e.setAttribute("position",hg.call(i,n.vertices)),e.setAttribute("color",GM.call(s,n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new we(n.lineDistances.length,1);e.setAttribute("lineDistance",lH.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}};Qo.prototype.isGeometry=!0;var tb=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,i,s,o=t.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=i*3-n.start,e.push(n)),n={start:i*3,materialIndex:s})}n!==void 0&&(n.count=i*3-n.start,e.push(n)),this.groups=e}fromGeometry(t){let e=t.faces,n=t.vertices,i=t.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[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,d=c.length,h;if(d>0){h=[];for(let y=0;y<d;y++)h[y]={name:c[y].name,data:[]};this.morphTargets.normal=h}let f=t.skinIndices,g=t.skinWeights,p=f.length===n.length,m=g.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=i[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 F,new F,new F))}if(o===!0){let w=i[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 F,new F,new F))}for(let w=0;w<l;w++){let A=a[w].vertices;u[w].data.push(A[v.a],A[v.b],A[v.c])}for(let w=0;w<d;w++){let A=c[w].vertexNormals[y];h[w].data.push(A.a,A.b,A.c)}p&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),m&&this.skinWeights.push(g[v.a],g[v.b],g[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}},vu=class{constructor(t,e,n,i,s,o=0){this.a=t,this.b=e,this.c=n,this.normal=i&&i.isVector3?i:new _,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Le,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(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 lH(r){return this.array.set(r),this}function GM(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),s=new Le),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function kM(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),s=new F),t[e++]=s.x,t[e++]=s.y}return this}function hg(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),s=new _),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function zM(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),s=new Qe),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var cH=["a","b","c"];function uH(r,t){switch(t){case"c":return r.c;case"b":return r.b;case"a":default:return r.a}}function nb(r,t,e){let n=Math.min(r,t),i=Math.max(r,t),s=n+"_"+i;return e.get(s)}function rb(r,t,e,n,i,s){let o=Math.min(r,t),a=Math.max(r,t),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=e[o],d=e[a];u={a:c,b:d,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(i),s[r].edges.push(u),s[t].edges.push(u)}function dH(r,t,e,n){let i,s,o;for(i=0,s=r.length;i<s;i++)e[i]={edges:[]};for(i=0,s=t.length;i<s;i++)o=t[i],rb(o.a,o.b,r,n,o,e),rb(o.b,o.c,r,n,o,e),rb(o.c,o.a,r,n,o,e)}function fg(r,t,e,n,i){r.push(new vu(t,e,n,void 0,void 0,i))}function xu(r,t){return Math.abs(t-r)/2+Math.min(r,t)}function pg(r,t,e,n){r.push([t.clone(),e.clone(),n.clone()])}var mg=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Te?t=new Qo().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 _,n,i,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,h=[],f=new Map;dH(l,u,h,f);let g=[],p,m,y,v,x,b,w;for(let Z of Array.from(f.keys())){for(m=f.get(Z),y=new _,x=3/8,b=1/8,w=m.faces.length,w!=2&&(x=.5,b=0,w!=1),y.addVectors(m.a,m.b).multiplyScalar(x),e.set(0,0,0),o=0;o<w;o++){for(v=m.faces[o],a=0;a<3&&(p=l[uH(v,cH[a])],!(p!==m.a&&p!==m.b));a++);p&&e.add(p)}e.multiplyScalar(b),y.add(e),m.newEdge=g.length,g.push(y)}let A,T,S,E,M,I,P,C=[];for(i=0,s=l.length;i<s;i++){for(I=l[i],M=h[i].edges,n=M.length,n==3?A=3/16:n>3&&(A=3/(8*n)),T=1-n*Number(A),S=A,n<=2&&(n==2?(T=3/4,S=1/8):n==1||n==0),P=I.clone().multiplyScalar(T),e.set(0,0,0),o=0;o<n;o++)E=M[o],p=E.a!==I?E.a:E.b,e.add(p);e.multiplyScalar(Number(S)),P.add(e),C.push(P)}let D=C.concat(g),B=C.length,k,X,W,q=[],H=[],K,R,U,z,j=new F,G=new F,re=new F;for(i=0,s=u.length;i<s;i++)v=u[i],k=Number(nb(v.a,v.b,f).newEdge)+B,X=Number(nb(v.b,v.c,f).newEdge)+B,W=Number(nb(v.c,v.a,f).newEdge)+B,fg(q,k,X,W,v.materialIndex),fg(q,v.a,k,W,v.materialIndex),fg(q,v.b,X,k,v.materialIndex),fg(q,v.c,W,X,v.materialIndex),d&&(K=c[i],R=K[0],U=K[1],z=K[2],j.set(xu(R.x,U.x),xu(R.y,U.y)),G.set(xu(U.x,z.x),xu(U.y,z.y)),re.set(xu(R.x,z.x),xu(R.y,z.y)),pg(H,j,G,re),pg(H,R,j,re),pg(H,U,G,j),pg(H,z,re,G));t.vertices=D,t.faces=q,d&&(t.faceVertexUvs[0]=H)}};var Dn=new _,VM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=r.geometry??t?.geometry??new Te().copy(new Gn(100,100,100)),n;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Dn),n={width:Dn.x,height:Dn.y,depth:Dn.z,subdivisions:0}):n=t.parameters;let i={...n,...r.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:e}}static build(r){let{width:t,height:e,depth:n,subdivisions:i}=r.parameters,s=r.geometry??new Te().copy(new Gn(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Dn)):Dn.set(o.width,o.height,o.depth),(t!==Dn.x||e!==Dn.y||n!==Dn.z)&&s.scale(Dn.x===0?1:t/Dn.x,Dn.y===0?1:e/Dn.y,Dn.z===0?1:n/Dn.z);let a=s.originalGeometry;return i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new mg(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),a!==void 0&&Object.assign(s,{originalGeometry:a}),delete r.geometry,Object.assign(s,{userData:{...r,type:"NonParametricGeometry"}})}static loadFromUrl(r,t,e){new Jl(e).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(Dn);let o=100/Dn.x;Object.assign(s.parameters,{width:100,height:Dn.y*o,depth:Dn.z*o}),t(this.build(s))})}};var gg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters);return{shape:r.shape&&r.shape instanceof St?r.shape:new St,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,spikes:n,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=r.parameters,l=r.shape,u=t*.5,c=e*.5,d=0,h=0,f=2*Math.PI/n;for(let p=0;p<n;p++){let m=f*p,y=d+Math.sin(m)*u,v=h+Math.cos(m)*c;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let p=0,m=l.points.length;p<m;p++)l.points[p].roundness=i;l.roundness=i,l.update();let g=Ir.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(g,{userData:{...r,type:"PolygonGeometry"}})}};var HM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},r.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(r){let{width:t,height:e,depth:n,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=new sb(t*.5,e,i,s,o,a,l);return u.scale(1,1,n/t),Object.assign(u,{userData:{...r,type:"PyramidGeometry"}})}};function Ph(r,t,e){e.x=r.x*t.x,e.y=r.y,e.z=r.x*t.y}function ib(r,t,e,n,i,s){let o=t.clone().sub(r),a=e.clone().sub(r),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===i){let u=o.add(a).normalize();s.copy(r).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(r),s.addScaledVector(o,i/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function hH(r,t,e){let n=r.clone().sub(t),i=e.clone().sub(t);return n.projectOnVector(i),n.add(t)}var sb=class extends Te{constructor(t=.5,e=1,n=4,i=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),i=Math.floor(i),a=Math.floor(a);let l=[],u=[],c=[],d=[],h=0,f=e/2,g=Math.PI/n,p=t*Math.cos(Math.PI/n),m=2*Math.PI/n,y=(n-2)*Math.PI/n,v=Math.PI-y,x=new _(0,-f,0),b=new _(0,f,0),w=new F(t,-f),A=new F(p,-f),T=new F(0,b.y).sub(A),S=new F(0,b.y).sub(w),E=new F(T.y,-T.x).normalize(),M=new F(S.y,-S.x).normalize(),P=t*Math.cos(Math.PI/n)*Math.tan((Math.PI-T.angle())/2)-1e-8;o=Math.min(o,P);let C;{let H=new _(E.x,E.y,0),K=new _(Math.cos(m)*H.x,H.y,Math.sin(m)*H.x);C=H.angleTo(K)}let D=o/Math.tan((Math.PI-T.angle())/2),B=o/Math.tan((Math.PI-C)/2),k=new _;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),d.push(0,0);let H=h++,K=[],R=w.clone(),U=D/Math.cos(Math.PI/n);R.x-=U;for(let z=0;z<n;z++){let j=z/n*Math.PI*2+g,G=new F(Math.sin(j),Math.cos(j));Ph(R,G,k),u.push(k.x,k.y,k.z),c.push(0,-1,0),d.push(0,0),K.push(h++)}for(let z=0;z<K.length;z++)l.push(K[z],H,K[(z+1)%K.length])}let X=[];{let H=new _,K=new _,R=new _,U=new _,z=new _,j=new _;for(let G=0;G<n;G++){let re=G/n*Math.PI*2+g,Z=(G+.5)/n*Math.PI*2+g,J=(G+1)/n*Math.PI*2+g,V=new F(Math.sin(re),Math.cos(re)),pe=new F(Math.sin(Z),Math.cos(Z)),ie=new F(Math.sin(J),Math.cos(J));Ph(w,V,K),Ph(w,ie,R),Ph(E,pe,H),ib(b,K,R,B,B,U),u.push(U.x,U.y,U.z),ib(K,b,R,B,D,z),u.push(z.x,z.y,z.z),ib(R,K,b,D,B,j),u.push(j.x,j.y,j.z),c.push(H.x,H.y,H.z),c.push(H.x,H.y,H.z),c.push(H.x,H.y,H.z),d.push(0,0),d.push(0,0),d.push(0,0);let ae=h++,fe=h++,xe=h++;if(l.push(ae,fe,xe),o>0){{let Pe=K.clone().add(R).multiplyScalar(.5),be=b.clone().sub(Pe).normalize(),ht=x.clone().sub(Pe).normalize().add(be).normalize().multiplyScalar(-1),L=j.clone().sub(z);W(Pe,L,ht,T.angle())}let me,Me;{let Pe=new _;Ph(M,ie,Pe);let be=j.clone().add(U).multiplyScalar(.5);be=hH(be,R,b);let Fe=j.clone().sub(U);[me,Me]=W(be,Fe,Pe,C,U.y)}{let Pe=me,be=Pe.clone().setY(0).normalize(),Fe=new _(0,-1,0),ht=be.clone().cross(Fe);q(Pe,be,Fe,ht)}X.concat(Me);{let Pe=T.angle(),be=Math.PI-Pe,Fe=b.clone();Fe.y-=o/Math.sin(Pe-Math.PI/2);let ht=new _,L=[];for(let ee=0;ee<a;ee++){let he=[],ge=Math.PI/2-be*ee/a,Ie=Math.cos(ge),Ge=Math.sin(ge),De=Z;for(let ue=0;ue<=ee;ue++){let je=Math.cos(De),qe=Math.sin(De);H.x=Ie*qe,H.y=Ge,H.z=Ie*je,ht.copy(Fe).addScaledVector(H,o),u.push(ht.x,ht.y,ht.z),c.push(H.x,H.y,H.z),d.push(0,0),he.push(h++),De+=Math.PI*2/ee/n}L.push(he)}Me.reverse(),L.push(Me);let O=L.length-1;for(let ee=0;ee<O;ee++){let he=L[ee],ge=L[ee+1],Ie=he.length-1;l.push(ge[1],he[0],ge[0]);for(let Ge=1;Ge<=Ie;Ge++)l.push(he[Ge],he[Ge-1],ge[Ge]),l.push(ge[Ge+1],he[Ge],ge[Ge])}}}}}this.setIndex(l),this.setAttribute("position",new we(u,3)),this.setAttribute("normal",new we(c,3)),this.setAttribute("uv",new we(d,2));function W(H,K,R,U,z){let j=-U/2,G=(Math.PI-U)/2,re=K.clone().normalize().cross(R);H.addScaledVector(R,-o/Math.sin(G));let Z=new _,J=new _,V=1,pe=h,ie=[];for(let ae=0;ae<=a;ae++){let fe=j+ae/a*U;J.set(0,0,0),J.addScaledVector(re,Math.sin(fe)),J.addScaledVector(R,Math.cos(fe));for(let xe=0;xe<=V;xe++){let me=xe/V-.5;if(Z.copy(H),Z.addScaledVector(K,me),Z.addScaledVector(J,o),z!=null){let Me=Math.max(0,Z.y-z);Z.addScaledVector(K,-Me/K.y)}u.push(Z.x,Z.y,Z.z),c.push(J.x,J.y,J.z),d.push(0,0),xe===0&&ie.push(h),h++}}for(let ae=0;ae<a;ae++)for(let fe=0;fe<V;fe++){let xe=pe+fe+(V+1)*ae,me=xe+(V+1),Me=me+1,Pe=xe+1;l.push(xe,me,Pe),l.push(me,Me,Pe)}return[H.clone().addScaledVector(K,.5),ie]}function q(H,K,R,U){let z=Math.PI/2,j=S.angle()-z,G=[],re=new _,Z=new _;for(let V=0;V<=a;V++){let pe=[],ie=V/a;for(let ae=0;ae<=V;ae++){let xe=((V?ae/V:0)-.5)*v,me=Math.cos(xe),Me=Math.sin(xe),Pe=Math.atan(Math.tan(j)*me),be=(z+Pe)*ie,Fe=Math.cos(be),ht=Math.sin(be);re.set(0,0,0),re.addScaledVector(K,ht*me),re.addScaledVector(R,Fe),re.addScaledVector(U,ht*Me),Z.copy(H).addScaledVector(re,o),u.push(Z.x,Z.y,Z.z),c.push(re.x,re.y,re.z),d.push(0,0),pe.push(h++)}G.push(pe)}let J=G.length-1;for(let V=0;V<J;V++){let pe=G[V],ie=G[V+1],ae=pe.length-1;l.push(pe[0],ie[1],ie[0]);for(let fe=1;fe<=ae;fe++)l.push(pe[fe-1],pe[fe],ie[fe]),l.push(pe[fe],ie[fe+1],ie[fe])}}}};var yg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters),n=Object.assign(t?.ui??{enabledIndieCorners:!1},r.ui);return{shape:r.shape&&r.shape instanceof St?r.shape:new St,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(r){let t=r.shape,{width:e,height:n,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u={x:e*.5,y:n*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function h(b,w,A){return w>e&&A>n?Math.min(b*e/w,b*n/A):w>e?b*e/w:A>n?b*n/A:b}let f=[];f[0]=i[0]===0?0:h(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:h(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:h(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:h(i[3],i[3]+i[0],i[3]+i[2]);let g=c.x,p=d.x,m=d.y,y=c.y;t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(p,m)),t.addPoint(t.createPoint(p,y)),t.addPoint(t.createPoint(g,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=Ir.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...r,type:"RectangleGeometry"}})}};var WM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},r.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(r){let{width:t=100,height:e=t,depth:n=t,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=r.parameters,c=new Na(.5*t,i,s,o,a,l,u);return c.scale(1,e/t,n/t),Object.assign(c,{userData:{...r,type:"SphereGeometry"}})}};var jM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(r){let{width:t=100,height:e=t,widthSegments:n=8,heightSegments:i=8}=r.parameters,s=new Vs(t,e,n,i);return s.scale(1,1,1),Object.assign(s,{userData:{...r,type:"PlaneGeometry"}})}};var qM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},r.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(r){let{width:t,height:e,depth:n,angle:i,cornerRadius:s,cornerSegments:o}=r.parameters,a=new ob(t,e,n,i,s,o);return Object.assign(a,{userData:{...r,type:"BackdropGeometry"}})}},ob=class extends Te{constructor(t=1,e=1,n=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-c,i),i*=Math.PI/180;let d=[],h=Math.PI/2,f=(Z=0,J=0,V=0)=>new _(Z,J,V),g=f(),p=f(),[m,y,v]=[e/2,t/2,n/2],x=-y,b=+y,[w,A,T]=[f(x,-m,+v),f(x,-m,-v),f(x,+m,-v)],S=(Z,J=!1)=>Math.sin(Z-Math.PI/(1+ +J)),E=(Z,J=!1)=>Math.cos(Z-Math.PI/(1+ +J));T.y=Math.sin(i)*e-m;let M=Math.cos(i)*e-v,I=w.z-c;i<=h?(T.z=Math.min(M,I),T.z==I&&(T.y-=(M-I)/Math.tan(h-i))):A.z=Math.min(A.z-M-v,w.z-c),g.subVectors(w,A),p.subVectors(T,A);let P=Math.min(g.length(),p.length())*s/100,C=P*Math.tan(i/2),D=P/Math.cos(i/2),B=g.clone().normalize().add(p.normalize()).setLength(D).add(A);g.set(0,S(i,!0),E(i,!0)),d.push([T,g.clone()]);let k=(Math.PI-i)/o;for(let Z=0;Z<=o;Z++){let J=h+i+Z*k;g.set(0,Math.sin(J)*C,Math.cos(J)*C),g.add(B),p.set(0,S(J),E(J)),d.push([g.clone(),p.clone()])}d.push([w,f(0,1,0)]);let X=Math.sin(k/2)*C*2,W=d.length-1,q=d[0][0].distanceTo(d[1][0]),H=d[W-1][0].distanceTo(d[W][0]),K=q+X*o+H;d[0].push(1);for(let Z=0;Z<=o;Z++)d[Z+1].push(1-(q+Z*X)/K);d[W].push(0);let[R,U,z]=d[0],j,G,re;for(let Z=1;Z<d.length;Z++)[j,G,re]=d[Z],a.push(x,R.y,R.z,x,j.y,j.z,b,R.y,R.z,b,R.y,R.z,x,j.y,j.z,b,j.y,j.z),l.push(0,U.y,U.z,0,G.y,G.z,0,U.y,U.z,0,U.y,U.z,0,G.y,G.z,0,G.y,G.z),u.push(0,z,0,re,1,z,1,z,0,re,1,re),[R,U,z]=[j,G,re];this.setAttribute("position",new we(a,3)),this.setAttribute("normal",new we(l,3)),this.setAttribute("uv",new we(u,2))}};var vg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof St?r.shape:new St,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,innerRadiusPercent:n,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=r.parameters,c=r.shape,d=t*.5,h=e*.5,f=0,g=0,p=o*Math.PI/360/i,m=Math.PI/2*3*-1,y=d*n/100,v=h*n/100;if(i===3&&n===50){p=2*Math.PI/i;for(let b=0;b<i;b++){let w=p*b,A=f+Math.sin(w)*d,T=g+Math.cos(w)*h;c.addPoint(c.createPoint(A,T))}}else for(let b=0;b<i;b++){let w=f+Math.cos(m)*d,A=g+Math.sin(m)*h;c.addPoint(c.createPoint(w,A)),m+=p,w=f+Math.cos(m)*y,A=g+Math.sin(m)*v,b<=i,c.addPoint(c.createPoint(w,A)),m+=p}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=Ir.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...r,type:"StarGeometry"}})}};var XM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},r.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(r){let{width:t,height:e}=r.parameters,n=new Vs(t,e);return Object.assign(n,{userData:{...r,type:"TextFrameGeometry"}})}};var YM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:n,height:i,depth:s})}}static build(r){let{width:t,height:e,depth:n,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=fH(t,e,n,t*.5,o,s,0,0,i,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...r,type:"TorusGeometry"}})}};function fH(r,t,e,n,i,s,o,a,l,u,c){return[t,e]=[e,t],o=t/2,i/=2*Math.PI,i==1&&(u=0),new nl(!0,r,t,e,n,i,s,o,a,l,u,c)}var KM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},r.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(r){let{width:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:o}=r.parameters,a=t*.5;a!==e&&(a-=e);let l=new Yl(a,e,n,i,s,o);return Object.assign(l,{userData:{...r,type:"TorusKnotGeometry"}})}};var ZM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},r.parameters);return{shape:r.shape&&r.shape instanceof St?r.shape:new St,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(r){let{width:t=100,height:e,cornerRadius:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=r.parameters,l=r.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 h=0,f=l.points.length;h<f;h++)l.points[h].roundness=n;l.roundness=n,l.update();let d=Ir.create({shape:l,parameters:{roundness:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(d,{userData:{...r,type:"TriangleGeometry"}})}};function QM(r,t){let e=2*Math.PI;return(r%e+e)%e===(t%e+e)%e}function pH(r,t,e){let n=[new _,new _,new _],i=[new _,new _,new _];return r.extractBasis(n[0],n[1],n[2]),t.extractBasis(i[0],i[1],i[2]),n.forEach((s,o)=>{let a=i[o],l=Ve.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new de().makeBasis(n[0],n[1],n[2])}var JM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??yu.create({parameters:hx}).userData.shape;return{path:r.path??Vc.defaultData(),parameters:Object.assign(e,{width:n,height:i,depth:s,extrusion:{...Om,...e.extrusion}}),shapeData:o}}static build(r){if(r.path.points.length>=2){let e=new ab(r);return Object.assign(e,{userData:{...r,type:"PathGeometry"}})}else return Object.assign(new Te,{userData:{...r,type:"PathGeometry"}})}},ab=class extends Te{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)||!QM(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let n=this._computeBasisMatrices(e),{depth:i,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((i+s)*o):Math.ceil(Math.min(1,i+s)*o),u=Math.min(Math.max(2,l-a+1),o+2),c=[],d=[];for(let P=0;P<u;P++){let C=this.inputs.path.isClosed?(P+a)%e.length:Math.min(P+a,e.length-1);c.push(e[C].clone()),d.push(n[C].clone())}let h=(P,C,D)=>{c[P]=c[P].clone().lerp(c[C],D),d[P]=pH(d[P],d[C],D)},f=0,g=s*o%1;(!this.inputs.path.isClosed||i<=1)&&(g||s===0)&&(f=g,h(0,1,f));let p=0,m=(s+i)*o%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&s+i<1)&&m&&(p=m,h(c.length-1,c.length-2,1-p)),i===0){let P=c.length-1;c[P].copy(c[0]),d[P].copy(d[0])}this._applyPathModifiers(d,f,p);let{regions:y,infos:v,vertices:x}=this._computeShapePoints(5),b=0,w=0;v.sort((P,C)=>P.start-C.start),v.forEach(P=>{P.verticesStart=b,P.verticesCount=P.continuous.reduce((C,D,B)=>C+(B===0||!D?2:1),0),w+=P.verticesCount,b=w});let A=w*u,T,S=0;if(this._isOpenEnded()){let P;try{P=Bi({windingRule:ft.ODD,elementType:Jt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:y})}catch{P=$x}S=P.vertexCount}let E=A+2*S,M={positions:new Float32Array(E*3),normals:new Float32Array(E*3),uvs:new Float32Array(E*2)},I=[];v.forEach(P=>{this._extrudeRegion(P,x,d,c,M,I,this._isGeometryClosed()&&!this._isOpenEnded())}),T&&(this._closeEnd(T,A,I,M,d[0],c[0],!1),this._closeEnd(T,A+S,I,M,d[d.length-1],c[c.length-1],!0)),this.setAttribute("position",new Be(M.positions,3)),this.setAttribute("normal",new Be(M.normals,3)),this.setAttribute("uv",new Be(M.uvs,2)),this.setIndex(I)}_extractPathPoints(){let n=sg(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(n.length<2)return[];let i=[n[0]];return n.forEach(o=>{i[i.length-1].distanceToSquared(o)>.001&&i.push(o)}),this.inputs.path.isClosed&&i[i.length-1].distanceTo(i[0])<.001&&i.pop(),i}_computeBasisMatrices(e){let n=[],i=e.length,s=this.inputs.path.isClosed,o=new _,a=new _,l=new _,u=new _,c=new _(0,1,0);for(let m=0;m<i;m++){let y=e[m],v;m===0?v=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):v=e[m-1];let x;m===i-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[m-1]):x=e[m+1];let b=y.clone().sub(v).normalize(),w=x.clone().sub(y).normalize(),A=b.clone().add(w).normalize();l.copy(A),m===0&&(A.equals(c)||A.clone().negate().equals(c))&&c.set(0,0,1);let T=c.clone().cross(A).normalize(),S=A.clone().cross(T).normalize();c.copy(S),u.copy(T),m===0&&(o.copy(S),a.copy(A));let E=new de().makeBasis(T,S,A);n.push(E)}let d=s?a:l,h=s?o:new _(0,1,0),f=d.clone().cross(u).normalize(),g=Math.acos(h.dot(f));if(isNaN(g))return n;let p=h.clone().cross(f);d.dot(p)>0&&(g*=-1);for(let m=1;m<n.length;m++){let y=new de().makeRotationZ(g*m/n.length);n[m].multiply(y)}return n}_applyPathModifiers(e,n,i){let s=e.length,{angle:o,twist:a,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new de,d=new de;return e.forEach((h,f)=>{let g=f===0?0:f===s-1?1:(f-n)/(s-(i===0?0:1)-(n+(1-i)));c.makeRotationZ(Ve.lerp(o,o+a,g));let p=Ve.lerp(l,u,g);d.makeScale(p,p,p),h.multiply(c).multiply(d)}),e}_computeShapePoints(e=12,n=ft.ODD){let i=this.inputs.shapeData,s=i.extractShapePointsToFlatArray([],e),o=i.shapeHoles.map(p=>{let m=p.extractShapePointsToFlatArray([],e),y=[];for(let v=m.length-1;v>=1;v-=2){let x=m[v-1],b=m[v-0];y.push(x,b)}return y}),a;try{a=Bi({windingRule:n,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=Mh}let l;try{l=Bi({windingRule:ft.ODD,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=Jx}if(!a)throw new Error("error generating geometry");let u=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let p=0;p<l.elements.length;p++){let m=l.elements[p],y=p%2===0?a.vertexCount:0;a.elements.push(m+y)}for(let p=0;p<l.vertexIndices.length;p++){let m=l.vertexIndices[p],y=a.vertexCount;a.vertexIndices.push(m+y)}for(let p=0;p<l.vertices.length;p++){let m=l.vertices[p];a.vertices.push(m)}}let c=1/0,d=-1/0,h=1/0,f=-1/0;for(let p=0,m=a.vertexCount;p<m;p++){let y=p*2,v=a.vertices[y+0],x=a.vertices[y+1];v<c&&(c=v),v>d&&(d=v),x<h&&(h=x),x>f&&(f=x)}let g=[];for(let p=a.elementCount-1;p>=0;p--){let m=p>=u,y=p*2,v=a.elements[y+0],x=a.elements[y+1],b=v+x,w={start:v,count:x,normals:[],isHole:m,continuous:[],verticesStart:0,verticesCount:0};g.push(w);let A=v,T=b-1,S=v+1,E=i.roundedCurves.length;do{let M=A-v,I=a.vertices[T*2+0],P=a.vertices[T*2+1],C=a.vertices[A*2+0],D=a.vertices[A*2+1],B=a.vertices[S*2+0],k=a.vertices[S*2+1],X=C-I,W=D-P,q=Math.sqrt(X*X+W*W);X/=q,W/=q;let H=C-B,K=D-k,R=Math.sqrt(H*H+K*K);H/=R,K/=R,w.normals[M*2+0]=-K,w.normals[M*2+1]=H;let U=a.vertexIndices[A];if(Array.isArray(U))w.continuous[M]=!1;else{let[z,j]=i.getCurveIndexFromVertexId(U-1,!0);if(j>0&&j<1)w.continuous[M]=!0;else{let G=j===1?z+1:z-1;G=(G+E)%E;let re=j===1?0:1,Z=i.roundedCurves[z].getTangent(j),J=i.roundedCurves[G].getTangent(re);w.continuous[M]=Z.dot(J)>.95}}m&&(w.normals[M*2+0]*=-1,w.normals[M*2+1]*=-1),[T,A,S]=[A,S,S+1],S>=b&&(S-=x)}while(S!==v+1)}return{regions:[s,...o],infos:g,vertices:a.vertices}}_insertVertex(e,n,i,s,o){let a=n*2,l=n*3;e.positions[l+0]=i.x,e.positions[l+1]=i.y,e.positions[l+2]=i.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,i,s,o,a,l){let u=new _,c=new _,d=new _,h=new _,f=new F;i.forEach((p,m)=>{let y=s[m],v=e.verticesStart*i.length+e.verticesCount*m;for(let x=0;x<e.count;x++){let b=(e.start+x)*2;if(u.set(n[b+0],n[b+1],0),d.copy(u).applyMatrix4(p).add(y),e.continuous[x])h.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),h.copy(u).sub(c),h.set(-h.y,h.x,0),e.isHole||h.negate()}if(h.applyMatrix4(p).normalize(),f.set(x===0?1:x/e.count,m/(i.length-1)),this._insertVertex(o,v,d,h,f),v++,!e.continuous[x]||x===0){if(x===0)h.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,m/(i.length-1));else{let w=x===e.count-1?e.start*2:b+2;c.set(n[w+0],n[w+1],0),h.copy(c).sub(u),h.set(-h.y,h.x,0),e.isHole||h.negate()}h.applyMatrix4(p).normalize(),this._insertVertex(o,v,d,h,f),v++}}});let g=i.length-1;for(let p=0;p<g;p++){let m=e.verticesStart*i.length+e.verticesCount*p,y=e.verticesStart*i.length+e.verticesCount*(p+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=m+v,A=m+b,T=y+b,S=y+v;e.isHole?a.push(w,T,A,w,S,T):a.push(w,A,T,w,T,S),v++}}}_closeEnd(e,n,i,s,o,a,l){let u=e.vertexCount,c=new _(0,0,l?-1:1).applyMatrix4(o),d=new _,h=new F;for(let g=0;g<u;g++){let p=2*g;d.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(o).add(a),this._insertVertex(s,n+g,d,c,h)}let f=e.elements;for(let g=0;g<e.elementCount;g++){let p=3*g,m=f[p+0]+n,y=f[p+(l?1:2)]+n,v=f[p+(l?2:1)]+n;i.push(m,y,v)}}};function mH(){let r=new Te;return r.setAttribute("position",new Be(new Float32Array([]),3)),r.setIndex(new Be(new Uint16Array([]),1)),r}var gH=12,yH=1,bu=class extends Te{constructor(e,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];this.userData={parameters:e,type:"TextGeometry"};let i=n.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,n).then(()=>{this.update(e),n?.requestRender()})}async updateFont(e,n){let i=n.getFont(e);i&&(this.font=i,await i.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:i,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=e,d=c===2?u.toUpperCase():c===3?u.toLowerCase():u,h=vH(e,n,d),{shapes:f,charWidths:g,charCoords:p}=n.generateShapes(h,e),m=i*.5,y=s*.5,v=f.map(w=>new St().fromShape(w));this.vectorShapes=v;let x=v.map(w=>Ir.create({shape:w,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?ft.NONZERO:ft.ODD,subdivisions:this.isLowResolution&&o>0?yH:gH}})),b=x.length?eo(x):mH();b.translate(-m,y,0),this.dispose(),this.wrappedText=h,this.charCoords=p,this.charWidths=g,this.deleteAttribute("extrudeNormal"),Object.entries(b.attributes).forEach(([w,A])=>{this.setAttribute(w,A)}),this.setIndex(b.index),this.computeBoundingSphere()}clone(){let e=Oi(new Te,bu.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([n,i])=>{this.setAttribute(n,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function vH(r,t,e){e=e??r.text;let n=[""],i="";for(let s of e)i+=s,s===" "||s===`
|
|
3138
|
+
}`;function rN(r,t,e){let n=new Dd,i=new F,s=new F,o=new Qe,a=new Od({depthPacking:m0}),l=new jv,u={},c=e.maxTextureSize,d={[Wr]:bn,[bn]:Wr,[fr]:fr},h=new bt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new F},radius:{value:4}},vertexShader:tN,fragmentShader:nN}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let g=new Te;g.setAttribute("position",new Be(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new Un(g,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Cp,this.render=function(b,w,A){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;let T=r.getRenderTarget(),S=r.getActiveCubeFace(),E=r.getActiveMipmapLevel(),M=r.state;M.setBlending(Ft),M.buffers.color.setClear(1,1,1,1),M.buffers.depth.setTest(!0),M.setScissorTest(!1);for(let I=0,P=b.length;I<P;I++){let C=b[I],D=C.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",C,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;i.copy(D.mapSize);let B=D.getFrameExtents();if(i.multiply(B),s.copy(D.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/B.x),i.x=s.x*B.x,D.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/B.y),i.y=s.y*B.y,D.mapSize.y=s.y)),D.map===null){let X=this.type!==bd?{minFilter:Bt,magFilter:Bt}:{};D.map=new At(i.x,i.y,X),D.map.texture.name=C.name+".shadowMap",D.camera.updateProjectionMatrix()}r.setRenderTarget(D.map),r.clear();let k=D.getViewportCount();for(let X=0;X<k;X++){let W=D.getViewport(X);o.set(s.x*W.x,s.y*W.y,s.x*W.z,s.y*W.w),M.viewport(o),D.updateMatrices(C,X),n=D.getFrustum(),x(w,A,D.camera,C,this.type)}D.isPointLightShadow!==!0&&this.type===bd&&y(D,A),D.needsUpdate=!1}m.needsUpdate=!1,r.setRenderTarget(T,S,E)};function y(b,w){let A=t.update(p);h.defines.VSM_SAMPLES!==b.blurSamples&&(h.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new At(i.x,i.y)),h.uniforms.shadow_pass.value=b.map.texture,h.uniforms.resolution.value=b.mapSize,h.uniforms.radius.value=b.radius,r.setRenderTarget(b.mapPass),r.clear(),r.renderBufferDirect(w,null,A,h,p,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,r.setRenderTarget(b.map),r.clear(),r.renderBufferDirect(w,null,A,f,p,null)}function v(b,w,A,T,S,E){let M=null,I=A.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(I!==void 0)M=I;else if(M=A.isPointLight===!0?l:a,r.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 P=M.uuid,C=w.uuid,D=u[P];D===void 0&&(D={},u[P]=D);let B=D[C];B===void 0&&(B=M.clone(),D[C]=B),M=B}return M.visible=w.visible,M.wireframe=w.wireframe,E===bd?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:d[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,A.isPointLight===!0&&M.isMeshDistanceMaterial===!0&&(M.referencePosition.setFromMatrixPosition(A.matrixWorld),M.nearDistance=T,M.farDistance=S),M}function x(b,w,A,T,S){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&S===bd)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);let I=t.update(b),P=b.material;if(Array.isArray(P)){let C=I.groups;for(let D=0,B=C.length;D<B;D++){let k=C[D],X=P[k.materialIndex];if(X&&X.visible){let W=v(b,X,T,A.near,A.far,S);r.renderBufferDirect(A,null,I,W,b,k)}}}else if(P.visible){let C=v(b,P,T,A.near,A.far,S);r.renderBufferDirect(A,null,I,C,b,null)}}let M=b.children;for(let I=0,P=M.length;I<P;I++)x(M[I],w,A,T,S)}}function iN(r,t,e){let n=e.isWebGL2;function i(){let Y=!1,se=new Qe,ye=null,Ce=new Qe(0,0,0,0);return{setMask:function(Ue){ye!==Ue&&!Y&&(r.colorMask(Ue,Ue,Ue,Ue),ye=Ue)},setLocked:function(Ue){Y=Ue},setClear:function(Ue,tt,$t,Nn,ri){ri===!0&&(Ue*=Nn,tt*=Nn,$t*=Nn),se.set(Ue,tt,$t,Nn),Ce.equals(se)===!1&&(r.clearColor(Ue,tt,$t,Nn),Ce.copy(se))},reset:function(){Y=!1,ye=null,Ce.set(-1,0,0,0)}}}function s(){let Y=!1,se=null,ye=null,Ce=null;return{setTest:function(Ue){Ue?re(2929):Z(2929)},setMask:function(Ue){se!==Ue&&!Y&&(r.depthMask(Ue),se=Ue)},setFunc:function(Ue){if(ye!==Ue){switch(Ue){case LI:r.depthFunc(512);break;case RI:r.depthFunc(519);break;case NI:r.depthFunc(513);break;case Iv:r.depthFunc(515);break;case BI:r.depthFunc(514);break;case FI:r.depthFunc(518);break;case UI:r.depthFunc(516);break;case GI:r.depthFunc(517);break;default:r.depthFunc(515)}ye=Ue}},setLocked:function(Ue){Y=Ue},setClear:function(Ue){Ce!==Ue&&(r.clearDepth(Ue),Ce=Ue)},reset:function(){Y=!1,se=null,ye=null,Ce=null}}}function o(){let Y=!1,se=null,ye=null,Ce=null,Ue=null,tt=null,$t=null,Nn=null,ri=null;return{setTest:function(Ht){Y||(Ht?re(2960):Z(2960))},setMask:function(Ht){se!==Ht&&!Y&&(r.stencilMask(Ht),se=Ht)},setFunc:function(Ht,Is,ii){(ye!==Ht||Ce!==Is||Ue!==ii)&&(r.stencilFunc(Ht,Is,ii),ye=Ht,Ce=Is,Ue=ii)},setOp:function(Ht,Is,ii){(tt!==Ht||$t!==Is||Nn!==ii)&&(r.stencilOp(Ht,Is,ii),tt=Ht,$t=Is,Nn=ii)},setLocked:function(Ht){Y=Ht},setClear:function(Ht){ri!==Ht&&(r.clearStencil(Ht),ri=Ht)},reset:function(){Y=!1,se=null,ye=null,Ce=null,Ue=null,tt=null,$t=null,Nn=null,ri=null}}}let a=new i,l=new s,u=new o,c=new WeakMap,d=new WeakMap,h={},f={},g=new WeakMap,p=[],m=null,y=!1,v=null,x=null,b=null,w=null,A=null,T=null,S=null,E=!1,M=null,I=null,P=null,C=null,D=null,B=r.getParameter(35661),k=!1,X=0,W=r.getParameter(7938);W.indexOf("WebGL")!==-1?(X=parseFloat(/^WebGL (\d)/.exec(W)[1]),k=X>=1):W.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(W)[1]),k=X>=2);let q=null,H={},K=r.getParameter(3088),R=r.getParameter(2978),U=new Qe().fromArray(K),z=new Qe().fromArray(R);function j(Y,se,ye){let Ce=new Uint8Array(4),Ue=r.createTexture();r.bindTexture(Y,Ue),r.texParameteri(Y,10241,9728),r.texParameteri(Y,10240,9728);for(let tt=0;tt<ye;tt++)r.texImage2D(se+tt,0,6408,1,1,0,6408,5121,Ce);return Ue}let G={};G[3553]=j(3553,3553,1),G[34067]=j(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),re(2929),l.setFunc(Iv),me(!1),Me(JS),re(2884),fe(Ft);function re(Y){h[Y]!==!0&&(r.enable(Y),h[Y]=!0)}function Z(Y){h[Y]!==!1&&(r.disable(Y),h[Y]=!1)}function J(Y,se){return f[Y]!==se?(r.bindFramebuffer(Y,se),f[Y]=se,n&&(Y===36009&&(f[36160]=se),Y===36160&&(f[36009]=se)),!0):!1}function V(Y,se){let ye=p,Ce=!1;if(Y)if(ye=g.get(se),ye===void 0&&(ye=[],g.set(se,ye)),Y.isWebGLMultipleRenderTargets){let Ue=Y.texture;if(ye.length!==Ue.length||ye[0]!==36064){for(let tt=0,$t=Ue.length;tt<$t;tt++)ye[tt]=36064+tt;ye.length=Ue.length,Ce=!0}}else ye[0]!==36064&&(ye[0]=36064,Ce=!0);else ye[0]!==1029&&(ye[0]=1029,Ce=!0);Ce&&(e.isWebGL2?r.drawBuffers(ye):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ye))}function pe(Y){return m!==Y?(r.useProgram(Y),m=Y,!0):!1}let ie={[Ol]:32774,[wI]:32778,[AI]:32779};if(n)ie[nw]=32775,ie[rw]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(ie[nw]=Y.MIN_EXT,ie[rw]=Y.MAX_EXT)}let ae={[_I]:0,[TI]:1,[EI]:768,[I1]:770,[OI]:776,[II]:774,[CI]:772,[MI]:769,[D1]:771,[DI]:775,[PI]:773};function fe(Y,se,ye,Ce,Ue,tt,$t,Nn){if(Y===Ft){y===!0&&(Z(3042),y=!1);return}if(y===!1&&(re(3042),y=!0),Y!==SI){if(Y!==v||Nn!==E){if((x!==Ol||A!==Ol)&&(r.blendEquation(32774),x=Ol,A=Ol),Nn)switch(Y){case Nl:r.blendFuncSeparate(1,771,1,771);break;case $S:r.blendFunc(1,1);break;case ew:r.blendFuncSeparate(0,769,0,1);break;case tw:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case Nl:r.blendFuncSeparate(770,771,1,771);break;case $S:r.blendFunc(770,1);break;case ew:r.blendFuncSeparate(0,769,0,1);break;case tw:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}b=null,w=null,T=null,S=null,v=Y,E=Nn}return}Ue=Ue||se,tt=tt||ye,$t=$t||Ce,(se!==x||Ue!==A)&&(r.blendEquationSeparate(ie[se],ie[Ue]),x=se,A=Ue),(ye!==b||Ce!==w||tt!==T||$t!==S)&&(r.blendFuncSeparate(ae[ye],ae[Ce],ae[tt],ae[$t]),b=ye,w=Ce,T=tt,S=$t),v=Y,E=!1}function xe(Y,se){Y.side===fr?Z(2884):re(2884);let ye=Y.side===bn;se&&(ye=!ye),me(ye),Y.blending===Nl&&Y.transparent===!1?fe(Ft):fe(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 Ce=Y.stencilWrite;u.setTest(Ce),Ce&&(u.setMask(Y.stencilWriteMask),u.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),u.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),be(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?re(32926):Z(32926)}function me(Y){M!==Y&&(Y?r.frontFace(2304):r.frontFace(2305),M=Y)}function Me(Y){Y!==xI?(re(2884),Y!==I&&(Y===JS?r.cullFace(1029):Y===bI?r.cullFace(1028):r.cullFace(1032))):Z(2884),I=Y}function Pe(Y){Y!==P&&(k&&r.lineWidth(Y),P=Y)}function be(Y,se,ye){Y?(re(32823),(C!==se||D!==ye)&&(r.polygonOffset(se,ye),C=se,D=ye)):Z(32823)}function Fe(Y){Y?re(3089):Z(3089)}function ht(Y){Y===void 0&&(Y=33984+B-1),q!==Y&&(r.activeTexture(Y),q=Y)}function L(Y,se,ye){ye===void 0&&(q===null?ye=33984+B-1:ye=q);let Ce=H[ye];Ce===void 0&&(Ce={type:void 0,texture:void 0},H[ye]=Ce),(Ce.type!==Y||Ce.texture!==se)&&(q!==ye&&(r.activeTexture(ye),q=ye),r.bindTexture(Y,se||G[Y]),Ce.type=Y,Ce.texture=se)}function O(){let Y=H[q];Y!==void 0&&Y.type!==void 0&&(r.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function ee(){try{r.compressedTexImage2D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function he(){try{r.compressedTexImage3D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ge(){try{r.texSubImage2D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ie(){try{r.texSubImage3D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ge(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function De(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ue(){try{r.texStorage2D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function je(){try{r.texStorage3D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function qe(){try{r.texImage2D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function _e(){try{r.texImage3D.apply(r,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Re(Y){U.equals(Y)===!1&&(r.scissor(Y.x,Y.y,Y.z,Y.w),U.copy(Y))}function Ne(Y){z.equals(Y)===!1&&(r.viewport(Y.x,Y.y,Y.z,Y.w),z.copy(Y))}function pt(Y,se){let ye=d.get(se);ye===void 0&&(ye=new WeakMap,d.set(se,ye));let Ce=ye.get(Y);Ce===void 0&&(Ce=r.getUniformBlockIndex(se,Y.name),ye.set(Y,Ce))}function Nt(Y,se){let Ce=d.get(se).get(Y);c.get(se)!==Ce&&(r.uniformBlockBinding(se,Ce,Y.__bindingPointIndex),c.set(se,Ce))}function gn(){r.disable(3042),r.disable(2884),r.disable(2929),r.disable(32823),r.disable(3089),r.disable(2960),r.disable(32926),r.blendEquation(32774),r.blendFunc(1,0),r.blendFuncSeparate(1,0,1,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(513),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(519,0,4294967295),r.stencilOp(7680,7680,7680),r.clearStencil(0),r.cullFace(1029),r.frontFace(2305),r.polygonOffset(0,0),r.activeTexture(33984),r.bindFramebuffer(36160,null),n===!0&&(r.bindFramebuffer(36009,null),r.bindFramebuffer(36008,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},q=null,H={},f={},g=new WeakMap,p=[],m=null,y=!1,v=null,x=null,b=null,w=null,A=null,T=null,S=null,E=!1,M=null,I=null,P=null,C=null,D=null,U.set(0,0,r.canvas.width,r.canvas.height),z.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:re,disable:Z,bindFramebuffer:J,drawBuffers:V,useProgram:pe,setBlending:fe,setMaterial:xe,setFlipSided:me,setCullFace:Me,setLineWidth:Pe,setPolygonOffset:be,setScissorTest:Fe,activeTexture:ht,bindTexture:L,unbindTexture:O,compressedTexImage2D:ee,compressedTexImage3D:he,texImage2D:qe,texImage3D:_e,updateUBOMapping:pt,uniformBlockBinding:Nt,texStorage2D:ue,texStorage3D:je,texSubImage2D:ge,texSubImage3D:Ie,compressedTexSubImage2D:Ge,compressedTexSubImage3D:De,scissor:Re,viewport:Ne,reset:gn}}function sN(r,t,e,n,i,s,o){let a=i.isWebGL2,l=i.maxTextures,u=i.maxCubemapSize,c=i.maxTextureSize,d=i.maxSamples,h=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),g=new WeakMap,p,m=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(L,O){return y?new OffscreenCanvas(L,O):ap("canvas")}function x(L,O,ee,he){let ge=1;if((L.width>he||L.height>he)&&(ge=he/Math.max(L.width,L.height)),ge<1||O===!0)if(typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&L instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&L instanceof ImageBitmap){let Ie=O?op:Math.floor,Ge=Ie(ge*L.width),De=Ie(ge*L.height);p===void 0&&(p=v(Ge,De));let ue=ee?v(Ge,De):p;return ue.width=Ge,ue.height=De,ue.getContext("2d").drawImage(L,0,0,Ge,De),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+L.width+"x"+L.height+") to ("+Ge+"x"+De+")."),ue}else return"data"in L&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+L.width+"x"+L.height+")."),L;return L}function b(L){return Bv(L.width)&&Bv(L.height)}function w(L){return a?!1:L.wrapS!==hr||L.wrapT!==hr||L.minFilter!==Bt&&L.minFilter!==st}function A(L,O){return L.generateMipmaps&&O&&L.minFilter!==Bt&&L.minFilter!==st}function T(L){r.generateMipmap(L)}function S(L,O,ee,he,ge=!1){if(a===!1)return O;if(L!==null){if(r[L]!==void 0)return r[L];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+L+"'")}let Ie=O;return O===6403&&(ee===5126&&(Ie=33326),ee===5131&&(Ie=33325),ee===5121&&(Ie=33321)),O===33319&&(ee===5126&&(Ie=33328),ee===5131&&(Ie=33327),ee===5121&&(Ie=33323)),O===6408&&(ee===5126&&(Ie=34836),ee===5131&&(Ie=34842),ee===5121&&(Ie=he===Xe&&ge===!1?35907:32856),ee===32819&&(Ie=32854),ee===32820&&(Ie=32855)),(Ie===33325||Ie===33326||Ie===33327||Ie===33328||Ie===34842||Ie===34836)&&t.get("EXT_color_buffer_float"),Ie}function E(L,O,ee){return A(L,ee)===!0||L.isFramebufferTexture&&L.minFilter!==Bt&&L.minFilter!==st?Math.log2(Math.max(O.width,O.height))+1:L.mipmaps!==void 0&&L.mipmaps.length>0?L.mipmaps.length:L.isCompressedTexture&&Array.isArray(L.image)?O.mipmaps.length:1}function M(L){return L===Bt||L===iw||L===Xy?9728:9729}function I(L){let O=L.target;O.removeEventListener("dispose",I),C(O),O.isVideoTexture&&g.delete(O)}function P(L){let O=L.target;O.removeEventListener("dispose",P),B(O)}function C(L){let O=n.get(L);if(O.__webglInit===void 0)return;let ee=L.source,he=m.get(ee);if(he){let ge=he[O.__cacheKey];ge.usedTimes--,ge.usedTimes===0&&D(L),Object.keys(he).length===0&&m.delete(ee)}n.remove(L)}function D(L){let O=n.get(L);r.deleteTexture(O.__webglTexture);let ee=L.source,he=m.get(ee);delete he[O.__cacheKey],o.memory.textures--}function B(L){let O=L.texture,ee=n.get(L),he=n.get(O);if(he.__webglTexture!==void 0&&(r.deleteTexture(he.__webglTexture),o.memory.textures--),L.depthTexture&&L.depthTexture.dispose(),L.isWebGLCubeRenderTarget)for(let ge=0;ge<6;ge++)r.deleteFramebuffer(ee.__webglFramebuffer[ge]),ee.__webglDepthbuffer&&r.deleteRenderbuffer(ee.__webglDepthbuffer[ge]);else{if(r.deleteFramebuffer(ee.__webglFramebuffer),ee.__webglDepthbuffer&&r.deleteRenderbuffer(ee.__webglDepthbuffer),ee.__webglMultisampledFramebuffer&&r.deleteFramebuffer(ee.__webglMultisampledFramebuffer),ee.__webglColorRenderbuffer)for(let ge=0;ge<ee.__webglColorRenderbuffer.length;ge++)ee.__webglColorRenderbuffer[ge]&&r.deleteRenderbuffer(ee.__webglColorRenderbuffer[ge]);ee.__webglDepthRenderbuffer&&r.deleteRenderbuffer(ee.__webglDepthRenderbuffer)}if(L.isWebGLMultipleRenderTargets)for(let ge=0,Ie=O.length;ge<Ie;ge++){let Ge=n.get(O[ge]);Ge.__webglTexture&&(r.deleteTexture(Ge.__webglTexture),o.memory.textures--),n.remove(O[ge])}n.remove(O),n.remove(L)}let k=0;function X(){k=0}function W(){let L=k;return L>=l&&console.warn("THREE.WebGLTextures: Trying to use "+L+" texture units while this GPU supports only "+l),k+=1,L}function q(L){let O=[];return O.push(L.wrapS),O.push(L.wrapT),O.push(L.wrapR||0),O.push(L.magFilter),O.push(L.minFilter),O.push(L.anisotropy),O.push(L.internalFormat),O.push(L.format),O.push(L.type),O.push(L.generateMipmaps),O.push(L.premultiplyAlpha),O.push(L.flipY),O.push(L.unpackAlignment),O.push(L.encoding),O.join()}function H(L,O){let ee=n.get(L);if(L.isVideoTexture&&Fe(L),L.isRenderTargetTexture===!1&&L.version>0&&ee.__version!==L.version){let he=L.image;if(he===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(he.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Z(ee,L,O);return}}e.bindTexture(3553,ee.__webglTexture,33984+O)}function K(L,O){let ee=n.get(L);if(L.version>0&&ee.__version!==L.version){Z(ee,L,O);return}e.bindTexture(35866,ee.__webglTexture,33984+O)}function R(L,O){let ee=n.get(L);if(L.version>0&&ee.__version!==L.version){Z(ee,L,O);return}e.bindTexture(32879,ee.__webglTexture,33984+O)}function U(L,O){let ee=n.get(L);if(L.version>0&&ee.__version!==L.version){J(ee,L,O);return}e.bindTexture(34067,ee.__webglTexture,33984+O)}let z={[Fl]:10497,[hr]:33071,[Lv]:33648},j={[Bt]:9728,[iw]:9984,[Xy]:9986,[st]:9729,[XI]:9985,[Ta]:9987};function G(L,O,ee){if(ee?(r.texParameteri(L,10242,z[O.wrapS]),r.texParameteri(L,10243,z[O.wrapT]),(L===32879||L===35866)&&r.texParameteri(L,32882,z[O.wrapR]),r.texParameteri(L,10240,j[O.magFilter]),r.texParameteri(L,10241,j[O.minFilter])):(r.texParameteri(L,10242,33071),r.texParameteri(L,10243,33071),(L===32879||L===35866)&&r.texParameteri(L,32882,33071),(O.wrapS!==hr||O.wrapT!==hr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(L,10240,M(O.magFilter)),r.texParameteri(L,10241,M(O.minFilter)),O.minFilter!==Bt&&O.minFilter!==st&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let he=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===Bt||O.minFilter!==Xy&&O.minFilter!==Ta||O.type===Zi&&t.has("OES_texture_float_linear")===!1||a===!1&&O.type===Md&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||n.get(O).__currentAnisotropy)&&(r.texParameterf(L,he.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),n.get(O).__currentAnisotropy=O.anisotropy)}}function re(L,O){let ee=!1;L.__webglInit===void 0&&(L.__webglInit=!0,O.addEventListener("dispose",I));let he=O.source,ge=m.get(he);ge===void 0&&(ge={},m.set(he,ge));let Ie=q(O);if(Ie!==L.__cacheKey){ge[Ie]===void 0&&(ge[Ie]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),ge[Ie].usedTimes++;let Ge=ge[L.__cacheKey];Ge!==void 0&&(ge[L.__cacheKey].usedTimes--,Ge.usedTimes===0&&D(O)),L.__cacheKey=Ie,L.__webglTexture=ge[Ie].texture}return ee}function Z(L,O,ee){let he=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(he=35866),O.isData3DTexture&&(he=32879);let ge=re(L,O),Ie=O.source;e.bindTexture(he,L.__webglTexture,33984+ee);let Ge=n.get(Ie);if(Ie.version!==Ge.__version||ge===!0){e.activeTexture(33984+ee),r.pixelStorei(37440,O.flipY),r.pixelStorei(37441,O.premultiplyAlpha),r.pixelStorei(3317,O.unpackAlignment),r.pixelStorei(37443,0);let De=w(O)&&b(O.image)===!1,ue=x(O.image,De,!1,c);ue=ht(O,ue);let je=b(ue)||a,qe=s.convert(O.format,O.encoding),_e=s.convert(O.type),Re=S(O.internalFormat,qe,_e,O.encoding,O.isVideoTexture);G(he,O,je);let Ne,pt=O.mipmaps,Nt=a&&O.isVideoTexture!==!0,gn=Ge.__version===void 0||ge===!0,Y=E(O,ue,je);if(O.isDepthTexture)Re=6402,a?O.type===Zi?Re=36012:O.type===Us?Re=33190:O.type===So?Re=35056:Re=33189:O.type===Zi&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===Aa&&Re===6402&&O.type!==R1&&O.type!==Us&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=Us,_e=s.convert(O.type)),O.format===_o&&Re===6402&&(Re=34041,O.type!==So&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=So,_e=s.convert(O.type))),gn&&(Nt?e.texStorage2D(3553,1,Re,ue.width,ue.height):e.texImage2D(3553,0,Re,ue.width,ue.height,0,qe,_e,null));else if(O.isDataTexture)if(pt.length>0&&je){Nt&&gn&&e.texStorage2D(3553,Y,Re,pt[0].width,pt[0].height);for(let se=0,ye=pt.length;se<ye;se++)Ne=pt[se],Nt?e.texSubImage2D(3553,se,0,0,Ne.width,Ne.height,qe,_e,Ne.data):e.texImage2D(3553,se,Re,Ne.width,Ne.height,0,qe,_e,Ne.data);O.generateMipmaps=!1}else Nt?(gn&&e.texStorage2D(3553,Y,Re,ue.width,ue.height),e.texSubImage2D(3553,0,0,0,ue.width,ue.height,qe,_e,ue.data)):e.texImage2D(3553,0,Re,ue.width,ue.height,0,qe,_e,ue.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Nt&&gn&&e.texStorage3D(35866,Y,Re,pt[0].width,pt[0].height,ue.depth);for(let se=0,ye=pt.length;se<ye;se++)Ne=pt[se],O.format!==oi?qe!==null?Nt?e.compressedTexSubImage3D(35866,se,0,0,0,Ne.width,Ne.height,ue.depth,qe,Ne.data,0,0):e.compressedTexImage3D(35866,se,Re,Ne.width,Ne.height,ue.depth,0,Ne.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Nt?e.texSubImage3D(35866,se,0,0,0,Ne.width,Ne.height,ue.depth,qe,_e,Ne.data):e.texImage3D(35866,se,Re,Ne.width,Ne.height,ue.depth,0,qe,_e,Ne.data)}else{Nt&&gn&&e.texStorage2D(3553,Y,Re,pt[0].width,pt[0].height);for(let se=0,ye=pt.length;se<ye;se++)Ne=pt[se],O.format!==oi?qe!==null?Nt?e.compressedTexSubImage2D(3553,se,0,0,Ne.width,Ne.height,qe,Ne.data):e.compressedTexImage2D(3553,se,Re,Ne.width,Ne.height,0,Ne.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Nt?e.texSubImage2D(3553,se,0,0,Ne.width,Ne.height,qe,_e,Ne.data):e.texImage2D(3553,se,Re,Ne.width,Ne.height,0,qe,_e,Ne.data)}else if(O.isDataArrayTexture)Nt?(gn&&e.texStorage3D(35866,Y,Re,ue.width,ue.height,ue.depth),e.texSubImage3D(35866,0,0,0,0,ue.width,ue.height,ue.depth,qe,_e,ue.data)):e.texImage3D(35866,0,Re,ue.width,ue.height,ue.depth,0,qe,_e,ue.data);else if(O.isData3DTexture)Nt?(gn&&e.texStorage3D(32879,Y,Re,ue.width,ue.height,ue.depth),e.texSubImage3D(32879,0,0,0,0,ue.width,ue.height,ue.depth,qe,_e,ue.data)):e.texImage3D(32879,0,Re,ue.width,ue.height,ue.depth,0,qe,_e,ue.data);else if(O.isFramebufferTexture){if(gn)if(Nt)e.texStorage2D(3553,Y,Re,ue.width,ue.height);else{let se=ue.width,ye=ue.height;for(let Ce=0;Ce<Y;Ce++)e.texImage2D(3553,Ce,Re,se,ye,0,qe,_e,null),se>>=1,ye>>=1}}else if(pt.length>0&&je){Nt&&gn&&e.texStorage2D(3553,Y,Re,pt[0].width,pt[0].height);for(let se=0,ye=pt.length;se<ye;se++)Ne=pt[se],Nt?e.texSubImage2D(3553,se,0,0,qe,_e,Ne):e.texImage2D(3553,se,Re,qe,_e,Ne);O.generateMipmaps=!1}else Nt?(gn&&e.texStorage2D(3553,Y,Re,ue.width,ue.height),e.texSubImage2D(3553,0,0,0,qe,_e,ue)):e.texImage2D(3553,0,Re,qe,_e,ue);A(O,je)&&T(he),Ge.__version=Ie.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function J(L,O,ee){if(O.image.length!==6)return;let he=re(L,O),ge=O.source;e.bindTexture(34067,L.__webglTexture,33984+ee);let Ie=n.get(ge);if(ge.version!==Ie.__version||he===!0){e.activeTexture(33984+ee),r.pixelStorei(37440,O.flipY),r.pixelStorei(37441,O.premultiplyAlpha),r.pixelStorei(3317,O.unpackAlignment),r.pixelStorei(37443,0);let Ge=O.isCompressedTexture||O.image[0].isCompressedTexture,De=O.image[0]&&O.image[0].isDataTexture,ue=[];for(let se=0;se<6;se++)!Ge&&!De?ue[se]=x(O.image[se],!1,!0,u):ue[se]=De?O.image[se].image:O.image[se],ue[se]=ht(O,ue[se]);let je=ue[0],qe=b(je)||a,_e=s.convert(O.format,O.encoding),Re=s.convert(O.type),Ne=S(O.internalFormat,_e,Re,O.encoding),pt=a&&O.isVideoTexture!==!0,Nt=Ie.__version===void 0||he===!0,gn=E(O,je,qe);G(34067,O,qe);let Y;if(Ge){pt&&Nt&&e.texStorage2D(34067,gn,Ne,je.width,je.height);for(let se=0;se<6;se++){Y=ue[se].mipmaps;for(let ye=0;ye<Y.length;ye++){let Ce=Y[ye];O.format!==oi?_e!==null?pt?e.compressedTexSubImage2D(34069+se,ye,0,0,Ce.width,Ce.height,_e,Ce.data):e.compressedTexImage2D(34069+se,ye,Ne,Ce.width,Ce.height,0,Ce.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):pt?e.texSubImage2D(34069+se,ye,0,0,Ce.width,Ce.height,_e,Re,Ce.data):e.texImage2D(34069+se,ye,Ne,Ce.width,Ce.height,0,_e,Re,Ce.data)}}}else{Y=O.mipmaps,pt&&Nt&&(Y.length>0&&gn++,e.texStorage2D(34067,gn,Ne,ue[0].width,ue[0].height));for(let se=0;se<6;se++)if(De){pt?e.texSubImage2D(34069+se,0,0,0,ue[se].width,ue[se].height,_e,Re,ue[se].data):e.texImage2D(34069+se,0,Ne,ue[se].width,ue[se].height,0,_e,Re,ue[se].data);for(let ye=0;ye<Y.length;ye++){let Ue=Y[ye].image[se].image;pt?e.texSubImage2D(34069+se,ye+1,0,0,Ue.width,Ue.height,_e,Re,Ue.data):e.texImage2D(34069+se,ye+1,Ne,Ue.width,Ue.height,0,_e,Re,Ue.data)}}else{pt?e.texSubImage2D(34069+se,0,0,0,_e,Re,ue[se]):e.texImage2D(34069+se,0,Ne,_e,Re,ue[se]);for(let ye=0;ye<Y.length;ye++){let Ce=Y[ye];pt?e.texSubImage2D(34069+se,ye+1,0,0,_e,Re,Ce.image[se]):e.texImage2D(34069+se,ye+1,Ne,_e,Re,Ce.image[se])}}}A(O,qe)&&T(34067),Ie.__version=ge.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function V(L,O,ee,he,ge){let Ie=s.convert(ee.format,ee.encoding),Ge=s.convert(ee.type),De=S(ee.internalFormat,Ie,Ge,ee.encoding);n.get(O).__hasExternalTextures||(ge===32879||ge===35866?e.texImage3D(ge,0,De,O.width,O.height,O.depth,0,Ie,Ge,null):e.texImage2D(ge,0,De,O.width,O.height,0,Ie,Ge,null)),e.bindFramebuffer(36160,L),be(O)?h.framebufferTexture2DMultisampleEXT(36160,he,ge,n.get(ee).__webglTexture,0,Pe(O)):(ge===3553||ge>=34069&&ge<=34074)&&r.framebufferTexture2D(36160,he,ge,n.get(ee).__webglTexture,0),e.bindFramebuffer(36160,null)}function pe(L,O,ee){if(r.bindRenderbuffer(36161,L),O.depthBuffer&&!O.stencilBuffer){let he=33189;if(ee||be(O)){let ge=O.depthTexture;ge&&ge.isDepthTexture&&(ge.type===Zi?he=36012:ge.type===Us&&(he=33190));let Ie=Pe(O);be(O)?h.renderbufferStorageMultisampleEXT(36161,Ie,he,O.width,O.height):r.renderbufferStorageMultisample(36161,Ie,he,O.width,O.height)}else r.renderbufferStorage(36161,he,O.width,O.height);r.framebufferRenderbuffer(36160,36096,36161,L)}else if(O.depthBuffer&&O.stencilBuffer){let he=Pe(O);ee&&be(O)===!1?r.renderbufferStorageMultisample(36161,he,35056,O.width,O.height):be(O)?h.renderbufferStorageMultisampleEXT(36161,he,35056,O.width,O.height):r.renderbufferStorage(36161,34041,O.width,O.height),r.framebufferRenderbuffer(36160,33306,36161,L)}else{let he=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let ge=0;ge<he.length;ge++){let Ie=he[ge],Ge=s.convert(Ie.format,Ie.encoding),De=s.convert(Ie.type),ue=S(Ie.internalFormat,Ge,De,Ie.encoding),je=Pe(O);ee&&be(O)===!1?r.renderbufferStorageMultisample(36161,je,ue,O.width,O.height):be(O)?h.renderbufferStorageMultisampleEXT(36161,je,ue,O.width,O.height):r.renderbufferStorage(36161,ue,O.width,O.height)}}r.bindRenderbuffer(36161,null)}function ie(L,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,L),!(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),H(O.depthTexture,0);let he=n.get(O.depthTexture).__webglTexture,ge=Pe(O);if(O.depthTexture.format===Aa)be(O)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,he,0,ge):r.framebufferTexture2D(36160,36096,3553,he,0);else if(O.depthTexture.format===_o)be(O)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,he,0,ge):r.framebufferTexture2D(36160,33306,3553,he,0);else throw new Error("Unknown depthTexture format")}function ae(L){let O=n.get(L),ee=L.isWebGLCubeRenderTarget===!0;if(L.depthTexture&&!O.__autoAllocateDepthBuffer){if(ee)throw new Error("target.depthTexture not supported in Cube render targets");ie(O.__webglFramebuffer,L)}else if(ee){O.__webglDepthbuffer=[];for(let he=0;he<6;he++)e.bindFramebuffer(36160,O.__webglFramebuffer[he]),O.__webglDepthbuffer[he]=r.createRenderbuffer(),pe(O.__webglDepthbuffer[he],L,!1)}else e.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=r.createRenderbuffer(),pe(O.__webglDepthbuffer,L,!1);e.bindFramebuffer(36160,null)}function fe(L,O,ee){let he=n.get(L);O!==void 0&&V(he.__webglFramebuffer,L,L.texture,36064,3553),ee!==void 0&&ae(L)}function xe(L){let O=L.texture,ee=n.get(L),he=n.get(O);L.addEventListener("dispose",P),L.isWebGLMultipleRenderTargets!==!0&&(he.__webglTexture===void 0&&(he.__webglTexture=r.createTexture()),he.__version=O.version,o.memory.textures++);let ge=L.isWebGLCubeRenderTarget===!0,Ie=L.isWebGLMultipleRenderTargets===!0,Ge=b(L)||a;if(ge){ee.__webglFramebuffer=[];for(let De=0;De<6;De++)ee.__webglFramebuffer[De]=r.createFramebuffer()}else{if(ee.__webglFramebuffer=r.createFramebuffer(),Ie)if(i.drawBuffers){let De=L.texture;for(let ue=0,je=De.length;ue<je;ue++){let qe=n.get(De[ue]);qe.__webglTexture===void 0&&(qe.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&L.samples>0&&be(L)===!1){let De=Ie?O:[O];ee.__webglMultisampledFramebuffer=r.createFramebuffer(),ee.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ee.__webglMultisampledFramebuffer);for(let ue=0;ue<De.length;ue++){let je=De[ue];ee.__webglColorRenderbuffer[ue]=r.createRenderbuffer(),r.bindRenderbuffer(36161,ee.__webglColorRenderbuffer[ue]);let qe=s.convert(je.format,je.encoding),_e=s.convert(je.type),Re=S(je.internalFormat,qe,_e,je.encoding,L.isXRRenderTarget===!0),Ne=Pe(L);r.renderbufferStorageMultisample(36161,Ne,Re,L.width,L.height),r.framebufferRenderbuffer(36160,36064+ue,36161,ee.__webglColorRenderbuffer[ue])}r.bindRenderbuffer(36161,null),L.depthBuffer&&(ee.__webglDepthRenderbuffer=r.createRenderbuffer(),pe(ee.__webglDepthRenderbuffer,L,!0)),e.bindFramebuffer(36160,null)}}if(ge){e.bindTexture(34067,he.__webglTexture),G(34067,O,Ge);for(let De=0;De<6;De++)V(ee.__webglFramebuffer[De],L,O,36064,34069+De);A(O,Ge)&&T(34067),e.unbindTexture()}else if(Ie){let De=L.texture;for(let ue=0,je=De.length;ue<je;ue++){let qe=De[ue],_e=n.get(qe);e.bindTexture(3553,_e.__webglTexture),G(3553,qe,Ge),V(ee.__webglFramebuffer,L,qe,36064+ue,3553),A(qe,Ge)&&T(3553)}e.unbindTexture()}else{let De=3553;(L.isWebGL3DRenderTarget||L.isWebGLArrayRenderTarget)&&(a?De=L.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(De,he.__webglTexture),G(De,O,Ge),V(ee.__webglFramebuffer,L,O,36064,De),A(O,Ge)&&T(De),e.unbindTexture()}L.depthBuffer&&ae(L)}function me(L){let O=b(L)||a,ee=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let he=0,ge=ee.length;he<ge;he++){let Ie=ee[he];if(A(Ie,O)){let Ge=L.isWebGLCubeRenderTarget?34067:3553,De=n.get(Ie).__webglTexture;e.bindTexture(Ge,De),T(Ge),e.unbindTexture()}}}function Me(L){if(a&&L.samples>0&&be(L)===!1){let O=L.isWebGLMultipleRenderTargets?L.texture:[L.texture],ee=L.width,he=L.height,ge=16384,Ie=[],Ge=L.stencilBuffer?33306:36096,De=n.get(L),ue=L.isWebGLMultipleRenderTargets===!0;if(ue)for(let je=0;je<O.length;je++)e.bindFramebuffer(36160,De.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+je,36161,null),e.bindFramebuffer(36160,De.__webglFramebuffer),r.framebufferTexture2D(36009,36064+je,3553,null,0);e.bindFramebuffer(36008,De.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,De.__webglFramebuffer);for(let je=0;je<O.length;je++){Ie.push(36064+je),L.depthBuffer&&Ie.push(Ge);let qe=De.__ignoreDepthValues!==void 0?De.__ignoreDepthValues:!1;if(qe===!1&&(L.depthBuffer&&(ge|=256),L.stencilBuffer&&(ge|=1024)),ue&&r.framebufferRenderbuffer(36008,36064,36161,De.__webglColorRenderbuffer[je]),qe===!0&&(r.invalidateFramebuffer(36008,[Ge]),r.invalidateFramebuffer(36009,[Ge])),ue){let _e=n.get(O[je]).__webglTexture;r.framebufferTexture2D(36009,36064,3553,_e,0)}r.blitFramebuffer(0,0,ee,he,0,0,ee,he,ge,9728),f&&r.invalidateFramebuffer(36008,Ie)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),ue)for(let je=0;je<O.length;je++){e.bindFramebuffer(36160,De.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+je,36161,De.__webglColorRenderbuffer[je]);let qe=n.get(O[je]).__webglTexture;e.bindFramebuffer(36160,De.__webglFramebuffer),r.framebufferTexture2D(36009,36064+je,3553,qe,0)}e.bindFramebuffer(36009,De.__webglMultisampledFramebuffer)}}function Pe(L){return Math.min(d,L.samples)}function be(L){let O=n.get(L);return a&&L.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Fe(L){let O=o.render.frame;g.get(L)!==O&&(g.set(L,O),L.update())}function ht(L,O){let ee=L.encoding,he=L.format,ge=L.type;return L.isCompressedTexture===!0||L.isVideoTexture===!0||L.format===Nv||ee!==jr&&(ee===Xe?a===!1?t.has("EXT_sRGB")===!0&&he===oi?(L.format=Nv,L.minFilter=st,L.generateMipmaps=!1):O=lp.sRGBToLinear(O):(he!==oi||ge!==kt)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ee)),O}this.allocateTextureUnit=W,this.resetTextureUnits=X,this.setTexture2D=H,this.setTexture2DArray=K,this.setTexture3D=R,this.setTextureCube=U,this.rebindTextures=fe,this.setupRenderTarget=xe,this.updateRenderTargetMipmap=me,this.updateMultisampleRenderTarget=Me,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=V,this.useMultisampledRTT=be}function oN(r,t,e){let n=e.isWebGL2;function i(s,o=null){let a;if(s===kt)return 5121;if(s===QI)return 32819;if(s===JI)return 32820;if(s===YI)return 5120;if(s===KI)return 5122;if(s===R1)return 5123;if(s===ZI)return 5124;if(s===Us)return 5125;if(s===Zi)return 5126;if(s===Md)return n?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===$I)return 6406;if(s===oi)return 6408;if(s===eD)return 6409;if(s===tD)return 6410;if(s===Aa)return 6402;if(s===_o)return 34041;if(s===Nv)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===nD)return 6403;if(s===rD)return 36244;if(s===iD)return 33319;if(s===sD)return 33320;if(s===oD)return 36249;if(s===Yy||s===Ky||s===Zy||s===Qy)if(o===Xe)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Yy)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ky)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Zy)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Qy)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Yy)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ky)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Zy)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Qy)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===sw||s===ow||s===aw||s===lw)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===sw)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===ow)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===aw)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===lw)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===aD)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===cw||s===uw)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===cw)return o===Xe?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===uw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===dw||s===hw||s===fw||s===pw||s===mw||s===gw||s===yw||s===vw||s===xw||s===bw||s===Sw||s===ww||s===Aw||s===_w)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===dw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===hw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===fw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===pw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===mw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===gw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===yw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===vw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===xw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===bw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Sw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===ww)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Aw)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===_w)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Jy)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===Jy)return o===Xe?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===lD||s===Tw||s===Ew||s===Mw)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===Jy)return a.COMPRESSED_RED_RGTC1_EXT;if(s===Tw)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Ew)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Mw)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===So?n?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}var qv=class extends cn{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},Qi=class extends ut{constructor(){super(),this.isGroup=!0,this.type="Group"}},aN={type:"move"},_d=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Qi,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 Qi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new _,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new _),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Qi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new _,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new _),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 i=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 p of t.hand.values()){let m=e.getJointPose(p,n),y=this._getHandJoint(u,p);m!==null&&(y.matrix.fromArray(m.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=m.radius),y.visible=m!==null}let c=u.joints["index-finger-tip"],d=u.joints["thumb-tip"],h=c.position.distanceTo(d.position),f=.02,g=.005;u.inputState.pinching&&h>f+g?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&h<=f-g&&(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&&(i=e.getPose(t.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(aN)))}return a!==null&&(a.visible=i!==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 Qi;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},Eo=class extends Gt{constructor(t,e,n,i,s,o,a,l,u,c){if(c=c!==void 0?c:Aa,c!==Aa&&c!==_o)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===Aa&&(n=Us),n===void 0&&c===_o&&(n=So),super(null,i,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Bt,this.minFilter=l!==void 0?l:Bt,this.flipY=!1,this.generateMipmaps=!1}},Xv=class extends Wt{constructor(t,e){super();let n=this,i=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,d=null,h=null,f=null,g=null,p=e.getContextAttributes(),m=null,y=null,v=[],x=[],b=new Set,w=new Map,A=new cn;A.layers.enable(1),A.viewport=new Qe;let T=new cn;T.layers.enable(2),T.viewport=new Qe;let S=[A,T],E=new qv;E.layers.enable(1),E.layers.enable(2);let M=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(R){let U=v[R];return U===void 0&&(U=new _d,v[R]=U),U.getTargetRaySpace()},this.getControllerGrip=function(R){let U=v[R];return U===void 0&&(U=new _d,v[R]=U),U.getGripSpace()},this.getHand=function(R){let U=v[R];return U===void 0&&(U=new _d,v[R]=U),U.getHandSpace()};function P(R){let U=x.indexOf(R.inputSource);if(U===-1)return;let z=v[U];z!==void 0&&z.dispatchEvent({type:R.type,data:R.inputSource})}function C(){i.removeEventListener("select",P),i.removeEventListener("selectstart",P),i.removeEventListener("selectend",P),i.removeEventListener("squeeze",P),i.removeEventListener("squeezestart",P),i.removeEventListener("squeezeend",P),i.removeEventListener("end",C),i.removeEventListener("inputsourceschange",D);for(let R=0;R<v.length;R++){let U=x[R];U!==null&&(x[R]=null,v[R].disconnect(U))}M=null,I=null,t.setRenderTarget(m),f=null,h=null,d=null,i=null,y=null,K.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(R){s=R,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(R){a=R,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(R){u=R},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(R){if(i=R,i!==null){if(m=t.getRenderTarget(),i.addEventListener("select",P),i.addEventListener("selectstart",P),i.addEventListener("selectend",P),i.addEventListener("squeeze",P),i.addEventListener("squeezestart",P),i.addEventListener("squeezeend",P),i.addEventListener("end",C),i.addEventListener("inputsourceschange",D),p.xrCompatible!==!0&&await e.makeXRCompatible(),i.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let U={antialias:i.renderState.layers===void 0?p.antialias:!0,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,e,U),i.updateRenderState({baseLayer:f}),y=new At(f.framebufferWidth,f.framebufferHeight,{format:oi,type:kt,encoding:t.outputEncoding,stencilBuffer:p.stencil})}else{let U=null,z=null,j=null;p.depth&&(j=p.stencil?35056:33190,U=p.stencil?_o:Aa,z=p.stencil?So:Us);let G={colorFormat:32856,depthFormat:j,scaleFactor:s};d=new XRWebGLBinding(i,e),h=d.createProjectionLayer(G),i.updateRenderState({layers:[h]}),y=new At(h.textureWidth,h.textureHeight,{format:oi,type:kt,depthTexture:new Eo(h.textureWidth,h.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,U),stencilBuffer:p.stencil,encoding:t.outputEncoding,samples:p.antialias?4:0});let re=t.properties.get(y);re.__ignoreDepthValues=h.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await i.requestReferenceSpace(a),K.setContext(i),K.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function D(R){for(let U=0;U<R.removed.length;U++){let z=R.removed[U],j=x.indexOf(z);j>=0&&(x[j]=null,v[j].disconnect(z))}for(let U=0;U<R.added.length;U++){let z=R.added[U],j=x.indexOf(z);if(j===-1){for(let re=0;re<v.length;re++)if(re>=x.length){x.push(z),j=re;break}else if(x[re]===null){x[re]=z,j=re;break}if(j===-1)break}let G=v[j];G&&G.connect(z)}}let B=new _,k=new _;function X(R,U,z){B.setFromMatrixPosition(U.matrixWorld),k.setFromMatrixPosition(z.matrixWorld);let j=B.distanceTo(k),G=U.projectionMatrix.elements,re=z.projectionMatrix.elements,Z=G[14]/(G[10]-1),J=G[14]/(G[10]+1),V=(G[9]+1)/G[5],pe=(G[9]-1)/G[5],ie=(G[8]-1)/G[0],ae=(re[8]+1)/re[0],fe=Z*ie,xe=Z*ae,me=j/(-ie+ae),Me=me*-ie;U.matrixWorld.decompose(R.position,R.quaternion,R.scale),R.translateX(Me),R.translateZ(me),R.matrixWorld.compose(R.position,R.quaternion,R.scale),R.matrixWorldInverse.copy(R.matrixWorld).invert();let Pe=Z+me,be=J+me,Fe=fe-Me,ht=xe+(j-Me),L=V*J/be*Pe,O=pe*J/be*Pe;R.projectionMatrix.makePerspective(Fe,ht,L,O,Pe,be)}function W(R,U){U===null?R.matrixWorld.copy(R.matrix):R.matrixWorld.multiplyMatrices(U.matrixWorld,R.matrix),R.matrixWorldInverse.copy(R.matrixWorld).invert()}this.updateCamera=function(R){if(i===null)return;E.near=T.near=A.near=R.near,E.far=T.far=A.far=R.far,(M!==E.near||I!==E.far)&&(i.updateRenderState({depthNear:E.near,depthFar:E.far}),M=E.near,I=E.far);let U=R.parent,z=E.cameras;W(E,U);for(let G=0;G<z.length;G++)W(z[G],U);E.matrixWorld.decompose(E.position,E.quaternion,E.scale),R.matrix.copy(E.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale);let j=R.children;for(let G=0,re=j.length;G<re;G++)j[G].updateMatrixWorld(!0);z.length===2?X(E,A,T):E.projectionMatrix.copy(A.projectionMatrix)},this.getCamera=function(){return E},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(R){l=R,h!==null&&(h.fixedFoveation=R),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=R)},this.getPlanes=function(){return b};let q=null;function H(R,U){if(c=U.getViewerPose(u||o),g=U,c!==null){let z=c.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let j=!1;z.length!==E.cameras.length&&(E.cameras.length=0,j=!0);for(let G=0;G<z.length;G++){let re=z[G],Z=null;if(f!==null)Z=f.getViewport(re);else{let V=d.getViewSubImage(h,re);Z=V.viewport,G===0&&(t.setRenderTargetTextures(y,V.colorTexture,h.ignoreDepthValues?void 0:V.depthStencilTexture),t.setRenderTarget(y))}let J=S[G];J===void 0&&(J=new cn,J.layers.enable(G),J.viewport=new Qe,S[G]=J),J.matrix.fromArray(re.transform.matrix),J.projectionMatrix.fromArray(re.projectionMatrix),J.viewport.set(Z.x,Z.y,Z.width,Z.height),G===0&&E.matrix.copy(J.matrix),j===!0&&E.cameras.push(J)}}for(let z=0;z<v.length;z++){let j=x[z],G=v[z];j!==null&&G!==void 0&&G.update(j,U,u||o)}if(q&&q(R,U),U.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:U.detectedPlanes});let z=null;for(let j of b)U.detectedPlanes.has(j)||(z===null&&(z=[]),z.push(j));if(z!==null)for(let j of z)b.delete(j),w.delete(j),n.dispatchEvent({type:"planeremoved",data:j});for(let j of U.detectedPlanes)if(!b.has(j))b.add(j),w.set(j,U.lastChangedTime),n.dispatchEvent({type:"planeadded",data:j});else{let G=w.get(j);j.lastChangedTime>G&&(w.set(j,j.lastChangedTime),n.dispatchEvent({type:"planechanged",data:j}))}}g=null}let K=new U1;K.setAnimationLoop(H),this.setAnimationLoop=function(R){q=R},this.dispose=function(){}}};function lN(r,t){function e(p,m){m.color.getRGB(p.fogColor.value,F1(r)),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function n(p,m,y,v,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?i(p,m):m.isMeshToonMaterial?(i(p,m),c(p,m)):m.isMeshPhongMaterial?(i(p,m),u(p,m)):m.isMeshStandardMaterial?(i(p,m),d(p,m),m.isMeshPhysicalMaterial&&h(p,m,x)):m.isMeshMatcapMaterial?(i(p,m),f(p,m)):m.isMeshDepthMaterial?i(p,m):m.isMeshDistanceMaterial?(i(p,m),g(p,m)):m.isMeshNormalMaterial?i(p,m):m.isLineBasicMaterial?(s(p,m),m.isLineDashedMaterial&&o(p,m)):m.isPointsMaterial?a(p,m,y,v):m.isSpriteMaterial?l(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function i(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.bumpMap&&(p.bumpMap.value=m.bumpMap,p.bumpScale.value=m.bumpScale,m.side===bn&&(p.bumpScale.value*=-1)),m.displacementMap&&(p.displacementMap.value=m.displacementMap,p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap),m.normalMap&&(p.normalMap.value=m.normalMap,p.normalScale.value.copy(m.normalScale),m.side===bn&&p.normalScale.value.negate()),m.specularMap&&(p.specularMap.value=m.specularMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let y=t.get(m).envMap;if(y&&(p.envMap.value=y,p.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap){p.lightMap.value=m.lightMap;let b=r.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=m.lightMapIntensity*b}m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity);let v;m.map?v=m.map:m.specularMap?v=m.specularMap:m.displacementMap?v=m.displacementMap:m.normalMap?v=m.normalMap:m.bumpMap?v=m.bumpMap:m.roughnessMap?v=m.roughnessMap:m.metalnessMap?v=m.metalnessMap:m.alphaMap?v=m.alphaMap:m.emissiveMap?v=m.emissiveMap:m.clearcoatMap?v=m.clearcoatMap:m.clearcoatNormalMap?v=m.clearcoatNormalMap:m.clearcoatRoughnessMap?v=m.clearcoatRoughnessMap:m.iridescenceMap?v=m.iridescenceMap:m.iridescenceThicknessMap?v=m.iridescenceThicknessMap:m.specularIntensityMap?v=m.specularIntensityMap:m.specularColorMap?v=m.specularColorMap:m.transmissionMap?v=m.transmissionMap:m.thicknessMap?v=m.thicknessMap:m.sheenColorMap?v=m.sheenColorMap:m.sheenRoughnessMap&&(v=m.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix));let x;m.aoMap?x=m.aoMap:m.lightMap&&(x=m.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uv2Transform.value.copy(x.matrix))}function s(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity}function o(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function a(p,m,y,v){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*y,p.scale.value=v*.5,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let x;m.map?x=m.map:m.alphaMap&&(x=m.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uvTransform.value.copy(x.matrix))}function l(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let y;m.map?y=m.map:m.alphaMap&&(y=m.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix))}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function c(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function d(p,m){p.roughness.value=m.roughness,p.metalness.value=m.metalness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function h(p,m,y){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),p.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===bn&&p.clearcoatNormalScale.value.negate())),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap)}function f(p,m){m.matcap&&(p.matcap.value=m.matcap)}function g(p,m){p.referencePosition.value.copy(m.referencePosition),p.nearDistance.value=m.nearDistance,p.farDistance.value=m.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:n}}function cN(r,t,e,n){let i={},s={},o=[],a=e.isWebGL2?r.getParameter(35375):0;function l(v,x){let b=x.program;n.uniformBlockBinding(v,b)}function u(v,x){let b=i[v.id];b===void 0&&(g(v),b=c(v),i[v.id]=b,v.addEventListener("dispose",m));let w=x.program;n.updateUBOMapping(v,w);let A=t.render.frame;s[v.id]!==A&&(h(v),s[v.id]=A)}function c(v){let x=d();v.__bindingPointIndex=x;let b=r.createBuffer(),w=v.__size,A=v.usage;return r.bindBuffer(35345,b),r.bufferData(35345,w,A),r.bindBuffer(35345,null),r.bindBufferBase(35345,x,b),b}function d(){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 h(v){let x=i[v.id],b=v.uniforms,w=v.__cache;r.bindBuffer(35345,x);for(let A=0,T=b.length;A<T;A++){let S=b[A];if(f(S,A,w)===!0){let E=S.__offset,M=Array.isArray(S.value)?S.value:[S.value],I=0;for(let P=0;P<M.length;P++){let C=M[P],D=p(C);typeof C=="number"?(S.__data[0]=C,r.bufferSubData(35345,E+I,S.__data)):C.isMatrix3?(S.__data[0]=C.elements[0],S.__data[1]=C.elements[1],S.__data[2]=C.elements[2],S.__data[3]=C.elements[0],S.__data[4]=C.elements[3],S.__data[5]=C.elements[4],S.__data[6]=C.elements[5],S.__data[7]=C.elements[0],S.__data[8]=C.elements[6],S.__data[9]=C.elements[7],S.__data[10]=C.elements[8],S.__data[11]=C.elements[0]):(C.toArray(S.__data,I),I+=D.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(35345,E,S.__data)}}r.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 A=Array.isArray(w)?w:[w],T=[];for(let S=0;S<A.length;S++)T.push(A[S].clone());b[x]=T}return!0}else if(typeof w=="number"){if(b[x]!==w)return b[x]=w,!0}else{let A=Array.isArray(b[x])?b[x]:[b[x]],T=Array.isArray(w)?w:[w];for(let S=0;S<A.length;S++){let E=A[S];if(E.equals(T[S])===!1)return E.copy(T[S]),!0}}return!1}function g(v){let x=v.uniforms,b=0,w=16,A=0;for(let T=0,S=x.length;T<S;T++){let E=x[T],M={boundary:0,storage:0},I=Array.isArray(E.value)?E.value:[E.value];for(let P=0,C=I.length;P<C;P++){let D=I[P],B=p(D);M.boundary+=B.boundary,M.storage+=B.storage}if(E.__data=new Float32Array(M.storage/Float32Array.BYTES_PER_ELEMENT),E.__offset=b,T>0){A=b%w;let P=w-A;A!==0&&P-M.boundary<0&&(b+=w-A,E.__offset=b)}b+=M.storage}return A=b%w,A>0&&(b+=w-A),v.__size=b,v.__cache={},this}function p(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 m(v){let x=v.target;x.removeEventListener("dispose",m);let b=o.indexOf(x.__bindingPointIndex);o.splice(b,1),r.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function y(){for(let v in i)r.deleteBuffer(i[v]);o=[],i={},s={}}return{bind:l,update:u,dispose:y}}function uN(){let r=ap("canvas");return r.style.display="block",r}function v0(r={}){this.isWebGLRenderer=!0;let t=r.canvas!==void 0?r.canvas:uN(),e=r.context!==void 0?r.context:null,n=r.depth!==void 0?r.depth:!0,i=r.stencil!==void 0?r.stencil:!0,s=r.antialias!==void 0?r.antialias:!1,o=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,a=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,l=r.powerPreference!==void 0?r.powerPreference:"default",u=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,c;e!==null?c=e.getContextAttributes().alpha:c=r.alpha!==void 0?r.alpha:!1;let d=null,h=null,f=[],g=[];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=jr,this.physicallyCorrectLights=!1,this.toneMapping=ks,this.toneMappingExposure=1;let p=this,m=!1,y=0,v=0,x=null,b=-1,w=null,A=new Qe,T=new Qe,S=null,E=t.width,M=t.height,I=1,P=null,C=null,D=new Qe(0,0,E,M),B=new Qe(0,0,E,M),k=!1,X=new Dd,W=!1,q=!1,H=null,K=new de,R=new F,U=new _,z={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function j(){return x===null?I:1}let G=e;function re(N,te){for(let oe=0;oe<N.length;oe++){let $=N[oe],ce=t.getContext($,te);if(ce!==null)return ce}return null}try{let N={alpha:!0,depth:n,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ws}`),t.addEventListener("webglcontextlost",Re,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",pt,!1),G===null){let te=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&te.shift(),G=re(te,N),G===null)throw re(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}G.getShaderPrecisionFormat===void 0&&(G.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let Z,J,V,pe,ie,ae,fe,xe,me,Me,Pe,be,Fe,ht,L,O,ee,he,ge,Ie,Ge,De,ue,je;function qe(){Z=new DR(G),J=new TR(G,Z,r),Z.init(J),De=new oN(G,Z,J),V=new iN(G,Z,J),pe=new RR,ie=new q3,ae=new sN(G,Z,V,ie,J,De,pe),fe=new MR(p),xe=new IR(p),me=new HD(G,J),ue=new AR(G,Z,me,J),Me=new OR(G,me,pe,ue),Pe=new UR(G,Me,me,pe),ge=new FR(G,J,ae),O=new ER(ie),be=new j3(p,fe,xe,Z,J,ue,O),Fe=new lN(p,ie),ht=new Y3,L=new eN(Z,J),he=new wR(p,fe,xe,V,Pe,c,o),ee=new rN(p,Pe,J),je=new cN(G,pe,J,V),Ie=new _R(G,Z,pe,J),Ge=new LR(G,Z,pe,J),pe.programs=be.programs,p.capabilities=J,p.extensions=Z,p.properties=ie,p.renderLists=ht,p.shadowMap=ee,p.state=V,p.info=pe}qe();let _e=new Xv(p,G);this.xr=_e,this.getContext=function(){return G},this.getContextAttributes=function(){return G.getContextAttributes()},this.forceContextLoss=function(){let N=Z.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){let N=Z.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(N){N!==void 0&&(I=N,this.setSize(E,M,!1))},this.getSize=function(N){return N.set(E,M)},this.setSize=function(N,te,oe){if(_e.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}E=N,M=te,t.width=Math.floor(N*I),t.height=Math.floor(te*I),oe!==!1&&(t.style.width=N+"px",t.style.height=te+"px"),this.setViewport(0,0,N,te)},this.getDrawingBufferSize=function(N){return N.set(E*I,M*I).floor()},this.setDrawingBufferSize=function(N,te,oe){E=N,M=te,I=oe,t.width=Math.floor(N*oe),t.height=Math.floor(te*oe),this.setViewport(0,0,N,te)},this.getCurrentViewport=function(N){return N.copy(A)},this.getViewport=function(N){return N.copy(D)},this.setViewport=function(N,te,oe,$){N.isVector4?D.set(N.x,N.y,N.z,N.w):D.set(N,te,oe,$),V.viewport(A.copy(D).multiplyScalar(I).floor())},this.getScissor=function(N){return N.copy(B)},this.setScissor=function(N,te,oe,$){N.isVector4?B.set(N.x,N.y,N.z,N.w):B.set(N,te,oe,$),V.scissor(T.copy(B).multiplyScalar(I).floor())},this.getScissorTest=function(){return k},this.setScissorTest=function(N){V.setScissorTest(k=N)},this.setOpaqueSort=function(N){P=N},this.setTransparentSort=function(N){C=N},this.getClearColor=function(N){return N.copy(he.getClearColor())},this.setClearColor=function(){he.setClearColor.apply(he,arguments)},this.getClearAlpha=function(){return he.getClearAlpha()},this.setClearAlpha=function(){he.setClearAlpha.apply(he,arguments)},this.clear=function(N=!0,te=!0,oe=!0){let $=0;N&&($|=16384),te&&($|=256),oe&&($|=1024),G.clear($)},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",Re,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",pt,!1),ht.dispose(),L.dispose(),ie.dispose(),fe.dispose(),xe.dispose(),Pe.dispose(),ue.dispose(),je.dispose(),be.dispose(),_e.dispose(),_e.removeEventListener("sessionstart",Ce),_e.removeEventListener("sessionend",Ue),H&&(H.dispose(),H=null),tt.stop()};function Re(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let N=pe.autoReset,te=ee.enabled,oe=ee.autoUpdate,$=ee.needsUpdate,ce=ee.type;qe(),pe.autoReset=N,ee.enabled=te,ee.autoUpdate=oe,ee.needsUpdate=$,ee.type=ce}function pt(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function Nt(N){let te=N.target;te.removeEventListener("dispose",Nt),gn(te)}function gn(N){Y(N),ie.remove(N)}function Y(N){let te=ie.get(N).programs;te!==void 0&&(te.forEach(function(oe){be.releaseProgram(oe)}),N.isShaderMaterial&&be.releaseShaderCache(N))}this.renderBufferDirect=function(N,te,oe,$,ce,Ze){te===null&&(te=z);let it=ce.isMesh&&ce.matrixWorld.determinant()<0,at=lI(N,te,oe,$,ce);V.setMaterial($,it);let ct=oe.index,wt=1;$.wireframe===!0&&(ct=Me.getWireframeAttribute(oe),wt=2);let mt=oe.drawRange,gt=oe.attributes.position,yn=mt.start*wt,kr=(mt.start+mt.count)*wt;Ze!==null&&(yn=Math.max(yn,Ze.start*wt),kr=Math.min(kr,(Ze.start+Ze.count)*wt)),ct!==null?(yn=Math.max(yn,0),kr=Math.min(kr,ct.count)):gt!=null&&(yn=Math.max(yn,0),kr=Math.min(kr,gt.count));let Ds=kr-yn;if(Ds<0||Ds===1/0)return;ue.setup(ce,$,at,oe,ct);let ma,vn=Ie;if(ct!==null&&(ma=me.get(ct),vn=Ge,vn.setIndex(ma)),ce.isMesh)$.wireframe===!0?(V.setLineWidth($.wireframeLinewidth*j()),vn.setMode(1)):vn.setMode(4);else if(ce.isLine){let yt=$.linewidth;yt===void 0&&(yt=1),V.setLineWidth(yt*j()),ce.isLineSegments?vn.setMode(1):ce.isLineLoop?vn.setMode(2):vn.setMode(3)}else ce.isPoints?vn.setMode(0):ce.isSprite&&vn.setMode(4);if(ce.isInstancedMesh)vn.renderInstances(yn,Ds,ce.count);else if(oe.isInstancedBufferGeometry){let yt=oe._maxInstanceCount!==void 0?oe._maxInstanceCount:1/0,Vy=Math.min(oe.instanceCount,yt);vn.renderInstances(yn,Ds,Vy)}else vn.render(yn,Ds)},this.compile=function(N,te){function oe($,ce,Ze){$.transparent===!0&&$.side===fr&&$.forceSinglePass===!1?($.side=bn,$.needsUpdate=!0,ii($,ce,Ze),$.side=Wr,$.needsUpdate=!0,ii($,ce,Ze),$.side=fr):ii($,ce,Ze)}h=L.get(N),h.init(),g.push(h),N.traverseVisible(function($){$.isLight&&$.layers.test(te.layers)&&(h.pushLight($),$.castShadow&&h.pushShadow($))}),h.setupLights(p.physicallyCorrectLights),N.traverse(function($){let ce=$.material;if(ce)if(Array.isArray(ce))for(let Ze=0;Ze<ce.length;Ze++){let it=ce[Ze];oe(it,N,$)}else oe(ce,N,$)}),g.pop(),h=null};let se=null;function ye(N){se&&se(N)}function Ce(){tt.stop()}function Ue(){tt.start()}let tt=new U1;tt.setAnimationLoop(ye),typeof self<"u"&&tt.setContext(self),this.setAnimationLoop=function(N){se=N,_e.setAnimationLoop(N),N===null?tt.stop():tt.start()},_e.addEventListener("sessionstart",Ce),_e.addEventListener("sessionend",Ue),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(m===!0)return;N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),_e.enabled===!0&&_e.isPresenting===!0&&(_e.cameraAutoUpdate===!0&&_e.updateCamera(te),te=_e.getCamera()),N.isScene===!0&&N.onBeforeRender(p,N,te,x),h=L.get(N,g.length),h.init(),g.push(h),K.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),X.setFromProjectionMatrix(K),q=this.localClippingEnabled,W=O.init(this.clippingPlanes,q),d=ht.get(N,f.length),d.init(),f.push(d),$t(N,te,0,p.sortObjects),d.finish(),p.sortObjects===!0&&d.sort(P,C),W===!0&&O.beginShadows();let oe=h.state.shadowsArray;if(ee.render(oe,N,te),W===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),he.render(d,N),h.setupLights(p.physicallyCorrectLights),te.isArrayCamera){let $=te.cameras;for(let ce=0,Ze=$.length;ce<Ze;ce++){let it=$[ce];Nn(d,N,it,it.viewport)}}else Nn(d,N,te);x!==null&&(ae.updateMultisampleRenderTarget(x),ae.updateRenderTargetMipmap(x)),N.isScene===!0&&N.onAfterRender(p,N,te),ue.resetDefaultState(),b=-1,w=null,g.pop(),g.length>0?h=g[g.length-1]:h=null,f.pop(),f.length>0?d=f[f.length-1]:d=null};function $t(N,te,oe,$){if(N.visible===!1)return;if(N.layers.test(te.layers)){if(N.isGroup)oe=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(te);else if(N.isLight)h.pushLight(N),N.castShadow&&h.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||X.intersectsSprite(N)){$&&U.setFromMatrixPosition(N.matrixWorld).applyMatrix4(K);let it=Pe.update(N),at=N.material;at.visible&&d.push(N,it,at,oe,U.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==pe.render.frame&&(N.skeleton.update(),N.skeleton.frame=pe.render.frame),!N.frustumCulled||X.intersectsObject(N))){$&&U.setFromMatrixPosition(N.matrixWorld).applyMatrix4(K);let it=Pe.update(N),at=N.material;if(Array.isArray(at)){let ct=it.groups;for(let wt=0,mt=ct.length;wt<mt;wt++){let gt=ct[wt],yn=at[gt.materialIndex];yn&&yn.visible&&d.push(N,it,yn,oe,U.z,gt)}}else at.visible&&d.push(N,it,at,oe,U.z,null)}}let Ze=N.children;for(let it=0,at=Ze.length;it<at;it++)$t(Ze[it],te,oe,$)}function Nn(N,te,oe,$){let ce=N.opaque,Ze=N.transmissive,it=N.transparent;h.setupLightsView(oe),W===!0&&O.setGlobalState(p.clippingPlanes,oe),Ze.length>0&&ri(ce,te,oe),$&&V.viewport(A.copy($)),ce.length>0&&Ht(ce,te,oe),Ze.length>0&&Ht(Ze,te,oe),it.length>0&&Ht(it,te,oe),V.buffers.depth.setTest(!0),V.buffers.depth.setMask(!0),V.buffers.color.setMask(!0),V.setPolygonOffset(!1)}function ri(N,te,oe){let $=J.isWebGL2;H===null&&(H=new At(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")?Md:kt,minFilter:Ta,samples:$&&s===!0?4:0})),p.getDrawingBufferSize(R),$?H.setSize(R.x,R.y):H.setSize(op(R.x),op(R.y));let ce=p.getRenderTarget();p.setRenderTarget(H),p.clear();let Ze=p.toneMapping;p.toneMapping=ks,Ht(N,te,oe),p.toneMapping=Ze,ae.updateMultisampleRenderTarget(H),ae.updateRenderTargetMipmap(H),p.setRenderTarget(ce)}function Ht(N,te,oe){let $=te.isScene===!0?te.overrideMaterial:null;for(let ce=0,Ze=N.length;ce<Ze;ce++){let it=N[ce],at=it.object,ct=it.geometry,wt=$===null?it.material:$,mt=it.group;at.layers.test(oe.layers)&&Is(at,te,oe,ct,wt,mt)}}function Is(N,te,oe,$,ce,Ze){N.onBeforeRender(p,te,oe,$,ce,Ze),N.modelViewMatrix.multiplyMatrices(oe.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),ce.onBeforeRender(p,te,oe,$,N,Ze),ce.transparent===!0&&ce.side===fr&&ce.forceSinglePass===!1?(ce.side=bn,ce.needsUpdate=!0,p.renderBufferDirect(oe,te,$,ce,N,Ze),ce.side=Wr,ce.needsUpdate=!0,p.renderBufferDirect(oe,te,$,ce,N,Ze),ce.side=fr):p.renderBufferDirect(oe,te,$,ce,N,Ze),N.onAfterRender(p,te,oe,$,ce,Ze)}function ii(N,te,oe){te.isScene!==!0&&(te=z);let $=ie.get(N),ce=h.state.lights,Ze=h.state.shadowsArray,it=ce.state.version,at=be.getParameters(N,ce.state,Ze,te,oe),ct=be.getProgramCacheKey(at),wt=$.programs;$.environment=N.isMeshStandardMaterial?te.environment:null,$.fog=te.fog,$.envMap=(N.isMeshStandardMaterial?xe:fe).get(N.envMap||$.environment),wt===void 0&&(N.addEventListener("dispose",Nt),wt=new Map,$.programs=wt);let mt=wt.get(ct);if(mt!==void 0){if($.currentProgram===mt&&$.lightsStateVersion===it)return KS(N,at),mt}else at.uniforms=be.getUniforms(N),N.onBuild(oe,at,p),N.onBeforeCompile(at,p),mt=be.acquireProgram(at,ct),wt.set(ct,mt),$.uniforms=at.uniforms;let gt=$.uniforms;(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(gt.clippingPlanes=O.uniform),KS(N,at),$.needsLights=uI(N),$.lightsStateVersion=it,$.needsLights&&(gt.ambientLightColor.value=ce.state.ambient,gt.lightProbe.value=ce.state.probe,gt.directionalLights.value=ce.state.directional,gt.directionalLightShadows.value=ce.state.directionalShadow,gt.spotLights.value=ce.state.spot,gt.spotLightShadows.value=ce.state.spotShadow,gt.rectAreaLights.value=ce.state.rectArea,gt.ltc_1.value=ce.state.rectAreaLTC1,gt.ltc_2.value=ce.state.rectAreaLTC2,gt.pointLights.value=ce.state.point,gt.pointLightShadows.value=ce.state.pointShadow,gt.hemisphereLights.value=ce.state.hemi,gt.directionalShadowMap.value=ce.state.directionalShadowMap,gt.directionalShadowMatrix.value=ce.state.directionalShadowMatrix,gt.spotShadowMap.value=ce.state.spotShadowMap,gt.spotLightMatrix.value=ce.state.spotLightMatrix,gt.spotLightMap.value=ce.state.spotLightMap,gt.pointShadowMap.value=ce.state.pointShadowMap,gt.pointShadowMatrix.value=ce.state.pointShadowMatrix);let yn=mt.getUniforms(),kr=Bl.seqWithValue(yn.seq,gt);return $.currentProgram=mt,$.uniformsList=kr,mt}function KS(N,te){let oe=ie.get(N);oe.outputEncoding=te.outputEncoding,oe.instancing=te.instancing,oe.skinning=te.skinning,oe.morphTargets=te.morphTargets,oe.morphNormals=te.morphNormals,oe.morphColors=te.morphColors,oe.morphTargetsCount=te.morphTargetsCount,oe.numClippingPlanes=te.numClippingPlanes,oe.numIntersection=te.numClipIntersection,oe.vertexAlphas=te.vertexAlphas,oe.vertexTangents=te.vertexTangents,oe.toneMapping=te.toneMapping}function lI(N,te,oe,$,ce){te.isScene!==!0&&(te=z),ae.resetTextureUnits();let Ze=te.fog,it=$.isMeshStandardMaterial?te.environment:null,at=x===null?p.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:jr,ct=($.isMeshStandardMaterial?xe:fe).get($.envMap||it),wt=$.vertexColors===!0&&!!oe.attributes.color&&oe.attributes.color.itemSize===4,mt=!!$.normalMap&&!!oe.attributes.tangent,gt=!!oe.morphAttributes.position,yn=!!oe.morphAttributes.normal,kr=!!oe.morphAttributes.color,Ds=$.toneMapped?p.toneMapping:ks,ma=oe.morphAttributes.position||oe.morphAttributes.normal||oe.morphAttributes.color,vn=ma!==void 0?ma.length:0,yt=ie.get($),Vy=h.state.lights;if(W===!0&&(q===!0||N!==w)){let zr=N===w&&$.id===b;O.setState($,N,zr)}let Bn=!1;$.version===yt.__version?(yt.needsLights&&yt.lightsStateVersion!==Vy.state.version||yt.outputEncoding!==at||ce.isInstancedMesh&&yt.instancing===!1||!ce.isInstancedMesh&&yt.instancing===!0||ce.isSkinnedMesh&&yt.skinning===!1||!ce.isSkinnedMesh&&yt.skinning===!0||yt.envMap!==ct||$.fog===!0&&yt.fog!==Ze||yt.numClippingPlanes!==void 0&&(yt.numClippingPlanes!==O.numPlanes||yt.numIntersection!==O.numIntersection)||yt.vertexAlphas!==wt||yt.vertexTangents!==mt||yt.morphTargets!==gt||yt.morphNormals!==yn||yt.morphColors!==kr||yt.toneMapping!==Ds||J.isWebGL2===!0&&yt.morphTargetsCount!==vn)&&(Bn=!0):(Bn=!0,yt.__version=$.version);let ga=yt.currentProgram;Bn===!0&&(ga=ii($,te,ce));let ZS=!1,ud=!1,Hy=!1,lr=ga.getUniforms(),ya=yt.uniforms;if(V.useProgram(ga.program)&&(ZS=!0,ud=!0,Hy=!0),$.id!==b&&(b=$.id,ud=!0),ZS||w!==N){if(lr.setValue(G,"projectionMatrix",N.projectionMatrix),J.logarithmicDepthBuffer&&lr.setValue(G,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),w!==N&&(w=N,ud=!0,Hy=!0),$.isShaderMaterial||$.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshStandardMaterial||$.envMap){let zr=lr.map.cameraPosition;zr!==void 0&&zr.setValue(G,U.setFromMatrixPosition(N.matrixWorld))}($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial)&&lr.setValue(G,"isOrthographic",N.isOrthographicCamera===!0),($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial||$.isShadowMaterial||ce.isSkinnedMesh)&&lr.setValue(G,"viewMatrix",N.matrixWorldInverse)}if(ce.isSkinnedMesh){lr.setOptional(G,ce,"bindMatrix"),lr.setOptional(G,ce,"bindMatrixInverse");let zr=ce.skeleton;zr&&(J.floatVertexTextures?(zr.boneTexture===null&&zr.computeBoneTexture(),lr.setValue(G,"boneTexture",zr.boneTexture,ae),lr.setValue(G,"boneTextureSize",zr.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 Wy=oe.morphAttributes;if((Wy.position!==void 0||Wy.normal!==void 0||Wy.color!==void 0&&J.isWebGL2===!0)&&ge.update(ce,oe,$,ga),(ud||yt.receiveShadow!==ce.receiveShadow)&&(yt.receiveShadow=ce.receiveShadow,lr.setValue(G,"receiveShadow",ce.receiveShadow)),$.isMeshGouraudMaterial&&$.envMap!==null&&(ya.envMap.value=ct,ya.flipEnvMap.value=ct.isCubeTexture&&ct.isRenderTargetTexture===!1?-1:1),ud&&(lr.setValue(G,"toneMappingExposure",p.toneMappingExposure),yt.needsLights&&cI(ya,Hy),Ze&&$.fog===!0&&Fe.refreshFogUniforms(ya,Ze),Fe.refreshMaterialUniforms(ya,$,I,M,H),Bl.upload(G,yt.uniformsList,ya,ae)),$.isShaderMaterial&&$.uniformsNeedUpdate===!0&&(Bl.upload(G,yt.uniformsList,ya,ae),$.uniformsNeedUpdate=!1),$.isSpriteMaterial&&lr.setValue(G,"center",ce.center),lr.setValue(G,"modelViewMatrix",ce.modelViewMatrix),lr.setValue(G,"normalMatrix",ce.normalMatrix),lr.setValue(G,"modelMatrix",ce.matrixWorld),$.isShaderMaterial||$.isRawShaderMaterial){let zr=$.uniformsGroups;for(let jy=0,dI=zr.length;jy<dI;jy++)if(J.isWebGL2){let QS=zr[jy];je.update(QS,ga),je.bind(QS,ga)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return ga}function cI(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 uI(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,oe){ie.get(N.texture).__webglTexture=te,ie.get(N.depthTexture).__webglTexture=oe;let $=ie.get(N);$.__hasExternalTextures=!0,$.__hasExternalTextures&&($.__autoAllocateDepthBuffer=oe===void 0,$.__autoAllocateDepthBuffer||Z.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),$.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(N,te){let oe=ie.get(N);oe.__webglFramebuffer=te,oe.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(N,te=0,oe=0){x=N,y=te,v=oe;let $=!0,ce=null,Ze=!1,it=!1;if(N){let ct=ie.get(N);ct.__useDefaultFramebuffer!==void 0?(V.bindFramebuffer(36160,null),$=!1):ct.__webglFramebuffer===void 0?ae.setupRenderTarget(N):ct.__hasExternalTextures&&ae.rebindTextures(N,ie.get(N.texture).__webglTexture,ie.get(N.depthTexture).__webglTexture);let wt=N.texture;(wt.isData3DTexture||wt.isDataArrayTexture||wt.isCompressedArrayTexture)&&(it=!0);let mt=ie.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(ce=mt[te],Ze=!0):J.isWebGL2&&N.samples>0&&ae.useMultisampledRTT(N)===!1?ce=ie.get(N).__webglMultisampledFramebuffer:ce=mt,A.copy(N.viewport),T.copy(N.scissor),S=N.scissorTest}else A.copy(D).multiplyScalar(I).floor(),T.copy(B).multiplyScalar(I).floor(),S=k;if(V.bindFramebuffer(36160,ce)&&J.drawBuffers&&$&&V.drawBuffers(N,ce),V.viewport(A),V.scissor(T),V.setScissorTest(S),Ze){let ct=ie.get(N.texture);G.framebufferTexture2D(36160,36064,34069+te,ct.__webglTexture,oe)}else if(it){let ct=ie.get(N.texture),wt=te||0;G.framebufferTextureLayer(36160,36064,ct.__webglTexture,oe||0,wt)}b=-1},this.readRenderTargetPixels=function(N,te,oe,$,ce,Ze,it){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let at=ie.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&it!==void 0&&(at=at[it]),at){V.bindFramebuffer(36160,at);try{let ct=N.texture,wt=ct.format,mt=ct.type;if(wt!==oi&&De.convert(wt)!==G.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let gt=mt===Md&&(Z.has("EXT_color_buffer_half_float")||J.isWebGL2&&Z.has("EXT_color_buffer_float"));if(mt!==kt&&De.convert(mt)!==G.getParameter(35738)&&!(mt===Zi&&(J.isWebGL2||Z.has("OES_texture_float")||Z.has("WEBGL_color_buffer_float")))&&!gt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=N.width-$&&oe>=0&&oe<=N.height-ce&&G.readPixels(te,oe,$,ce,De.convert(wt),De.convert(mt),Ze)}finally{let ct=x!==null?ie.get(x).__webglFramebuffer:null;V.bindFramebuffer(36160,ct)}}},this.copyFramebufferToTexture=function(N,te,oe=0){let $=Math.pow(2,-oe),ce=Math.floor(te.image.width*$),Ze=Math.floor(te.image.height*$);ae.setTexture2D(te,0),G.copyTexSubImage2D(3553,oe,0,0,N.x,N.y,ce,Ze),V.unbindTexture()},this.copyTextureToTexture=function(N,te,oe,$=0){let ce=te.image.width,Ze=te.image.height,it=De.convert(oe.format),at=De.convert(oe.type);ae.setTexture2D(oe,0),G.pixelStorei(37440,oe.flipY),G.pixelStorei(37441,oe.premultiplyAlpha),G.pixelStorei(3317,oe.unpackAlignment),te.isDataTexture?G.texSubImage2D(3553,$,N.x,N.y,ce,Ze,it,at,te.image.data):te.isCompressedTexture?G.compressedTexSubImage2D(3553,$,N.x,N.y,te.mipmaps[0].width,te.mipmaps[0].height,it,te.mipmaps[0].data):G.texSubImage2D(3553,$,N.x,N.y,it,at,te.image),$===0&&oe.generateMipmaps&&G.generateMipmap(3553),V.unbindTexture()},this.copyTextureToTexture3D=function(N,te,oe,$,ce=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Ze=N.max.x-N.min.x+1,it=N.max.y-N.min.y+1,at=N.max.z-N.min.z+1,ct=De.convert($.format),wt=De.convert($.type),mt;if($.isData3DTexture)ae.setTexture3D($,0),mt=32879;else if($.isDataArrayTexture)ae.setTexture2DArray($,0),mt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}G.pixelStorei(37440,$.flipY),G.pixelStorei(37441,$.premultiplyAlpha),G.pixelStorei(3317,$.unpackAlignment);let gt=G.getParameter(3314),yn=G.getParameter(32878),kr=G.getParameter(3316),Ds=G.getParameter(3315),ma=G.getParameter(32877),vn=oe.isCompressedTexture?oe.mipmaps[0]:oe.image;G.pixelStorei(3314,vn.width),G.pixelStorei(32878,vn.height),G.pixelStorei(3316,N.min.x),G.pixelStorei(3315,N.min.y),G.pixelStorei(32877,N.min.z),oe.isDataTexture||oe.isData3DTexture?G.texSubImage3D(mt,ce,te.x,te.y,te.z,Ze,it,at,ct,wt,vn.data):oe.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),G.compressedTexSubImage3D(mt,ce,te.x,te.y,te.z,Ze,it,at,ct,vn.data)):G.texSubImage3D(mt,ce,te.x,te.y,te.z,Ze,it,at,ct,wt,vn),G.pixelStorei(3314,gt),G.pixelStorei(32878,yn),G.pixelStorei(3316,kr),G.pixelStorei(3315,Ds),G.pixelStorei(32877,ma),ce===0&&$.generateMipmaps&&G.generateMipmap(mt),V.unbindTexture()},this.initTexture=function(N){N.isCubeTexture?ae.setTextureCube(N,0):N.isData3DTexture?ae.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?ae.setTexture2DArray(N,0):ae.setTexture2D(N,0),V.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,V.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var Yv=class extends v0{};Yv.prototype.isWebGL1Renderer=!0;var kl=class{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Le(t),this.near=e,this.far=n}clone(){return new kl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},pr=class extends ut{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}},mp=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Rv,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ji()}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 i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[n+i];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=Ji()),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=Ji()),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}}},ur=new _,Ca=class{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}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++)ur.fromBufferAttribute(this,e),ur.applyMatrix4(t),this.setXYZ(e,ur.x,ur.y,ur.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)ur.fromBufferAttribute(this,e),ur.applyNormalMatrix(t),this.setXYZ(e,ur.x,ur.y,ur.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)ur.fromBufferAttribute(this,e),ur.transformDirection(t),this.setXYZ(e,ur.x,ur.y,ur.z);return this}setX(t,e){return this.normalized&&(e=Rt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Rt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Rt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Rt(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=Gs(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Gs(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Gs(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Gs(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Rt(e,this.array),n=Rt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Rt(e,this.array),n=Rt(n,this.array),i=Rt(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Rt(e,this.array),n=Rt(n,this.array),i=Rt(i,this.array),s=Rt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,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 i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new Be(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 Ca(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 i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+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 gp=class extends Be{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}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 ai=class extends Ea{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Le(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(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}},u1=new _,d1=new _,h1=new de,_v=new Ti,Kf=new Sn,Pa=class extends ut{constructor(t=new Te,e=new ai){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 i=1,s=e.count;i<s;i++)u1.fromBufferAttribute(e,i-1),d1.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=u1.distanceTo(d1);t.setAttribute("lineDistance",new we(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,i=this.matrixWorld,s=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Kf.copy(n.boundingSphere),Kf.applyMatrix4(i),Kf.radius+=s,t.ray.intersectsSphere(Kf)===!1)return;h1.copy(i).invert(),_v.copy(t.ray).applyMatrix4(h1);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new _,c=new _,d=new _,h=new _,f=this.isLineSegments?2:1,g=n.index,m=n.attributes.position;if(g!==null){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){let w=g.getX(x),A=g.getX(x+1);if(u.fromBufferAttribute(m,w),c.fromBufferAttribute(m,A),_v.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let S=t.ray.origin.distanceTo(h);S<t.near||S>t.far||e.push({distance:S,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(m.count,o.start+o.count);for(let x=y,b=v-1;x<b;x+=f){if(u.fromBufferAttribute(m,x),c.fromBufferAttribute(m,x+1),_v.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let A=t.ray.origin.distanceTo(h);A<t.near||A>t.far||e.push({distance:A,point:d.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 i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},f1=new _,p1=new _,Mo=class extends Pa{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 i=0,s=e.count;i<s;i+=2)f1.fromBufferAttribute(e,i),p1.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+f1.distanceTo(p1);t.setAttribute("lineDistance",new we(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var yp=class extends Gt{constructor(t,e,n,i,s,o,a,l,u){super(t,e,n,i,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:st,this.magFilter=s!==void 0?s:st,this.generateMipmaps=!1;let c=this;function d(){c.needsUpdate=!0,t.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(d)}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 li=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,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(i),e.push(s),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),i=0,s=n.length,o;e?o=e:o=t*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),u=n[i]-o,u<0)a=i+1;else if(u>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let c=n[i],h=n[i+1]-c,f=(o-c)/h;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new F:new _);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 _,i=[],s=[],o=[],a=new _,l=new de;for(let f=0;f<=t;f++){let g=f/t;i[f]=this.getTangentAt(g,new _)}s[0]=new _,o[0]=new _;let u=Number.MAX_VALUE,c=Math.abs(i[0].x),d=Math.abs(i[0].y),h=Math.abs(i[0].z);c<=u&&(u=c,n.set(1,0,0)),d<=u&&(u=d,n.set(0,1,0)),h<=u&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let g=Math.acos(_n(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,g))}o[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(_n(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let g=1;g<=t;g++)s[g].applyMatrix4(l.makeRotationAxis(i[g],f*g)),o[g].crossVectors(i[g],s[g])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(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}},Ia=class extends li{constructor(t=0,e=0,n=1,i=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=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let n=e||new F,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+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),d=Math.sin(this.aRotation),h=l-this.aX,f=u-this.aY;l=h*c-f*d+this.aX,u=h*d+f*c+this.aY}return n.set(l,u)}copy(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}},Kv=class extends Ia{constructor(t,e,n,i,s,o){super(t,e,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function x0(){let r=0,t=0,e=0,n=0;function i(s,o,a,l){r=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){i(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,d){let h=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+d)+(l-a)/d;h*=c,f*=c,i(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return r+t*s+e*o+n*a}}}var Zf=new _,Tv=new x0,Ev=new x0,Mv=new x0,Zv=class extends li{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new _){let n=e,i=this.points,s=i.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=i[(a-1)%s]:(Zf.subVectors(i[0],i[1]).add(i[0]),u=Zf);let d=i[a%s],h=i[(a+1)%s];if(this.closed||a+2<s?c=i[(a+2)%s]:(Zf.subVectors(i[s-1],i[s-2]).add(i[s-1]),c=Zf),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,g=Math.pow(u.distanceToSquared(d),f),p=Math.pow(d.distanceToSquared(h),f),m=Math.pow(h.distanceToSquared(c),f);p<1e-4&&(p=1),g<1e-4&&(g=p),m<1e-4&&(m=p),Tv.initNonuniformCatmullRom(u.x,d.x,h.x,c.x,g,p,m),Ev.initNonuniformCatmullRom(u.y,d.y,h.y,c.y,g,p,m),Mv.initNonuniformCatmullRom(u.z,d.z,h.z,c.z,g,p,m)}else this.curveType==="catmullrom"&&(Tv.initCatmullRom(u.x,d.x,h.x,c.x,this.tension),Ev.initCatmullRom(u.y,d.y,h.y,c.y,this.tension),Mv.initCatmullRom(u.z,d.z,h.z,c.z,this.tension));return n.set(Tv.calc(l),Ev.calc(l),Mv.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.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 i=this.points[e];t.points.push(i.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 i=t.points[e];this.points.push(new _().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function m1(r,t,e,n,i){let s=(n-t)*.5,o=(i-e)*.5,a=r*r,l=r*a;return(2*e-2*n+s+o)*l+(-3*e+3*n-2*s-o)*a+s*r+e}function dN(r,t){let e=1-r;return e*e*t}function hN(r,t){return 2*(1-r)*r*t}function fN(r,t){return r*r*t}function Td(r,t,e,n){return dN(r,t)+hN(r,e)+fN(r,n)}function pN(r,t){let e=1-r;return e*e*e*t}function mN(r,t){let e=1-r;return 3*e*e*r*t}function gN(r,t){return 3*(1-r)*r*r*t}function yN(r,t){return r*r*r*t}function Ed(r,t,e,n,i){return pN(r,t)+mN(r,e)+gN(r,n)+yN(r,i)}var nr=class extends li{constructor(t=new F,e=new F,n=new F,i=new F){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new F){let n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Ed(t,i.x,s.x,o.x,a.x),Ed(t,i.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}},Da=class extends li{constructor(t=new _,e=new _,n=new _,i=new _){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new _){let n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Ed(t,i.x,s.x,o.x,a.x),Ed(t,i.y,s.y,o.y,a.y),Ed(t,i.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}},rr=class extends li{constructor(t=new F,e=new F){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new F){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 F;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}},Ld=class extends li{constructor(t=new _,e=new _){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new _){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}},qr=class extends li{constructor(t=new F,e=new F,n=new F){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new F){let n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(Td(t,i.x,s.x,o.x),Td(t,i.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}},Qv=class extends li{constructor(t=new _,e=new _,n=new _){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new _){let n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(Td(t,i.x,s.x,o.x),Td(t,i.y,s.y,o.y),Td(t,i.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}},zl=class extends li{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new F){let n=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],u=i[o],c=i[o>i.length-2?i.length-1:o+1],d=i[o>i.length-3?i.length-1:o+2];return n.set(m1(a,l.x,u.x,c.x,d.x),m1(a,l.y,u.y,c.y,d.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new F().fromArray(i))}return this}},vN=Object.freeze({__proto__:null,ArcCurve:Kv,CatmullRomCurve3:Zv,CubicBezierCurve:nr,CubicBezierCurve3:Da,EllipseCurve:Ia,LineCurve:rr,LineCurve3:Ld,QuadraticBezierCurve:qr,QuadraticBezierCurve3:Qv,SplineCurve:zl}),Rd=class extends li{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 rr(e,t))}getPoint(t,e){let n=t*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=n){let o=i[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,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,i=this.curves.length;n<i;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 i=0,s=this.curves;i<s.length;i++){let o=s[i],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 i=t.curves[e];this.curves.push(i.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 i=this.curves[e];t.curves.push(i.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 i=t.curves[e];this.curves.push(new vN[i.type]().fromJSON(i))}return this}},Oa=class extends Rd{constructor(t){super(),this.type="Path",this.currentPoint=new F,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 rr(this.currentPoint.clone(),new F(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){let s=new qr(this.currentPoint.clone(),new F(t,e),new F(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,s,o){let a=new nr(this.currentPoint.clone(),new F(t,e),new F(n,i),new F(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new zl(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,n,i,s,o),this}absarc(t,e,n,i,s,o){return this.absellipse(t,e,n,n,i,s,o),this}ellipse(t,e,n,i,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,n,i,s,o,a,l),this}absellipse(t,e,n,i,s,o,a,l){let u=new Ia(t,e,n,i,s,o,a,l);if(this.curves.length>0){let d=u.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(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}},Vl=class extends Te{constructor(t=[new F(0,-.5),new F(.5,0),new F(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=_n(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,d=new _,h=new F,f=new _,g=new _,p=new _,m=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:m=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-m,f.z=y*0,p.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(p.x,p.y,p.z);break;default:m=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-m,f.z=y*0,g.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),l.push(f.x,f.y,f.z),p.copy(g)}for(let v=0;v<=e;v++){let x=n+v*c*i,b=Math.sin(x),w=Math.cos(x);for(let A=0;A<=t.length-1;A++){d.x=t[A].x*b,d.y=t[A].y,d.z=t[A].x*w,o.push(d.x,d.y,d.z),h.x=v/e,h.y=A/(t.length-1),a.push(h.x,h.y);let T=l[3*A+0]*b,S=l[3*A+1],E=l[3*A+0]*w;u.push(T,S,E)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let b=x+v*t.length,w=b,A=b+t.length,T=b+t.length+1,S=b+1;s.push(w,A,S),s.push(T,S,A)}this.setIndex(s),this.setAttribute("position",new we(o,3)),this.setAttribute("uv",new we(a,2)),this.setAttribute("normal",new we(u,3))}static fromJSON(t){return new Vl(t.points,t.segments,t.phiStart,t.phiLength)}};var La=class extends Te{constructor(t=1,e=1,n=1,i=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;i=Math.floor(i),s=Math.floor(s);let c=[],d=[],h=[],f=[],g=0,p=[],m=n/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new we(d,3)),this.setAttribute("normal",new we(h,3)),this.setAttribute("uv",new we(f,2));function v(){let b=new _,w=new _,A=0,T=(e-t)/n;for(let S=0;S<=s;S++){let E=[],M=S/s,I=M*(e-t)+t;for(let P=0;P<=i;P++){let C=P/i,D=C*l+a,B=Math.sin(D),k=Math.cos(D);w.x=I*B,w.y=-M*n+m,w.z=I*k,d.push(w.x,w.y,w.z),b.set(B,T,k).normalize(),h.push(b.x,b.y,b.z),f.push(C,1-M),E.push(g++)}p.push(E)}for(let S=0;S<i;S++)for(let E=0;E<s;E++){let M=p[E][S],I=p[E+1][S],P=p[E+1][S+1],C=p[E][S+1];c.push(M,I,C),c.push(I,P,C),A+=6}u.addGroup(y,A,0),y+=A}function x(b){let w=g,A=new F,T=new _,S=0,E=b===!0?t:e,M=b===!0?1:-1;for(let P=1;P<=i;P++)d.push(0,m*M,0),h.push(0,M,0),f.push(.5,.5),g++;let I=g;for(let P=0;P<=i;P++){let D=P/i*l+a,B=Math.cos(D),k=Math.sin(D);T.x=E*k,T.y=m*M,T.z=E*B,d.push(T.x,T.y,T.z),h.push(0,M,0),A.x=B*.5+.5,A.y=k*.5*M+.5,f.push(A.x,A.y),g++}for(let P=0;P<i;P++){let C=w+P,D=I+P;b===!0?c.push(D,D+1,C):c.push(D+1,D,C),S+=3}u.addGroup(y,S,b===!0?1:2),y+=S}}static fromJSON(t){return new La(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Hl=class extends La{constructor(t=1,e=1,n=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new Hl(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Wl=class extends Te{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};let s=[],o=[];a(i),u(n),c(),this.setAttribute("position",new we(s,3)),this.setAttribute("normal",new we(s.slice(),3)),this.setAttribute("uv",new we(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new _,b=new _,w=new _;for(let A=0;A<e.length;A+=3)f(e[A+0],x),f(e[A+1],b),f(e[A+2],w),l(x,b,w,v)}function l(v,x,b,w){let A=w+1,T=[];for(let S=0;S<=A;S++){T[S]=[];let E=v.clone().lerp(b,S/A),M=x.clone().lerp(b,S/A),I=A-S;for(let P=0;P<=I;P++)P===0&&S===A?T[S][P]=E:T[S][P]=E.clone().lerp(M,P/I)}for(let S=0;S<A;S++)for(let E=0;E<2*(A-S)-1;E++){let M=Math.floor(E/2);E%2===0?(h(T[S][M+1]),h(T[S+1][M]),h(T[S][M])):(h(T[S][M+1]),h(T[S+1][M+1]),h(T[S+1][M]))}}function u(v){let x=new _;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 _;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=m(v)/2/Math.PI+.5,w=y(v)/Math.PI+.5;o.push(b,1-w)}g(),d()}function d(){for(let v=0;v<o.length;v+=6){let x=o[v+0],b=o[v+2],w=o[v+4],A=Math.max(x,b,w),T=Math.min(x,b,w);A>.9&&T<.1&&(x<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),w<.2&&(o[v+4]+=1))}}function h(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 g(){let v=new _,x=new _,b=new _,w=new _,A=new F,T=new F,S=new F;for(let E=0,M=0;E<s.length;E+=9,M+=6){v.set(s[E+0],s[E+1],s[E+2]),x.set(s[E+3],s[E+4],s[E+5]),b.set(s[E+6],s[E+7],s[E+8]),A.set(o[M+0],o[M+1]),T.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 I=m(w);p(A,M+0,v,I),p(T,M+2,x,I),p(S,M+4,b,I)}}function p(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 m(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 Wl(t.vertices,t.indices,t.radius,t.details)}},jl=class extends Wl{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new jl(t.radius,t.detail)}};var Hs=class extends Oa{constructor(t){super(t),this.uuid=Ji(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,i=this.holes.length;n<i;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 i=t.holes[e];this.holes.push(i.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 i=this.holes[e];t.holes.push(i.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 i=t.holes[e];this.holes.push(new Oa().fromJSON(i))}return this}},xN={triangulate:function(r,t,e=2){let n=t&&t.length,i=n?t[0]*e:r.length,s=H1(r,0,i,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,d,h,f;if(n&&(s=_N(r,t,s,e)),r.length>80*e){a=u=r[0],l=c=r[1];for(let g=e;g<i;g+=e)d=r[g],h=r[g+1],d<a&&(a=d),h<l&&(l=h),d>u&&(u=d),h>c&&(c=h);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return Nd(s,o,e,a,l,f,0),o}};function H1(r,t,e,n,i){let s,o;if(i===NN(r,t,e,n)>0)for(s=t;s<e;s+=n)o=g1(s,r[s],r[s+1],o);else for(s=e-n;s>=t;s-=n)o=g1(s,r[s],r[s+1],o);return o&&Ip(o,o.next)&&(Fd(o),o=o.next),o}function Ra(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(Ip(e,e.next)||Qt(e.prev,e,e.next)===0)){if(Fd(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Nd(r,t,e,n,i,s,o){if(!r)return;!o&&s&&PN(r,n,i,s);let a=r,l,u;for(;r.prev!==r.next;){if(l=r.prev,u=r.next,s?SN(r,n,i,s):bN(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(u.i/e|0),Fd(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=wN(Ra(r),t,e),Nd(r,t,e,n,i,s,2)):o===2&&AN(r,t,e,n,i,s):Nd(Ra(r),t,e,n,i,s,1);break}}}function bN(r){let t=r.prev,e=r,n=r.next;if(Qt(t,e,n)>=0)return!1;let i=t.x,s=e.x,o=n.x,a=t.y,l=e.y,u=n.y,c=i<s?i<o?i:o:s<o?s:o,d=a<l?a<u?a:u:l<u?l:u,h=i>s?i>o?i:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,g=n.next;for(;g!==t;){if(g.x>=c&&g.x<=h&&g.y>=d&&g.y<=f&&Rl(i,a,s,l,o,u,g.x,g.y)&&Qt(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function SN(r,t,e,n){let i=r.prev,s=r,o=r.next;if(Qt(i,s,o)>=0)return!1;let a=i.x,l=s.x,u=o.x,c=i.y,d=s.y,h=o.y,f=a<l?a<u?a:u:l<u?l:u,g=c<d?c<h?c:h:d<h?d:h,p=a>l?a>u?a:u:l>u?l:u,m=c>d?c>h?c:h:d>h?d:h,y=Jv(f,g,t,e,n),v=Jv(p,m,t,e,n),x=r.prevZ,b=r.nextZ;for(;x&&x.z>=y&&b&&b.z<=v;){if(x.x>=f&&x.x<=p&&x.y>=g&&x.y<=m&&x!==i&&x!==o&&Rl(a,c,l,d,u,h,x.x,x.y)&&Qt(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=f&&b.x<=p&&b.y>=g&&b.y<=m&&b!==i&&b!==o&&Rl(a,c,l,d,u,h,b.x,b.y)&&Qt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=p&&x.y>=g&&x.y<=m&&x!==i&&x!==o&&Rl(a,c,l,d,u,h,x.x,x.y)&&Qt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=p&&b.y>=g&&b.y<=m&&b!==i&&b!==o&&Rl(a,c,l,d,u,h,b.x,b.y)&&Qt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function wN(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!Ip(i,s)&&W1(i,n,n.next,s)&&Bd(i,s)&&Bd(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Fd(n),Fd(n.next),n=r=s),n=n.next}while(n!==r);return Ra(n)}function AN(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&ON(o,a)){let l=j1(o,a);o=Ra(o,o.next),l=Ra(l,l.next),Nd(o,t,e,n,i,s,0),Nd(l,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function _N(r,t,e,n){let i=[],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:r.length,u=H1(r,a,l,n,!1),u===u.next&&(u.steiner=!0),i.push(DN(u));for(i.sort(TN),s=0;s<i.length;s++)e=EN(i[s],e);return e}function TN(r,t){return r.x-t.x}function EN(r,t){let e=MN(r,t);if(!e)return t;let n=j1(e,r);return Ra(n,n.next),Ra(e,e.next)}function MN(r,t){let e=t,n=-1/0,i,s=r.x,o=r.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let h=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=s&&h>n&&(n=h,i=e.x<e.next.x?e:e.next,h===s))return i}e=e.next}while(e!==t);if(!i)return null;let a=i,l=i.x,u=i.y,c=1/0,d;e=i;do s>=e.x&&e.x>=l&&s!==e.x&&Rl(o<u?s:n,o,l,u,o<u?n:s,o,e.x,e.y)&&(d=Math.abs(o-e.y)/(s-e.x),Bd(e,r)&&(d<c||d===c&&(e.x>i.x||e.x===i.x&&CN(i,e)))&&(i=e,c=d)),e=e.next;while(e!==a);return i}function CN(r,t){return Qt(r.prev,r,t.prev)<0&&Qt(t.next,r,r.next)<0}function PN(r,t,e,n){let i=r;do i.z===0&&(i.z=Jv(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,IN(i)}function IN(r){let t,e,n,i,s,o,a,l,u=1;do{for(e=r,r=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)?(i=e,e=e.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;e=n}s.nextZ=null,u*=2}while(o>1);return r}function Jv(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function DN(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function Rl(r,t,e,n,i,s,o,a){return(i-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(n-a)}function ON(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!LN(r,t)&&(Bd(r,t)&&Bd(t,r)&&RN(r,t)&&(Qt(r.prev,r,t.prev)||Qt(r,t.prev,t))||Ip(r,t)&&Qt(r.prev,r,r.next)>0&&Qt(t.prev,t,t.next)>0)}function Qt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Ip(r,t){return r.x===t.x&&r.y===t.y}function W1(r,t,e,n){let i=Jf(Qt(r,t,e)),s=Jf(Qt(r,t,n)),o=Jf(Qt(e,n,r)),a=Jf(Qt(e,n,t));return!!(i!==s&&o!==a||i===0&&Qf(r,e,t)||s===0&&Qf(r,n,t)||o===0&&Qf(e,r,n)||a===0&&Qf(e,t,n))}function Qf(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Jf(r){return r>0?1:r<0?-1:0}function LN(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&W1(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Bd(r,t){return Qt(r.prev,r,r.next)<0?Qt(r,t,r.next)>=0&&Qt(r,r.prev,t)>=0:Qt(r,t,r.prev)<0||Qt(r,r.next,t)<0}function RN(r,t){let e=r,n=!1,i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function j1(r,t){let e=new $v(r.i,r.x,r.y),n=new $v(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function g1(r,t,e,n){let i=new $v(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Fd(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function $v(r,t,e){this.i=r,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 NN(r,t,e,n){let i=0;for(let s=t,o=e-n;s<e;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}var ql=class{static area(t){let e=t.length,n=0;for(let i=e-1,s=0;s<e;i=s++)n+=t[i].x*t[s].y-t[s].x*t[i].y;return n*.5}static isClockWise(t){return ql.area(t)<0}static triangulateShape(t,e){let n=[],i=[],s=[];y1(t),v1(n,t);let o=t.length;e.forEach(y1);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,v1(n,e[l]);let a=xN.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function y1(r){let t=r.length;t>2&&r[t-1].equals(r[0])&&r.pop()}function v1(r,t){for(let e=0;e<t.length;e++)r.push(t[e].x),r.push(t[e].y)}var Xl=class extends Wl{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Xl(t.radius,t.detail)}};var Na=class extends Te{constructor(t=1,e=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,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=[],d=new _,h=new _,f=[],g=[],p=[],m=[];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 A=w/e;d.x=-t*Math.cos(i+A*s)*Math.sin(o+x*a),d.y=t*Math.cos(o+x*a),d.z=t*Math.sin(i+A*s)*Math.sin(o+x*a),g.push(d.x,d.y,d.z),h.copy(d).normalize(),p.push(h.x,h.y,h.z),m.push(A+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],A=c[y+1][v+1];(y!==0||o>0)&&f.push(x,b,A),(y!==n-1||l<Math.PI)&&f.push(b,w,A)}this.setIndex(f),this.setAttribute("position",new we(g,3)),this.setAttribute("normal",new we(p,3)),this.setAttribute("uv",new we(m,2))}static fromJSON(t){return new Na(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var Yl=class extends Te{constructor(t=1,e=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);let a=[],l=[],u=[],c=[],d=new _,h=new _,f=new _,g=new _,p=new _,m=new _,y=new _;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,g),m.subVectors(g,f),y.addVectors(g,f),p.crossVectors(m,y),y.crossVectors(p,m),p.normalize(),y.normalize();for(let w=0;w<=i;++w){let A=w/i*Math.PI*2,T=-e*Math.cos(A),S=e*Math.sin(A);d.x=f.x+(T*y.x+S*p.x),d.y=f.y+(T*y.y+S*p.y),d.z=f.z+(T*y.z+S*p.z),l.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),u.push(h.x,h.y,h.z),c.push(x/n),c.push(w/i)}}for(let x=1;x<=n;x++)for(let b=1;b<=i;b++){let w=(i+1)*(x-1)+(b-1),A=(i+1)*x+(b-1),T=(i+1)*x+b,S=(i+1)*(x-1)+b;a.push(w,A,S),a.push(A,T,S)}this.setIndex(a),this.setAttribute("position",new we(l,3)),this.setAttribute("normal",new we(u,3)),this.setAttribute("uv",new we(c,2));function v(x,b,w,A,T){let S=Math.cos(x),E=Math.sin(x),M=w/b*x,I=Math.cos(M);T.x=A*(2+I)*.5*S,T.y=A*(2+I)*E*.5,T.z=A*Math.sin(M)*.5}}static fromJSON(t){return new Yl(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function bo(r,t,e){return q1(r)?new r.constructor(r.subarray(t,e!==void 0?e:r.length)):r.slice(t,e)}function $f(r,t,e){return!r||!e&&r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function q1(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var Kl=class{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],s=e[n-1];n:{e:{let o;t:{r:if(!(t<i)){for(let a=n+2;;){if(i===void 0){if(t<s)break r;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=e[++n],t<i)break e}o=e.length;break t}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(i=s,s=e[--n-1],t>=s)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(i=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i;for(let o=0;o!==i;++o)e[o]=n[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},e0=class extends Kl{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Cw,endingEnd:Cw}}intervalChanged_(t,e,n){let i=this.parameterPositions,s=t-2,o=t+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Pw:s=t,a=2*e-n;break;case Iw:s=i.length-2,a=e+i[s]-i[s+1];break;default:s=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Pw:o=t,l=2*n-e;break;case Iw:o=1,l=n+i[1]-i[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,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,g=(n-e)/(i-e),p=g*g,m=p*g,y=-h*m+2*h*p-h*g,v=(1+h)*m+(-1.5-2*h)*p+(-.5+h)*g+1,x=(-1-f)*m+(1.5+f)*p+.5*g,b=f*m-f*p;for(let w=0;w!==a;++w)s[w]=y*o[c+w]+v*o[u+w]+x*o[l+w]+b*o[d+w];return s}},t0=class extends Kl{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(n-e)/(i-e),d=1-c;for(let h=0;h!==a;++h)s[h]=o[u+h]*d+o[l+h]*c;return s}},n0=class extends Kl{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}},Mi=class{constructor(t,e,n,i){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=$f(e,this.TimeBufferType),this.values=$f(n,this.ValueBufferType),this.setInterpolation(i||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:$f(t.times,Array),values:$f(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new n0(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new t0(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new e0(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case ip:e=this.InterpolantFactoryMethodDiscrete;break;case sp:e=this.InterpolantFactoryMethodLinear;break;case $y: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 ip;case this.InterpolantFactoryMethodLinear:return sp;case this.InterpolantFactoryMethodSmooth:return $y}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){let n=this.times,i=n.length,s=0,o=i-1;for(;s!==i&&n[s]<t;)++s;for(;o!==-1&&n[o]>e;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=bo(n,s,o),this.values=bo(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,i=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(i!==void 0&&q1(i))for(let a=0,l=i.length;a!==l;++a){let u=i[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}return t}optimize(){let t=bo(this.times),e=bo(this.values),n=this.getValueSize(),i=this.getInterpolation()===$y,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(i)l=!0;else{let d=a*n,h=d-n,f=d+n;for(let g=0;g!==n;++g){let p=e[d+g];if(p!==e[h+g]||p!==e[f+g]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let d=a*n,h=o*n;for(let f=0;f!==n;++f)e[h+f]=e[d+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=bo(t,0,o),this.values=bo(e,0,o*n)):(this.times=t,this.values=e),this}clone(){let t=bo(this.times,0),e=bo(this.values,0),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};Mi.prototype.TimeBufferType=Float32Array;Mi.prototype.ValueBufferType=Float32Array;Mi.prototype.DefaultInterpolation=sp;var Ba=class extends Mi{};Ba.prototype.ValueTypeName="bool";Ba.prototype.ValueBufferType=Array;Ba.prototype.DefaultInterpolation=ip;Ba.prototype.InterpolantFactoryMethodLinear=void 0;Ba.prototype.InterpolantFactoryMethodSmooth=void 0;var r0=class extends Mi{};r0.prototype.ValueTypeName="color";var i0=class extends Mi{};i0.prototype.ValueTypeName="number";var s0=class extends Kl{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(i-e),u=t*a;for(let c=u+a;u!==c;u+=4)rt.slerpFlat(s,0,o,u-a,o,u,l);return s}},Ud=class extends Mi{InterpolantFactoryMethodLinear(t){return new s0(this.times,this.values,this.getValueSize(),t)}};Ud.prototype.ValueTypeName="quaternion";Ud.prototype.DefaultInterpolation=sp;Ud.prototype.InterpolantFactoryMethodSmooth=void 0;var Fa=class extends Mi{};Fa.prototype.ValueTypeName="string";Fa.prototype.ValueBufferType=Array;Fa.prototype.DefaultInterpolation=ip;Fa.prototype.InterpolantFactoryMethodLinear=void 0;Fa.prototype.InterpolantFactoryMethodSmooth=void 0;var o0=class extends Mi{};o0.prototype.ValueTypeName="vector";var x1={enabled:!1,files:{},add:function(r,t){this.enabled!==!1&&(this.files[r]=t)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},Gd=class{constructor(t,e,n){let i=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&&i.onStart!==void 0&&i.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,i.onProgress!==void 0&&i.onProgress(c,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(c){i.onError!==void 0&&i.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,d){return u.push(c,d),this},this.removeHandler=function(c){let d=u.indexOf(c);return d!==-1&&u.splice(d,2),this},this.getHandler=function(c){for(let d=0,h=u.length;d<h;d+=2){let f=u[d],g=u[d+1];if(f.global&&(f.lastIndex=0),f.test(c))return g}return null}}},BN=new Gd,Zl=class{constructor(t){this.manager=t!==void 0?t:BN,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(i,s){n.load(t,i,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}},Fs={},a0=class extends Error{constructor(t,e){super(t),this.response=e}},Ql=class extends Zl{constructor(t){super(t)}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=x1.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(Fs[t]!==void 0){Fs[t].push({onLoad:e,onProgress:n,onError:i});return}Fs[t]=[],Fs[t].push({onLoad:e,onProgress:n,onError:i});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=Fs[t],d=u.body.getReader(),h=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=h?parseInt(h):0,g=f!==0,p=0,m=new ReadableStream({start(y){v();function v(){d.read().then(({done:x,value:b})=>{if(x)y.close();else{p+=b.byteLength;let w=new ProgressEvent("progress",{lengthComputable:g,loaded:p,total:f});for(let A=0,T=c.length;A<T;A++){let S=c[A];S.onProgress&&S.onProgress(w)}y.enqueue(b),v()}})}}});return new Response(m)}else throw new a0(`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 d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return u.arrayBuffer().then(g=>f.decode(g))}}}).then(u=>{x1.add(t,u);let c=Fs[t];delete Fs[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=Fs[t];if(c===void 0)throw this.manager.itemError(t),u;delete Fs[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];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 Co=class extends ut{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Le(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}},vp=class extends Co{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Le(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},Cv=new de,b1=new _,S1=new _,kd=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new F(512,512),this.map=null,this.mapPass=null,this.matrix=new de,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Dd,this._frameExtents=new F(1,1),this._viewportCount=1,this._viewports=[new Qe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;b1.setFromMatrixPosition(t.matrixWorld),e.position.copy(b1),S1.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(S1),e.updateMatrixWorld(),Cv.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Cv),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Cv)}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}},l0=class extends kd{constructor(){super(new cn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,n=Pd*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(n!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},xp=class extends Co{constructor(t,e,n=0,i=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new l0}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}},w1=new de,xd=new _,Pv=new _,c0=class extends kd{constructor(){super(new cn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new F(4,2),this._viewportCount=6,this._viewports=[new Qe(2,1,1,1),new Qe(0,1,1,1),new Qe(3,1,1,1),new Qe(1,1,1,1),new Qe(3,0,1,1),new Qe(1,0,1,1)],this._cubeDirections=[new _(1,0,0),new _(-1,0,0),new _(0,0,1),new _(0,0,-1),new _(0,1,0),new _(0,-1,0)],this._cubeUps=[new _(0,1,0),new _(0,1,0),new _(0,1,0),new _(0,1,0),new _(0,0,1),new _(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,i=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),xd.setFromMatrixPosition(t.matrixWorld),n.position.copy(xd),Pv.copy(n.position),Pv.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Pv),n.updateMatrixWorld(),i.makeTranslation(-xd.x,-xd.y,-xd.z),w1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(w1)}},bp=class extends Co{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new c0}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}},u0=class extends kd{constructor(){super(new Ma(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Sp=class extends Co{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.shadow=new u0}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var d0=class extends Te{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}},Jl=class extends Zl{constructor(t){super(t)}load(t,e,n,i){let s=this,o=new Ql(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){i?i(l):console.error(l),s.manager.itemError(t)}},n,i)}parse(t){let e={},n={};function i(f,g){if(e[g]!==void 0)return e[g];let m=f.interleavedBuffers[g],y=s(f,m.buffer),v=If(m.type,y),x=new mp(v,m.stride);return x.uuid=m.uuid,e[g]=x,x}function s(f,g){if(n[g]!==void 0)return n[g];let m=f.arrayBuffers[g],y=new Uint32Array(m).buffer;return n[g]=y,y}let o=t.isInstancedBufferGeometry?new d0:new Te,a=t.data.index;if(a!==void 0){let f=If(a.type,a.array);o.setIndex(new Be(f,1))}let l=t.data.attributes;for(let f in l){let g=l[f],p;if(g.isInterleavedBufferAttribute){let m=i(t.data,g.data);p=new Ca(m,g.itemSize,g.offset,g.normalized)}else{let m=If(g.type,g.array),y=g.isInstancedBufferAttribute?gp:Be;p=new y(m,g.itemSize,g.normalized)}g.name!==void 0&&(p.name=g.name),g.usage!==void 0&&p.setUsage(g.usage),g.updateRange!==void 0&&(p.updateRange.offset=g.updateRange.offset,p.updateRange.count=g.updateRange.count),o.setAttribute(f,p)}let u=t.data.morphAttributes;if(u)for(let f in u){let g=u[f],p=[];for(let m=0,y=g.length;m<y;m++){let v=g[m],x;if(v.isInterleavedBufferAttribute){let b=i(t.data,v.data);x=new Ca(b,v.itemSize,v.offset,v.normalized)}else{let b=If(v.type,v.array);x=new Be(b,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),p.push(x)}o.morphAttributes[f]=p}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let d=t.data.groups||t.data.drawcalls||t.data.offsets;if(d!==void 0)for(let f=0,g=d.length;f!==g;++f){let p=d[f];o.addGroup(p.start,p.count,p.materialIndex)}let h=t.data.boundingSphere;if(h!==void 0){let f=new _;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new Sn(f,h.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var wp=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=A1(),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=A1();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function A1(){return(typeof performance>"u"?Date:performance).now()}var b0="\\[\\]\\.:\\/",FN=new RegExp("["+b0+"]","g"),S0="[^"+b0+"]",UN="[^"+b0.replace("\\.","")+"]",GN=/((?:WC+[\/:])*)/.source.replace("WC",S0),kN=/(WCOD+)?/.source.replace("WCOD",UN),zN=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",S0),VN=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",S0),HN=new RegExp("^"+GN+kN+zN+VN+"$"),WN=["material","materials","bones","map"],h0=class{constructor(t,e,n){let i=n||Mt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].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()}},Mt=class{constructor(t,e,n){this.path=e,this.parsedPath=n||Mt.parseTrackName(e),this.node=Mt.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 Mt.Composite(t,e,n):new Mt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(FN,"")}static parseTrackName(t){let e=HN.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]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);WN.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+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},i=n(t.children);if(i)return i}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 i=0,s=n.length;i!==s;++i)t[e++]=n[i]}_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 i=0,s=n.length;i!==s;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=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,i=e.propertyName,s=e.propertyIndex;if(t||(t=Mt.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[i];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+i+" 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(i==="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=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Mt.Composite=h0;Mt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Mt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Mt.prototype.GetterByBindingType=[Mt.prototype._getValue_direct,Mt.prototype._getValue_array,Mt.prototype._getValue_arrayElement,Mt.prototype._getValue_toArray];Mt.prototype.SetterByBindingTypeAndVersioning=[[Mt.prototype._setValue_direct,Mt.prototype._setValue_direct_setNeedsUpdate,Mt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Mt.prototype._setValue_array,Mt.prototype._setValue_array_setNeedsUpdate,Mt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Mt.prototype._setValue_arrayElement,Mt.prototype._setValue_arrayElement_setNeedsUpdate,Mt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Mt.prototype._setValue_fromArray,Mt.prototype._setValue_fromArray_setNeedsUpdate,Mt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var M6=new Float32Array(1);var Se=class{constructor(t){this.value=t}clone(){return new Se(this.value.clone===void 0?this.value:this.value.clone())}};var $l=class{constructor(t,e,n=0,i=1/0){this.ray=new Ti(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new Id,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 f0(t,this,n,e),n.sort(_1),n}intersectObjects(t,e=!0,n=[]){for(let i=0,s=t.length;i<s;i++)f0(t[i],this,n,e);return n.sort(_1),n}};function _1(r,t){return r.distance-t.distance}function f0(r,t,e,n){if(r.layers.test(t.layers)&&r.raycast(t,e),n===!0){let i=r.children;for(let s=0,o=i.length;s<o;s++)f0(i[s],t,e,!0)}}var zd=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(_n(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var T1=new F,Ap=class{constructor(t=new F(1/0,1/0),e=new F(-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=T1.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 T1.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)}},E1=new _,ep=new _,Cn=class{constructor(t=new _,e=new _){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){E1.subVectors(t,this.start),ep.subVectors(this.end,this.start);let n=ep.dot(ep),s=ep.dot(E1)/n;return e&&(s=_n(s,0,1)),s}closestPointToPoint(t,e,n){let i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).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)}},M1=new _,_p=class extends ut{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Te,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;i.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new we(i,3));let s=new ai({fog:!1,toneMapped:!1});this.cone=new Mo(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),M1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(M1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Tp=class extends Un{constructor(t,e,n){let i=new Na(e,4,2),s=new zs({wireframe:!0,fog:!1,toneMapped:!1});super(i,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 C1=new _,tp=new _,P1=new _,Ep=class extends ut{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 i=new Te;i.setAttribute("position",new we([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new ai({fog:!1,toneMapped:!1});this.lightPlane=new Pa(i,s),this.add(this.lightPlane),i=new Te,i.setAttribute("position",new we([0,0,0,0,0,1],3)),this.targetLine=new Pa(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),C1.setFromMatrixPosition(this.light.matrixWorld),tp.setFromMatrixPosition(this.light.target.matrixWorld),P1.subVectors(tp,C1),this.lightPlane.lookAt(tp),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(tp),this.targetLine.scale.z=P1.length()}},np=new _,en=new Ei,Po=class extends Mo{constructor(t){let e=new Te,n=new ai({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(g,p){l(g),l(p)}function l(g){i.push(0,0,0),s.push(0,0,0),o[g]===void 0&&(o[g]=[]),o[g].push(i.length/3-1)}e.setAttribute("position",new we(i,3)),e.setAttribute("color",new we(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 Le(16755200),c=new Le(16711680),d=new Le(43775),h=new Le(16777215),f=new Le(3355443);this.setColors(u,c,d,h,f)}setColors(t,e,n,i,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,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,n=1,i=1;en.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ln("c",e,t,en,0,0,-1),ln("t",e,t,en,0,0,1),ln("n1",e,t,en,-n,-i,-1),ln("n2",e,t,en,n,-i,-1),ln("n3",e,t,en,-n,i,-1),ln("n4",e,t,en,n,i,-1),ln("f1",e,t,en,-n,-i,1),ln("f2",e,t,en,n,-i,1),ln("f3",e,t,en,-n,i,1),ln("f4",e,t,en,n,i,1),ln("u1",e,t,en,n*.7,i*1.1,-1),ln("u2",e,t,en,-n*.7,i*1.1,-1),ln("u3",e,t,en,0,i*2,-1),ln("cf1",e,t,en,-n,0,1),ln("cf2",e,t,en,n,0,1),ln("cf3",e,t,en,0,-i,1),ln("cf4",e,t,en,0,i,1),ln("cn1",e,t,en,-n,0,-1),ln("cn2",e,t,en,n,0,-1),ln("cn3",e,t,en,0,-i,-1),ln("cn4",e,t,en,0,i,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ln(r,t,e,n,i,s,o){np.set(i,s,o).unproject(n);let a=t[r];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],np.x,np.y,np.z)}}var Io=class extends Mo{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]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Te;s.setIndex(new Be(n,1)),s.setAttribute("position",new we(i,3)),super(s,new ai({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 Mp=class extends Mo{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],i=new Te;i.setAttribute("position",new we(e,3)),i.setAttribute("color",new we(n,3));let s=new ai({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,n){let i=new Le,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ws}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ws);var nc=".",Vd=Symbol("target"),w0=Symbol("unsubscribe");function Hd(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function X1(r){return(typeof r=="object"?r===null:typeof r!="function")||r instanceof RegExp}var Yr=Array.isArray;function Ua(r){return typeof r=="symbol"}var jN={after:(r,t)=>Yr(r)?r.slice(t.length):t===""?r:r.slice(t.length+1),concat:(r,t)=>Yr(r)?(r=[...r],t&&r.push(t),r):t&&t.toString!==void 0?(r!==""&&(r+=nc),Ua(t)?r+t.toString():r+t):r,initial:r=>{if(Yr(r))return r.slice(0,-1);if(r==="")return r;let t=r.lastIndexOf(nc);return t===-1?"":r.slice(0,t)},last:r=>{if(Yr(r))return r[r.length-1]||"";if(r==="")return r;let t=r.lastIndexOf(nc);return t===-1?r:r.slice(t+1)},walk:(r,t)=>{if(Yr(r))for(let e of r)t(e);else if(r!==""){let e=0,n=r.indexOf(nc);if(n===-1)t(r);else for(;e<r.length;)n===-1&&(n=r.length),t(r.slice(e,n)),e=n+1,n=r.indexOf(nc,e)}},get(r,t){return this.walk(t,e=>{r&&(r=r[e])}),r}},mr=jN;function A0(r){return typeof r=="object"&&typeof r.next=="function"}function _0(r,t,e,n,i){let s=r.next;if(t.name==="entries")r.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],t,o.value[0],n),o.value[1]=i(o.value[1],t,o.value[0],n)),o};else if(t.name==="values"){let o=e[Vd].keys();r.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,t,o.next().value,n)),a}}else r.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,t,o.value,n)),o};return r}function Dp(r,t,e){return r.isUnsubscribed||t.ignoreSymbols&&Ua(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var Wd=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),i=n[e];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(t,e),n[e]=i),i}getProxy(t,e,n,i){if(this.isUnsubscribed)return t;let s=t[i],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,mr.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,i,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,i):Reflect.set(t,e,n)}return!0}deleteProperty(t,e,n){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(t);i&&(delete i[e],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(t,e,n){let i=this._getOwnPropertyDescriptor(e,n);return t!==void 0&&i!==void 0&&Object.is(t.value,i.value)&&(t.writable||!1)===(i.writable||!1)&&(t.enumerable||!1)===(i.enumerable||!1)&&(t.configurable||!1)===(i.configurable||!1)&&t.get===i.get&&t.set===i.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 rc(r){return toString.call(r)==="[object Object]"}function ic(){return!0}function Do(r,t){return r.length!==t.length||r.some((e,n)=>t[n]!==e)}var Op=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var qN=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),T0={push:ic,pop:ic,shift:ic,unshift:ic,copyWithin:Do,reverse:Do,sort:Do,splice:Do,flat:Do,fill:Do},Y1=new Set([...Op,...qN,...Object.keys(T0)]);function sc(r,t){if(r.size!==t.size)return!0;for(let e of r)if(!t.has(e))return!0;return!1}var E0=["keys","values","entries"],M0=new Set(["has","toString"]),C0={add:sc,clear:sc,delete:sc,forEach:sc},K1=new Set([...M0,...Object.keys(C0),...E0]);function oc(r,t){if(r.size!==t.size)return!0;let e;for(let[n,i]of r)if(e=t.get(n),e!==i||e===void 0&&!t.has(n))return!0;return!1}var XN=new Set([...M0,"get"]),P0={set:oc,clear:oc,delete:oc,forEach:oc},Z1=new Set([...XN,...Object.keys(P0),...E0]);var zn=class{constructor(t,e,n,i){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return Op.has(t)}_shallowClone(t){let e=t;if(rc(t))e={...t};else if(Yr(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,i]of t.entries())e.set(n,this._shallowClone(i))}return this._clonedCache.add(e),e}preferredThisArg(t,e,n,i){return t?(Yr(i)?this._onIsChanged=T0[e]:i instanceof Set?this._onIsChanged=C0[e]:i instanceof Map&&(this._onIsChanged=P0[e]),i):n}update(t,e,n){let i=mr.after(t,this._path);if(e!=="length"){let s=this.clone;mr.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property: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],mr.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var ac=class extends zn{static isHandledMethod(t){return Y1.has(t)}};var jd=class extends zn{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var lc=class extends zn{static isHandledMethod(t){return K1.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 cc=class extends zn{static isHandledMethod(t){return Z1.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 qd=class extends zn{constructor(t,e,n,i){super(void 0,e,n,i),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 Xd=class extends zn{constructor(t,e,n,i){super(void 0,e,n,i),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 Pi=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return rc(t)||Yr(t)||Hd(t)}static isHandledMethod(t,e){return rc(t)?zn.isHandledMethod(e):Yr(t)?ac.isHandledMethod(e):t instanceof Set?lc.isHandledMethod(e):t instanceof Map?cc.isHandledMethod(e):Hd(t)}get isCloning(){return this._stack.length>0}start(t,e,n){let i=zn;Yr(t)?i=ac:t instanceof Date?i=jd:t instanceof Set?i=lc:t instanceof Map?i=cc:t instanceof WeakSet?i=qd:t instanceof WeakMap&&(i=Xd),this._stack.push(new i(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:i}=t,s=Pi.isHandledMethod(n,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,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 YN={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},I0=(r,t,e={})=>{e={...YN,...e};let n=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=e,l=new Wd(i),u=typeof e.onValidate=="function",c=new Pi(u),d=(v,x,b,w,A)=>!u||c.isCloning||e.onValidate(mr.concat(l.getPath(v),x),b,w,A)===!0,h=(v,x,b,w)=>{!Dp(l,e,x)&&!(o&&l.isDetached(v,r))&&f(l.getPath(v),x,b,w)},f=(v,x,b,w,A)=>{c.isCloning?c.update(v,x,w):t(mr.concat(v,x),b,w,A)},g=v=>v&&(v[n]||v),p=(v,x,b,w)=>X1(v)||b==="constructor"||s&&!Pi.isHandledMethod(x,b)||Dp(l,e,b)||l.isGetInvariant(x,b)||o&&l.isDetached(x,r)?v:(w===void 0&&(w=l.getPath(x)),l.getProxy(v,mr.concat(w,b),m,n)),m={get(v,x,b){if(Ua(x)){if(x===n||x===Vd)return v;if(x===w0&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let w=Hd(v)?Reflect.get(v,x):Reflect.get(v,x,b);return p(w,v,x)},set(v,x,b,w){b=g(b);let A=v[n]||v,T=A[x];if(i(T,b)&&x in v)return!0;let S=d(v,x,b,T);return S&&l.setProperty(A,x,b,w,T)?(h(v,x,v[x],T),!0):!S},defineProperty(v,x,b){if(!l.isSameDescriptor(b,v,x)){let w=v[x];d(v,x,b.value,w)&&l.defineProperty(v,x,b,w)&&h(v,x,b.value,w)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let b=Reflect.get(v,x),w=d(v,x,void 0,b);return w&&l.deleteProperty(v,x,b)?(h(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))&&Pi.isHandledType(w)){let A=mr.initial(l.getPath(v)),T=Pi.isHandledMethod(w,v.name);c.start(w,A,b);let S=Reflect.apply(v,c.preferredThisArg(v,x,w),T?b.map(I=>g(I)):b),E=c.isChanged(w,i),M=c.stop();if(Pi.isHandledType(S)&&T&&(x instanceof Map&&v.name==="get"&&(A=mr.concat(A,b[0])),S=l.getProxy(S,A,m)),E){let I={name:v.name,args:b,result:S},P=c.isCloning?mr.initial(A):A,C=c.isCloning?mr.last(A):"";d(mr.get(r,P),C,w,M,I)?f(P,C,w,M,I):c.undo(w)}return(x instanceof Map||x instanceof Set)&&A0(S)?_0(S,v,x,A,p):S}return Reflect.apply(v,x,b)}},y=l.getProxy(r,e.pathAsArray?[]:"",m);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};I0.target=r=>r&&r[Vd]||r;I0.unsubscribe=r=>r[w0]||r;var D0=I0;var KN=typeof global=="object"&&global&&global.Object===Object&&global,Lp=KN;var ZN=typeof self=="object"&&self&&self.Object===Object&&self,QN=Lp||ZN||Function("return this")(),rn=QN;var JN=rn.Symbol,Vn=JN;var Q1=Object.prototype,$N=Q1.hasOwnProperty,eB=Q1.toString,Yd=Vn?Vn.toStringTag:void 0;function tB(r){var t=$N.call(r,Yd),e=r[Yd];try{r[Yd]=void 0;var n=!0}catch{}var i=eB.call(r);return n&&(t?r[Yd]=e:delete r[Yd]),i}var J1=tB;var nB=Object.prototype,rB=nB.toString;function iB(r){return rB.call(r)}var $1=iB;var sB="[object Null]",oB="[object Undefined]",eA=Vn?Vn.toStringTag:void 0;function aB(r){return r==null?r===void 0?oB:sB:eA&&eA in Object(r)?J1(r):$1(r)}var Kr=aB;function lB(r){return r!=null&&typeof r=="object"}var Jn=lB;var cB="[object Symbol]";function uB(r){return typeof r=="symbol"||Jn(r)&&Kr(r)==cB}var Oo=uB;function dB(r,t){for(var e=-1,n=r==null?0:r.length,i=Array(n);++e<n;)i[e]=t(r[e],e,r);return i}var Rp=dB;var hB=Array.isArray,Pn=hB;var fB=1/0,tA=Vn?Vn.prototype:void 0,nA=tA?tA.toString:void 0;function rA(r){if(typeof r=="string")return r;if(Pn(r))return Rp(r,rA)+"";if(Oo(r))return nA?nA.call(r):"";var t=r+"";return t=="0"&&1/r==-fB?"-0":t}var iA=rA;var pB=/\s/;function mB(r){for(var t=r.length;t--&&pB.test(r.charAt(t)););return t}var sA=mB;var gB=/^\s+/;function yB(r){return r&&r.slice(0,sA(r)+1).replace(gB,"")}var oA=yB;function vB(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}var Hn=vB;var aA=0/0,xB=/^[-+]0x[0-9a-f]+$/i,bB=/^0b[01]+$/i,SB=/^0o[0-7]+$/i,wB=parseInt;function AB(r){if(typeof r=="number")return r;if(Oo(r))return aA;if(Hn(r)){var t=typeof r.valueOf=="function"?r.valueOf():r;r=Hn(t)?t+"":t}if(typeof r!="string")return r===0?r:+r;r=oA(r);var e=bB.test(r);return e||SB.test(r)?wB(r.slice(2),e?2:8):xB.test(r)?aA:+r}var O0=AB;function _B(r){return r}var lA=_B;var TB="[object AsyncFunction]",EB="[object Function]",MB="[object GeneratorFunction]",CB="[object Proxy]";function PB(r){if(!Hn(r))return!1;var t=Kr(r);return t==EB||t==MB||t==TB||t==CB}var Np=PB;var IB=rn["__core-js_shared__"],Bp=IB;var cA=function(){var r=/[^.]+$/.exec(Bp&&Bp.keys&&Bp.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function DB(r){return!!cA&&cA in r}var uA=DB;var OB=Function.prototype,LB=OB.toString;function RB(r){if(r!=null){try{return LB.call(r)}catch{}try{return r+""}catch{}}return""}var js=RB;var NB=/[\\^$.*+?()[\]{}|]/g,BB=/^\[object .+?Constructor\]$/,FB=Function.prototype,UB=Object.prototype,GB=FB.toString,kB=UB.hasOwnProperty,zB=RegExp("^"+GB.call(kB).replace(NB,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function VB(r){if(!Hn(r)||uA(r))return!1;var t=Np(r)?zB:BB;return t.test(js(r))}var dA=VB;function HB(r,t){return r?.[t]}var hA=HB;function WB(r,t){var e=hA(r,t);return dA(e)?e:void 0}var _r=WB;var jB=_r(rn,"WeakMap"),Fp=jB;var fA=Object.create,qB=function(){function r(){}return function(t){if(!Hn(t))return{};if(fA)return fA(t);r.prototype=t;var e=new r;return r.prototype=void 0,e}}(),pA=qB;function XB(r,t,e){switch(e.length){case 0:return r.call(t);case 1:return r.call(t,e[0]);case 2:return r.call(t,e[0],e[1]);case 3:return r.call(t,e[0],e[1],e[2])}return r.apply(t,e)}var mA=XB;function YB(r,t){var e=-1,n=r.length;for(t||(t=Array(n));++e<n;)t[e]=r[e];return t}var gA=YB;var KB=800,ZB=16,QB=Date.now;function JB(r){var t=0,e=0;return function(){var n=QB(),i=ZB-(n-e);if(e=n,i>0){if(++t>=KB)return arguments[0]}else t=0;return r.apply(void 0,arguments)}}var yA=JB;function $B(r){return function(){return r}}var vA=$B;var eF=function(){try{var r=_r(Object,"defineProperty");return r({},"",{}),r}catch{}}(),uc=eF;var tF=uc?function(r,t){return uc(r,"toString",{configurable:!0,enumerable:!1,value:vA(t),writable:!0})}:lA,xA=tF;var nF=yA(xA),bA=nF;function rF(r,t){for(var e=-1,n=r==null?0:r.length;++e<n&&t(r[e],e,r)!==!1;);return r}var SA=rF;var iF=9007199254740991,sF=/^(?:0|[1-9]\d*)$/;function oF(r,t){var e=typeof r;return t=t??iF,!!t&&(e=="number"||e!="symbol"&&sF.test(r))&&r>-1&&r%1==0&&r<t}var dc=oF;function aF(r,t,e){t=="__proto__"&&uc?uc(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[t]=e}var Up=aF;function lF(r,t){return r===t||r!==r&&t!==t}var hc=lF;var cF=Object.prototype,uF=cF.hasOwnProperty;function dF(r,t,e){var n=r[t];(!(uF.call(r,t)&&hc(n,e))||e===void 0&&!(t in r))&&Up(r,t,e)}var fc=dF;function hF(r,t,e,n){var i=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=n?n(e[a],r[a],a,e,r):void 0;l===void 0&&(l=r[a]),i?Up(e,a,l):fc(e,a,l)}return e}var $i=hF;var wA=Math.max;function fF(r,t,e){return t=wA(t===void 0?r.length-1:t,0),function(){for(var n=arguments,i=-1,s=wA(n.length-t,0),o=Array(s);++i<s;)o[i]=n[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=n[i];return a[t]=e(o),mA(r,this,a)}}var AA=fF;var pF=9007199254740991;function mF(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=pF}var pc=mF;function gF(r){return r!=null&&pc(r.length)&&!Np(r)}var Gp=gF;var yF=Object.prototype;function vF(r){var t=r&&r.constructor,e=typeof t=="function"&&t.prototype||yF;return r===e}var mc=vF;function xF(r,t){for(var e=-1,n=Array(r);++e<r;)n[e]=t(e);return n}var _A=xF;var bF="[object Arguments]";function SF(r){return Jn(r)&&Kr(r)==bF}var L0=SF;var TA=Object.prototype,wF=TA.hasOwnProperty,AF=TA.propertyIsEnumerable,_F=L0(function(){return arguments}())?L0:function(r){return Jn(r)&&wF.call(r,"callee")&&!AF.call(r,"callee")},gc=_F;function TF(){return!1}var EA=TF;var PA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,MA=PA&&typeof module=="object"&&module&&!module.nodeType&&module,EF=MA&&MA.exports===PA,CA=EF?rn.Buffer:void 0,MF=CA?CA.isBuffer:void 0,CF=MF||EA,Ga=CF;var PF="[object Arguments]",IF="[object Array]",DF="[object Boolean]",OF="[object Date]",LF="[object Error]",RF="[object Function]",NF="[object Map]",BF="[object Number]",FF="[object Object]",UF="[object RegExp]",GF="[object Set]",kF="[object String]",zF="[object WeakMap]",VF="[object ArrayBuffer]",HF="[object DataView]",WF="[object Float32Array]",jF="[object Float64Array]",qF="[object Int8Array]",XF="[object Int16Array]",YF="[object Int32Array]",KF="[object Uint8Array]",ZF="[object Uint8ClampedArray]",QF="[object Uint16Array]",JF="[object Uint32Array]",zt={};zt[WF]=zt[jF]=zt[qF]=zt[XF]=zt[YF]=zt[KF]=zt[ZF]=zt[QF]=zt[JF]=!0;zt[PF]=zt[IF]=zt[VF]=zt[DF]=zt[HF]=zt[OF]=zt[LF]=zt[RF]=zt[NF]=zt[BF]=zt[FF]=zt[UF]=zt[GF]=zt[kF]=zt[zF]=!1;function $F(r){return Jn(r)&&pc(r.length)&&!!zt[Kr(r)]}var IA=$F;function eU(r){return function(t){return r(t)}}var yc=eU;var DA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Kd=DA&&typeof module=="object"&&module&&!module.nodeType&&module,tU=Kd&&Kd.exports===DA,R0=tU&&Lp.process,nU=function(){try{var r=Kd&&Kd.require&&Kd.require("util").types;return r||R0&&R0.binding&&R0.binding("util")}catch{}}(),qs=nU;var OA=qs&&qs.isTypedArray,rU=OA?yc(OA):IA,kp=rU;var iU=Object.prototype,sU=iU.hasOwnProperty;function oU(r,t){var e=Pn(r),n=!e&&gc(r),i=!e&&!n&&Ga(r),s=!e&&!n&&!i&&kp(r),o=e||n||i||s,a=o?_A(r.length,String):[],l=a.length;for(var u in r)(t||sU.call(r,u))&&!(o&&(u=="length"||i&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||dc(u,l)))&&a.push(u);return a}var zp=oU;function aU(r,t){return function(e){return r(t(e))}}var Vp=aU;var lU=Vp(Object.keys,Object),LA=lU;var cU=Object.prototype,uU=cU.hasOwnProperty;function dU(r){if(!mc(r))return LA(r);var t=[];for(var e in Object(r))uU.call(r,e)&&e!="constructor"&&t.push(e);return t}var RA=dU;function hU(r){return Gp(r)?zp(r):RA(r)}var vc=hU;function fU(r){var t=[];if(r!=null)for(var e in Object(r))t.push(e);return t}var NA=fU;var pU=Object.prototype,mU=pU.hasOwnProperty;function gU(r){if(!Hn(r))return NA(r);var t=mc(r),e=[];for(var n in r)n=="constructor"&&(t||!mU.call(r,n))||e.push(n);return e}var BA=gU;function yU(r){return Gp(r)?zp(r,!0):BA(r)}var xc=yU;var vU=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,xU=/^\w*$/;function bU(r,t){if(Pn(r))return!1;var e=typeof r;return e=="number"||e=="symbol"||e=="boolean"||r==null||Oo(r)?!0:xU.test(r)||!vU.test(r)||t!=null&&r in Object(t)}var FA=bU;var SU=_r(Object,"create"),Xs=SU;function wU(){this.__data__=Xs?Xs(null):{},this.size=0}var UA=wU;function AU(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}var GA=AU;var _U="__lodash_hash_undefined__",TU=Object.prototype,EU=TU.hasOwnProperty;function MU(r){var t=this.__data__;if(Xs){var e=t[r];return e===_U?void 0:e}return EU.call(t,r)?t[r]:void 0}var kA=MU;var CU=Object.prototype,PU=CU.hasOwnProperty;function IU(r){var t=this.__data__;return Xs?t[r]!==void 0:PU.call(t,r)}var zA=IU;var DU="__lodash_hash_undefined__";function OU(r,t){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=Xs&&t===void 0?DU:t,this}var VA=OU;function bc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}bc.prototype.clear=UA;bc.prototype.delete=GA;bc.prototype.get=kA;bc.prototype.has=zA;bc.prototype.set=VA;var N0=bc;function LU(){this.__data__=[],this.size=0}var HA=LU;function RU(r,t){for(var e=r.length;e--;)if(hc(r[e][0],t))return e;return-1}var Lo=RU;var NU=Array.prototype,BU=NU.splice;function FU(r){var t=this.__data__,e=Lo(t,r);if(e<0)return!1;var n=t.length-1;return e==n?t.pop():BU.call(t,e,1),--this.size,!0}var WA=FU;function UU(r){var t=this.__data__,e=Lo(t,r);return e<0?void 0:t[e][1]}var jA=UU;function GU(r){return Lo(this.__data__,r)>-1}var qA=GU;function kU(r,t){var e=this.__data__,n=Lo(e,r);return n<0?(++this.size,e.push([r,t])):e[n][1]=t,this}var XA=kU;function Sc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}Sc.prototype.clear=HA;Sc.prototype.delete=WA;Sc.prototype.get=jA;Sc.prototype.has=qA;Sc.prototype.set=XA;var Ro=Sc;var zU=_r(rn,"Map"),No=zU;function VU(){this.size=0,this.__data__={hash:new N0,map:new(No||Ro),string:new N0}}var YA=VU;function HU(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}var KA=HU;function WU(r,t){var e=r.__data__;return KA(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Bo=WU;function jU(r){var t=Bo(this,r).delete(r);return this.size-=t?1:0,t}var ZA=jU;function qU(r){return Bo(this,r).get(r)}var QA=qU;function XU(r){return Bo(this,r).has(r)}var JA=XU;function YU(r,t){var e=Bo(this,r),n=e.size;return e.set(r,t),this.size+=e.size==n?0:1,this}var $A=YU;function wc(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t<e;){var n=r[t];this.set(n[0],n[1])}}wc.prototype.clear=YA;wc.prototype.delete=ZA;wc.prototype.get=QA;wc.prototype.has=JA;wc.prototype.set=$A;var ka=wc;var KU="Expected a function";function B0(r,t){if(typeof r!="function"||t!=null&&typeof t!="function")throw new TypeError(KU);var e=function(){var n=arguments,i=t?t.apply(this,n):n[0],s=e.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return e.cache=s.set(i,o)||s,o};return e.cache=new(B0.Cache||ka),e}B0.Cache=ka;var e_=B0;var ZU=500;function QU(r){var t=e_(r,function(n){return e.size===ZU&&e.clear(),n}),e=t.cache;return t}var t_=QU;var JU=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$U=/\\(\\)?/g,eG=t_(function(r){var t=[];return r.charCodeAt(0)===46&&t.push(""),r.replace(JU,function(e,n,i,s){t.push(i?s.replace($U,"$1"):n||e)}),t}),n_=eG;function tG(r){return r==null?"":iA(r)}var r_=tG;function nG(r,t){return Pn(r)?r:FA(r,t)?[r]:n_(r_(r))}var ci=nG;var rG=1/0;function iG(r){if(typeof r=="string"||Oo(r))return r;var t=r+"";return t=="0"&&1/r==-rG?"-0":t}var Fo=iG;function sG(r,t){t=ci(t,r);for(var e=0,n=t.length;r!=null&&e<n;)r=r[Fo(t[e++])];return e&&e==n?r:void 0}var Hp=sG;function oG(r,t){for(var e=-1,n=t.length,i=r.length;++e<n;)r[i+e]=t[e];return r}var Ac=oG;var i_=Vn?Vn.isConcatSpreadable:void 0;function aG(r){return Pn(r)||gc(r)||!!(i_&&r&&r[i_])}var s_=aG;function o_(r,t,e,n,i){var s=-1,o=r.length;for(e||(e=s_),i||(i=[]);++s<o;){var a=r[s];t>0&&e(a)?t>1?o_(a,t-1,e,n,i):Ac(i,a):n||(i[i.length]=a)}return i}var a_=o_;function lG(r){var t=r==null?0:r.length;return t?a_(r,1):[]}var l_=lG;function cG(r){return bA(AA(r,void 0,l_),r+"")}var Wp=cG;var uG=Vp(Object.getPrototypeOf,Object),_c=uG;var dG="[object Object]",hG=Function.prototype,fG=Object.prototype,c_=hG.toString,pG=fG.hasOwnProperty,mG=c_.call(Object);function gG(r){if(!Jn(r)||Kr(r)!=dG)return!1;var t=_c(r);if(t===null)return!0;var e=pG.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&c_.call(e)==mG}var u_=gG;function yG(r,t,e){var n=-1,i=r.length;t<0&&(t=-t>i?0:i+t),e=e>i?i:e,e<0&&(e+=i),i=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(i);++n<i;)s[n]=r[n+t];return s}var d_=yG;function vG(){this.__data__=new Ro,this.size=0}var h_=vG;function xG(r){var t=this.__data__,e=t.delete(r);return this.size=t.size,e}var f_=xG;function bG(r){return this.__data__.get(r)}var p_=bG;function SG(r){return this.__data__.has(r)}var m_=SG;var wG=200;function AG(r,t){var e=this.__data__;if(e instanceof Ro){var n=e.__data__;if(!No||n.length<wG-1)return n.push([r,t]),this.size=++e.size,this;e=this.__data__=new ka(n)}return e.set(r,t),this.size=e.size,this}var g_=AG;function Tc(r){var t=this.__data__=new Ro(r);this.size=t.size}Tc.prototype.clear=h_;Tc.prototype.delete=f_;Tc.prototype.get=p_;Tc.prototype.has=m_;Tc.prototype.set=g_;var Ec=Tc;function _G(r,t){return r&&$i(t,vc(t),r)}var y_=_G;function TG(r,t){return r&&$i(t,xc(t),r)}var v_=TG;var w_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,x_=w_&&typeof module=="object"&&module&&!module.nodeType&&module,EG=x_&&x_.exports===w_,b_=EG?rn.Buffer:void 0,S_=b_?b_.allocUnsafe:void 0;function MG(r,t){if(t)return r.slice();var e=r.length,n=S_?S_(e):new r.constructor(e);return r.copy(n),n}var A_=MG;function CG(r,t){for(var e=-1,n=r==null?0:r.length,i=0,s=[];++e<n;){var o=r[e];t(o,e,r)&&(s[i++]=o)}return s}var __=CG;function PG(){return[]}var jp=PG;var IG=Object.prototype,DG=IG.propertyIsEnumerable,T_=Object.getOwnPropertySymbols,OG=T_?function(r){return r==null?[]:(r=Object(r),__(T_(r),function(t){return DG.call(r,t)}))}:jp,Mc=OG;function LG(r,t){return $i(r,Mc(r),t)}var E_=LG;var RG=Object.getOwnPropertySymbols,NG=RG?function(r){for(var t=[];r;)Ac(t,Mc(r)),r=_c(r);return t}:jp,qp=NG;function BG(r,t){return $i(r,qp(r),t)}var M_=BG;function FG(r,t,e){var n=t(r);return Pn(r)?n:Ac(n,e(r))}var Xp=FG;function UG(r){return Xp(r,vc,Mc)}var Zd=UG;function GG(r){return Xp(r,xc,qp)}var Yp=GG;var kG=_r(rn,"DataView"),Kp=kG;var zG=_r(rn,"Promise"),Zp=zG;var VG=_r(rn,"Set"),Qp=VG;var C_="[object Map]",HG="[object Object]",P_="[object Promise]",I_="[object Set]",D_="[object WeakMap]",O_="[object DataView]",WG=js(Kp),jG=js(No),qG=js(Zp),XG=js(Qp),YG=js(Fp),za=Kr;(Kp&&za(new Kp(new ArrayBuffer(1)))!=O_||No&&za(new No)!=C_||Zp&&za(Zp.resolve())!=P_||Qp&&za(new Qp)!=I_||Fp&&za(new Fp)!=D_)&&(za=function(r){var t=Kr(r),e=t==HG?r.constructor:void 0,n=e?js(e):"";if(n)switch(n){case WG:return O_;case jG:return C_;case qG:return P_;case XG:return I_;case YG:return D_}return t});var Ys=za;var KG=Object.prototype,ZG=KG.hasOwnProperty;function QG(r){var t=r.length,e=new r.constructor(t);return t&&typeof r[0]=="string"&&ZG.call(r,"index")&&(e.index=r.index,e.input=r.input),e}var L_=QG;var JG=rn.Uint8Array,Cc=JG;function $G(r){var t=new r.constructor(r.byteLength);return new Cc(t).set(new Cc(r)),t}var Pc=$G;function ek(r,t){var e=t?Pc(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.byteLength)}var R_=ek;var tk=/\w*$/;function nk(r){var t=new r.constructor(r.source,tk.exec(r));return t.lastIndex=r.lastIndex,t}var N_=nk;var B_=Vn?Vn.prototype:void 0,F_=B_?B_.valueOf:void 0;function rk(r){return F_?Object(F_.call(r)):{}}var U_=rk;function ik(r,t){var e=t?Pc(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.length)}var G_=ik;var sk="[object Boolean]",ok="[object Date]",ak="[object Map]",lk="[object Number]",ck="[object RegExp]",uk="[object Set]",dk="[object String]",hk="[object Symbol]",fk="[object ArrayBuffer]",pk="[object DataView]",mk="[object Float32Array]",gk="[object Float64Array]",yk="[object Int8Array]",vk="[object Int16Array]",xk="[object Int32Array]",bk="[object Uint8Array]",Sk="[object Uint8ClampedArray]",wk="[object Uint16Array]",Ak="[object Uint32Array]";function _k(r,t,e){var n=r.constructor;switch(t){case fk:return Pc(r);case sk:case ok:return new n(+r);case pk:return R_(r,e);case mk:case gk:case yk:case vk:case xk:case bk:case Sk:case wk:case Ak:return G_(r,e);case ak:return new n;case lk:case dk:return new n(r);case ck:return N_(r);case uk:return new n;case hk:return U_(r)}}var k_=_k;function Tk(r){return typeof r.constructor=="function"&&!mc(r)?pA(_c(r)):{}}var z_=Tk;var Ek="[object Map]";function Mk(r){return Jn(r)&&Ys(r)==Ek}var V_=Mk;var H_=qs&&qs.isMap,Ck=H_?yc(H_):V_,W_=Ck;var Pk="[object Set]";function Ik(r){return Jn(r)&&Ys(r)==Pk}var j_=Ik;var q_=qs&&qs.isSet,Dk=q_?yc(q_):j_,X_=Dk;var Ok=1,Lk=2,Rk=4,Y_="[object Arguments]",Nk="[object Array]",Bk="[object Boolean]",Fk="[object Date]",Uk="[object Error]",K_="[object Function]",Gk="[object GeneratorFunction]",kk="[object Map]",zk="[object Number]",Z_="[object Object]",Vk="[object RegExp]",Hk="[object Set]",Wk="[object String]",jk="[object Symbol]",qk="[object WeakMap]",Xk="[object ArrayBuffer]",Yk="[object DataView]",Kk="[object Float32Array]",Zk="[object Float64Array]",Qk="[object Int8Array]",Jk="[object Int16Array]",$k="[object Int32Array]",ez="[object Uint8Array]",tz="[object Uint8ClampedArray]",nz="[object Uint16Array]",rz="[object Uint32Array]",Ut={};Ut[Y_]=Ut[Nk]=Ut[Xk]=Ut[Yk]=Ut[Bk]=Ut[Fk]=Ut[Kk]=Ut[Zk]=Ut[Qk]=Ut[Jk]=Ut[$k]=Ut[kk]=Ut[zk]=Ut[Z_]=Ut[Vk]=Ut[Hk]=Ut[Wk]=Ut[jk]=Ut[ez]=Ut[tz]=Ut[nz]=Ut[rz]=!0;Ut[Uk]=Ut[K_]=Ut[qk]=!1;function Jp(r,t,e,n,i,s){var o,a=t&Ok,l=t&Lk,u=t&Rk;if(e&&(o=i?e(r,n,i,s):e(r)),o!==void 0)return o;if(!Hn(r))return r;var c=Pn(r);if(c){if(o=L_(r),!a)return gA(r,o)}else{var d=Ys(r),h=d==K_||d==Gk;if(Ga(r))return A_(r,a);if(d==Z_||d==Y_||h&&!i){if(o=l||h?{}:z_(r),!a)return l?M_(r,v_(o,r)):E_(r,y_(o,r))}else{if(!Ut[d])return i?r:{};o=k_(r,d,a)}}s||(s=new Ec);var f=s.get(r);if(f)return f;s.set(r,o),X_(r)?r.forEach(function(m){o.add(Jp(m,t,e,m,r,s))}):W_(r)&&r.forEach(function(m,y){o.set(y,Jp(m,t,e,y,r,s))});var g=u?l?Yp:Zd:l?xc:vc,p=c?void 0:g(r);return SA(p||r,function(m,y){p&&(y=m,m=r[y]),fc(o,y,Jp(m,t,e,y,r,s))}),o}var $p=Jp;var iz=1,sz=4;function oz(r){return $p(r,iz|sz)}var Ks=oz;var az="__lodash_hash_undefined__";function lz(r){return this.__data__.set(r,az),this}var Q_=lz;function cz(r){return this.__data__.has(r)}var J_=cz;function em(r){var t=-1,e=r==null?0:r.length;for(this.__data__=new ka;++t<e;)this.add(r[t])}em.prototype.add=em.prototype.push=Q_;em.prototype.has=J_;var $_=em;function uz(r,t){for(var e=-1,n=r==null?0:r.length;++e<n;)if(t(r[e],e,r))return!0;return!1}var eT=uz;function dz(r,t){return r.has(t)}var tT=dz;var hz=1,fz=2;function pz(r,t,e,n,i,s){var o=e&hz,a=r.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var u=s.get(r),c=s.get(t);if(u&&c)return u==t&&c==r;var d=-1,h=!0,f=e&fz?new $_:void 0;for(s.set(r,t),s.set(t,r);++d<a;){var g=r[d],p=t[d];if(n)var m=o?n(p,g,d,t,r,s):n(g,p,d,r,t,s);if(m!==void 0){if(m)continue;h=!1;break}if(f){if(!eT(t,function(y,v){if(!tT(f,v)&&(g===y||i(g,y,e,n,s)))return f.push(v)})){h=!1;break}}else if(!(g===p||i(g,p,e,n,s))){h=!1;break}}return s.delete(r),s.delete(t),h}var tm=pz;function mz(r){var t=-1,e=Array(r.size);return r.forEach(function(n,i){e[++t]=[i,n]}),e}var nT=mz;function gz(r){var t=-1,e=Array(r.size);return r.forEach(function(n){e[++t]=n}),e}var rT=gz;var yz=1,vz=2,xz="[object Boolean]",bz="[object Date]",Sz="[object Error]",wz="[object Map]",Az="[object Number]",_z="[object RegExp]",Tz="[object Set]",Ez="[object String]",Mz="[object Symbol]",Cz="[object ArrayBuffer]",Pz="[object DataView]",iT=Vn?Vn.prototype:void 0,F0=iT?iT.valueOf:void 0;function Iz(r,t,e,n,i,s,o){switch(e){case Pz:if(r.byteLength!=t.byteLength||r.byteOffset!=t.byteOffset)return!1;r=r.buffer,t=t.buffer;case Cz:return!(r.byteLength!=t.byteLength||!s(new Cc(r),new Cc(t)));case xz:case bz:case Az:return hc(+r,+t);case Sz:return r.name==t.name&&r.message==t.message;case _z:case Ez:return r==t+"";case wz:var a=nT;case Tz:var l=n&yz;if(a||(a=rT),r.size!=t.size&&!l)return!1;var u=o.get(r);if(u)return u==t;n|=vz,o.set(r,t);var c=tm(a(r),a(t),n,i,s,o);return o.delete(r),c;case Mz:if(F0)return F0.call(r)==F0.call(t)}return!1}var sT=Iz;var Dz=1,Oz=Object.prototype,Lz=Oz.hasOwnProperty;function Rz(r,t,e,n,i,s){var o=e&Dz,a=Zd(r),l=a.length,u=Zd(t),c=u.length;if(l!=c&&!o)return!1;for(var d=l;d--;){var h=a[d];if(!(o?h in t:Lz.call(t,h)))return!1}var f=s.get(r),g=s.get(t);if(f&&g)return f==t&&g==r;var p=!0;s.set(r,t),s.set(t,r);for(var m=o;++d<l;){h=a[d];var y=r[h],v=t[h];if(n)var x=o?n(v,y,h,t,r,s):n(y,v,h,r,t,s);if(!(x===void 0?y===v||i(y,v,e,n,s):x)){p=!1;break}m||(m=h=="constructor")}if(p&&!m){var b=r.constructor,w=t.constructor;b!=w&&"constructor"in r&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof w=="function"&&w instanceof w)&&(p=!1)}return s.delete(r),s.delete(t),p}var oT=Rz;var Nz=1,aT="[object Arguments]",lT="[object Array]",nm="[object Object]",Bz=Object.prototype,cT=Bz.hasOwnProperty;function Fz(r,t,e,n,i,s){var o=Pn(r),a=Pn(t),l=o?lT:Ys(r),u=a?lT:Ys(t);l=l==aT?nm:l,u=u==aT?nm:u;var c=l==nm,d=u==nm,h=l==u;if(h&&Ga(r)){if(!Ga(t))return!1;o=!0,c=!1}if(h&&!c)return s||(s=new Ec),o||kp(r)?tm(r,t,e,n,i,s):sT(r,t,l,e,n,i,s);if(!(e&Nz)){var f=c&&cT.call(r,"__wrapped__"),g=d&&cT.call(t,"__wrapped__");if(f||g){var p=f?r.value():r,m=g?t.value():t;return s||(s=new Ec),i(p,m,e,n,s)}}return h?(s||(s=new Ec),oT(r,t,e,n,i,s)):!1}var uT=Fz;function dT(r,t,e,n,i){return r===t?!0:r==null||t==null||!Jn(r)&&!Jn(t)?r!==r&&t!==t:uT(r,t,e,n,dT,i)}var hT=dT;function Uz(r,t){return r!=null&&t in Object(r)}var fT=Uz;function Gz(r,t,e){t=ci(t,r);for(var n=-1,i=t.length,s=!1;++n<i;){var o=Fo(t[n]);if(!(s=r!=null&&e(r,o)))break;r=r[o]}return s||++n!=i?s:(i=r==null?0:r.length,!!i&&pc(i)&&dc(o,i)&&(Pn(r)||gc(r)))}var pT=Gz;function kz(r,t){return r!=null&&pT(r,t,fT)}var mT=kz;var zz=function(){return rn.Date.now()},rm=zz;var Vz="Expected a function",Hz=Math.max,Wz=Math.min;function jz(r,t,e){var n,i,s,o,a,l,u=0,c=!1,d=!1,h=!0;if(typeof r!="function")throw new TypeError(Vz);t=O0(t)||0,Hn(e)&&(c=!!e.leading,d="maxWait"in e,s=d?Hz(O0(e.maxWait)||0,t):s,h="trailing"in e?!!e.trailing:h);function f(A){var T=n,S=i;return n=i=void 0,u=A,o=r.apply(S,T),o}function g(A){return u=A,a=setTimeout(y,t),c?f(A):o}function p(A){var T=A-l,S=A-u,E=t-T;return d?Wz(E,s-S):E}function m(A){var T=A-l,S=A-u;return l===void 0||T>=t||T<0||d&&S>=s}function y(){var A=rm();if(m(A))return v(A);a=setTimeout(y,p(A))}function v(A){return a=void 0,h&&n?f(A):(n=i=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,n=l=i=a=void 0}function b(){return a===void 0?o:v(rm())}function w(){var A=rm(),T=m(A);if(n=arguments,i=this,l=A,T){if(a===void 0)return g(l);if(d)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 Qd=jz;function qz(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}var gT=qz;function Xz(r,t){return t.length<2?r:Hp(r,d_(t,0,-1))}var yT=Xz;function Yz(r,t){return hT(r,t)}var Va=Yz;function Kz(r,t){return t=ci(t,r),r=yT(r,t),r==null||delete r[Fo(gT(t))]}var vT=Kz;function Zz(r){return u_(r)?void 0:r}var xT=Zz;var Qz=1,Jz=2,$z=4,eV=Wp(function(r,t){var e={};if(r==null)return e;var n=!1;t=Rp(t,function(s){return s=ci(s,r),n||(n=s.length>1),s}),$i(r,Yp(r),e),n&&(e=$p(e,Qz|Jz|$z,xT));for(var i=t.length;i--;)vT(e,t[i]);return e}),Ic=eV;function tV(r,t,e,n){if(!Hn(r))return r;t=ci(t,r);for(var i=-1,s=t.length,o=s-1,a=r;a!=null&&++i<s;){var l=Fo(t[i]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return r;if(i!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=Hn(c)?c:dc(t[i+1])?[]:{})}fc(a,l,u),a=a[l]}return r}var bT=tV;function nV(r,t,e){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=Hp(r,o);e(a,o)&&bT(s,ci(o,r),a)}return s}var ST=nV;function rV(r,t){return ST(r,t,function(e,n){return mT(r,n)})}var wT=rV;var iV=Wp(function(r,t){return r==null?{}:wT(r,t)}),Uo=iV;var _T,TT=new Promise(r=>{_T=r}),AT=!1;async function ET(){if(AT)return;let r=await import("./physics.js");await r.init(),_T(r),AT=!0}var Ot=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,Ot.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],i;n===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:n};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,Ot.prototype),{data:a,actual:t,reverse:i}}else if(t.type===2){let{id:n}=t,i=e[n];if(i===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,Ot.prototype),delete s[n],{data:s,actual:t,reverse:{type:1,id:n,data:i}}}}return null}};function Jd(r){if(r.deepFreeze!==void 0){r.deepFreeze(r);return}let t=Object.getOwnPropertyNames(r);for(let e of t){let n=r[e];n&&typeof n=="object"&&Jd(n)}return Object.freeze(r)}function MT(r,t){let e=0;for(;e<r.length&&e<t.length;){if(r[e]<t[e])return-1;if(r[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==r.length?1:0}var Dc=class extends Error{};function im(r){let t={...r};return Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}function es(r,t,e){if(r===void 0?t===void 0?(r=0,t=10):r=t-10:t===void 0&&(t=r+10),r>t){let s=r;r=t,t=s}let n=[],i=1/(e+1);for(let s=0;s<e;s++){let o=r+(t-r)*(s+.75+Math.random()*.5)*i;n.push(o)}return n}function Oc(r){return r instanceof Uint8Array||r instanceof Uint16Array||r instanceof Uint32Array||r instanceof Int8Array||r instanceof Int16Array||r instanceof Int32Array||r instanceof Float32Array||r instanceof Float64Array}function CT(){return typeof process<"u"}function PT(r,t){for(let e of r)t(e.id,e.data)!==!0&&PT(e.children,t)}function IT(r,t){if(t(r.id,r.data)!==!0)for(let e of r.children)IT(e,t)}var qt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,qt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Jd(this[e]),e++}fillCaches0(e,n){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,n);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,n){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===n)return!0;e=i}return!1}isDescendantOf(e,n){for(;e;){let i=this.parent(e);if(i===n)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,n){if(e===null)this.traverse(n);else{let i=this.get(e);i&&IT(i,n)}}traverse(e){PT(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 i=e,s=n;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,qt.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 i of n)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:n,fi:i,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:i,id:s,data:o,children:a};return u=[...u,c],u.sort((h,f)=>h.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 i=this.parent(n);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(u=>u.id===n);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:n,fi:i,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 Dc("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],d=this.modifyArrayBy(o,l);o=n,l=d.childrenArray(o);let h=c.fi;return c={...c,fi:i},l=[...l,c],l.sort((f,g)=>f.fi-g.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(o,l),{data:d,actual:e,reverse:{type:9,parent:a,fi:h,id:s}}}previous(e,n){if(n===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(e)){if(s.id===n)return i;i=s.id}return null}traverseSortNext(e){let n=this.parent(e);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===e)+1;if(s<i.length)return i[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 i=this.childrenArray(n),s=i.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(i[s].id):n}}getAllSorted(e){let n=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&n.push({...i,...s})}n.sort((i,s)=>MT(i.sortKey,s.sortKey));for(let i of n)delete i.sortKey;return n}getWithSortKey(e){var n=e;let i=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)i.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:i}}}insertBeforeHelper(e,n,i){return this.insertAfterHelper(e,this.previous(e,n),i)}insertAfterHelper(e,n,i){let s=this.childrenArray(e);if(n===null){if(s.length===0)return es(0,i,i);{let o=s[0].fi;return es(o-i,o,i)}}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 es(l,l+i,i)}else return es(o.fi,a.fi,i)}}};var Lc;(t=>{function r(e,n){if(n.type!==0)return null;if(Array.isArray(e)){let i=n.props,s={},o=[...e],a=!1;if(i)for(let l of Object.keys(i)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=i[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let i=n.props,s={},o={...e},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let u=i[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}t.runOp=r})(Lc||(Lc={}));var He=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,He.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Jd(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,He.prototype);let n=e;return CT()||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:i,data:s}=e,o=this,a={fi:n,id:i,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:i}}}deleteOp(e){let{id:n}=e,i=this,s=i.findIndex(l=>l.id===n);if(s===-1)return null;e.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:n,id:i}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,d)=>c.fi-d.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let i of this){if(i.id===e)return n;n=i.id}return null}insertBeforeHelper(e,n){return this.insertAfterHelper(this.previous(e),n)}insertAfterHelper(e,n){let i=this;if(e===null){if(i.length===0)return es(0,n,n);{let s=i[0].fi;return es(s-n,s,n)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return es(a,a+n,n)}else return es(s.fi,o.fi,n)}}};function Rc(r){return r&&typeof r=="object"&&r instanceof Xt}var Xt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],n=this,i=0,s={};for(;i<t.path.length;){if(e.push(n),n=n===void 0?void 0:n[t.path[i]],n!==void 0&&!Rc(n))return null;i+=1}n=n?im(n):new Xt;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(;i>0;){if(Object.keys(n).length===0){let l=e[i-1];l&&(n=im(l),delete n[t.path[i-1]])}else{let l=e[i-1];if(l){let u=im(l);u[t.path[i-1]]=n,n=u}else{let u=new Xt;u[t.path[i-1]]=n,n=u}}i-=1}let o=Object.setPrototypeOf(n,Xt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},Zs;(n=>{function r(i,s){return $d(i,s)??i}n.apply=r;function t(i,s){return G0(i,s)}n.merge=t;function e(i,s){let o=0,a=s.path,l=i;for(;o<a.length&&l!==void 0;){if(l=gr.zoomOnce(l,a[o]),l===void 0)return s;if(!Rc(l))return;o+=1}if(l===void 0)return s;if(!!Rc(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=U0([s],l);return u?(console.log(u),u):s}else return s}n.filterOp=e})(Zs||(Zs={}));function U0(r,t){if(t===void 0)return;let e=!1,n=r.map(i=>{let s=i.id,o=$d(i.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=i.data),i.children){let a=U0(i.children,t);return a!==void 0?e=!0:a=i.children,{...i,id:s,data:o,children:a}}else return{...i,id:s,data:o}});if(e)return n}function sV(r,t){if(t===void 0)return;let e=!1,n=r.map(i=>{let s=i.id,o=$d(i.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=i.data),{...i,id:s,data:o}});if(e)return Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}function $d(r,t){if(!Rc(t))return t;if(r instanceof qt){let e=U0(r,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}else{if(r instanceof He)return sV(r,t);if(Array.isArray(r)){let e=!1,n=r.map((i,s)=>{let o=$d(i,t[s]);return e=e||o!==void 0,o===void 0&&(o=i),o});return e?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else{if(r instanceof Xt)return G0(r,t);if(r&&typeof r=="object"){let e={},n=!1;for(let[i,s]of Object.entries(r)){let o=$d(s,t[i]);n=n||o!==void 0,o===void 0&&(o=s),e[i]=o}return n?(Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e):void 0}}}}function G0(r,t){if(r===void 0)return t;if(t===void 0)return r;if(!Rc(t))return t;if(!Rc(r))return Zs.apply(r,t);let e=new Set;for(let i of Object.keys(r))e.add(i);for(let i of Object.keys(t))e.add(i);let n=new Xt;for(let i of e){let s=G0(r===void 0?void 0:r[i],t===void 0?void 0:t[i]);n[i]=s}return n}function DT(r,t){let e={cur:[],result:[],len:0};return r=eh(r,t,e)??r,[r,e.result]}function sm(r,t){return r===null?null:(r.cur[r.len]=t,r.len+=1,r)}function om(r){r&&(r.len-=1)}function oV(r){if(r===null)return null;r.result.push(r.cur.slice(0,r.len))}function OT(r,t,e){let n=!1,i=r.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=eh(s.data,t,sm(e,o));om(e),n=n||l!==void 0,l===void 0&&(l=s.data);let u=OT(s.children,t,e);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return i}function aV(r,t,e){let n=!1,i=r.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=eh(s.data,t,sm(e,o));return om(e),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i}function eh(r,t,e){if(r instanceof qt){let n=OT(r,t,e);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}else{if(r instanceof He)return aV(r,t,e);if(Array.isArray(r)){let n=!1,i=r.map((s,o)=>{let a=eh(s,t,sm(e,o));return om(e),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i):void 0}else if(r&&typeof r=="object"&&!Oc(r)){let n={},i=!1;for(let[s,o]of Object.entries(r))if(s!=="name"&&s!=="text"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");i=!0,s=a}let l=eh(o,t,sm(e,s));om(e),i=i||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return i?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else if(typeof r=="string"){let n=t[r];if(n!==void 0){if(r.length!==36)throw new Error("for now you should only call this method when the key is a uuid");oV(e)}return n}else return}}var am;(t=>{function r(e,n){let i=gr.zoom(n,e.path);if(typeof i=="object"){let s={};for(let o of Object.keys(e.props))s[o]=i[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=r})(am||(am={}));var $n;(a=>{function r(l,u){return{...l,path:l.path.slice(u)}}a.drop=r;function t(l,u){return e(l,u)?.data??l}a.applySimple=t;function e(l,u){let c=u.path;for(var d=[];;){let h;if(l instanceof Xt&&u.type===0&&(h=l.runOp({...u,path:c.slice(d.length)}),h===null&&(h=void 0)),d.length===c.length&&(l instanceof qt||l instanceof He||l instanceof Ot?h=l.runOp(u):h=Lc.runOp(l,u)),h!==void 0)if(h!==null){let p=h.data;for(let m=d.length-1;m>=0;m--){let y=c[m],v=d[m];if(v instanceof qt){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof He){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Ot){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Xt){let x={...v,[y]:p};p=Object.setPrototypeOf(x,Xt.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=p;p=[...v],p[y]=x}else p={...v,[y]:p};else return null}return{data:p,actual:{...h.actual,path:c},reverse:{...h.reverse,path:c}}}else return null;let f=c[d.length],g;if(l instanceof qt){if(typeof f=="number")throw new Error("");g=l.get(f)?.data}else if(l instanceof He){if(typeof f=="number")throw new Error("");g=l.get(f)?.data}else l!==null&&(g=l[f]);if(g!==void 0)d.push(l),l=g;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 i(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=i;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&i(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})($n||($n={}));var k0;(l=>{function r(){return[]}l.empty=r;function t(u,c){let d=[];for(let h of u){let[f,...g]=h.path;f===c&&d.push({...h,path:g})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function n(u,c){return[...u,...c]}l.concat=n;function i(u,c){return[...u.filter(h=>!c.some(f=>$n.subsumed(h,f))),...c]}l.compress=i;function s(u,c){return u.every(d=>c.every(h=>$n.commutative(d,h)))}l.commutative=s;function o(u,c){for(let d of c){let h=a(u,d);h!==null&&(u=h.data)}return u}l.applyAll=o;function a(u,c){var d=u;let h=[],f=[];for(let g of c)try{if(g.type===3){let p=gr.zoom(d,[...g.path,g.id]),m=$n.apply(d,{...g,type:2});if(m!==null){d=m.data;let[y,v]=DT(d,{[g.id]:p});d=y;for(let x of v){let b=x[x.length-1];x.splice(x.length-1,1),h.push({type:0,path:x,props:{[b]:p}}),f.push({type:0,path:x,props:{[b]:g.id}})}f.push(m.reverse),h.push(m.actual)}}else{let p=$n.apply(d,g);p!==null&&(h.push(p.actual),d=p.data,f.push(p.reverse))}}catch(p){if(p instanceof Dc)return null;throw p}return{data:d,actual:h,reverse:f.reverse()}}l.apply=a})(k0||(k0={}));var LT=Symbol(),lV=Symbol(),cm=Symbol(),Ha=class{reportOp(t,e,n=[]){let i=this;if(e===null)return;i._current=e.data;let s=n;for(;!(i instanceof lm);){let o=i._path,a=i._current;if(o!==""&&s.splice(0,0,o),i=i._parent,i===null)return;i.update(o,a)}i.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let n=e[cm];n&&n(),delete this._children[t]}}}},V0=class extends Ha{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,Lc.runOp(this._current,t),t.path)}},H0=class extends Ha{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,Ot.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},RT={get(r,t){if(t===cm)return()=>{r._parent=null};if(t===LT)return r._current;if(t===lV)return r;let{_current:e,_children:n}=r;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e[t],o=um(r,t,s);return o!==s?(n===void 0&&(n={},r._children=n),n[t]=o,o):s},has(r,t){return t in r._current},ownKeys(r){return Reflect.ownKeys(r._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(r){return Object.getPrototypeOf(r._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(r,t){let e=r._current,n=Reflect.getOwnPropertyDescriptor(e,t);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:e[t]}}},cV={...RT,set(r,t,e){let n={type:0,props:{[t]:Wn(e)??e}};return r.deleteChildren(t),r.runOp(n),!0},deleteProperty(r,t){let e={type:0,props:{[t]:void 0}};return r.deleteChildren(t),r.runOp(e),!0}},uV={...RT,set(r,t,e){return e===void 0?this.deleteProperty(r,t):(r.deleteChildren(t),r.runOp({type:1,id:t,data:e})),!0},deleteProperty(r,t){return r.runOp({type:2,id:t}),!0}},Nc=class extends Ha{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[cm]=()=>{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,i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=um(this,t,s);return o!==s?(n===void 0&&(n={},this._children=n),n[t]=o,o):s}add(t,e,n,i,s){this.runOp({type:7,parent:t,fi:e,id:n,data:i,children:s})}move(t,e,n){this.runOp({type:9,parent:t,fi:e,id:n})}insertAfter(t,e,n){let i=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,i[s],o.id,o.data,o.children)}}insertBefore(t,e,n){let i=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(t,i[s],o.id,o.data,o.children)}}moveAfter(t,e,n){let i=this._current.insertAfterHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,i[s],o)}}moveBefore(t,e,n){let i=this._current.insertBeforeHelper(t,e,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(t,i[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)}},Bc=class extends Ha{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[cm]=()=>{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 i=this._current[n].id,s=this._current[n].fi;t(this.data(this._current[n].id),i,s)}}find(t){let e=this.length;for(let n=0;n<e;n++){let i=this._current[n].id;if(t(this.data(i),i))return this.get(i)}}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,i=n===void 0?void 0:n[t];if(i!==void 0)return i;let s=e.get(t)?.data,o=um(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 i=0;i<e.length;i++){let s=e[i];this.add(n[i],s.id,s.data)}}insertBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.add(n[i],s.id,s.data)}}moveAfter(t,e){let n=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(n[i],s)}}moveBefore(t,e){let n=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let s=e[i];this.move(n[i],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function z0(r,t,e){if(r.length>0){let n=r[r.length-1];if(n.type===0&&t.type===0&&gr.equal(n.path,e)){Object.assign(n.props,t.props);return}}r.push({...t,path:e})}var lm=class extends Ha{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,i){z0(this.ts,e,t),z0(this.actual,n,t),z0(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function um(r,t,e){return e instanceof qt?new Nc(r,t,e):e instanceof He?new Bc(r,t,e):e instanceof Ot?new Proxy(new H0(r,t,e),uV):e!==null&&typeof e=="object"?Oc(e)?e:new Proxy(new V0(r,t,e),cV):e}function W0(r){let t=new lm(r);return[um(t,"",r),t]}function Fc(r,t){let[e,n]=W0(r);return t(e),n.result()}function Wn(r){return r instanceof Nc||r instanceof Bc?r._current:r!==null&&typeof r=="object"?r[LT]:r}var gr;(i=>{function r(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}i.equal=r;function 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}i.removeOverridden=t;function e(s,o){if((s instanceof qt||s instanceof Nc)&&typeof o=="string")return s.data(o);if((s instanceof He||s instanceof Bc)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}i.zoomOnce=e;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}i.zoom=n})(gr||(gr={}));function NT(r,t){let e=[];if(t.length===r.length)for(var n=0;n<r.length;){if(t[n]==="*")e.push(r[n]);else if(r[n]!==t[n])return null;n+=1}else return null;return e}function Ii(r,t){let e=[];if(t.length<=r.length)for(var n=0;n<t.length;){if(t[n]==="*")e.push(r[n]);else if(r[n]!==t[n])return null;n+=1}else return null;return e}var dm=class{},th=class extends dm{constructor(e){super();this.id=e}},nh=class extends dm{constructor(e){super();this.data=e}};var q0;try{q0=new TextDecoder}catch{}var Oe,ko,Q=0;var HT=[],X0=HT,Y0=0,Tr={},_t,Go,ui=0,ts=0,Zr,Qs,yr=[],Ct,BT={useRecords:!1,mapsAsObjects:!0},rh=class{},Z0=new rh;Z0.name="MessagePack 0xC1";var Uc=!1,ns=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(Oe)return YT(()=>(fm(),this?this.unpack(t,e):ns.prototype.unpack.call(BT,t,e)));ko=e>-1?e:t.length,Q=0,Y0=0,ts=0,Go=null,X0=HT,Zr=null,Oe=t;try{Ct=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw Oe=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 ns){if(Tr=this,this.structures)return _t=this.structures,hm();(!_t||_t.length>0)&&(_t=[])}else Tr=BT,(!_t||_t.length>0)&&(_t=[]);return hm()}unpackMultiple(t,e){let n,i=0;try{Uc=!0;let s=t.length,o=this?this.unpack(t,s):gm.unpack(t,s);if(e){for(e(o);Q<s;)if(i=Q,e(hm())===!1)return}else{for(n=[o];Q<s;)i=Q,n.push(hm());return n}}catch(s){throw s.lastPosition=i,s.values=n,s}finally{Uc=!1,fm()}}_mergeStructures(t,e){t=t||[];for(let n=0,i=t.length;n<i;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 i=t[n],s=e[n];s&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[n]=i),t[n]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function hm(){try{if(!Tr.trusted&&!Uc){let t=_t.sharedLength||0;t<_t.length&&(_t.length=t)}let r=sn();if(Q==ko)_t.restoreStructures&&FT(),_t=null,Oe=null,Qs&&(Qs=null);else if(Q>ko){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Uc)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw _t.restoreStructures&&FT(),fm(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function FT(){for(let r in _t.restoreStructures)_t[r]=_t.restoreStructures[r];_t.restoreStructures=null}function sn(){let r=Oe[Q++];if(r<160)if(r<128){if(r<64)return r;{let t=_t[r&63]||Tr.getStructures&&WT()[r&63];return t?(t.read||(t.read=Q0(t,r&63)),t.read()):r}}else if(r<144)if(r-=128,Tr.mapsAsObjects){let t={};for(let e=0;e<r;e++)t[qT()]=sn();return t}else{let t=new Map;for(let e=0;e<r;e++)t.set(sn(),sn());return t}else{r-=144;let t=new Array(r);for(let e=0;e<r;e++)t[e]=sn();return t}else if(r<192){let t=r-160;if(ts>=Q)return Go.slice(Q-ui,(Q+=t)-ui);if(ts==0&&ko<140){let e=t<16?J0(t):jT(t);if(e!=null)return e}return K0(t)}else{let t;switch(r){case 192:return null;case 193:return Zr?(t=sn(),t>0?Zr[1].slice(Zr.position1,Zr.position1+=t):Zr[0].slice(Zr.position0,Zr.position0-=t)):Z0;case 194:return!1;case 195:return!0;case 196:return j0(Oe[Q++]);case 197:return t=Ct.getUint16(Q),Q+=2,j0(t);case 198:return t=Ct.getUint32(Q),Q+=4,j0(t);case 199:return Wa(Oe[Q++]);case 200:return t=Ct.getUint16(Q),Q+=2,Wa(t);case 201:return t=Ct.getUint32(Q),Q+=4,Wa(t);case 202:if(t=Ct.getFloat32(Q),Tr.useFloat32>2){let e=mm[(Oe[Q]&127)<<1|Oe[Q+1]>>7];return Q+=4,(e*t+(t>0?.5:-.5)>>0)/e}return Q+=4,t;case 203:return t=Ct.getFloat64(Q),Q+=8,t;case 204:return Oe[Q++];case 205:return t=Ct.getUint16(Q),Q+=2,t;case 206:return t=Ct.getUint32(Q),Q+=4,t;case 207:return Tr.int64AsNumber?(t=Ct.getUint32(Q)*4294967296,t+=Ct.getUint32(Q+4)):t=Ct.getBigUint64(Q),Q+=8,t;case 208:return Ct.getInt8(Q++);case 209:return t=Ct.getInt16(Q),Q+=2,t;case 210:return t=Ct.getInt32(Q),Q+=4,t;case 211:return Tr.int64AsNumber?(t=Ct.getInt32(Q)*4294967296,t+=Ct.getUint32(Q+4)):t=Ct.getBigInt64(Q),Q+=8,t;case 212:if(t=Oe[Q++],t==114)return VT(Oe[Q++]&63);{let e=yr[t];if(e)return e.read?(Q++,e.read(sn())):e.noBuffer?(Q++,e()):e(Oe.subarray(Q,++Q));throw new Error("Unknown extension "+t)}case 213:return t=Oe[Q],t==114?(Q++,VT(Oe[Q++]&63,Oe[Q++])):Wa(2);case 214:return Wa(4);case 215:return Wa(8);case 216:return Wa(16);case 217:return t=Oe[Q++],ts>=Q?Go.slice(Q-ui,(Q+=t)-ui):hV(t);case 218:return t=Ct.getUint16(Q),Q+=2,ts>=Q?Go.slice(Q-ui,(Q+=t)-ui):fV(t);case 219:return t=Ct.getUint32(Q),Q+=4,ts>=Q?Go.slice(Q-ui,(Q+=t)-ui):pV(t);case 220:return t=Ct.getUint16(Q),Q+=2,GT(t);case 221:return t=Ct.getUint32(Q),Q+=4,GT(t);case 222:return t=Ct.getUint16(Q),Q+=2,kT(t);case 223:return t=Ct.getUint32(Q),Q+=4,kT(t);default:if(r>=224)return r-256;if(r===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+r)}}}var dV=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Q0(r,t){function e(){if(e.count++>2){let i=r.read=new Function("r","return function(){return {"+r.map(s=>dV.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(sn);return r.highByte===0&&(r.read=UT(t,r.read)),i()}let n={};for(let i=0,s=r.length;i<s;i++){let o=r[i];n[o]=sn()}return n}return e.count=0,r.highByte===0?UT(t,e):e}var UT=(r,t)=>function(){let e=Oe[Q++];if(e===0)return t();let n=r<32?-(r+(e<<5)):r+(e<<5),i=_t[n]||WT()[n];if(!i)throw new Error("Record id is not defined for "+n);return i.read||(i.read=Q0(i,r)),i.read()};function WT(){let r=YT(()=>(Oe=null,Tr.getStructures()));return _t=Tr._mergeStructures(r,_t)}var K0=pm,hV=pm,fV=pm,pV=pm;function pm(r){let t;if(r<16&&(t=J0(r)))return t;if(r>64&&q0)return q0.decode(Oe.subarray(Q,Q+=r));let e=Q+r,n=[];for(t="";Q<e;){let i=Oe[Q++];if((i&128)===0)n.push(i);else if((i&224)===192){let s=Oe[Q++]&63;n.push((i&31)<<6|s)}else if((i&240)===224){let s=Oe[Q++]&63,o=Oe[Q++]&63;n.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Oe[Q++]&63,o=Oe[Q++]&63,a=Oe[Q++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(i);n.length>=4096&&(t+=jn.apply(String,n),n.length=0)}return n.length>0&&(t+=jn.apply(String,n)),t}function GT(r){let t=new Array(r);for(let e=0;e<r;e++)t[e]=sn();return t}function kT(r){if(Tr.mapsAsObjects){let t={};for(let e=0;e<r;e++)t[qT()]=sn();return t}else{let t=new Map;for(let e=0;e<r;e++)t.set(sn(),sn());return t}}var jn=String.fromCharCode;function jT(r){let t=Q,e=new Array(r);for(let n=0;n<r;n++){let i=Oe[Q++];if((i&128)>0){Q=t;return}e[n]=i}return jn.apply(String,e)}function J0(r){if(r<4)if(r<2){if(r===0)return"";{let t=Oe[Q++];if((t&128)>1){Q-=1;return}return jn(t)}}else{let t=Oe[Q++],e=Oe[Q++];if((t&128)>0||(e&128)>0){Q-=2;return}if(r<3)return jn(t,e);let n=Oe[Q++];if((n&128)>0){Q-=3;return}return jn(t,e,n)}else{let t=Oe[Q++],e=Oe[Q++],n=Oe[Q++],i=Oe[Q++];if((t&128)>0||(e&128)>0||(n&128)>0||(i&128)>0){Q-=4;return}if(r<6){if(r===4)return jn(t,e,n,i);{let s=Oe[Q++];if((s&128)>0){Q-=5;return}return jn(t,e,n,i,s)}}else if(r<8){let s=Oe[Q++],o=Oe[Q++];if((s&128)>0||(o&128)>0){Q-=6;return}if(r<7)return jn(t,e,n,i,s,o);let a=Oe[Q++];if((a&128)>0){Q-=7;return}return jn(t,e,n,i,s,o,a)}else{let s=Oe[Q++],o=Oe[Q++],a=Oe[Q++],l=Oe[Q++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){Q-=8;return}if(r<10){if(r===8)return jn(t,e,n,i,s,o,a,l);{let u=Oe[Q++];if((u&128)>0){Q-=9;return}return jn(t,e,n,i,s,o,a,l,u)}}else if(r<12){let u=Oe[Q++],c=Oe[Q++];if((u&128)>0||(c&128)>0){Q-=10;return}if(r<11)return jn(t,e,n,i,s,o,a,l,u,c);let d=Oe[Q++];if((d&128)>0){Q-=11;return}return jn(t,e,n,i,s,o,a,l,u,c,d)}else{let u=Oe[Q++],c=Oe[Q++],d=Oe[Q++],h=Oe[Q++];if((u&128)>0||(c&128)>0||(d&128)>0||(h&128)>0){Q-=12;return}if(r<14){if(r===12)return jn(t,e,n,i,s,o,a,l,u,c,d,h);{let f=Oe[Q++];if((f&128)>0){Q-=13;return}return jn(t,e,n,i,s,o,a,l,u,c,d,h,f)}}else{let f=Oe[Q++],g=Oe[Q++];if((f&128)>0||(g&128)>0){Q-=14;return}if(r<15)return jn(t,e,n,i,s,o,a,l,u,c,d,h,f,g);let p=Oe[Q++];if((p&128)>0){Q-=15;return}return jn(t,e,n,i,s,o,a,l,u,c,d,h,f,g,p)}}}}}function j0(r){return Tr.copyBuffers?Uint8Array.prototype.slice.call(Oe,Q,Q+=r):Oe.subarray(Q,Q+=r)}function Wa(r){let t=Oe[Q++];if(yr[t])return yr[t](Oe.subarray(Q,Q+=r));throw new Error("Unknown extension type "+t)}var zT=new Array(4096);function qT(){let r=Oe[Q++];if(r>=160&&r<192){if(r=r-160,ts>=Q)return Go.slice(Q-ui,(Q+=r)-ui);if(!(ts==0&&ko<180))return K0(r)}else return Q--,sn();let t=(r<<5^(r>1?Ct.getUint16(Q):r>0?Oe[Q]:0))&4095,e=zT[t],n=Q,i=Q+r-3,s,o=0;if(e&&e.bytes==r){for(;n<i;){if(s=Ct.getUint32(n),s!=e[o++]){n=1879048192;break}n+=4}for(i+=3;n<i;)if(s=Oe[n++],s!=e[o++]){n=1879048192;break}if(n===i)return Q=n,e.string;i-=3,n=Q}for(e=[],zT[t]=e,e.bytes=r;n<i;)s=Ct.getUint32(n),e.push(s),n+=4;for(i+=3;n<i;)s=Oe[n++],e.push(s);let a=r<16?J0(r):jT(r);return a!=null?e.string=a:e.string=K0(r)}var VT=(r,t)=>{var e=sn();let n=r;t!==void 0&&(r=r<32?-((t<<5)+r):(t<<5)+r,e.highByte=t);let i=_t[r];return i&&i.isShared&&((_t.restoreStructures||(_t.restoreStructures=[]))[r]=i),_t[r]=e,e.read=Q0(e,n),e.read()},XT=typeof self=="object"?self:global;yr[0]=()=>{};yr[0].noBuffer=!0;yr[101]=()=>{let r=sn();return(XT[r[0]]||Error)(r[1])};yr[105]=r=>{let t=Ct.getUint32(Q-4);Qs||(Qs=new Map);let e=Oe[Q],n;e>=144&&e<160||e==220||e==221?n=[]:n={};let i={target:n};Qs.set(t,i);let s=sn();return i.used?Object.assign(n,s):(i.target=s,s)};yr[112]=r=>{let t=Ct.getUint32(Q-4),e=Qs.get(t);return e.used=!0,e.target};yr[115]=()=>new Set(sn());var $0=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");yr[116]=r=>{let t=r[0],e=$0[t];if(!e)throw new Error("Could not find typed array for code "+t);return new XT[e](Uint8Array.prototype.slice.call(r,1).buffer)};yr[120]=()=>{let r=sn();return new RegExp(r[0],r[1])};yr[98]=r=>{let t=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],e=Q;Q+=t-4,Zr=[sn(),sn()],Zr.position0=0,Zr.position1=0;let n=Q;Q=e;try{return sn()}finally{Q=n}};yr[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function YT(r){let t=ko,e=Q,n=Y0,i=ui,s=ts,o=Go,a=X0,l=Qs,u=Zr,c=new Uint8Array(Oe.slice(0,ko)),d=_t,h=_t.slice(0,_t.length),f=Tr,g=Uc,p=r();return ko=t,Q=e,Y0=n,ui=i,ts=s,Go=o,X0=a,Qs=l,Zr=u,Oe=c,Uc=g,_t=d,_t.splice(0,_t.length,...h),Tr=f,Ct=new DataView(Oe.buffer,Oe.byteOffset,Oe.byteLength),p}function fm(){Oe=null,Qs=null,_t=null}function KT(r){r.unpack?yr[r.type]=r.unpack:yr[r.type]=r}var mm=new Array(147);for(let r=0;r<256;r++)mm[r]=+("1e"+Math.floor(45.15-r*.30103));var gm=new ns({useRecords:!1}),mV=gm.unpack,gV=gm.unpackMultiple,yV=gm.unpack,ym={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},vV=new Float32Array(1),_$=new Uint8Array(vV.buffer,0,4);var vm;try{vm=new TextEncoder}catch{}var xm,tx,bm=typeof Buffer<"u",ex=bm?Buffer.allocUnsafeSlow:Uint8Array,$T=bm?Buffer:Uint8Array,ZT=bm?4294967296:2144337920,le,un,ne=0,rs,is=null,xV=/[\u0080-\uFFFF]/,ih=Symbol("record-id"),ja=class extends ns{constructor(t){super(t),this.offset=0;let e,n,i,s,o,a,l=0,u=$T.prototype.utf8Write?function(S,E,M){return le.utf8Write(S,E,M)}:vm&&vm.encodeInto?function(S,E){return vm.encodeInto(S,le.subarray(E)).written}:!1,c=this;t||(t={});let d=t&&t.sequential,h=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=h?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let g=t.maxOwnStructures;g==null&&(g=h?32:64),d&&!t.saveStructures&&(this.structures=[]);let p=f>32||g+f>64,m=f+64,y=f+g+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,b=0;this.pack=this.encode=function(S,E){if(le||(le=new ex(8192),un=new DataView(le.buffer,0,8192),ne=0),rs=le.length-10,rs-ne<2048?(le=new ex(le.length),un=new DataView(le.buffer,0,le.length),rs=le.length-10,ne=0):ne=ne+7&2147483640,n=ne,a=c.structuredClone?new Map:null,c.bundleStrings?(is=["",""],le[ne++]=214,le[ne++]=98,is.position=ne-n,ne+=4):is=null,i=c.structures,i){i.uninitialized&&(i=c._mergeStructures(c.getStructures()));let M=i.sharedLength||0;if(M>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let I=0;I<M;I++){let P=i[I];if(!P)continue;let C,D=i.transitions;for(let B=0,k=P.length;B<k;B++){let X=P[B];C=D[X],C||(C=D[X]=Object.create(null)),D=C}D[ih]=I+64}l=M}d||(i.nextId=M+64)}s&&(s=!1),o=i||[];try{if(w(S),is){un.setUint32(is.position+n,ne-is.position-n);let M=is;is=null,w(M[0]),w(M[1])}if(c.offset=ne,a&&a.idsToInsert){ne+=a.idsToInsert.length*6,ne>rs&&T(ne),c.offset=ne;let M=SV(le.subarray(n,ne),a.idsToInsert);return a=null,M}return E&tE?(le.start=n,le.end=ne,le):le.subarray(n,ne)}finally{if(i){if(b<10&&b++,x>1e4)i.transitions=null,b=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let M=0,I=v.length;M<I;M++)v[M][ih]=0;v=[]}if(s&&c.saveStructures){let M=i.sharedLength||f;i.length>M&&(i=i.slice(0,M));let I=le.subarray(n,ne);return c.saveStructures(i,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(S)):(l=M,I)}}E&CV&&(ne=n)}};let w=S=>{ne>rs&&(le=T(ne));var E=typeof S,M;if(E==="string"){let I=S.length;if(is&&I>=8&&I<4096){let D=xV.test(S);is[D?0:1]+=S,le[ne++]=193,w(D?-I:I);return}let P;I<32?P=1:I<256?P=2:I<65536?P=3:P=5;let C=I*3;if(ne+C>rs&&(le=T(ne+C)),I<64||!u){let D,B,k,X=ne+P;for(D=0;D<I;D++)B=S.charCodeAt(D),B<128?le[X++]=B:B<2048?(le[X++]=B>>6|192,le[X++]=B&63|128):(B&64512)===55296&&((k=S.charCodeAt(D+1))&64512)===56320?(B=65536+((B&1023)<<10)+(k&1023),D++,le[X++]=B>>18|240,le[X++]=B>>12&63|128,le[X++]=B>>6&63|128,le[X++]=B&63|128):(le[X++]=B>>12|224,le[X++]=B>>6&63|128,le[X++]=B&63|128);M=X-ne-P}else M=u(S,ne+P,C);M<32?le[ne++]=160|M:M<256?(P<2&&le.copyWithin(ne+2,ne+1,ne+1+M),le[ne++]=217,le[ne++]=M):M<65536?(P<3&&le.copyWithin(ne+3,ne+2,ne+2+M),le[ne++]=218,le[ne++]=M>>8,le[ne++]=M&255):(P<5&&le.copyWithin(ne+5,ne+3,ne+3+M),le[ne++]=219,un.setUint32(ne,M),ne+=4),ne+=M}else if(E==="number")if(S>>>0===S)S<64?le[ne++]=S:S<256?(le[ne++]=204,le[ne++]=S):S<65536?(le[ne++]=205,le[ne++]=S>>8,le[ne++]=S&255):(le[ne++]=206,un.setUint32(ne,S),ne+=4);else if(S>>0===S)S>=-32?le[ne++]=256+S:S>=-128?(le[ne++]=208,le[ne++]=S+256):S>=-32768?(le[ne++]=209,un.setInt16(ne,S),ne+=2):(le[ne++]=210,un.setInt32(ne,S),ne+=4);else{let I;if((I=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){le[ne++]=202,un.setFloat32(ne,S);let P;if(I<4||(P=S*mm[(le[ne]&127)<<1|le[ne+1]>>7])>>0===P){ne+=4;return}else ne--}le[ne++]=203,un.setFloat64(ne,S),ne+=8}else if(E==="object")if(!S)le[ne++]=192;else{if(a){let P=a.get(S);if(P){if(!P.id){let C=a.idsToInsert||(a.idsToInsert=[]);P.id=C.push(P)}le[ne++]=214,le[ne++]=112,un.setUint32(ne,P.id),ne+=4;return}else a.set(S,{offset:ne-n})}let I=S.constructor;if(I===Object)A(S,!0);else if(I===Array){M=S.length,M<16?le[ne++]=144|M:M<65536?(le[ne++]=220,le[ne++]=M>>8,le[ne++]=M&255):(le[ne++]=221,un.setUint32(ne,M),ne+=4);for(let P=0;P<M;P++)w(S[P])}else if(I===Map){M=S.size,M<16?le[ne++]=128|M:M<65536?(le[ne++]=222,le[ne++]=M>>8,le[ne++]=M&255):(le[ne++]=223,un.setUint32(ne,M),ne+=4);for(let[P,C]of S)w(P),w(C)}else{for(let P=0,C=xm.length;P<C;P++){let D=tx[P];if(S instanceof D){let B=xm[P];if(B.write){B.type&&(le[ne++]=212,le[ne++]=B.type,le[ne++]=0),w(B.write.call(this,S));return}let k=le,X=un,W=ne;le=null;let q;try{q=B.pack.call(this,S,H=>(le=k,k=null,ne+=H,ne>rs&&T(ne),{target:le,targetView:un,position:ne-H}),w)}finally{k&&(le=k,un=X,ne=W,rs=le.length-10)}q&&(q.length+ne>rs&&T(q.length+ne),ne=bV(q,le,ne,B.type));return}}A(S,!S.hasOwnProperty)}}else if(E==="boolean")le[ne++]=S?195:194;else if(E==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))le[ne++]=211,un.setBigInt64(ne,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)le[ne++]=207,un.setBigUint64(ne,S);else if(this.largeBigIntToFloat)le[ne++]=203,un.setFloat64(ne,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");ne+=8}else if(E==="undefined")this.encodeUndefinedAsNil?le[ne++]=192:(le[ne++]=212,le[ne++]=0,le[ne++]=0);else if(E==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+E)},A=this.useRecords===!1?this.variableMapSize?S=>{let E=Object.keys(S),M=E.length;M<16?le[ne++]=128|M:M<65536?(le[ne++]=222,le[ne++]=M>>8,le[ne++]=M&255):(le[ne++]=223,un.setUint32(ne,M),ne+=4);let I;for(let P=0;P<M;P++)w(I=E[P]),w(S[I])}:(S,E)=>{le[ne++]=222;let M=ne-n;ne+=2;let I=0;for(let P in S)(E||S.hasOwnProperty(P))&&(w(P),w(S[P]),I++);le[M+++n]=I>>8,le[M+n]=I&255}:S=>{let E=Object.keys(S),M,I=o.transitions||(o.transitions=Object.create(null)),P=0;for(let D=0,B=E.length;D<B;D++){let k=E[D];M=I[k],M||(M=I[k]=Object.create(null),P++),I=M}let C=I[ih];if(C)C>=96&&p?(le[ne++]=((C-=96)&31)+96,le[ne++]=C>>5):le[ne++]=C;else{C=o.nextId,C||(C=64),C<m&&this.shouldShareStructure&&!this.shouldShareStructure(E)?(C=o.nextOwnId,C<y||(C=m),o.nextOwnId=C+1):(C>=y&&(C=m),o.nextId=C+1);let D=E.highByte=C>=96&&p?C-96>>5:-1;I[ih]=C,o[C-64]=E,C<m?(E.isShared=!0,o.sharedLength=C-63,s=!0,D>=0?(le[ne++]=(C&31)+96,le[ne++]=D):le[ne++]=C):(D>=0?(le[ne++]=213,le[ne++]=114,le[ne++]=(C&31)+96,le[ne++]=D):(le[ne++]=212,le[ne++]=114,le[ne++]=C),P&&(x+=b*P),v.length>=g&&(v.shift()[ih]=0),v.push(I),w(E))}for(let D=0,B=E.length;D<B;D++)w(S[E[D]])},T=S=>{let E;if(S>16777216){if(S-n>ZT)throw new Error("Packed buffer would be larger than maximum buffer size");E=Math.min(ZT,Math.round(Math.max((S-n)*(S>67108864?1.25:2),4194304)/4096)*4096)}else E=(Math.max(S-n<<2,le.length-1)>>12)+1<<12;let M=new ex(E);return un=new DataView(M.buffer,0,E),le.copy?le.copy(M,0,n,S):M.set(le.slice(n,S)),ne-=n,n=0,rs=M.length-10,le=M}}useBuffer(t){le=t,un=new DataView(le.buffer,le.byteOffset,le.byteLength),ne=0}};tx=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,rh];xm=[{pack(r,t,e){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:i,targetView:s,position:o}=t(6);i[o++]=214,i[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:i,targetView:s,position:o}=t(10);i[o++]=215,i[o++]=255,s.setUint32(o,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:s,position:o}=t(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=t(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,r.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(r,t,e){let n=Array.from(r),{target:i,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),e(n)}},{pack(r,t,e){let{target:n,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=101,n[i++]=0),e([r.name,r.message])}},{pack(r,t,e){let{target:n,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=120,n[i++]=0),e([r.source,r.flags])}},{pack(r,t){this.structuredClone?QT(r,16,t):JT(bm?Buffer.from(r):new Uint8Array(r),t)}},{pack(r,t){let e=r.constructor;e!==$T&&this.structuredClone?QT(r,$0.indexOf(e.name),t):JT(r,t)}},{pack(r,t){let{target:e,position:n}=t(1);e[n]=193}}];function QT(r,t,e,n){let i=r.byteLength;if(i+1<256){var{target:s,position:o}=e(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=e(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=e(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),o)}function JT(r,t){let e=r.byteLength;var n,i;if(e<256){var{target:n,position:i}=t(e+2);n[i++]=196,n[i++]=e}else if(e<65536){var{target:n,position:i}=t(e+3);n[i++]=197,n[i++]=e>>8,n[i++]=e&255}else{var{target:n,position:i,targetView:s}=t(e+5);n[i++]=198,s.setUint32(i,e),i+=4}n.set(r,i)}function bV(r,t,e,n){let i=r.length;switch(i){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:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=n,t.set(r,e),e+=i,e}function SV(r,t){let e,n=t.length*6,i=r.length-n;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;r.copyWithin(s+n,s,i),n-=6;let a=s+n;r[a++]=214,r[a++]=105,r[a++]=o>>24,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=o&255,i=s}return r}function zo(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");tx.unshift(r.Class),xm.unshift(r)}KT(r)}var eE=new ja({useRecords:!1}),wV=eE.pack,AV=eE.pack;var{NEVER:_V,ALWAYS:TV,DECIMAL_ROUND:EV,DECIMAL_FIT:MV}=ym,tE=512,CV=1024;var nE=new ja({structuredClone:!0});zo({Class:Ot.prototype.constructor,type:1,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Ot.prototype),r}});zo({Class:He.prototype.constructor,type:2,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,He.prototype),r}});zo({Class:qt.prototype.constructor,type:3,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,qt.prototype),r}});zo({Class:th.prototype.constructor,type:4,write(r){return r.id},read(r){return new th(r)}});zo({Class:nh.prototype.constructor,type:5,write(r){return r.data},read(r){return new nh(r)}});zo({Class:Xt.prototype.constructor,type:6,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Xt.prototype),r}});function PV(r){var t=0;if(r.length===0)return t;for(let e=0;e<r.length;e++){let n=r[e];t=(t<<5)-t+n,t=t&t}return t}function nx(r){if(Oc(r))return r;if(Array.isArray(r))return r.map(nx);if(typeof r=="object"&&r!==null){let t={};for(let e of Object.keys(r).sort())t[e]=nx(r[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}else return r}var Sm;(n=>{function r(i){return nE.pack(i)}n.serialize=r;function t(i){return nE.unpack(i)}n.deserialize=t;function e(i){return PV(r(nx(i))).toString()}n.checksum=e})(Sm||(Sm={}));var Gc={["LookAt"]:[],["Follow"]:[],["MouseHover"]:["Transition"],["Scroll"]:["Transition"],["Start"]:["Transition","Audio","Video"],["Conditional"]:["Transition","Audio","Video"],["MouseDown"]:["Transition","Audio","Video","Link","Reset"],["MouseUp"]:["Transition","Audio","Video","Link","Reset"],["MousePress"]:["Transition","Audio","Video","Link","Reset"],["KeyDown"]:["Transition","Audio","Video","Link","Reset"],["KeyUp"]:["Transition","Audio","Video","Link","Reset"],["KeyPress"]:["Transition","Audio","Video","Link","Reset"],["GameControl"]:["Transition","Audio"],["Collision"]:["Transition","Audio"]},rE;(e=>{function r(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="KeyPress"}e.is=r;function t(n){return n==="MouseDown"||n==="MouseUp"||n==="MousePress"?{type:n,disabled:!1,toggle:!1,actions:new He}:{type:n,disabled:!1,key:void 0,toggle:!1,actions:new He}}e.defaultData=t})(rE||(rE={}));var wm;(e=>{function r(n){return{type:"Property",value:[n??null,"position","x"]}}e.propertyDefaultData=r,e.valueDefaultData={type:"Literal",value:0}})(wm||(wm={}));var rx;(n=>{function r(i){return{type:"Comparison",operator:"==",lOperand:wm.propertyDefaultData(i),rOperand:{...wm.valueDefaultData}}}n.comparisonDefaultData=r;function t(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}n.distanceDefaultData=t;function e(i,s){return{type:"State",object:i??null,state:s??null}}n.stateDefaultData=e})(rx||(rx={}));var iE;(e=>{function r(n){return n.type==="Conditional"}e.is=r;function t(n){return{type:"Conditional",disabled:!1,inActions:new He,outActions:new He,condition:rx.distanceDefaultData(n)}}e.defaultData=t})(iE||(iE={}));var Am;(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})(Am||(Am={}));var _m;(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})(_m||(_m={}));var sE;(e=>{function r(n){return n.type==="MouseHover"}e.is=r;function t(){return{type:"MouseHover",disabled:!1,actions:new He}}e.defaultData=t})(sE||(sE={}));var oE;(e=>{function r(n){return n.type==="Scroll"}e.is=r;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new He}}e.defaultData=t})(oE||(oE={}));var aE;(e=>{function r(n){return n.type==="Start"}e.is=r;function t(){return{type:"Start",disabled:!1,actions:new He}}e.defaultData=t})(aE||(aE={}));var lE;(e=>{function r(n){return n.type==="Collision"}e.is=r;function t(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new He}}e.defaultData=t})(lE||(lE={}));var qa;(e=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]}e.isEqual=r;function t(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s]}e.lerp=t})(qa||(qa={}));var ss;(a=>{function r(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}a.isEqual=r;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 i(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=i;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})(ss||(ss={}));var sh;(e=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]&&n[2]===i[2]&&n[3]===i[3]}e.isEqual=r;function t(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s,n[2]+(i[2]-n[2])*s,n[3]+(i[3]-n[3])*s]}e.lerp=t})(sh||(sh={}));var Vo;(i=>{i.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}i.isEqual=t;function e(s){return s??i.identity}i.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}i.applyMatrix4=n})(Vo||(Vo={}));var ir;(u=>{function r(c){return typeof c=="object"&&typeof c.r=="number"&&typeof c.g=="number"&&typeof c.b=="number"}u.isRGB=r,u.white={r:1,g:1,b:1},u.red={r:1,g:0,b:0},u.black={r:0,g:0,b:0};function i(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}u.toRgb255a1=i;function s(c){return{r:c.r,g:c.g,b:c.b}}u.clone=s;function o(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}u.fromHex=o;function a(c,d){return c.r===d.r&&c.g===d.g&&c.b===d.b}u.equals=a;function l(c,d,h){return{r:c.r+(d.r-c.r)*h,g:c.g+(d.g-c.g)*h,b:c.b+(d.b-c.b)*h}}u.lerp=l})(ir||(ir={}));var Er;(a=>{a.white={...ir.white,a:1},a.transparent={...ir.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{...ir.fromHex(l),a:u}}a.fromHexAndA=n;function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=i;function s(l,u){return ir.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})(Er||(Er={}));var Tm;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Tm||(Tm={}));var cE;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(cE||(cE={}));var uE;(t=>t.defaultData={control1:[.5,.05],control2:[.1,.3]})(uE||(uE={}));var Di;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(n){return e.all.includes(n)}e.is=t})(Di||(Di={}));var Xa;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1,autoZoom:!1,autoZoomFrustumSize:790},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=n})(Xa||(Xa={}));var os;(e=>{function r(n,i=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(n[0],n[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[n[0]+n[0]*i,0,0]},grid:{count:[2,2,2],size:n.map(s=>s*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=r;function t(n,i){let s={...n};if(ix.forEach(o=>{Object.assign(s,{[o]:i[o]??n[o]})}),s.radial={...n.radial},i.radial){let o=n.radial,a=i.radial;sx.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...n.linear},i.linear){let o=n.linear,a=i.linear;ox.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...n.grid},i.grid){let o=n.grid,a=i.grid;ax.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...n.toObject},i.toObject){let o=n.toObject,a=i.toObject;lx.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...n.randomnessObject},i.randomnessObject){let o=n.randomnessObject,a=i.randomnessObject;cx.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(os||(os={}));var Em;(n=>{n.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(i,s){let o=[];i.count!==void 0&&o.push({type:0,path:s,props:{count:i.count}});for(let a of t){let l=i[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}n.toOps=e})(Em||(Em={}));var ix=["count"],sx=["radius","start","end","position","scale","rotation"],ox=["position","scale","rotation"],ax=["count","size"],lx=["count","position","scale","rotation"],cx=["strength","scale","rotation","position","movement","seed","freqScale"];var Ya;(e=>{let r={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...r,blendFunction:16,granularity:15},bloom:{...r,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...r,offset:[2,2]},vignette:{...r,darkness:1,offset:0},hueSaturation:{...r,hue:3,saturation:0},brightnessContrast:{...r,brightness:.25,contrast:0},depthOfField:{...r,focalLength:2,focusDistance:2,bokehScale:2},noise:{...r,blendFunction:16}}})(Ya||(Ya={}));var Mm;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(n){return e.all.includes(n)}e.is=t})(Mm||(Mm={}));var Cm;(e=>{function r(n){return t(n)}e.defaultData=r;function t(n){if(n==="PointLight")return{type:n,color:Er.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(n==="SpotLight")return{type:n,color:Er.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(n==="DirectionalLight")return{type:n,color:Er.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Cm||(Cm={}));var ux;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(n,i){return n.castShadow===i.castShadow&&n.receiveShadow===i.receiveShadow}e.equals=t})(ux||(ux={}));var dx;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(n,i){return n.flatShading===i.flatShading&&n.side===i.side&&n.wireframe===i.wireframe}e.equals=t})(dx||(dx={}));var Pm;(t=>t.defaultData={...dx.defaultData,...ux.defaultData})(Pm||(Pm={}));var kc;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(kc||(kc={}));var Im=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],dE=["wrapping","image","video"],vr;(i=>{function r(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}i.patch=r;function t(s,o){return s==="light"&&o?e(o):n(s)}i.defaultData=t;function e(s){switch(s){case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",alpha:.6,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function n(s){switch(s){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"video",projection:0,texture:{video:kc.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:ir.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...ir.fromHex(6710886),a:1},colorB:{...ir.fromHex(6710886),a:1},colorC:{...ir.fromHex(16777215),a:1},colorD:{...ir.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:Er.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Er.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:Er.fromHexAndA(0,1),contourColor:Er.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(vr||(vr={}));var qn;(l=>{function r(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}l.isMergable=r;function t(u){let c="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([h,f])=>{c+=`${h}${f}`,Array.isArray(f)?f.forEach(g=>c+=`${g}`):typeof f=="object"?Object.values(f).forEach(g=>{typeof g=="number"?c+=`${g.toFixed(4)}`:c+=`${g}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new He}}l.defaultEmptyData=e;function n(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=n;function i(u,c){return{...u,name:c}}l.withName=i;function s(u,c="layer1",d="layer2"){let h=new He;return h.push({fi:0,data:vr.defaultData("light",u),id:c}),h.push({fi:1,data:vr.defaultData("color"),id:d}),{layers:h}}l.defaultTwoLayerData=s;function o(u,c="phong",d="layer1",h="layer2"){let f=vr.defaultData("texture");Object.assign(f.texture,{image:u});let g=new He;return g.push({fi:0,data:f,id:d}),g.push({fi:1,data:vr.defaultData("light",c),id:h}),{layers:g}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",d="layer1",h="layer2"){let f=vr.defaultData("video");Object.assign(f.texture,{video:u});let g=new He;return g.push({fi:0,data:f,id:d}),g.push({fi:1,data:vr.defaultData("light",c),id:h}),{layers:g}}l.defaultTwoLayerVideoTextureData=a})(qn||(qn={}));var zc;(t=>{function r(){return{points:new He,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=r})(zc||(zc={}));var Vc;(t=>{function r(){return{points:new He,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=r})(Vc||(Vc={}));var hx={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0};var Dm;(t=>{function r(e,n){let i={...e};return fx.forEach(s=>{Object.assign(i,{[s]:n[s]??e[s]})}),i}t.merge=r})(Dm||(Dm={}));var Om={shape:hx,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},fx=["depth","offset","angle","twist","startScale","endScale"];var oh;(t=>{function r(e){return e==="PolygonGeometry"||e==="RectangleGeometry"||e==="StarGeometry"||e==="TriangleGeometry"||e==="EllipseGeometry"}t.is2DParametricMesh=r})(oh||(oh={}));var Lm;(t=>{function r(e,n){let i={...e};return Object.assign(i,n),i.type==="PathGeometry"&&"extrusion"in n&&n.extrusion&&(i.extrusion={...e.extrusion},Object.assign(i.extrusion,Dm.merge(i.extrusion,n.extrusion))),i}t.merge=r})(Lm||(Lm={}));var Ho;(t=>{function r(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:Vc.defaultData(),extrusion:Om};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:zc.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:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};throw new Error("not implemented")}t.defaultData=r})(Ho||(Ho={}));var px=["width","height","depth"];var hE;(e=>{function r(n){return n==="Component"||n==="Instance"}e.isComponentRelated=r;function t(n){return n==="Empty"||n==="Instance"}e.isEmptyOrComponent=t})(hE||(hE={}));var Hc;(i=>{i.identity={...Tm.identity,hiddenMatrix:Vo.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.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}}i.merge=e;function n(s,o){return{position:ss.isEqual(s.position,o.position)?null:o.position,rotation:ss.isEqual(s.rotation,o.rotation)?null:o.rotation,scale:ss.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:Vo.isEqual(s.hiddenMatrix,o.hiddenMatrix)?null:o.hiddenMatrix}}i.diff=n})(Hc||(Hc={}));var mx;(t=>t.defaultData={fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(mx||(mx={}));var Qr;(t=>t.defaultData={states:new He,events:new He,visible:!0,raycastLock:!1,physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Hc.identity,cloner:null})(Qr||(Qr={}));var fE;(t=>t.defaultData={type:"Empty",...Qr.defaultData})(fE||(fE={}));var pE;(t=>t.defaultData={type:"Component",...Qr.defaultData})(pE||(pE={}));var Ka;(t=>t.defaultData={type:"Mesh",...Qr.defaultData,...Pm.defaultData})(Ka||(Ka={}));var Wc;(t=>t.defaultData={...Qr.defaultData,...Hc.identity,...Xa.defaultData})(Wc||(Wc={}));var Rm;(t=>{function r(e){return{...Qr.defaultData,...Cm.defaultData(e)}}t.defaultData=r})(Rm||(Rm={}));var jc;(e=>{function r(n,i,s=0){for(;s<i.length;){let o=n?n[i[s]]:void 0;if(i.length===s+1)return o;if(o)n=o.descendants,s+=1;else return}}e.resolveWithDes=r;function t(n,i,s=0){let o=r(n,i,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(jc||(jc={}));var Wo;(s=>{s.rootOverrideProps=["physics"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function n(o,a){return{...Qr.defaultData,...a,component:o,overrides:new Xt,physics:void 0,type:"Instance"}}s.ofComponent=n;function i(o){let a=Hc.fromObject(o.data);return n(o.id,a)}s.fromComponentData=i})(Wo||(Wo={}));var Nm;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Vo.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:mx.defaultData,states:new He,events:new He,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Xa.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",...Qr.defaultData,...Ka.defaultData,geometry:Ho.defaultData("RectangleGeometry"),material:qn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Qr.defaultData,...Ka.defaultData,geometry:Ho.defaultData("BooleanGeometry"),material:qn.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Qr.defaultData,...Ka.defaultData,geometry:Ho.defaultData("TextGeometry"),material:qn.defaultTwoLayerData("phong","layer1","layer2")}))(Nm||(Nm={}));var Js;(i=>{function r(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Xt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Xt})))):Di.is(s.type)&&(a.perspective={},a.orthographic={}),a}i.newEmpty=r;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Fc(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let d=l.layers.data(u);d&&vr.patch(d,c)}}).data),a.materials&&o.materials&&(a.materials=Fc(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[d,h]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&vr.patch(f,h)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(d,h){for(let[f,g]of Object.entries(h.layers)){let{texture:p,...m}=g;if(p!==void 0&&Object.keys(p).length>0){let y={path:[...d,"layers",f,"texture"],props:p,type:0};l.push(y)}if(Object.keys(m).length>0){let y={path:[...d,"layers",f],props:m,type:0};l.push(y)}}}for(let[d,h]of Object.entries(o))if(d!=="name")if(d==="cloner")l.push(...Em.toOps(h,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:h.slide,offset:h.offset},type:0});else if(d==="material")c(["material"],h);else if(d==="materials")for(let[f,g]of Object.entries(h))c(["materials",f],g);else if(u[d]===0){if(d==="geometry"&&h.extrusion!==void 0){let f={path:[d,"extrusion"],props:h.extrusion,type:0};l.push(f),h={...h},delete h.extrusion}if(Object.keys(h).length>0){let f={path:[d],props:h,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[d]=h;return l}i.toOps=e;function n(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,Hc.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})}),Di.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:Lm.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:os.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:os.merge(a.cloner,o.cloner)});else if(Mm.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=ir.clone(l.color))}return a}i.patch=n})(Js||(Js={}));var lh;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:ir.white,near:.1,far:2e3})(lh||(lh={}));var qc;(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,autoZoom:!1})(qc||(qc={}));var $s;(t=>t.defaultData={orbitControls:qc.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:typeof window<"u"?Math.floor(window.devicePixelRatio):1,stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((e,n)=>{let i=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?i=30:(n===4||n===11||n===9)&&(i=-30),[120,[i,s],"show"]}),gameControlObject:null})($s||($s={}));function Oi(r,t){return Object.setPrototypeOf(r,t),r}var IV=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),DV=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),OV=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Za&&"ontouchend"in document,LV=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,RV=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,NV=()=>{if(typeof window>"u")return!1;let r=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(r)&&/Apple Computer/.test(t)},BV=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},ste=IV(),Za=DV(),ch=OV(),mE=LV(),In=RV(),gx=NV(),yx=Number(BV());function Bm(r){return Array.isArray(r)?r:[r]}function gE(r,t){let e=0;for(;e<r.length&&e<t.length;){if(r[e]<t[e])return-1;if(r[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==r.length?1:0}function uh(r){return Za?r.metaKey:r.ctrlKey}var Je=[],Um={},dh={},Fm={};function yE(r){Je.includes(r)||Je.push(r)}function Xc(r){delete Um[r.pointerId];for(let t=0;t<Je.length;t++)if(Je[t].pointerId===r.pointerId){Je.splice(t,1);break}}function vE(){Je.splice(0,Je.length)}function Gm(r){if(r.pointerType!=="touch")return;let t=Um[r.pointerId];t===void 0&&(t={x:0,y:0},Um[r.pointerId]=t),t.x=r.pageX,t.y=r.pageY}function km(r){let t=r.pointerId===Je[0].pointerId?Je[1]:Je[0];return Um[t.pointerId]}function xE(r){dh[r.key]=!0,Fm[r.key]=Fm[r.key]===void 0?1:Fm[r.key]+1}function bE(r){if(Za&&dh.Meta)for(let t in dh)dh[t]=!1;else dh[r.key]=!1;Fm={}}function SE(r){r.addEventListener("pointerdown",yE,!0),r.addEventListener("pointerdown",Gm,!0),r.addEventListener("pointermove",Gm,!0),r.addEventListener("pointerup",Xc,!0),r.addEventListener("pointercancel",Xc,!0),r.addEventListener("pointerleave",Xc,!0),window.addEventListener("keydown",xE,!0),window.addEventListener("keyup",bE,!0)}function wE(r){r.removeEventListener("pointerdown",yE,!0),r.removeEventListener("pointerdown",Gm,!0),r.removeEventListener("pointermove",Gm,!0),r.removeEventListener("pointerup",Xc,!0),r.removeEventListener("pointercancel",Xc,!0),r.removeEventListener("pointerleave",Xc,!0),window.removeEventListener("keydown",xE,!0),window.removeEventListener("keyup",bE,!0)}var xr;(t=>t.defaultData={ambientLight:{enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!0,softShadowQuality:"low"},usePhysics:!1,gravity:-10,pixelsPerMeter:200,skinWidthRelative:.02,stepThreshRelative:.3,slopeThresh:65})(xr||(xr={}));var zm;(o=>{o.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(a={withLight:!0,withSquare:!0}){let l=new qt,u=Nm.defaultMeshObject;return a.withLight===!0&&l.push({fi:-1,data:{...Rm.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),a.withSquare===!0&&l.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:u,children:[]}),l}o.defaultData={backgroundColor:Er.fromHexAndA(1908256,1),postprocessing:Ya.defaultData,fog:lh.defaultData,objects:t(),environment:xr.defaultData,publish:$s.defaultData},o.emptyData=function(a){return{backgroundColor:Er.fromHexAndA(1908256,1),postprocessing:Ya.defaultData,fog:lh.defaultData,objects:a?t(a):new qt,environment:xr.defaultData,publish:$s.defaultData}};function i(a){return{...o.defaultData,objects:Oi(a,qt.prototype)}}o.withObjs=i;function s(a,l){return i([{id:a,data:l,children:[],fi:0}])}o.withObj=s})(zm||(zm={}));var Yc;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(Yc||(Yc={}));var Kc;(n=>{function r(){let i={};return i["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Oi(i,Ot.prototype)}n.defaultColors=r;function t(i){let s={};return i?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Yc.emptyImage,name:"AI generated image"}),Oi(s,Ot.prototype)}n.defaultImages=t;function e(){return{materials:new Ot,images:new Ot,videos:new Ot,colors:new Ot,audios:new Ot,fonts:new Ot,penumbraSize:[.5,.5,.5]}}n.emptyData=e})(Kc||(Kc={}));function AE(r){r.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,n=t.colorB,i=[[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++)i.push(i[1]),s.push(1);let o={...Uo(Wn(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:i,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={...Wn(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Vm(r,t){Object.values(r.shared.materials).forEach(e=>t(e))}function Hm(r,t){r.scene.objects.traverse((e,n)=>{"materials"in n?n.materials.forEach(i=>{typeof i!="string"&&t(i)}):"material"in n&&typeof n.material!="string"&&t(n.material)})}function FV(r){Object.assign(r.scene.publish,{orbitControls:{...qc.defaultData,...Wn(r.scene.publish.orbitControls)}})}function UV(r){Object.assign(r.scene.publish.settings,{video:{...$s.defaultData.settings.video,...Wn(r.scene.publish.settings.video)}})}function GV(r){function t(e){if(e.layers){for(let n of Object.values(e.layers))if(n){for(let[i,s]of Object.entries(n))if((Im.includes(i)||typeof s=="boolean")&&delete n[i],i==="texture")for(let[o,a]of Object.entries(s))(dE.includes(o)||typeof a=="boolean")&&delete s[o]}}}r.scene.objects.traverse((e,n)=>{n.states.forEach(i=>{let s=i;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function kV(r){r.scene.publish.withBackground=!0}function zV(r){r.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function VV(r){r.scene.objects.traverse((t,e)=>{let n=e.cloner;n&&(n.radial.scale=n.radial.scale.map(i=>i+1),n.linear.scale=n.linear.scale.map(i=>i+1))})}function HV(r){r.scene.objects.traverse((t,e)=>{let n=e.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function WV(r){r.scene.objects.traverse((t,e)=>{let n=r.scene.objects.unproxy().parent(t);if(n){let i=Wn(r.scene.objects.data(n));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Wn(e).booleanExclude!==!0)}})}function jV(r){r.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 qV(r){function t(n){Object.setPrototypeOf(n,Xt.prototype),n.texture&&Object.setPrototypeOf(n.texture,Xt.prototype)}function e(n){Object.setPrototypeOf(n,Xt.prototype);for(let i in n)t(n[i])}r.scene.objects.traverse((n,i)=>{i.states.forEach(s=>{let o=s;if(o.material){let a=Wn(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=Wn(l).layers;e(u),l.layers=u}})})}function _E(r){r.layers===void 0&&Object.assign(r,qn.defaultTwoLayerData("lambert"))}function vx(r){!r.layers||r.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 i={...Wn(t),colors:e,steps:n};Object.assign(t,i)}})}function XV(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function TE(r){r.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(n=>{typeof n!="string"&&vx(n)}):"material"in e&&typeof e.material!="string"&&vx(e.material)}),Object.values(r.shared.materials).forEach(t=>vx(t))}function YV(r){r.scene.environment.ambientLight.softShadows=!1,r.scene.environment.ambientLight.softShadowQuality="low",r.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),r.shared.penumbraSize=new Array(5).fill(.5)}function KV(r){r.shared.audios=Oi({},Ot.prototype)}function ZV(r){r.shared.videos=Oi({},Ot.prototype)}function QV(r){let t=r.shared.materials;Object.entries(t).forEach(([e,n])=>{if(!n.layers){let i={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:i})}})}function JV(r){Object.entries(Wn(r.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.images[n]}),Object.entries(Wn(r.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.audios[n]})}function $V(r){r.scene.publish.settings.web.preload=!1}function EE(r){r.layers&&r.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 e4(r){r.shared.fonts=Oi({},Ot.prototype)}function t4(r){return r.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function n4(r){let t=[];r.scene.objects.traverse((e,n)=>{let i=n;if(i.type==="TextFrame"){let s=qn.defaultTwoLayerData("phong"),o=typeof i.color=="string"?r.shared.colors[i.color]:i.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=i.alpha;let a=t4(i.font);r.shared.fonts[a]===void 0&&(r.shared.fonts[a]={name:a});let l={name:i.name,...Qr.defaultData,...Ka.defaultData,flatShading:!1,wireframe:!1,geometry:{...Ho.defaultData("TextGeometry"),width:i.width,height:i.height,font:a,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Wn(i.states),events:Wn(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},u=Wn(r.scene.objects).parent(e);r.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{r.scene.objects.delete(e)})}function r4(r){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};r.scene.objects.traverse((e,n)=>{n.events.forEach(i=>{if(!!t[Number(i.type)])if(Object.assign(i,{type:t[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new He,move:new He,jump:new He}});else{let s=new He;Object.assign(i,{actions:s}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&s.push({fi:0,id:Ve.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,Uo(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let d={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},h={state:o.state,...d,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new He({fi:0,id:Ve.generateUUID(),data:u},{fi:1,id:Ve.generateUUID(),data:h})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function i4(r){r.scene.objects.traverse((t,e)=>{function n(i,s){let o=new He,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let d;a.push(u),l.interaction==="play"?d={...Uo(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(d={...Uo(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&o.push({fi:c,id:u,data:d})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:Ve.generateUUID(),data:{type:i,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}function ME(r){let t=r.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=vr.defaultData("light","phong"),n=t;Object.assign(n,e),n.visible=!1}}function CE(r){Vm(r,ME),Hm(r,ME)}function s4(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function o4(r){r.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 a4(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=qn.defaultTwoLayerData("phong"))})}function l4(r){r.scene.publish.orbitControls.autoZoom===void 0&&(r.scene.publish.orbitControls.autoZoom=!1),r.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 c4(r){r.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 u4(r){r.scene.publish.mouseEventTarget===void 0&&(r.scene.publish.mouseEventTarget="canvas"),r.scene.publish.settings.web.hint===void 0&&(r.scene.publish.settings.web.hint=!1)}function d4(r){let{video:t}=r.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function h4(r){r.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.resetYPosition=Math.abs(n.resetYPosition-e.position[1]))})})}var PE=36;function IE(r){let t=r.schema??0;t!==PE&&(console.warn("updating from ",t,"to ",PE),t<1&&(Hm(r,AE),Vm(r,AE),r.schema=1),t<2&&(FV(r),r.schema=2),t<3&&(GV(r),r.schema=3),t<4&&(kV(r),r.schema=4),t<5&&(zV(r),r.schema=5),t<6&&(VV(r),r.schema=6),t<7&&(HV(r),r.schema=7),t<8&&(r.schema=8),t<9&&(TE(r),r.schema=9),t<10&&(XV(r),r.schema=10),t<11&&(YV(r),r.schema=11),t<12&&(TE(r),r.schema=12),t<13&&(KV(r),r.schema=13),t<14&&(QV(r),r.schema=14),t<15&&(JV(r),r.schema=15),t<16&&($V(r),r.schema=16),t<17&&(Hm(r,EE),Vm(r,EE),r.schema=17),t<18&&(Hm(r,_E),Vm(r,_E),r.schema=18),t<19&&(UV(r),r.schema=19),t<20&&(e4(r),n4(r),r.schema=20),t<21&&(r4(r),i4(r),r.schema=21),t<22&&(CE(r),r.schema=22),t<23&&(s4(r),r.schema=23),t<24&&(o4(r),r.schema=24),(t<25||r.shared.videos===void 0)&&(ZV(r),t<25&&(r.schema=25)),t<26&&(WV(r),r.schema=26),t<27&&(jV(r),r.schema=27),t<28&&(CE(r),r.schema=28),t<29&&(qV(r),r.schema=29),t<30&&(a4(r),r.schema=30),t<31&&(l4(r),r.schema=31),t<33&&(c4(r),r.schema=33),t<34&&(u4(r),r.schema=34),t<35&&(d4(r),r.schema=35),t<36&&(h4(r),r.schema=36))}function eo(r,t=!1){let e=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new Te,u=0;for(let c=0;c<r.length;++c){let d=r[c],h=0;if(e!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in d.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(d.attributes[f]),h++}if(h!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in d.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(d.morphAttributes[f])}if(t){let f;if(e)f=d.index.count;else if(d.attributes.position!==void 0)f=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,f,c),u+=f}}if(e){let c=0,d=[];for(let h=0;h<r.length;++h){let f=r[h].index;for(let g=0;g<f.count;++g)d.push(f.getX(g)+c);c+=r[h].attributes.position.count}l.setIndex(d)}for(let c in s){let d=DE(s[c]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,d)}for(let c in o){let d=o[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let h=0;h<d;++h){let f=[];for(let p=0;p<o[c].length;++p)f.push(o[c][p][h]);let g=DE(f);if(!g)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(g)}}return l}function DE(r){let t,e,n,i=0;for(let a=0;a<r.length;++a){let l=r[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(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;i+=l.array.length}let s=new t(i),o=0;for(let a=0;a<r.length;++a)s.set(r[a].array,o),o+=r[a].array.length;return new Be(s,e,n)}var Wm;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",speedTranslate:1e3,speedRotate:100,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new He,move:new He,jump:new He}}))(Wm||(Wm={}));var OE=Math.pow(2,-24);var Qa=class{constructor(){}};function di(r,t,e){return e.min.x=t[r],e.min.y=t[r+1],e.min.z=t[r+2],e.max.x=t[r+3],e.max.y=t[r+4],e.max.z=t[r+5],e}function xx(r){let t=-1,e=-1/0;for(let n=0;n<3;n++){let i=r[n+3]-r[n];i>e&&(e=i,t=n)}return t}function bx(r,t){t.set(r)}function Sx(r,t,e){let n,i;for(let s=0;s<3;s++){let o=s+3;n=r[s],i=t[s],e[s]=n<i?n:i,n=r[o],i=t[o],e[o]=n>i?n:i}}function hh(r,t,e){for(let n=0;n<3;n++){let i=t[r+2*n],s=t[r+2*n+1],o=i-s,a=i+s;o<e[n]&&(e[n]=o),a>e[n+3]&&(e[n+3]=a)}}function Qc(r){let t=r[3]-r[0],e=r[4]-r[1],n=r[5]-r[2];return 2*(t*e+e*n+n*t)}function m4(r,t){if(!r.index){let e=r.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;e>65535?i=new Uint32Array(new n(4*e)):i=new Uint16Array(new n(2*e)),r.setIndex(new Be(i,1));for(let s=0;s<e;s++)i[s]=s}}function g4(r){if(!r.groups||!r.groups.length)return[{offset:0,count:r.index.count/3}];let t=[],e=new Set;for(let i of r.groups)e.add(i.start),e.add(i.start+i.count);let n=Array.from(e.values()).sort((i,s)=>i-s);for(let i=0;i<n.length-1;i++){let s=n[i],o=n[i+1];t.push({offset:s/3,count:(o-s)/3})}return t}function Ax(r,t,e,n,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,d=1/0,h=1/0,f=1/0,g=-1/0,p=-1/0,m=-1/0,y=i!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let b=r[v+0],w=r[v+1],A=b-w,T=b+w;A<s&&(s=A),T>l&&(l=T),y&&b<d&&(d=b),y&&b>g&&(g=b);let S=r[v+2],E=r[v+3],M=S-E,I=S+E;M<o&&(o=M),I>u&&(u=I),y&&S<h&&(h=S),y&&S>p&&(p=S);let P=r[v+4],C=r[v+5],D=P-C,B=P+C;D<a&&(a=D),B>c&&(c=B),y&&P<f&&(f=P),y&&P>m&&(m=P)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,y&&(i[0]=d,i[1]=h,i[2]=f,i[3]=g,i[4]=p,i[5]=m)}function y4(r,t,e,n){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,d=(t+e)*6;c<d;c+=6){let h=r[c+0];h<i&&(i=h),h>a&&(a=h);let f=r[c+2];f<s&&(s=f),f>l&&(l=f);let g=r[c+4];g<o&&(o=g),g>u&&(u=g)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function v4(r,t,e,n,i){let s=e,o=e+n-1,a=i.pos,l=i.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=r[s*3+u];r[s*3+u]=r[o*3+u],r[o*3+u]=c;let d=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=d;let h=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=h}s++,o--}else return s}}var to=32,x4=(r,t)=>r.candidate-t.candidate,jo=new Array(to).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),jm=new Float32Array(6);function b4(r,t,e,n,i,s){let o=-1,a=0;if(s===0)o=xx(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=xx(r),o!==-1&&(a=S4(e,n,i,o));else if(s===2){let l=Qc(r),u=1.25*i,c=n*6,d=(n+i)*6;for(let h=0;h<3;h++){let f=t[h],m=(t[h+3]-f)/to;if(i<to/4){let y=[...jo];y.length=i;let v=0;for(let b=c;b<d;b+=6,v++){let w=y[v];w.candidate=e[b+2*h],w.count=0;let{bounds:A,leftCacheBounds:T,rightCacheBounds:S}=w;for(let E=0;E<3;E++)S[E]=1/0,S[E+3]=-1/0,T[E]=1/0,T[E+3]=-1/0,A[E]=1/0,A[E+3]=-1/0;hh(b,e,A)}y.sort(x4);let x=i;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<d;b+=6){let w=e[b+2*h];for(let A=0;A<x;A++){let T=y[A];w>=T.candidate?hh(b,e,T.rightCacheBounds):(hh(b,e,T.leftCacheBounds),T.count++)}}for(let b=0;b<x;b++){let w=y[b],A=w.count,T=i-w.count,S=w.leftCacheBounds,E=w.rightCacheBounds,M=0;A!==0&&(M=Qc(S)/l);let I=0;T!==0&&(I=Qc(E)/l);let P=1+1.25*(M*A+I*T);P<u&&(o=h,u=P,a=w.candidate)}}else{for(let x=0;x<to;x++){let b=jo[x];b.count=0,b.candidate=f+m+x*m;let w=b.bounds;for(let A=0;A<3;A++)w[A]=1/0,w[A+3]=-1/0}for(let x=c;x<d;x+=6){let A=~~((e[x+2*h]-f)/m);A>=to&&(A=to-1);let T=jo[A];T.count++,hh(x,e,T.bounds)}let y=jo[to-1];bx(y.bounds,y.rightCacheBounds);for(let x=to-2;x>=0;x--){let b=jo[x],w=jo[x+1];Sx(b.bounds,w.rightCacheBounds,b.rightCacheBounds)}let v=0;for(let x=0;x<to-1;x++){let b=jo[x],w=b.count,A=b.bounds,S=jo[x+1].rightCacheBounds;w!==0&&(v===0?bx(A,jm):Sx(A,jm,jm)),v+=w;let E=0,M=0;v!==0&&(E=Qc(jm)/l);let I=i-v;I!==0&&(M=Qc(S)/l);let P=1+1.25*(E*v+M*I);P<u&&(o=h,u=P,a=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function S4(r,t,e,n){let i=0;for(let s=t,o=t+e;s<o;s++)i+=r[s*6+n*2];return i/e}function w4(r,t){let e=r.attributes.position,n=e.array,i=r.index.array,s=i.length/3,o=new Float32Array(s*6),a=e.offset||0,l=3;e.isInterleavedBufferAttribute&&(l=e.data.stride);for(let u=0;u<s;u++){let c=u*3,d=u*6,h=i[c+0]*l+a,f=i[c+1]*l+a,g=i[c+2]*l+a;for(let p=0;p<3;p++){let m=n[h+p],y=n[f+p],v=n[g+p],x=m;y<x&&(x=y),v<x&&(x=v);let b=m;y>b&&(b=y),v>b&&(b=v);let w=(b-x)/2,A=p*2;o[d+A+0]=x+w,o[d+A+1]=w+(Math.abs(x)+w)*OE,x<t[p]&&(t[p]=x),b>t[p+3]&&(t[p+3]=b)}}return o}function A4(r,t){function e(y){h&&h(y/f)}function n(y,v,x,b=null,w=0){if(!g&&w>=l&&(g=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(r))),x<=c||w>=l)return e(v+x),y.offset=v,y.count=x,y;let A=b4(y.boundingData,b,o,v,x,d);if(A.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let T=v4(a,o,v,x,A);if(T===v||T===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=A.axis;let S=new Qa,E=v,M=T-v;y.left=S,S.boundingData=new Float32Array(6),Ax(o,E,M,S.boundingData,s),n(S,E,M,s,w+1);let I=new Qa,P=T,C=x-M;y.right=I,I.boundingData=new Float32Array(6),Ax(o,P,C,I.boundingData,s),n(I,P,C,s,w+1)}return y}m4(r,t);let i=new Float32Array(6),s=new Float32Array(6),o=w4(r,i),a=r.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,d=t.strategy,h=t.onProgress,f=r.index.count/3,g=!1,p=[],m=g4(r);if(m.length===1){let y=m[0],v=new Qa;v.boundingData=i,y4(o,y.offset,y.count,s),n(v,y.offset,y.count,s),p.push(v)}else for(let y of m){let v=new Qa;v.boundingData=new Float32Array(6),Ax(o,y.offset,y.count,v.boundingData,s),n(v,y.offset,y.count,s),p.push(v)}return p}function NE(r,t){let e=A4(r,t),n,i,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let d=e[c],h=l(d),f=new a(32*h);n=new Float32Array(f),i=new Uint32Array(f),s=new Uint16Array(f),u(0,d),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,d){let h=c/4,f=c/2,g=!!d.count,p=d.boundingData;for(let m=0;m<6;m++)n[h+m]=p[m];if(g){let m=d.offset,y=d.count;return i[h+6]=m,s[f+14]=y,s[f+15]=65535,c+32}else{let m=d.left,y=d.right,v=d.splitAxis,x;if(x=u(c+32,m),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[h+6]=x/4,x=u(x,y),i[h+7]=v,x}}}var Mr=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}setFromPoints(t,e){let n=1/0,i=-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,i=l>i?l:i}this.min=n,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}};Mr.prototype.setFromBox=function(){let r=new _;return function(e,n){let i=n.min,s=n.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){r.x=i.x*l+s.x*(1-l),r.y=i.y*u+s.y*(1-u),r.z=i.z*c+s.z*(1-c);let d=e.dot(r);o=Math.min(d,o),a=Math.max(d,a)}this.min=o,this.max=a}}();var _ne=function(){let r=new Mr;return function(e,n){let i=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 d=o[c],h=s[c];if(r.setFromPoints(h,a),d.isSeparated(r))return!1}for(let c=0;c<3;c++){let d=u[c],h=l[c];if(r.setFromPoints(h,i),d.isSeparated(r))return!1}}}();var _4=function(){let r=new _,t=new _,e=new _;return function(i,s,o){let a=i.start,l=r,u=s.start,c=t;e.subVectors(a,u),r.subVectors(i.end,s.start),t.subVectors(s.end,s.start);let d=e.dot(c),h=c.dot(l),f=c.dot(c),g=e.dot(l),m=l.dot(l)*f-h*h,y,v;m!==0?y=(d*h-g*f)/m:y=0,v=(d+y*h)/f,o.x=y,o.y=v}}(),fh=function(){let r=new F,t=new _,e=new _;return function(i,s,o,a){_4(i,s,r);let l=r.x,u=r.y;if(l>=0&&l<=1&&u>=0&&u<=1){i.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let d;u<0?d=s.start:d=s.end;let h=t,f=e;if(i.closestPointToPoint(d,!0,t),s.closestPointToPoint(c,!0,e),h.distanceToSquared(d)<=f.distanceToSquared(c)){o.copy(h),a.copy(d);return}else{o.copy(c),a.copy(f);return}}}}(),BE=function(){let r=new _,t=new _,e=new Tn,n=new Cn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:d}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=u,n.end=d,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=c,n.end=d,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;let p=o.getPlane(e);if(Math.abs(p.distanceToPoint(l))<=a){let y=p.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var T4=1e-15;function Jc(r){return Math.abs(r)<T4}var Cr=class extends tn{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new _),this.satBounds=new Array(4).fill().map(()=>new Mr),this.points=[this.a,this.b,this.c],this.sphere=new Sn,this.plane=new Tn,this.needsUpdate=!0}intersectsSphere(t){return BE(t,this)}update(){let t=this.a,e=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,i);let d=s[2],h=o[2];d.subVectors(e,n),h.setFromPoints(d,i);let f=s[3],g=o[3];f.subVectors(n,t),g.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};Cr.prototype.closestPointToSegment=function(){let r=new _,t=new _,e=new Cn;return function(i,s=null,o=null){let{start:a,end:l}=i,u=this.points,c,d=1/0;for(let h=0;h<3;h++){let f=(h+1)%3;e.start.copy(u[h]),e.end.copy(u[f]),fh(e,i,r,t),c=r.distanceToSquared(t),c<d&&(d=c,s&&s.copy(r),o&&o.copy(t))}return this.closestPointToPoint(a,r),c=a.distanceToSquared(r),c<d&&(d=c,s&&s.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),c=l.distanceToSquared(r),c<d&&(d=c,s&&s.copy(r),o&&o.copy(l)),Math.sqrt(d)}}();Cr.prototype.intersectsTriangle=function(){let r=new Cr,t=new Array(3),e=new Array(3),n=new Mr,i=new Mr,s=new _,o=new _,a=new _,l=new _,u=new Cn,c=new Cn,d=new Cn;return function(f,g=null){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(r.copy(f),r.update(),f=r);let p=this.plane,m=f.plane;if(Math.abs(p.normal.dot(m.normal))>1-1e-10){let y=this.satBounds,v=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let w=0;w<4;w++){let A=y[w],T=v[w];if(n.setFromPoints(T,e),A.isSeparated(n))return!1}let x=f.satBounds,b=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let A=x[w],T=b[w];if(n.setFromPoints(T,t),A.isSeparated(n))return!1}for(let w=0;w<4;w++){let A=v[w];for(let T=0;T<4;T++){let S=b[T];if(s.crossVectors(A,S),n.setFromPoints(s,t),i.setFromPoints(s,e),n.isSeparated(i))return!1}}return g&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),g.start.set(0,0,0),g.end.set(0,0,0)),!0}else{let y=this.points,v=!1,x=0;for(let C=0;C<3;C++){let D=y[C],B=y[(C+1)%3];u.start.copy(D),u.end.copy(B),u.delta(o);let k=v?c.start:c.end,X=Jc(m.distanceToPoint(D));if(Jc(m.normal.dot(o))&&X){c.copy(u),x=2;break}if((m.intersectLine(u,k)||X)&&!Jc(k.distanceTo(B))){if(x++,v)break;v=!0}}if(x===1&&this.containsPoint(c.start))return g&&(g.start.copy(c.start),g.end.copy(c.start)),!0;if(x!==2)return!1;let b=f.points,w=!1,A=0;for(let C=0;C<3;C++){let D=b[C],B=b[(C+1)%3];u.start.copy(D),u.end.copy(B),u.delta(a);let k=w?d.start:d.end,X=Jc(p.distanceToPoint(D));if(Jc(p.normal.dot(a))&&X){d.copy(u),A=2;break}if((p.intersectLine(u,k)||X)&&!Jc(k.distanceTo(B))){if(A++,w)break;w=!0}}if(A===1&&this.containsPoint(d.start))return g&&(g.start.copy(d.start),g.end.copy(d.start)),!0;if(A!==2)return!1;if(c.delta(o),d.delta(a),o.dot(a)<0){let C=d.start;d.start=d.end,d.end=C}let T=c.start.dot(o),S=c.end.dot(o),E=d.start.dot(o),M=d.end.dot(o),I=S<E,P=T<M;return T!==M&&E!==S&&I===P?!1:(g&&(l.subVectors(c.start,d.start),l.dot(o)>0?g.start.copy(c.start):g.start.copy(d.start),l.subVectors(c.end,d.end),l.dot(o)<0?g.end.copy(c.end):g.end.copy(d.end)),!0)}}}();Cr.prototype.distanceToPoint=function(){let r=new _;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();Cr.prototype.distanceToTriangle=function(){let r=new _,t=new _,e=["a","b","c"],n=new Cn,i=new Cn;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let d=0;d<3;d++){let h,f=e[d],g=o[f];this.closestPointToPoint(g,r),h=g.distanceToSquared(r),h<c&&(c=h,a&&a.copy(r),l&&l.copy(g));let p=this[f];o.closestPointToPoint(p,r),h=p.distanceToSquared(r),h<c&&(c=h,a&&a.copy(p),l&&l.copy(r))}for(let d=0;d<3;d++){let h=e[d],f=e[(d+1)%3];n.set(this[h],this[f]);for(let g=0;g<3;g++){let p=e[g],m=e[(g+1)%3];i.set(o[p],o[m]),fh(n,i,r,t);let y=r.distanceToSquared(t);y<c&&(c=y,a&&a.copy(r),l&&l.copy(t))}}return Math.sqrt(c)}}();var Pr=class extends xt{constructor(...t){super(...t),this.isOrientedBox=!0,this.matrix=new de,this.invMatrix=new de,this.points=new Array(8).fill().map(()=>new _),this.satAxes=new Array(3).fill().map(()=>new _),this.satBounds=new Array(3).fill().map(()=>new Mr),this.alignedSatBounds=new Array(3).fill().map(()=>new Mr),this.needsUpdate=!1}set(t,e,n){super.set(t,e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){super.copy(t),this.matrix.copy(t.matrix),this.needsUpdate=!0}};Pr.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,i=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let d=0;d<=1;d++){let h=1*u|2*c|4*d,f=i[h];f.x=u?n.x:e.x,f.y=c?n.y:e.y,f.z=d?n.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=i[0];for(let u=0;u<3;u++){let c=o[u],d=s[u],h=1<<u,f=i[h];c.subVectors(a,f),d.setFromPoints(c,i)}let l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Pr.prototype.intersectsBox=function(){let r=new Mr;return function(e){this.needsUpdate&&this.update();let n=e.min,i=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,a[0].isSeparated(r)||(r.min=n.y,r.max=i.y,a[1].isSeparated(r))||(r.min=n.z,r.max=i.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(r.setFromBox(u,e),c.isSeparated(r))return!1}return!0}}();Pr.prototype.intersectsTriangle=function(){let r=new Cr,t=new Array(3),e=new Mr,n=new Mr,i=new _;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let h=0;h<3;h++){let f=a[h],g=l[h];if(e.setFromPoints(g,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,d=this.points;for(let h=0;h<3;h++){let f=u[h],g=c[h];if(e.setFromPoints(g,d),f.isSeparated(e))return!1}for(let h=0;h<3;h++){let f=l[h];for(let g=0;g<4;g++){let p=c[g];if(i.crossVectors(f,p),e.setFromPoints(i,t),n.setFromPoints(i,d),e.isSeparated(n))return!1}}return!0}}();Pr.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}}();Pr.prototype.distanceToPoint=function(){let r=new _;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();Pr.prototype.distanceToBox=function(){let r=["x","y","z"],t=new Array(12).fill().map(()=>new Cn),e=new Array(12).fill().map(()=>new Cn),n=new _,i=new _;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),u&&u.copy(i)),0;let c=a*a,d=o.min,h=o.max,f=this.points,g=1/0;for(let m=0;m<8;m++){let y=f[m];i.copy(y).clamp(d,h);let v=y.distanceToSquared(i);if(v<g&&(g=v,l&&l.copy(y),u&&u.copy(i),v<c))return Math.sqrt(v)}let p=0;for(let m=0;m<3;m++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(m+1)%3,b=(m+2)%3,w=y<<x|v<<b,A=1<<m|y<<x|v<<b,T=f[w],S=f[A];t[p].set(T,S);let M=r[m],I=r[x],P=r[b],C=e[p],D=C.start,B=C.end;D[M]=d[M],D[I]=y?d[I]:h[I],D[P]=v?d[P]:h[I],B[M]=h[M],B[I]=y?d[I]:h[I],B[P]=v?d[P]:h[I],p++}for(let m=0;m<=1;m++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){i.x=m?h.x:d.x,i.y=y?h.y:d.y,i.z=v?h.z:d.z,this.closestPointToPoint(i,n);let x=i.distanceToSquared(n);if(x<g&&(g=x,l&&l.copy(n),u&&u.copy(i),x<c))return Math.sqrt(x)}for(let m=0;m<12;m++){let y=t[m];for(let v=0;v<12;v++){let x=e[v];fh(y,x,n,i);let b=n.distanceToSquared(i);if(b<g&&(g=b,l&&l.copy(n),u&&u.copy(i),b<c))return Math.sqrt(b)}}return Math.sqrt(g)}}();var Xm=new _,Ym=new _,Km=new _,FE=new F,UE=new F,GE=new F,kE=new _;function E4(r,t,e,n,i,s){let o;return s===bn?o=r.intersectTriangle(n,e,t,!0,i):o=r.intersectTriangle(t,e,n,s!==fr,i),o===null?null:{distance:r.origin.distanceTo(i),point:i.clone()}}function M4(r,t,e,n,i,s,o){Xm.fromBufferAttribute(t,n),Ym.fromBufferAttribute(t,i),Km.fromBufferAttribute(t,s);let a=E4(r,Xm,Ym,Km,kE,o);if(a){e&&(FE.fromBufferAttribute(e,n),UE.fromBufferAttribute(e,i),GE.fromBufferAttribute(e,s),a.uv=tn.getUV(kE,Xm,Ym,Km,FE,UE,GE,new F));let l={a:n,b:i,c:s,normal:new _,materialIndex:0};tn.getNormal(Xm,Ym,Km,l.normal),a.face=l,a.faceIndex=n}return a}function Tx(r,t,e,n,i){let s=n*3,o=r.index.getX(s),a=r.index.getX(s+1),l=r.index.getX(s+2),u=M4(e,r.attributes.position,r.attributes.uv,o,a,l,t);return u?(u.faceIndex=n,i&&i.push(u),u):null}function zE(r,t,e,n,i,s){for(let o=n,a=n+i;o<a;o++)Tx(r,t,e,o,s)}function VE(r,t,e,n,i){let s=1/0,o=null;for(let a=n,l=n+i;a<l;a++){let u=Tx(r,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Ex(r,t,e){return r===null||(r.point.applyMatrix4(t.matrixWorld),r.distance=r.point.distanceTo(e.ray.origin),r.object=t,r.distance<e.near||r.distance>e.far)?null:r}function hi(r,t,e,n){let i=r.a,s=r.b,o=r.c,a=t,l=t+1,u=t+2;e&&(a=e.getX(t),l=e.getX(t+1),u=e.getX(t+2)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function Mx(r,t,e,n,i,s,o){let a=e.index,l=e.attributes.position;for(let u=r,c=t+r;u<c;u++)if(hi(o,u*3,a,l),o.needsUpdate=!0,n(o,u,i,s))return!0;return!1}var $c=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 no(r,t){return t[r+15]===65535}function Ja(r,t){return t[r+6]}function eu(r,t){return t[r+14]}function tu(r){return r+8}function nu(r,t){return t[r+6]}function HE(r,t){return t[r+7]}var ru=new xt,Qm=new _,P4=["x","y","z"];function Jm(r,t,e,n,i){let s=r*2,o=iu,a=qo,l=Xo;if(no(s,a)){let c=Ja(r,l),d=eu(s,a);zE(t,e,n,c,d,i)}else{let c=tu(r);eg(c,o,n,Qm)&&Jm(c,t,e,n,i);let d=nu(r,l);eg(d,o,n,Qm)&&Jm(d,t,e,n,i)}}function $m(r,t,e,n){let i=r*2,s=iu,o=qo,a=Xo;if(no(i,o)){let u=Ja(r,a),c=eu(i,o);return VE(t,e,n,u,c)}else{let u=HE(r,a),c=P4[u],h=n.direction[c]>=0,f,g;h?(f=tu(r),g=nu(r,a)):(f=nu(r,a),g=tu(r));let m=eg(f,s,n,Qm)?$m(f,t,e,n):null;if(m){let x=m.point[c];if(h?x<=s[g+u]:x>=s[g+u+3])return m}let v=eg(g,s,n,Qm)?$m(g,t,e,n):null;return m&&v?m.distance<=v.distance?m:v:m||v||null}}var WE=function(){let r,t,e=[],n=new $c(()=>new xt);return function(...o){r=n.getPrimitive(),t=n.getPrimitive(),e.push(r,t);let a=i(...o);n.releasePrimitive(r),n.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],r=e[l-2]),a};function i(s,o,a,l,u=null,c=0,d=0){function h(x){let b=x*2,w=qo,A=Xo;for(;!no(b,w);)x=tu(x),b=x*2;return Ja(x,A)}function f(x){let b=x*2,w=qo,A=Xo;for(;!no(b,w);)x=nu(x,A),b=x*2;return Ja(x,A)+eu(b,w)}let g=s*2,p=iu,m=qo,y=Xo;if(no(g,m)){let x=Ja(s,y),b=eu(g,m);return di(s,p,r),l(x,b,!1,d,c+s,r)}else{let x=tu(s),b=nu(s,y),w=x,A=b,T,S,E,M;if(u&&(E=r,M=t,di(w,p,E),di(A,p,M),T=u(E),S=u(M),S<T)){w=b,A=x;let X=T;T=S,S=X,E=M}E||(E=r,di(w,p,E));let I=no(w*2,m),P=a(E,I,T,d+1,c+w),C;if(P===2){let X=h(w),q=f(w)-X;C=l(X,q,!0,d+1,c+w,E)}else C=P&&i(w,o,a,l,u,c,d+1);if(C)return!0;M=t,di(A,p,M);let D=no(A*2,m),B=a(M,D,S,d+1,c+A),k;if(B===2){let X=h(A),q=f(A)-X;k=l(X,q,!0,d+1,c+A,M)}else k=B&&i(A,o,a,l,u,c,d+1);return!!k}}}(),jE=function(){let r=new Cr,t=new Cr,e=new de,n=new Pr,i=new Pr;return function s(o,a,l,u,c=null){let d=o*2,h=iu,f=qo,g=Xo;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),no(d,f)){let m=a,y=m.index,v=m.attributes.position,x=l.index,b=l.attributes.position,w=Ja(o,g),A=eu(d,f);if(e.copy(u).invert(),l.boundsTree)return di(o,h,i),i.matrix.copy(e),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>i.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(u),S.b.applyMatrix4(u),S.c.applyMatrix4(u),S.needsUpdate=!0;for(let E=w*3,M=(A+w)*3;E<M;E+=3)if(hi(t,E,y,v),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let T=w*3,S=A+w*3;T<S;T+=3){hi(r,T,y,v),r.a.applyMatrix4(e),r.b.applyMatrix4(e),r.c.applyMatrix4(e),r.needsUpdate=!0;for(let E=0,M=x.count;E<M;E+=3)if(hi(t,E,x,b),t.needsUpdate=!0,r.intersectsTriangle(t))return!0}}else{let m=o+8,y=g[o+6];return di(m,h,ru),!!(c.intersectsBox(ru)&&s(m,a,l,u,c)||(di(y,h,ru),c.intersectsBox(ru)&&s(y,a,l,u,c)))}}}();function eg(r,t,e,n){return di(r,t,ru),e.intersectBox(ru,n)}var Cx=[],Zm,iu,qo,Xo;function su(r){Zm&&Cx.push(Zm),Zm=r,iu=new Float32Array(r),qo=new Uint16Array(r),Xo=new Uint32Array(r)}function ph(){Zm=null,iu=null,qo=null,Xo=null,Cx.length&&su(Cx.pop())}var Px=Symbol("skip tree generation"),Ix=new xt,Dx=new xt,ou=new de,$a=new Pr,mh=new Pr,gh=new _,tg=new _,I4=new _,D4=new _,O4=new _,qE=new xt,as=new $c(()=>new Cr),on=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."),on.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let n=t.geometry,i=t._roots,s=n.getIndex(),o;return e.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,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."),on.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:i,roots:s}=t,o=new on(e,{...n,[Px]:!0});if(o._roots=s,n.setIndex){let a=e.getIndex();if(a===null){let l=new Be(t.index,1,!1);e.setIndex(l)}else a.array!==i&&(a.array.set(i),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,[Px]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[Px]||(this._roots=NE(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new xt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,i=e.attributes.position,s=i.array,o=i.offset||0,a=3;i.isInterleavedBufferAttribute&&(a=i.data.stride);let l,u,c,d,h=0,f=this._roots;for(let p=0,m=f.length;p<m;p++)l=f[p],u=new Uint32Array(l),c=new Uint16Array(l),d=new Float32Array(l),g(0,h),h+=l.byteLength;function g(p,m,y=!1){let v=p*2;if(c[v+15]===65535){let b=u[p+6],w=c[v+14],A=1/0,T=1/0,S=1/0,E=-1/0,M=-1/0,I=-1/0;for(let P=3*b,C=3*(b+w);P<C;P++){let D=n[P]*a+o,B=s[D+0],k=s[D+1],X=s[D+2];B<A&&(A=B),B>E&&(E=B),k<T&&(T=k),k>M&&(M=k),X<S&&(S=X),X>I&&(I=X)}return d[p+0]!==A||d[p+1]!==T||d[p+2]!==S||d[p+3]!==E||d[p+4]!==M||d[p+5]!==I?(d[p+0]=A,d[p+1]=T,d[p+2]=S,d[p+3]=E,d[p+4]=M,d[p+5]=I,!0):!1}else{let b=p+8,w=u[p+6],A=b+m,T=w+m,S=y,E=!1,M=!1;t?S||(E=t.has(A),M=t.has(T),S=!E&&!M):(E=!0,M=!0);let I=S||E,P=S||M,C=!1;I&&(C=g(b,m,S));let D=!1;P&&(D=g(w,m,S));let B=C||D;if(B)for(let k=0;k<3;k++){let X=b+k,W=w+k,q=d[X],H=d[X+3],K=d[W],R=d[W+3];d[p+k]=q<K?q:K,d[p+k+3]=H>R?H:R}return B}}}traverse(t,e=0){let n=this._roots[e],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let d=i[a+6],h=s[u+14];t(l,c,new Float32Array(n,a*4,6),d,h)}else{let d=a+32/4,h=i[a+6],f=i[a+7];t(l,c,new Float32Array(n,a*4,6),f)||(o(d,l+1),o(h,l+1))}}}raycast(t,e=Wr){let n=this._roots,i=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=i.groups,u=o?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=a?e[l[c].materialIndex].side:u,f=s.length;if(su(n[c]),Jm(0,i,h,t,s),ph(),a){let g=l[c].materialIndex;for(let p=f,m=s.length;p<m;p++)s[p].face.materialIndex=g}}return s}raycastFirst(t,e=Wr){let n=this._roots,i=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=i.groups,u=s?e.side:e;for(let c=0,d=n.length;c<d;c++){let h=o?e[l[c].materialIndex].side:u;su(n[c]);let f=$m(0,i,h,t);ph(),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,i=!1;for(let s of this._roots)if(su(s),i=jE(0,n,t,e),ph(),i)break;return i}shapecast(t,e,n){let i=this.geometry;if(t instanceof Function){if(e){let h=e;e=(f,g,p,m)=>{let y=g*3;return h(f,y,y+1,y+2,p,m)}}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=as.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let h=l;l=(f,g,p,m,y)=>h(f,g,p,m,y)?!0:Mx(f,g,i,u,p,m,s)}else l||(u?l=(h,f,g,p)=>Mx(h,f,i,u,g,p,s):l=(h,f,g)=>g);let c=!1,d=0;for(let h of this._roots){if(su(h),c=WE(0,i,a,l,o,d),ph(),c)break;d+=h.byteLength}return as.releasePrimitive(s),c}bvhcast(t,e,n){let{intersectsRanges:i,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;ou.copy(e).invert();let c=as.getPrimitive(),d=as.getPrimitive();if(s){let f=function(g,p,m,y,v,x,b,w){for(let A=m,T=m+y;A<T;A++){hi(d,A*3,l,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let S=g,E=g+p;S<E;S++)if(hi(c,S*3,o,a),c.needsUpdate=!0,s(c,d,S,A,v,x,b,w))return!0}return!1};if(i){let g=i;i=function(p,m,y,v,x,b,w,A){return g(p,m,y,v,x,b,w,A)?!0:f(p,m,y,v,x,b,w,A)}}else i=f}t.getBoundingBox(Dx),Dx.applyMatrix4(e);let h=this.shapecast({intersectsBounds:f=>Dx.intersectsBox(f),intersectsRange:(f,g,p,m,y,v)=>(Ix.copy(v),Ix.applyMatrix4(ou),t.shapecast({intersectsBounds:x=>Ix.intersectsBox(x),intersectsRange:(x,b,w,A,T)=>i(f,g,x,b,m,y,A,T)}))});return as.releasePrimitive(c),as.releasePrimitive(d),h}intersectsBox(t,e){return $a.set(t.min,t.max,e),$a.needsUpdate=!0,this.shapecast({intersectsBounds:n=>$a.intersectsBox(n),intersectsTriangle:n=>$a.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},i={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),$a.set(t.boundingBox.min,t.boundingBox.max,e),$a.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,d=t.index,h=as.getPrimitive(),f=as.getPrimitive(),g=tg,p=I4,m=null,y=null;i&&(m=D4,y=O4);let v=1/0,x=null,b=null;return ou.copy(e).invert(),mh.matrix.copy(ou),this.shapecast({boundsTraverseOrder:w=>$a.distanceToBox(w),intersectsBounds:(w,A,T)=>T<v&&T<o?(A&&(mh.min.copy(w.min),mh.max.copy(w.max),mh.needsUpdate=!0),!0):!1,intersectsRange:(w,A)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:T=>mh.distanceToBox(T),intersectsBounds:(T,S,E)=>E<v&&E<o,intersectsRange:(T,S)=>{for(let E=T*3,M=(T+S)*3;E<M;E+=3){hi(f,E,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let I=w*3,P=(w+A)*3;I<P;I+=3){hi(h,I,u,l),h.needsUpdate=!0;let C=h.distanceToTriangle(f,g,m);if(C<v&&(p.copy(g),y&&y.copy(m),v=C,x=I/3,b=E/3),C<s)return!0}}}});{let T=d?d.count:c.count;for(let S=0,E=T;S<E;S+=3){hi(f,S,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let M=w*3,I=(w+A)*3;M<I;M+=3){hi(h,M,u,l),h.needsUpdate=!0;let P=h.distanceToTriangle(f,g,m);if(P<v&&(p.copy(g),y&&y.copy(m),v=P,x=M/3,b=S/3),P<s)return!0}}}}}),as.releasePrimitive(h),as.releasePrimitive(f),v===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=v,n.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(ou),p.applyMatrix4(ou),i.distance=p.sub(i.point).length(),i.faceIndex=b),n)}closestPointToPoint(t,e={},n=0,i=1/0){let s=n*n,o=i*i,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(gh.copy(t).clamp(c.min,c.max),gh.distanceToSquared(t)),intersectsBounds:(c,d,h)=>h<a&&h<o,intersectsTriangle:(c,d)=>{c.closestPointToPoint(t,gh);let h=t.distanceToSquared(gh);return h<a&&(tg.copy(gh),a=h,l=d),h<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(tg):e.point=tg.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{di(0,new Float32Array(n),qE),t.union(qE)}),t}},XE=on.prototype.raycast;on.prototype.raycast=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[t,e,n,i]=r;return XE.call(this,n,t.material).forEach(o=>{o=Ex(o,t,e),o&&i.push(o)}),i}else return XE.apply(this,r)};var YE=on.prototype.raycastFirst;on.prototype.raycastFirst=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[t,e,n]=r;return Ex(YE.call(this,n,t.material),t,e)}else return YE.apply(this,r)};var KE=on.prototype.closestPointToPoint;on.prototype.closestPointToPoint=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),r.unshift();let t=r[1],e={};return r[1]=e,KE.apply(this,r),t&&t.copy(e.point),e.distance}else return KE.apply(this,r)};var ZE=on.prototype.closestPointToGeometry;on.prototype.closestPointToGeometry=function(...r){let t=r[2],e=r[3];if(t&&t.isVector3||e&&e.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let n={},i={},s=r[1];return r[2]=n,r[3]=i,ZE.apply(this,r),t&&t.copy(n.point),e&&e.copy(i.point).applyMatrix4(s),n.distance}else return ZE.apply(this,r)};var QE=on.prototype.refit;on.prototype.refit=function(...r){let t=r[0],e=r[1];if(e&&(e instanceof Set||Array.isArray(e))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let n=new Set;e.forEach(i=>n.add(i)),t&&t.forEach(i=>n.add(i)),QE.call(this,n)}else QE.apply(this,r)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(r=>{let t=on.prototype[r];on.prototype[r]=function(...e){return(e[0]===null||e[0].isMesh)&&(e.shift(),console.warn(`MeshBVH: The function signature for "${r}" has changed and no longer takes Mesh. See docs for new signature.`)),t.apply(this,e)}});var Fu=dd($E());var L4=.5*(Math.sqrt(3)-1),yh=(3-Math.sqrt(3))/6,R4=1/3,ls=1/6,vre=(Math.sqrt(5)-1)/4,xre=(5-Math.sqrt(5))/20,vh=r=>Math.floor(r)|0,eM=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]),Lx=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 ng(r=Math.random){let t=nM(r),e=new Float64Array(t).map(i=>eM[i%12*2]),n=new Float64Array(t).map(i=>eM[i%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*L4,d=vh(s+c),h=vh(o+c),f=(d+h)*yh,g=d-f,p=h-f,m=s-g,y=o-p,v,x;m>y?(v=1,x=0):(v=0,x=1);let b=m-v+yh,w=y-x+yh,A=m-1+2*yh,T=y-1+2*yh,S=d&255,E=h&255,M=.5-m*m-y*y;if(M>=0){let C=S+t[E],D=e[C],B=n[C];M*=M,a=M*M*(D*m+B*y)}let I=.5-b*b-w*w;if(I>=0){let C=S+v+t[E+x],D=e[C],B=n[C];I*=I,l=I*I*(D*b+B*w)}let P=.5-A*A-T*T;if(P>=0){let C=S+1+t[E+1],D=e[C],B=n[C];P*=P,u=P*P*(D*A+B*T)}return 70*(a+l+u)}}function tM(r=Math.random){let t=nM(r),e=new Float64Array(t).map(s=>Lx[s%12*3]),n=new Float64Array(t).map(s=>Lx[s%12*3+1]),i=new Float64Array(t).map(s=>Lx[s%12*3+2]);return function(o,a,l){let u,c,d,h,f=(o+a+l)*R4,g=vh(o+f),p=vh(a+f),m=vh(l+f),y=(g+p+m)*ls,v=g-y,x=p-y,b=m-y,w=o-v,A=a-x,T=l-b,S,E,M,I,P,C;w>=A?A>=T?(S=1,E=0,M=0,I=1,P=1,C=0):w>=T?(S=1,E=0,M=0,I=1,P=0,C=1):(S=0,E=0,M=1,I=1,P=0,C=1):A<T?(S=0,E=0,M=1,I=0,P=1,C=1):w<T?(S=0,E=1,M=0,I=0,P=1,C=1):(S=0,E=1,M=0,I=1,P=1,C=0);let D=w-S+ls,B=A-E+ls,k=T-M+ls,X=w-I+2*ls,W=A-P+2*ls,q=T-C+2*ls,H=w-1+3*ls,K=A-1+3*ls,R=T-1+3*ls,U=g&255,z=p&255,j=m&255,G=.6-w*w-A*A-T*T;if(G<0)u=0;else{let V=U+t[z+t[j]];G*=G,u=G*G*(e[V]*w+n[V]*A+i[V]*T)}let re=.6-D*D-B*B-k*k;if(re<0)c=0;else{let V=U+S+t[z+E+t[j+M]];re*=re,c=re*re*(e[V]*D+n[V]*B+i[V]*k)}let Z=.6-X*X-W*W-q*q;if(Z<0)d=0;else{let V=U+I+t[z+P+t[j+C]];Z*=Z,d=Z*Z*(e[V]*X+n[V]*W+i[V]*q)}let J=.6-H*H-K*K-R*R;if(J<0)h=0;else{let V=U+1+t[z+1+t[j+1]];J*=J,h=J*J*(e[V]*H+n[V]*K+i[V]*R)}return 32*(u+c+d+h)}}function nM(r){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 i=n+~~(r()*(256-n)),s=e[n];e[n]=e[i],e[i]=s}for(let n=256;n<512;n++)e[n]=e[n-256];return e}var Li=new tn,rg=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 i=0;i<t.count;i+=3){let s=1;Li.a.fromBufferAttribute(t,i),Li.b.fromBufferAttribute(t,i+1),Li.c.fromBufferAttribute(t,i+2),s*=Li.getArea(),e[i/3]=s}this.distribution=new Float32Array(t.count/3);let n=0;for(let i=0;i<e.length;i++)n+=e[i],this.distribution[i]=n;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let n=this.distribution[this.distribution.length-1],i=this.binarySearch(this.randomFunction()*n);return this.sampleFace(i,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,n=0,i=e.length-1,s=-1;for(;n<=i;){let o=Math.ceil((n+i)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?i=o-1:n=o+1}return s}sampleFace(t,e,n){let i=this.randomFunction(),s=this.randomFunction();return i+s>1&&(i=1-i,s=1-s),Li.a.fromBufferAttribute(this.positionAttribute,t*3),Li.b.fromBufferAttribute(this.positionAttribute,t*3+1),Li.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Li.a,i).addScaledVector(Li.b,s).addScaledVector(Li.c,1-(i+s)),Li.getNormal(n),this}};var iM=dd(Rx()),N4=new de,B4=new de,F4=new de,xh;(t=>{function r(e){return e&&e.__isSPEObject}t.is=r})(xh||(xh={}));var au=r=>class extends r{constructor(){super(...arguments);this.hiddenMatrix=new de;this.matrixWorldRigid=new de;this.shearScale=new de;this.shearScaleInv=new de}get __isSPEObject(){return!0}isDescendantOf(n){n instanceof ut&&(n=n.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===n)return!0;i=i.parent}return!1}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);for(let i of this.children)i.updateMatrixWorld(n)}updateWorldMatrix(n,i){let s=this.parent;if(n&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseObject(n,i=0){if(n(this,i)!==!0)for(let o of this.children)xh.is(o)&&o.traverseObject(n,i+1)}updateMatrixWorldSVD(){let n=this.matrixWorld.elements,i=[[n[0],n[4],n[8]],[n[1],n[5],n[9]],[n[2],n[6],n[10]]],{u:s,v:o,q:a}=(0,iM.SVD)(i),l=N4.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=B4.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=F4.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),a.every(d=>Math.abs(a[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(n,i){this.updateWorldMatrix(!0,!1);let s=new de().copy(this.matrixWorld).invert();return n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),s.multiply(n.parent.matrixWorld)),"hiddenMatrix"in n&&n.hiddenMatrix instanceof de?n.hiddenMatrix.premultiply(s):n.applyMatrix4(s),n.updateWorldMatrix(!1,!1),this.add(n),i!==void 0&&(this.children.pop(),this.children.splice(i,0,n)),this}};var Nx=class extends au(ut){},U4=r=>r.type==="Mesh",fi=class extends Nx{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1}expand(){let e=0,n=this.object.entityChildren(e);for(;n;){let i=this.children[e];i?.object!==n&&(i&&this.remove(i),i=new fi(n),this.add(i),i.matrixAutoUpdate=!1,i.matrix=n.matrix,i.hiddenMatrix=n.hiddenMatrix),i.expand(),e+=1,n=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return 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 U4(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 el=new _,tl=new _,lu=new de,oM=[new _(-1,1,1),new _(-1,-1,1),new _(1,-1,1),new _(1,1,1),new _(-1,1,-1),new _(-1,-1,-1),new _(1,-1,-1),new _(1,1,-1)],G4=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],k4=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],sM=(r,t,e)=>{r.updateEntityBoxSize(el,tl),lu.copy(t).multiply(r.matrixWorld),tl.x===0&&tl.y===0&&tl.z===0?e.push(new _(el.x,el.y,el.z).applyMatrix4(lu)):oM.forEach(n=>{e.push(n.clone().multiply(tl).add(el).applyMatrix4(lu))})},bh=class extends xt{constructor(){super(...arguments);this.matrix=new de;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 i=new de().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,n)}expandByObjectSize(e,n,i=!1){let s=[];return i===!0?e.traverseEntity(o=>{(o.visible||o.cloner&&o.data.visible)&&sM(o,n,s)}):sM(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(lu.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(tl).multiplyScalar(.5),this.getCenter(el),lu.copy(this.matrix).setPosition(el),this.vertices=oM.map(e=>e.clone().multiply(tl).applyMatrix4(lu))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=G4.map(([e,n])=>new Cn(this.vertices[e],this.vertices[n])),this.centerEdges=this.edges.map(e=>e.getCenter(new _))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=k4.map(([e,n])=>this.vertices[e].clone().add(this.vertices[n]).multiplyScalar(.5))}};var Ri={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var Fx=class extends Rd{constructor(){super()}getPoints(t=12){let e=[],n,i=this.getCurveLengths(),o=i[i.length-1]/i.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?i[a]:i[a]-i[a-1],d=Math.ceil(t*c/o),h=u.getPoints(d);for(let f=0;f<h.length;f++){let g=h[f];n&&n.equals(g)||(e.push(g),n=g)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var Ux=.001;function Gx(r,t,e){return t.clone().sub(r).cross(t.clone().sub(e)).length()<=Ux}function Bx(r,t){let e=new _(...r.position),n=new _(...r.controlNext.position),i=new _(...t.controlPrevious.position),s=new _(...t.position);return Gx(e,n,s)&&Gx(e,i,s)}function sg(r){let t=r.points.map(c=>new _(...c.data.position)),e=[r.points[0]],n=new _(...e[0].data.position);for(let c=0;c<r.points.length-1;c++)Gx(n,t[c],t[c+1])||(e.push(r.points[c]),n=t[c]);e.push(r.points[r.points.length-1]);let i=r.isClosed,s=e.length-(i?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let d=e[c].data,h=new _(...d.position),f=new _(...d.controlPrevious.position),g=new _(...d.controlNext.position),p={position:h,baseRoundness:d.roundness,controlPrevious:f,controlNext:g};if(d.roundness===0||!r.isClosed&&(c===0||c===o-1)){a[c]={...p,removedLength:0};continue}let m=i&&c==0?o-1:c-1,y=i&&c==o-1?0:c+1,v=e[m].data,x=e[y].data,b=new _(...v.position),w=new _(...x.position),A=b.clone().sub(h).normalize(),T=w.clone().sub(h).normalize();Object.assign(p,{prevDir:A,nextDir:T});let S=Bx(v,d),E=Bx(d,x);if(!S||!E)a[c]={...p,removedLength:0};else{let M=A.clone().add(T).normalize(),I=M.clone().cross(A).length()/A.dot(M);a[c]={...p,tan:I,removedLength:d.roundness/I}}}for(let c=0;c<s;c++){let d=c,h=i&&c===o-1?0:c+1,f=a[d],g=a[h];if(f.removedLength!==0||g.removedLength!==0){let p=f.position.distanceTo(g.position);f.removedLength=Math.min(f.removedLength,p/2),g.removedLength=Math.min(g.removedLength,p/2)}}let l=[];for(let c=0;c<s;c++){let d=c,h=i&&c===o-1?0:c+1,f=a[d],g=a[h],p=null;if(!Bx(e[d].data,e[h].data))f.position.distanceTo(g.position)>Ux&&(p=new Da(f.position,f.controlNext,g.controlPrevious,g.position));else{let m=f.position.clone(),y=g.position.clone();(f.removedLength!==0||g.removedLength!==0)&&(f.nextDir&&m.add(f.nextDir.clone().setLength(f.removedLength)),g.prevDir&&y.add(g.prevDir.clone().setLength(g.removedLength))),m.distanceTo(y)>Ux&&(p=new Da(m,m.clone().lerp(y,.3),y.clone().lerp(m,.3),y))}l[2*c+1]=p}for(let c=0;c<o;c++){let d=a[c];if(d.removedLength===0){l[2*c]=null;continue}let h=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(h),g=d.nextDir.clone().multiplyScalar(d.removedLength).add(h),p=d.tan*d.removedLength,m=d.prevDir.clone().add(d.nextDir).normalize(),y=f.clone().lerp(g,.5),v=f.distanceTo(g)/2,x=m.clone().multiplyScalar(Math.sqrt(Math.pow(p,2)-Math.pow(v,2))).add(y),b=m.clone().multiplyScalar(-p).add(x),w=h.distanceTo(b)/h.distanceTo(y),A=d.prevDir.clone().multiplyScalar(w*h.distanceTo(f)).add(h),T=A.clone().lerp(b,2),S=f.clone().lerp(A,4/3),E=g.clone().lerp(T,4/3);l[2*c]=new Da(f,S,E,g)}let u=new Fx;return l.forEach(c=>{c&&u.add(c)}),u}var Pt;(t=>{function r(e){return e&&e.__isEntity}t.is=r})(Pt||(Pt={}));var ro=r=>Pt.is(r),z4={type:"completeState",isfromEntity:!0},og=r=>class extends au(r){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new bh;this._recursiveBBox=new bh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(n){let i=this.children[n];if(Pt.is(i))return i}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let n=this;for(;n.data.type!=="Instance";){let i=n.parent;if(Pt.is(i))n=i;else return}return n}forInstancesRec(n){this.instances.forEach(i=>{i.disposed||n(i),i.forInstancesRec(n)})}super_Entity(n,i){typeof n=="string"&&(this.uuid=n),this.identity=n,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(n,i,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)Js.toOps(this.data,o.data).forEach(l=>{let u=am.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,i)});if(n!==null){let o=this.data.states.data(n);o&&(this.dataPatched=Js.patch(this.data,o),Js.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,i)}))}s&&this.updateTransformState(this.dataPatched),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,i){n.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(n=>{ro(n)&&n.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(n=>{n.resetBBoxNeedsUpdateSelf()})}find(n){let i;return this.traverseEntity(s=>{s.uuid===n&&(i=s)}),i}traverseSortNextHelper(){let n=this.parent;if(n){let i=n.children,s=i.indexOf(this)+1;if(Pt.is(i[s]))return i[s];if(Pt.is(n))return n.traverseSortNextHelper()}}sortNext(){let n=this.children;return this.children.length>0&&Pt.is(this.children[0])?n[0]:this.traverseSortNextHelper()}goUp(n){let i=this;for(;n>0&&i!==null;)i=i.parent,n-=1;return i}hasAnccestorOrSelf(n){return this===n||this.hasAnccestor(n)}hasAnccestor(n){let i=this.parent;for(;i;){if(n===i)return!0;i=i.parent}return!1}countToAccestor(n){let i=0,s=this;for(;s!==n;){if(s===null)return-1;s=s.parent,i+=1}return i}forEachEntity(n){for(let i of this.children)ro(i)&&n(i)}traverseEntityAncestors(n){this.traverseAncestors(i=>{Pt.is(i)&&n(i)})}traverseEntity(n,i=0){if(n(this,i)!==!0)for(let o of this.children)ro(o)&&o.traverseEntity(n,i+1)}traverseVisibleEntity(n){n(this);for(let i of this.children)ro(i)&&i.visible&&i.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(n,i=!0){return super.copy(n,!1),this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),this}hasEntityChild(){return this.children.some(n=>ro(n))}isAncestorOf(n){if(this.uuid===n)return!1;let i=!1;return this.traverseEntity(s=>{s.uuid===n&&(i=!0)}),i}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Ic(i,n)}updateTransformState(n){let i=!1;return n.position&&(this.position.fromArray(n.position),i=!0),n.rotation&&(this.rotation.fromArray(n.rotation),i=!0),n.scale&&(i=!0,this.scale.fromArray(n.scale)),n.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(n.hiddenMatrix??Vo.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),n.position&&n.rotation&&n.scale&&n.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let n of this.children)Pt.is(n)&&n.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(n=>{Pt.is(n)&&n.disposeRecursively()})}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return Ic(i,n)}updateByOp(n,i,s,o){let a=this.data;this.data=i;let l=n,u=Ii(n.path,["states","*"]);if(u!==null){if(n.type===0){let[c]=u;if(this?.stateSelection===c){let d={...n.props};if(Object.values(n.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let f=gr.zoom(h,n.path.slice(2));if(f)for(let g in n.props)n.props[g]===void 0&&g in f&&(d[g]=f[g])}}l={...n,props:d,path:n.path.slice(2)}}}}else if(n.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(n.props.name!==void 0&&c.name){let{name:h,...f}=c;c=f}if(n.props.material!==void 0&&"material"in c){let{material:h,...f}=c;c=f}let d=gr.removeOverridden(n.path,n.props,c);l={...n,props:d}}}if(this.updateByPatchedOpBase(l,Js.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Ii(n.path,["overrides"])){let c=[],d=[...n.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(n.type===0)for(let h of Object.keys(n.props)){c[c.length-1]=h;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=n.props[h],f.updateState(Zs.apply(f.component.data,f.overrideData),s))}}else{let h=s.scene.findInstance([this.uuid,...c]);if(h){let f=gr.zoom(h.component.data,d);if(n={...n,path:d},n.type===0){let g=n.props;if(f)for(let[p,m]of Object.entries(n.props))m===void 0&&(g===n.props&&(g={...n.props}),g[p]=f[p]);n={...n,props:g}}h.overrideData=jc.resolve(i.overrides,c),h.updateByOp(n,$n.applySimple(h.data,n),s,!1)}}}else if(this.instances.length>0){let c;if(n.path.length===0&&n.type===0){let d;for(let h of Wo.rootOverrideProps)h in n.props&&(d===void 0&&(d={}),d[h]=n.props[h]);d&&(c={...n,props:d})}else for(let d of Wo.rootOverrideProps)if(Ii(n.path,[d])){c=n;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let h=Zs.filterOp(d.overrideData,c);h&&d.updateByOp(h,$n.applySimple(d.data,h),s,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let h=Zs.filterOp(d.overrideData,n);if(h){let f;a===d.data&&n===h?f=i:f=$n.applySimple(d.data,h),d.updateByOp(h,f,s,!0)}}})}}updateByPatchedOpBase(n,i,s){if(this.dataPatched=i,n.path.length===0&&n.type===0)n.props.type!==void 0&&!Di.is(n.props.type)&&Ri.changeEntityProptotype(this,i,s);else if(n.path.length===1&&n.path[0]==="geometry"&&n.type===0&&"type"in n.props){Ri.changeEntityProptotype(this,i,s);for(let o of this.children)Pt.is(o)&&o.updateVisible()}this.updateByPatchedOp(n,i,s)}updateByPatchedOp(n,i,s){if(n.path.length===0&&n.type===0&&this.updateState(n.props,s),Ii(n.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Ii(n.path,["cloner"])!==null){let o=$n.drop(n,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(i.cloner,s.scene):(this.setFromClonerState(i.cloner,s),this.expandCloner(s.scene)),this.updateVisible()}}updatePathSnapping(n){this._updatedPathSnapping=n,this._needApplyPathSnapping=!0}applyPathSnapping(n){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let l=n.find(i);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data,c=sg(u.geometry.path),d=(s+o)%1,h=c.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new de;l.updateMatrixWorld();let g=new de().multiplyMatrices(f.clone().invert(),l.matrixWorld);h.applyMatrix4(g);let p={position:h.toArray(),rotation:u.rotation};if(a==="tangential"){let m=new de().extractRotation(l.matrixWorld),y=c.getTangentAt(d).applyMatrix4(m).add(h),v=new de().lookAt(h,y,new _(0,1,0)),x=new jt().setFromRotationMatrix(v);p={...p,rotation:[x.x,x.y,x.z]}}this.updateTransformState(p),this.traverseEntity(m=>{m._cameraType&&m.dispatchEvent(z4)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(n,i){n.name!==void 0&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),"cloner"in n&&n.cloner!==void 0&&(this.setFromClonerState(n.cloner,i),this.updateVisible()),this.updateTransformState(n)}get attachedSurfaceCloners(){return this.children.filter(n=>n instanceof Ri.Cloner&&n.parameters.type==="toObject")}setFromClonerState(n,i){this.disposed||(n===null||n.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):(this.cloner===void 0&&(this.cloner=new Ri.Cloner(this,n),i.scene.addPendingExpandCloner(this)),this.cloner.updateState(n,i.scene)))}expandCloner(n){!this.disposed&&this.cloner&&this.cloner.expandClones(n)}invalidateClonerTransform(n){this.cloner&&this.cloner.invalidateTransform(n)}};var lM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},r.parameters),n=e.width/2,i=e.radiusTop??n,s=e.radiusBottom??n;return i===s?(i=n,s=n):i>s?(i=n,s=s*n/i):(i=i*n/s,s=n),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:i,radiusBottom:s})}}static build(r){let{width:t,depth:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:h,hollow:f}=r.parameters,g;return d||f?g=new Sh(u,c,n,i,s,o,a,l*Math.PI/180,d,d,h,f):g=new La(u,c,n,i,s,o,a,l*Math.PI/180),g.scale(1,1,e/t),Object.assign(g,{userData:{...r,type:"CylinderGeometry"}})}};function Yo(r,t,e){e.x=r.x*t.x,e.y=r.y,e.z=r.x*t.y}function aM(r){return new F(r.y,-r.x)}var Sh=class extends Te{constructor(t,e,n,i,s,o,a,l,u,c,d,h,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,n=n||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let g=[],p=[],m=[],y=[],v=0,x=n/2,b=new _,w=new _;f&&t==0&&(t=u),f&&e==0&&(e=c);let A=new F(t,x),T=new F(e,-x),S=null,E=null,M=null,I=null,P=A.clone().sub(T),C=0,D=0,B=0;h>0&&(C=Math.min(t,e)*(1-h),D=t-C,B=e-C);let k=A.clone();k.x-=C;let X=Math.PI-P.angle(),W=P.angle(),q=Math.tan(W/2),H=Math.tan(X/2),K=q+H,R=h?K:H,U=h?K:q;if(u=Math.min(u,(t-D)/R,P.length()/K),c=Math.min(c,(e-B)/U,P.length()/K),u>0){let J=u/q;S=A.clone().sub(new F(J,u)),h&&(M=S.clone(),M.x-=C-K*u),A.sub(P.clone().setLength(J))}if(c>0){let J=c/H;E=T.clone().sub(new F(J,-c)),T.add(P.clone().setLength(J)),h&&(I=E.clone(),I.x-=C-K*c,k.sub(P.clone().setLength(J)))}P=A.clone().sub(T);let z=P.length()<.5,j=[];for(let J=0;J<=i;J++){let V=[],pe=J/i,ie=pe*l+a,ae=new F(Math.sin(ie),Math.cos(ie));I&&E?(G(V,pe,ae,X,c,I,-1,!0),G(V,pe,ae,W,c,E,-1,!1)):E?(re(V,ae,E.x,0,-1),G(V,pe,ae,W,c,E,-1,!1)):o||re(V,ae,e,B,-1);let fe=aM(P).normalize();if(Yo(fe,ae,b),!z)for(let xe=0;xe<=s;xe++){let me=xe/s,Me=P.clone().multiplyScalar(me).add(T);Yo(Me,ae,w),p.push(w.x,w.y,w.z),m.push(b.x,b.y,b.z),y.push(pe,.5+w.y/n),V.push(v++)}if(M&&S?(G(V,pe,ae,X,u,S,1,!1),G(V,pe,ae,W,u,M,1,!0)):S?(G(V,pe,ae,X,u,S,1,!1),re(V,ae,S.x,0,1)):o||re(V,ae,t,D,1),h&&!z){let xe=aM(P).multiplyScalar(-1).normalize();Yo(xe,ae,b);for(let me=0;me<=s;me++){let Me=me/s,Pe=P.clone().multiplyScalar(-Me).add(k);Yo(Pe,ae,w),p.push(w.x,w.y,w.z),m.push(b.x,b.y,b.z),y.push(pe,.5+w.y/n),V.push(v++)}}h&&!o&&V.push(V[0]),j.push(V)}for(let J=0;J<j.length-1;J++)for(let V=0;V<j[0].length-1;V++){if(o&&h&&V==s)continue;let pe=j[J][V],ie=j[J+1][V],ae=j[J+1][V+1],fe=j[J][V+1],xe=p[ae*3+0],me=p[ae*3+2];g.push(pe,ie,fe),(xe!=0||me!=0)&&g.push(ie,ae,fe)}l<Math.PI*2&&(Z(-1,j[0],a),Z(1,j[j.length-1],a+l)),this.setIndex(g),this.setAttribute("position",new we(p,3)),this.setAttribute("normal",new we(m,3)),this.setAttribute("uv",new we(y,2));function G(J,V,pe,ie,ae,fe,xe,me){for(let Me=0;Me<d+1;Me++){let Pe=Me/d,be=xe<0?Pe:1-Pe;me&&(be-=1),be*=ie;let Fe=new F(Math.sin(be),Math.cos(be)*xe),ht=Fe.clone().multiplyScalar(ae).add(fe);Yo(ht,pe,w),p.push(w.x,w.y,w.z),Yo(Fe,pe,b),m.push(b.x,b.y,b.z),y.push(V,.5+w.y/n),J.push(v++)}}function re(J,V,pe,ie,ae){let fe=new _,xe=new F,me=[pe,ie];ae<0&&me.reverse();for(let Me of me)xe.set(Me,x*ae),Yo(xe,V,fe),p.push(fe.x,fe.y,fe.z),m.push(0,ae,0),y.push(.5,.5),J.push(v++)}function Z(J,V,pe){let ie=new F(Math.sin(pe),Math.cos(pe)),ae=new F(-Math.cos(pe),Math.sin(pe)),fe=new _,xe=J<0?(Pe,be,Fe)=>g.push(Pe,be,Fe):(Pe,be,Fe)=>g.push(Pe,Fe,be),me=new F((t+e+D+B)/4,0);Yo(me,ie,fe),p.push(fe.x,fe.y,fe.z),m.push(ae.x,0,ae.y),y.push(.5,.5);let Me=v++;for(let Pe of V){let be=p.slice(Pe*3,Pe*3+3);p.push(...be),m.push(ae.x,0,ae.y);let Fe=y.slice(Pe*2,Pe*2+2);y.push(...Fe),v++}for(let Pe=Me+1;Pe<v-1;Pe++)xe(Me,Pe,Pe+1);xe(Me,v-1,Me+1)}}};var cM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(r){let{width:t,depth:e,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=r.parameters,h;return u>0||c>0||l<360?h=new Sh(0,t/2,n,i,s,o,a,l*Math.PI/180,u,c,d,0,!0):h=new Hl(t/2,n,i,s,o),h.scale(1,1,e/t),Object.assign(h,{userData:{...r,type:"ConeGeometry"}})}};var uM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},r.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(r){let{width:t,height:e,depth:n,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=r.parameters,u;return a==0?u=new Gn(t,e,n,i,s,o):u=new zx(t,e,n,i,s,o,a,l),Object.assign(u,{userData:{...r,type:"CubeGeometry"}})}},kx=Math.PI/2,zx=class extends Te{constructor(t=1,e=1,n=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,n/2);let c=[],d=[],h=[],f=[],g=0,p=0;m("z","y","x",-1,-1,n,e,t,o,s,0),m("z","y","x",1,-1,n,e,-t,o,s,1),m("x","z","y",1,1,t,n,e,i,o,2),m("x","z","y",1,-1,t,n,-e,i,o,3),m("x","y","z",1,-1,t,e,n,i,s,4),m("x","y","z",-1,-1,t,e,-n,i,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,i,0),y("x","y","z",1,-1,1,t,e,n,i,1),y("x","y","z",-1,1,1,t,e,n,i,0),y("x","y","z",1,1,-1,t,e,n,i,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 we(d,3)),this.setAttribute("normal",new we(h,3)),this.setAttribute("uv",new we(f,2));function m(x,b,w,A,T,S,E,M,I,P,C){let D=(S-2*a)/I,B=(E-2*a)/P,k=S/2-a,X=E/2-a,W=M/2,q=I+1,H=P+1,K=0,R=0,U=new _;for(let z=0;z<H;z++){let j=z*B-X;for(let G=0;G<q;G++){let re=G*D-k;U[x]=re*A,U[b]=j*T,U[w]=W,d.push(U.x,U.y,U.z),U[x]=0,U[b]=0,U[w]=M>0?1:-1,h.push(U.x,U.y,U.z),f.push(G/I),f.push(1-z/P),K+=1}}for(let z=0;z<P;z++)for(let j=0;j<I;j++){let G=g+j+q*z,re=g+j+q*(z+1),Z=g+(j+1)+q*(z+1),J=g+(j+1)+q*z;c.push(G,re,J),c.push(re,Z,J),R+=6}u.addGroup(p,R,C),p+=R,g+=K}function y(x,b,w,A,T,S,E,M,I,P,C){let D=(E-2*a)/P,B=E/2-a,k=M/2-a,X=I/2,W=P+1,q=0,H=0,K=new _,R=new _;for(let U=0;U<l+1;U++){let z=U/l*kx,j=Math.sin(z)*a,G=(1-Math.cos(z))*a,re=Math.sin(z),Z=Math.cos(z);K[b]=(k+j)*T,K[w]=(X-G)*S,R[x]=0,R[b]=re*Math.sign(K[b]),R[w]=Z*Math.sign(K[w]);for(let J=0;J<W;J++){let V=J*D-B;K[x]=V*A,d.push(K.x,K.y,K.z),h.push(R.x,R.y,R.z),f.push(J/P),f.push(0),q+=1}}for(let U=0;U<l;U++)for(let z=0;z<P;z++){let j=g+z+W*U,G=g+z+W*(U+1),re=g+(z+1)+W*(U+1),Z=g+(z+1)+W*U;c.push(j,G,Z),c.push(G,re,Z),H+=6}u.addGroup(p,H,C),p+=H,g+=q}function v(x,b,w){let A=new _,T=new _(t/2,e/2,n/2);T.subScalar(a);let S=[],E=x*b*w>0?(I,P,C)=>c.push(I,P,C):(I,P,C)=>c.push(I,C,P);for(let I=0;I<=l;I++){let P=[],C=kx*(1-I/l),D=Math.cos(C),B=Math.sin(C),k=0;for(let X=0;X<=I;X++){let W=Math.cos(k),q=Math.sin(k);A.x=D*W,A.y=B,A.z=D*q;let H=T.clone().addScaledVector(A,a);d.push(x*H.x,b*H.y,w*H.z),h.push(x*A.x,b*A.y,w*A.z),f.push(0,0),P.push(g++),k+=kx/I}S.push(P)}let M=S.length-1;for(let I=0;I<M;I++){let P=S[I],C=S[I+1],D=P.length-1;E(P[0],C[1],C[0]);for(let B=1;B<=D;B++)E(P[B-1],P[B],C[B]),E(P[B],C[B+1],C[B])}}}};var Ko=class extends Te{constructor(t=[],e=[],n="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),d(),this.setAttribute("position",new we(a,3)),this.setAttribute("normal",new we(u,3)),this.setAttribute("uv",new we(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],g=new _,p=g.clone(),m=new tn,y=s*i,v=i-y,x=o+1,b=new _,w=(q,H)=>b.subVectors(q,H).normalize(),A=(q,H)=>Array(q).fill(void 0).map(H),T=A(t.length/3,(q,H)=>new _().fromArray(t,H*3).setLength(i)),S=[],E=1e6;for(let q=0;q<T.length;q++){let H=T[q],K=[],R,U,z,j=1e10,G=-1;for(;(G=e.indexOf(q,G+1))!=-1;){let V=G-G%3;R=e[V+(G+1)%3],U=e[V+(G+2)%3],z=H.distanceToSquared(T[R]),j=Math.min(j,z),K.push([R,U,z])}j+=1e-6;let re=[],Z=0,J=K.length;for(let V=0;V<J;V++){[R,U,z]=K[Z];let pe=S[R]?.includes(q)==!0;z<=j&&re.push(R+ +pe*E),Z=K.findIndex(ie=>ie[0]==U)}S.push(re)}let M=[];{let q=0,H=0,K,R,U=f==3;for(let z=0;z<=o;z++){K=z*(z+1)/2,R=(z+1)*(z+2)/2;for(let j=0;j<o-z;j++)[q,H]=[K+j+z+2,R+j+z+3],M.push(K,R,...U?[H,K]:[q,R],H,q),[K,R]=[q,H];M.push(K,R,K+o+2)}}let I=g.clone(),P=g.clone(),C=g.clone(),D=g.clone(),B=g.clone(),k=[],X=A(T.length,()=>A(f,()=>g.clone()));for(let q=0;q<T.length;q++){g.copy(T[q]).normalize(),I.copy(g).multiplyScalar(v);let H=S[q];for(let re=0;re<H.length;re++){let Z=H[re],J=H[(re+1)%f];m.setFromPointsAndIndices(T,q,Z%E,J%E),m.b.sub(m.a).setLength(1e10).add(m.a),m.c.sub(m.a).setLength(1e10).add(m.a),m.closestPointToPoint(I,X[q][re])}let K=[],R=[],U=[],z=new _;o==0&&[...X[q]].reduce((re,Z)=>re.add(Z),z).multiplyScalar(1/f);for(let re=0;re<f;re++){let Z=[],J=(re-1+f)%f,V=X[q][J],pe=X[q][re];g.copy(V).sub(I),p.copy(pe).sub(I);let ie=I.angleTo(g),ae=g.angleTo(p),fe=Math.cos(ie)*y;o==0?P.copy(z):P.copy(I).setLength(v+fe),R.push(fe);let xe=[P,V,pe];for(let me=0;me<2;me++){let Me=xe[me],Pe=xe[me+1];D.subVectors(Me,I),B.subVectors(Pe,I),C.crossVectors(D,B).normalize();for(let be=0;be<x;be++){let Fe=[ie,ae][me]*be/x;g.copy(D).applyAxisAngle(C,Fe).add(I),K.push(g.clone()),me&&(w(g,I),Z.push([be==0?Me:g.clone(),b.clone()]))}me&&(w(Pe,I),Z.push([Pe,b.clone()]))}U.push(Z)}k.push(U);let j=2*x,G=2;for(let re=0;re<f;re++){let Z=j*re,J=j*((re+1)%f),V=[K[Z]];for(let ie=1;ie<x;ie++){D=K[Z+ie],B=K[J+ie],V.push(D);for(let ae=1,fe=ie-G+1;ae<=fe;ae++)g.lerpVectors(D,B,ae/(fe+1)),g.sub(I).setLength(R[re]).add(I),V.push(g.clone());V.push(B)}for(let ie=0;ie<x;ie++)V.push(K[ie+x+Z]);V.push(K[J+x]);let pe=M.map(ie=>V[ie]);a.push(...pe.map(ie=>[ie.x,ie.y,ie.z]).flat()),u.push(...pe.map(ie=>(w(ie,I),[b.x,b.y,b.z])).flat())}}let W=[];for(let q=0;q<S.length;q++)for(let H=0;H<f;H++){let K=S[q][H];if(K<E){let R=S[K].findIndex(j=>j%E==q),U=k[q][H],z=k[K][R];for(let j=0;j<x;j++){let G=U[j],re=z[x-j],Z=U[j+1],J=z[x-(j+1)];[G,re,Z,Z,re,J].forEach(V=>{a.push(V[0].x,V[0].y,V[0].z),u.push(V[1].x,V[1].y,V[1].z)})}W.push(U[0][0],z[x][0],U[x][0],z[0][0])}}for(;W.length;){let q,H,K,R;[q,H]=W.splice(0,2);let U=[q];for(;q!=H;)U.push(H),K=W.indexOf(H),R=K%2,H=W.splice(K-R,2)[1-R];b.subVectors(U[0],U[1]).cross(g.subVectors(U[0],U[2])).normalize();let z=b.dot(U[0])<0;z&&b.negate();for(let j=1;j<=U.length-2;j++)[U[j+ +z],U[j+1-+z],U[0]].forEach(G=>{a.push(G.x,G.y,G.z),u.push(b.x,b.y,b.z)})}}function d(){let h=new _;for(let T=0;T<a.length;T+=3){h.x=a[T+0],h.y=a[T+1],h.z=a[T+2];let S=w(h)/2/Math.PI+.5,E=A(h)/Math.PI+.5;l.push(S,1-E)}let f=new _,g=new _,p=new _,m=new _,y=new F,v=new F,x=new F,b=(T,S,E,M)=>{M<0&&T.x===1&&(l[S]=T.x-1),E.x===0&&E.z===0&&(l[S]=M/2/Math.PI+.5)};for(let T=0,S=0;T<a.length;T+=9,S+=6){f.set(a[T+0],a[T+1],a[T+2]),g.set(a[T+3],a[T+4],a[T+5]),p.set(a[T+6],a[T+7],a[T+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]),m.copy(f).add(g).add(p).divideScalar(3);let E=w(m);b(y,S+0,f,E),b(v,S+2,g,E),b(x,S+4,p,E)}for(let T=0;T<l.length;T+=6){let S=l[T+0],E=l[T+2],M=l[T+4],I=Math.max(S,E,M),P=Math.min(S,E,M);I>.9&&P<.1&&(S<.2&&(l[T+0]+=1),E<.2&&(l[T+2]+=1),M<.2&&(l[T+4]+=1))}function w(T){return Math.atan2(T.z,-T.x)}function A(T){return Math.atan2(-T.y,Math.sqrt(T.x*T.x+T.z*T.z))}}}static fromJSON(t){return new Ko(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var dM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.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(r){let{width:t,height:e,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new wh(t*.5,s,o):new jl(t*.5,i);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...r,type:"DodecahedronGeometry"}})}},wh=class extends Ko{constructor(t=1,e=.2,n=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,n),this.type=l}static fromJSON(t){return new wh(t.radius,t.corner,t.cornerSides)}};var Ah=1e-12,cu=class{constructor(t){this.position=new F;this.startPosition=new F;this.uuid=Ve.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 cu(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},uu=class extends cu{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new uu(this.parent).copy(this)}},Ni=class extends cu{constructor(e,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new uu(this),new uu(this))}static create(e,n){let i=new Ni(e,new F(...n.position));return i.controls[0].position.set(...n.controlPrevious.position),i.controls[1].position.set(...n.controlNext.position),i.roundness=n.roundness,i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,i}getOppositeControl(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 i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(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 Ni(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 F,n=new F){let[i,s]=this.computeTangents();return i&&s&&(hM(i,e),hM(s,n)),[e,n]}computeTangent(e=new F){let[n,i]=this.computeTangents();return n&&i&&e.copy(n).add(i).normalize(),e}computeNormal(e=new F){let[n,i]=this.computeNormals();return e.copy(n).add(i).normalize(),e}};function hM(r,t=new F){let e=r.length();return t.set(-r.y/e,r.x/e)}var Hx=r=>r,du=new F,ag=new F,V4=new F,H4=new F,W4=new F,j4=new F,pM=new _,mM=new _;function gM(r){let t=new F;t.addVectors(r.v0,du.subVectors(r.v1,r.v0).multiplyScalar(2/3));let e=new F;return e.addVectors(r.v2,ag.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new nr(r.v0,t,e,r.v2)}function _h(r,t,e=Number.EPSILON){return Math.abs(r-t)<e}function q4(r,t,e=Number.EPSILON){return r.distanceTo(t)<e}function X4(r,t,e=Number.EPSILON){return r.distanceTo(t)<e}function Wx(r,t,e){let n=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2));return Math.acos((i*i+n*n-s*s)/(2*i*n))}function yM(r,t,e){return fM(r,t)&&fM(t,e)&&Vx(r.position,t.position,e.position)}function Vx(r,t,e){return du.copy(t).sub(r).cross(ag.copy(e).sub(r))===0}function vM(r,t,e,n,i){let s=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),o=(r.y+t.y)/2,a=(r.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(r.y-t.y)/s,u=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-r.x)/s;return n.set(a+l,o+u),i.set(a-l,o-u),[n,i]}function xM(r,t,e){let n=r.distanceTo(e),i=t.distanceTo(e);return n<i?t:r}function bM(r,t,e,n,i,s){let o=t.x-r.x,a=t.y-r.y,l=e.x-r.x,u=e.y-r.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),d;return Wx(t,r,e)>Math.PI&&(c*=-1),_h(u,a)?d=(a+u)*(n/c-.5)*8/3/(o-l):d=(o+l)*(n/c-.5)*8/3/(u-a),i.set(t.x-d*a,t.y+d*o),s.set(e.x+d*u,e.y-d*l),[i,s]}function jx(r,t){return r.position.equals(r.controls[1].position)&&t.position.equals(t.controls[0].position)}function fM(r,t){return Vx(r.position,r.controls[1].position,t.position)&&Vx(r.position,t.controls[0].position,t.position)}function SM(r,t,e,n,i=.5){let s=du.subVectors(t,r).multiplyScalar(i).add(r),o=ag.subVectors(e,t).multiplyScalar(i).add(t),a=V4.subVectors(n,e).multiplyScalar(i).add(e),l=s,u=H4.subVectors(o,s).multiplyScalar(i).add(s),c=W4.subVectors(a,o).multiplyScalar(i).add(o),d=a,h=j4.subVectors(c,u).multiplyScalar(i).add(u);return[r.x,r.y,l.x,l.y,u.x,u.y,h.x,h.y,c.x,c.y,d.x,d.y,n.x,n.y]}function wM(r,t,e=12,n=!0){let i=mM.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=Hx(t[l]),c=du,d=Zo(u,e);a.push(d);for(let h=0;h<=d;h++)if(u instanceof nr||u instanceof qr||u instanceof rr){if(u.getPoint(h/d,c),i.set(c.x,c.y,0),s!==void 0&&X4(s,i))continue;s===void 0&&(s=pM),s.copy(i),r.setXYZ(o,i.x,i.y,i.z),o++}}return n&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),r}function AM(r,t,e,n=12,i=!0){let s=mM.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=Hx(t[l]),d=du,h=Zo(c,n);a.push(h);for(let f=0;f<=h;f++)if(c instanceof nr||c instanceof qr||c instanceof rr){if(c.getPoint(f/h,d),s.set(d.x,d.y,0),u?.equals(s))continue;u===void 0?u=pM:(r.setXYZ(o,u.x,u.y,u.z),o++,r.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return i&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),a}function qx(r,t=12,e=!1){let n=[];for(let i=0,s=r.length;i<s;i++){let o=r[i],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=Zo(o.roundedCurveCorner,t)*.5;i>0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Zo(o.curveAfter,t)),n.push(a)}return r.length>0&&e&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=Zo(r[0].roundedCurveCorner,t)*.5),n}function Zo(r,t=12){return r&&r instanceof Ia?t*2:r&&(r instanceof rr||r instanceof Ld)?1:r&&r instanceof zl?t*r.points.length:t}function _M(r,t,e=12,n=!0){let i,s=0;for(let o=0;o<t.length;o++){let a=Hx(t[o]),l=Zo(a,e),u=du;for(let c=0;c<=l;c++)if(a instanceof nr||a instanceof qr||a instanceof rr){if(a.getPoint(c/l,u),i!==void 0&&q4(i,u,Ah))continue;i===void 0&&(i=ag),i.copy(u),r.push(u.x,u.y),s++}}return _h(r[0],r[r.length-2],Ah)&&_h(r[1],r[r.length-1],Ah)&&(r.pop(),r.pop()),n&&s>1&&!(_h(r[s-1],r[1],Ah)&&_h(r[s-2],r[0],Ah))&&(r.push(r[0],r[1]),s++),r}var Xx=new F,Y4=new F,K4=new F,Z4=new F,Q4=new F,J4=new F,St=class extends Hs{constructor(e=100,n=100){super();this.points=[];this.shapeHoles=[];this.plane=new Tn(new _(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=Ve.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=n}static createFromState(e,n,i){let s=new St;return s.isClosed=e.isClosed,s.points=e.points.map(o=>Ni.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>St.createFromState(o)),n!==void 0&&i!==void 0&&s.applySize(n,i),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let n=0,i=this.points.length;n<i;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,i=this.points.findIndex(s=>s.uuid===e);if(i<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(e);if(c<0)s+=u;else return c+s}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let n=this.points.length;for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],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 i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],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 i=Xx.set(e,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,n);this._update()}createPoint(e,n=0,i=Ve.generateUUID()){let s;e instanceof F?s=e:s=new F(e,n);let o=new Ni(i,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,i=this.points.length;n<i;n++){let s=this.points[n];if(s.uuid===e)return s}for(let n=0,i=this.shapeHoles.length;n<i;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(i=>i.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,i=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=i?this.roundedCurveDivisions:this.curveDivisions;return wM(e,i?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=qx(this.points,e,!1),this.roundedCurveDivisions=qx(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,n,i=12){return AM(e,this.curves,n,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),_M(e,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(e,n=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=Zo(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<i+c)return[l,(a-i+1)/c];i+=c}return[0,1]}getCurveT(e,n,i){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(jx(s,o)){let d=s.position.distanceTo(o.position);return s.position.distanceTo(Xx.set(i.x,i.y))/d}let u=0;for(let d=0;d<e;d++)u+=a[d];return(n-u)/l}dispose(){}_applyCurveForPoint(e,n){jx(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 i=this.curves[this.curves.length-1];e.curveBefore=i,n.curveAfter=i;let s=i.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,i=this.points.length;n<i;n++){let s=this.points[n];if(n===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[n-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let n=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(n,i)}if(this.points.length>2){let n=0;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i],a=this.points[i-1]??this.points[this.points.length-1],l=this.points[i+1]??this.points[0],u=o.roundness,c=a&&l&&yM(a,o,l);if(!o.controlsMoved()&&u>0&&!c){let d=o.curveBefore,h=o.curveAfter;if(d===void 0||h===void 0)continue;let f=o.roundedCurveBefore,g=o.roundedCurveAfter,p=d.getLength(),m=h.getLength(),y=Math.min(u,p*.499),v=Math.min(u,m*.499),x=Math.min(y,v),b=1-x/p,w=x/m,A=d.getPointAt(b,Xx),T=h.getPointAt(w,Y4);this._subSplitCurve(d,f,b,A,void 0),this._subSplitCurve(h,g,w,void 0,T);let S;if(this.useCubicForRoundedCorners){let E=Wx(A,o.position,T)/2,M=Math.tan(E)*A.distanceTo(o.position),[I,P]=vM(A,T,M,K4,Z4),C=xM(I,P,o.position),[D,B]=bM(C,A,T,M,Q4,J4);S=new nr(A.clone(),D.clone(),B.clone(),T.clone())}else S=new qr(A.clone(),o.position.clone(),T.clone());o.roundedCurveCorner=S,this.roundedCurves.splice(i+n,0,S),n++}}}}_subSplitCurve(e,n,i,s,o){if(e instanceof rr)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=e,l=n,u=a.getUtoTmapping(i,0),c=SM(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 St(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 i=0;i<n;i++){let s=i*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],d=e.points[s+5],h=e.points[s+6],f=new Ni(Ve.generateUUID(),new F(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=h,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let s=new St;return s.fromJSON(i),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let n=(s,o)=>{o instanceof nr&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},i=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof qr&&(s[a]=gM(s[a]));for(a=0,l=s.length;a<l;a++){let d=s[a],h=a>0?s[a-1]:null,f;d instanceof nr?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof rr&&(f=this.createPoint(d.v1)),f!==void 0&&(h!==null&&n(f,h),o.push(f))}let u=s[s.length-1],c=!1;return u instanceof nr?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof rr&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=i(e.curves),e instanceof Hs&&(this.shapeHoles=e.holes.map(s=>{let o=new St;return o.fromShape(s),o})),this.update(),this}updatePoint(e,n){let i=this.getPointByUuid(e);i&&(n.position!==void 0&&i.position.fromArray(n.position),n.roundness!==void 0&&(i.roundness=n.roundness),n.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(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 Kx=Math.PI*2;function Yx({x:r,y:t},e,n,i,s){return{x:r*e+i,y:t*n+s}}function $4(r,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),n=Math.cos(r),i=Math.sin(r),s=Math.cos(r+t),o=Math.sin(r+t);return[{x:n-i*e,y:i+n*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function TM(r,t,e,n){let i=r*n-t*e<0?-1:1,s=Math.min(1,Math.max(-1,r*e+t*n));return i*Math.acos(s)}function eH(r,t,e,n,i,s,o,a,l,u){let c=Math.pow(i,2),d=Math.pow(s,2),h=Math.pow(o,2),f=Math.pow(a,2),g=c*d-c*f-d*h;g<0&&(g=0),g/=c*f+d*h,g=Math.sqrt(g)*(l===u?-1:1);let p=g*i/s*a,m=g*-s/i*o,y=p+(r+e)/2,v=m+(t+n)/2,x=(o-p)/i,b=(a-m)/s,w=(-o-p)/i,A=(-a-m)/s,T=TM(1,0,x,b),S=TM(x,b,w,A);return!u&&S>0&&(S-=Kx),u&&S<0&&(S+=Kx),{centerx:y,centery:v,ang1:T,ang2:S}}function EM({px:r,py:t,cx:e,cy:n,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let u=(r-e)/2,c=(t-n)/2;if(u===0&&c===0)return[];i=Math.abs(i),s=Math.abs(s);let d=Math.pow(u,2)/Math.pow(i,2)+Math.pow(c,2)/Math.pow(s,2);d>1&&(i*=Math.sqrt(d),s*=Math.sqrt(d));let h=eH(r,t,e,n,i,s,u,c,o,a),{ang1:f,ang2:g}=h,{centerx:p,centery:m}=h,y=Math.abs(g)/(Kx/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);g/=v;for(let x=0;x<v;x++)l.push($4(f,g)),f+=g;return l.map(x=>{let{x:b,y:w}=Yx(x[0],i,s,p,m),{x:A,y:T}=Yx(x[1],i,s,p,m),{x:S,y:E}=Yx(x[2],i,s,p,m);return{x1:b,y1:w,x2:A,y2:T,x:S,y:E}})}var ft;(function(r){r[r.ODD=0]="ODD",r[r.NONZERO=1]="NONZERO",r[r.POSITIVE=2]="POSITIVE",r[r.NEGATIVE=3]="NEGATIVE",r[r.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(ft||(ft={}));var Jt;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Jt||(Jt={}));function Ye(r,t){if(!r)throw t||"Assertion Failed!"}var ke=function(){function r(){}return r.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},r.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},r.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},r.edgeGoesLeft=function(t){return r.vertLeq(t.Dst,t.Org)},r.edgeGoesRight=function(t){return r.vertLeq(t.Org,t.Dst)},r.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},r.edgeEval=function(t,e,n){Ye(r.vertLeq(t,e)&&r.vertLeq(e,n));var i=e.s-t.s,s=n.s-e.s;return i+s>0?i<s?e.t-t.t+(t.t-n.t)*(i/(i+s)):e.t-n.t+(n.t-t.t)*(s/(i+s)):0},r.edgeSign=function(t,e,n){Ye(r.vertLeq(t,e)&&r.vertLeq(e,n));var i=e.s-t.s,s=n.s-e.s;return i+s>0?(e.t-n.t)*i+(e.t-t.t)*s:0},r.transEval=function(t,e,n){Ye(r.transLeq(t,e)&&r.transLeq(e,n));var i=e.t-t.t,s=n.t-e.t;return i+s>0?i<s?e.s-t.s+(t.s-n.s)*(i/(i+s)):e.s-n.s+(n.s-t.s)*(s/(i+s)):0},r.transSign=function(t,e,n){Ye(r.transLeq(t,e)&&r.transLeq(e,n));var i=e.t-t.t,s=n.t-e.t;return i+s>0?(e.s-n.s)*i+(e.s-t.s)*s:0},r.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},r.interpolate=function(t,e,n,i){return t=t<0?0:t,n=n<0?0:n,t<=n?n===0?(e+i)/2:e+(i-e)*(t/(t+n)):i+(e-i)*(n/(t+n))},r.intersect=function(t,e,n,i,s){var o,a,l;r.vertLeq(t,e)||(l=t,t=e,e=l),r.vertLeq(n,i)||(l=n,n=i,i=l),r.vertLeq(t,n)||(l=t,t=n,n=l,l=e,e=i,i=l),r.vertLeq(n,e)?r.vertLeq(e,i)?(o=r.edgeEval(t,n,e),a=r.edgeEval(n,e,i),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,e.s)):(o=r.edgeSign(t,n,e),a=-r.edgeSign(t,i,e),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,i.s)):s.s=(n.s+e.s)/2,r.transLeq(t,e)||(l=t,t=e,e=l),r.transLeq(n,i)||(l=n,n=i,i=l),r.transLeq(t,n)||(l=t,t=n,n=l,l=e,e=i,i=l),r.transLeq(n,e)?r.transLeq(e,i)?(o=r.transEval(t,n,e),a=r.transEval(n,e,i),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,e.t)):(o=r.transSign(t,n,e),a=-r.transSign(t,i,e),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,i.t)):s.t=(n.t+e.t)/2},r}(),Th=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return r}(),lg=function(){function r(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(r.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),r}(),hu=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return r}(),MM=function(){function r(){var t=new hu,e=new Th,n=new lg(0),i=new lg(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,n.next=n,n.Sym=i,i.next=i,i.Sym=n,this.vHead=t,this.fHead=e,this.eHead=n,this.eHeadSym=i}return r.prototype.makeEdge_=function(t){var e=new lg(0),n=new lg(1);t.Sym.side<t.side&&(t=t.Sym);var i=t.Sym.next;return n.next=i,i.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},r.prototype.splice_=function(t,e){var n=t.Onext,i=e.Onext;n.Sym.Lnext=e,i.Sym.Lnext=t,t.Onext=i,e.Onext=n},r.prototype.makeVertex_=function(t,e,n){var i=t;Ye(i,"Vertex can't be null!");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=e;var o=e;do o.Org=i,o=o.Onext;while(o!==e)},r.prototype.makeFace_=function(t,e,n){var i=t;Ye(i,"Face can't be null");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=e,i.trail=null,i.marked=!1,i.inside=n.inside;var o=e;do o.Lface=i,o=o.Lnext;while(o!==e)},r.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},r.prototype.killVertex_=function(t,e){var n=t.anEdge,i=n;do i.Org=e,i=i.Onext;while(i!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},r.prototype.killFace_=function(t,e){var n=t.anEdge,i=n;do i.Lface=e,i=i.Lnext;while(i!==n);var s=t.prev,o=t.next;o.prev=s,s.next=o},r.prototype.makeEdge=function(){var t=new hu,e=new hu,n=new Th,i=this.makeEdge_(this.eHead);return this.makeVertex_(t,i,this.vHead),this.makeVertex_(e,i.Sym,this.vHead),this.makeFace_(n,i,this.fHead),i},r.prototype.splice=function(t,e){var n=!1,i=!1;if(t!==e){if(e.Org!==t.Org&&(i=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!i){var s=new hu;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!n){var o=new Th;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},r.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 i=new Th;this.makeFace_(i,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)},r.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),n=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var i=new hu;return this.makeVertex_(i,n,e.Org),e.Lface=n.Lface=t.Lface,e},r.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},r.prototype.connect=function(t,e){var n=!1,i=this.makeEdge_(t),s=i.Sym;if(e.Lface!==t.Lface&&(n=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(i,t.Lnext),this.splice_(s,e),i.Org=t.Dst,s.Org=e.Org,i.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!n){var o=new Th;this.makeFace_(o,i,t.Lface)}return i},r.prototype.zapFace=function(t){var e=t.anEdge,n,i,s,o,a;i=e.Lnext;do n=i,i=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},r.prototype.countFaceVerts_=function(t){var e=t.anEdge,n=0;do n++,e=e.Lnext;while(e!==t.anEdge);return n},r.prototype.mergeConvexFaces=function(t){var e,n,i,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;i=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&ke.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&ke.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=i;return!0},r.prototype.check=function(){var t=this.fHead,e=this.vHead,n=this.eHead,i,s,o,a,l,u;for(s=t,s=t;(i=s.next)!==t;s=i){Ye(i.prev===s),l=i.anEdge;do Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l),Ye(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(Ye(i.prev===s&&i.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){Ye(o.prev===a),l=o.anEdge;do Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l),Ye(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(Ye(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)Ye(l.Sym.next===u.Sym),Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Org!==null),Ye(l.Dst!==null),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l);Ye(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},r}(),CM=function(){function r(){this.handle=null}return r}(),PM=function(){function r(){this.key=null,this.node=0}return r}(),tH=function(){function r(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 CM,this.handles[n]=new PM;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return r.prototype.floatDown_=function(t){var e=this.nodes,n=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(n[e[o+1].handle].key,n[e[o].handle].key)&&++o,Ye(o<=this.max),s=e[o].handle,o>this.size||this.leq(n[i].key,n[s].key)){e[t].handle=i,n[i].node=t;break}e[t].handle=s,n[s].node=t,t=o}},r.prototype.floatUp_=function(t){var e=this.nodes,n=this.handles,i,s,o;for(i=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(n[s].key,n[i].key)){e[t].handle=i,n[i].node=t;break}e[t].handle=s,n[s].node=t,t=o}},r.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},r.prototype.min=function(){return this.handles[this.nodes[1].handle].key},r.prototype.insert=function(t){var e,n;if(e=++this.size,e*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new CM;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new PM}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},r.prototype.extractMin=function(){var t=this.nodes,e=this.handles,n=t[1].handle,i=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)),i},r.prototype.delete=function(t){var e=this.nodes,n=this.handles,i;Ye(t>=1&&t<=this.max&&n[t].key!==null),i=n[t].node,e[i].handle=e[this.size].handle,n[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(n[e[i>>1].handle].key,n[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),n[t].key=null,n[t].node=this.freeList,this.freeList=t},r}(),Zx=function(){function r(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return r}(),IM=function(){function r(){this.key=null,this.next=null,this.prev=null}return r}(),nH=function(){function r(t,e){this.frame=t,this.leq=e,this.head=new IM,this.head.next=this.head,this.head.prev=this.head}return r.prototype.min=function(){return this.head.next},r.prototype.max=function(){return this.head.prev},r.prototype.insert=function(t){return this.insertBefore(this.head,t)},r.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},r.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var n=new IM;return n.key=e,n.next=t.next,t.next.prev=n,n.prev=t,t.next=n,n},r.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},r}(),rH=function(){function r(){}return r.regionBelow=function(t){return t.nodeUp.prev.key},r.regionAbove=function(t){return t.nodeUp.next.key},r.debugEvent=function(t){},r.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},r.edgeLeq=function(t,e,n){var i=t.event,s=e.eUp,o=n.eUp;if(s.Dst===i)return o.Dst===i?ke.vertLeq(s.Org,o.Org)?ke.edgeSign(o.Dst,s.Org,o.Org)<=0:ke.edgeSign(s.Dst,o.Org,s.Org)>=0:ke.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return ke.edgeSign(s.Dst,i,s.Org)>=0;var a=ke.edgeEval(s.Dst,i,s.Org),l=ke.edgeEval(o.Dst,i,o.Org);return a>=l},r.deleteRegion=function(t,e){e.fixUpperEdge&&Ye(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},r.fixUpperEdge=function(t,e,n){Ye(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=n,n.activeRegion=e},r.topLeftRegion=function(t,e){var n=e.eUp.Org,i;do e=r.regionAbove(e);while(e.eUp.Org===n);if(e.fixUpperEdge){if(i=t.mesh.connect(r.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;r.fixUpperEdge(t,e,i),e=r.regionAbove(e)}return e},r.topRightRegion=function(t){var e=t.eUp.Dst;do t=r.regionAbove(t);while(t.eUp.Dst===e);return t},r.addRegionBelow=function(t,e,n){var i=new Zx;return i.eUp=n,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,n.activeRegion=i,i},r.isWindingInside=function(t,e){switch(t.windingRule){case ft.ODD:return(e&1)!==0;case ft.NONZERO:return e!==0;case ft.POSITIVE:return e>0;case ft.NEGATIVE:return e<0;case ft.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},r.computeWinding=function(t,e){e.windingNumber=r.regionAbove(e).windingNumber+e.eUp.winding,e.inside=r.isWindingInside(t,e.windingNumber)},r.finishRegion=function(t,e){var n=e.eUp,i=n.Lface;i.inside=e.inside,i.anEdge=n,r.deleteRegion(t,e)},r.finishLeftRegions=function(t,e,n){for(var i,s=null,o=e,a=e.eUp;o!==n;){if(o.fixUpperEdge=!1,s=r.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){r.finishRegion(t,o);break}i=t.mesh.connect(a.Lprev,i.Sym),r.fixUpperEdge(t,s,i)}a.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(a,i)),r.finishRegion(t,o),a=s.eUp,o=s}return a},r.addRightEdges=function(t,e,n,i,s,o){var a,l,u,c,d=!0;u=n;do Ye(ke.vertLeq(u.Org,u.Dst)),r.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==i);for(s===null&&(s=r.regionBelow(e).eUp.Rprev),l=e,c=s;a=r.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=r.isWindingInside(t,a.windingNumber),l.dirty=!0,!d&&r.checkForRightSplice(t,l)&&(r.addWinding(u,c),r.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=a,c=u;l.dirty=!0,Ye(l.windingNumber-u.winding===a.windingNumber),o&&r.walkDirtyRegions(t,l)},r.spliceMergeVertices=function(t,e,n){t.mesh.splice(e,n)},r.vertexWeights=function(t,e,n){var i=ke.vertL1dist(e,t),s=ke.vertL1dist(n,t),o=.5*s/(i+s),a=.5*i/(i+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]},r.getIntersectData=function(t,e,n,i,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,r.vertexWeights(e,n,i),r.vertexWeights(e,s,o)},r.checkForRightSplice=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp;if(ke.vertLeq(i.Org,s.Org)){if(ke.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;ke.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(t.pq.delete(i.Org.pqHandle),r.spliceMergeVertices(t,s.Oprev,i)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(i,s.Oprev),e.dirty=n.dirty=!0)}else{if(ke.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;r.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Oprev,i)}return!0},r.checkForLeftSplice=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp,o;if(Ye(!ke.vertEq(i.Dst,s.Dst)),ke.vertLeq(i.Dst,s.Dst)){if(ke.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;r.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(i),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(ke.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;e.dirty=n.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},r.checkForIntersect=function(t,e){var n=r.regionBelow(e),i=e.eUp,s=n.eUp,o=i.Org,a=s.Org,l=i.Dst,u=s.Dst,c,d,h=new hu,f,g;if(Ye(!ke.vertEq(u,l)),Ye(ke.edgeSign(l,t.event,o)<=0),Ye(ke.edgeSign(u,t.event,a)>=0),Ye(o!==t.event&&a!==t.event),Ye(!e.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),d=Math.max(a.t,u.t),c>d))return!1;if(ke.vertLeq(o,a)){if(ke.edgeSign(u,o,a)>0)return!1}else if(ke.edgeSign(l,a,o)<0)return!1;return r.debugEvent(t),ke.intersect(l,o,u,a,h),Ye(Math.min(o.t,l.t)<=h.t),Ye(h.t<=Math.max(a.t,u.t)),Ye(Math.min(u.s,l.s)<=h.s),Ye(h.s<=Math.max(a.s,o.s)),ke.vertLeq(h,t.event)&&(h.s=t.event.s,h.t=t.event.t),f=ke.vertLeq(o,a)?o:a,ke.vertLeq(f,h)&&(h.s=f.s,h.t=f.t),ke.vertEq(h,o)||ke.vertEq(h,a)?(r.checkForRightSplice(t,e),!1):!ke.vertEq(l,t.event)&&ke.edgeSign(l,t.event,h)>=0||!ke.vertEq(u,t.event)&&ke.edgeSign(u,t.event,h)<=0?u===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(s.Sym,i),e=r.topLeftRegion(t,e),i=r.regionBelow(e).eUp,r.finishLeftRegions(t,r.regionBelow(e),n),r.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(i.Lnext,s.Oprev),n=e,e=r.topRightRegion(e),g=r.regionBelow(e).eUp.Rprev,n.eUp=s.Oprev,s=r.finishLeftRegions(t,n,null),r.addRightEdges(t,e,s.Onext,i.Rprev,g,!0),!0):(ke.edgeSign(l,t.event,h)>=0&&(r.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),ke.edgeSign(u,t.event,h)<=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(i.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,i),i.Org.s=h.s,i.Org.t=h.t,i.Org.pqHandle=t.pq.insert(i.Org),r.getIntersectData(t,i.Org,o,l,a,u),r.regionAbove(e).dirty=e.dirty=n.dirty=!0,!1)},r.walkDirtyRegions=function(t,e){for(var n=r.regionBelow(e),i,s;;){for(;n.dirty;)e=n,n=r.regionBelow(n);if(!e.dirty&&(n=e,e=r.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,s=n.eUp,i.Dst!==s.Dst&&r.checkForLeftSplice(t,e)&&(n.fixUpperEdge?(r.deleteRegion(t,n),t.mesh.delete(s),n=r.regionBelow(e),s=n.eUp):e.fixUpperEdge&&(r.deleteRegion(t,e),t.mesh.delete(i),e=r.regionAbove(n),i=e.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!e.fixUpperEdge&&!n.fixUpperEdge&&(i.Dst===t.event||s.Dst===t.event)){if(r.checkForIntersect(t,e))return}else r.checkForRightSplice(t,e);i.Org===s.Org&&i.Dst===s.Dst&&(r.addWinding(s,i),r.deleteRegion(t,e),t.mesh.delete(i),e=r.regionAbove(n))}},r.connectRightVertex=function(t,e,n){var i,s=n.Onext,o=r.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&r.checkForIntersect(t,e),ke.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=r.topLeftRegion(t,e),s=r.regionBelow(e).eUp,r.finishLeftRegions(t,r.regionBelow(e),o),u=!0),ke.vertEq(l.Org,t.event)&&(t.mesh.splice(n,l.Oprev),n=r.finishLeftRegions(t,o,null),u=!0),u){r.addRightEdges(t,e,n.Onext,s,s,!0);return}ke.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=t.mesh.connect(n.Lprev,i),r.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,r.walkDirtyRegions(t,e)},r.connectLeftDegenerate=function(t,e,n){var i,s,o,a,l;if(i=e.eUp,ke.vertEq(i.Org,n)){Ye(!1),r.spliceMergeVertices(t,i,n.anEdge);return}if(!ke.vertEq(i.Dst,n)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(n.anEdge,i),r.sweepEvent(t,n);return}Ye(!1),e=r.topRightRegion(e),l=r.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(Ye(s!==o),r.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(n.anEdge,o),ke.edgeGoesLeft(s)||(s=null),r.addRightEdges(t,e,o.Onext,a,s,!0)},r.connectLeftVertex=function(t,e){var n,i,s,o,a,l,u=new Zx;if(u.eUp=e.anEdge.Sym,n=t.dict.search(u).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,ke.edgeSign(o.Dst,e,o.Org)===0){r.connectLeftDegenerate(t,n,e);return}if(s=ke.vertLeq(a.Dst,o.Dst)?n:i,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?r.fixUpperEdge(t,s,l):r.computeWinding(t,r.addRegionBelow(t,n,l)),r.sweepEvent(t,e)}else r.addRightEdges(t,n,e.anEdge,e.anEdge,null,!0)}},r.sweepEvent=function(t,e){t.event=e,r.debugEvent(t);for(var n=e.anEdge;n.activeRegion===null;)if(n=n.Onext,n===e.anEdge){r.connectLeftVertex(t,e);return}var i=r.topLeftRegion(t,n.activeRegion);Ye(i!==null);var s=r.regionBelow(i),o=s.eUp,a=r.finishLeftRegions(t,s,null);a.Onext===o?r.connectRightVertex(t,i,a):r.addRightEdges(t,i,a.Onext,o,o,!0)},r.addSentinel=function(t,e,n,i){var s=new Zx,o=t.mesh.makeEdge();o.Org.s=n,o.Org.t=i,o.Dst.s=e,o.Dst.t=i,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)},r.initEdgeDict=function(t){t.dict=new nH(t,r.edgeLeq);var e=t.bmax[0]-t.bmin[0],n=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-n,a=t.bmax[1]+n;r.addSentinel(t,i,s,o),r.addSentinel(t,i,s,a)},r.doneEdgeDict=function(t){for(var e,n=0;(e=t.dict.min().key)!==null;)e.sentinel||(Ye(e.fixUpperEdge),Ye(++n===1)),Ye(e.windingNumber===0),r.deleteRegion(t,e)},r.removeDegenerateEdges=function(t){var e,n,i,s=t.mesh.eHead;for(e=s.next;e!==s;e=n)n=e.next,i=e.Lnext,ke.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(r.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===n||i===n.Sym)&&(n=n.next),t.mesh.delete(i)),(e===n||e===n.Sym)&&(n=n.next),t.mesh.delete(e))},r.initPriorityQ=function(t){var e,n,i,s=0;for(i=t.mesh.vHead,n=i.next;n!==i;n=n.next)s++;for(s+=8,e=t.pq=new tH(s,ke.vertLeq),i=t.mesh.vHead,n=i.next;n!==i;n=n.next)n.pqHandle=e.insert(n);return n!==i?!1:(e.init(),!0)},r.donePriorityQ=function(t){t.pq=null},r.removeDegenerateFaces=function(t,e){var n,i,s;for(n=e.fHead.next;n!==e.fHead;n=i)i=n.next,s=n.anEdge,Ye(s.Lnext!==s),s.Lnext.Lnext===s&&(r.addWinding(s.Onext,s),t.mesh.delete(s));return!0},r.computeInterior=function(t,e){e===void 0&&(e=!0);var n,i;if(r.removeDegenerateEdges(t),!r.initPriorityQ(t))return!1;for(r.initEdgeDict(t);(n=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!ke.vertEq(i,n));)i=t.pq.extractMin(),r.spliceMergeVertices(t,n.anEdge,i.anEdge);r.sweepEvent(t,n)}return t.event=t.dict.min().key.eUp.Org,r.debugEvent(t),r.doneEdgeDict(t),r.donePriorityQ(t),r.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},r}(),iH=function(){function r(){this.mesh=new MM,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=ft.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return r.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},r.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},r.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},r.prototype.computeNormal_=function(t){var e,n,i,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],h=[0,0,0],f=[null,null,null],g=[null,null,null],p=this.mesh.vHead;e=p.next;for(var m=0;m<3;++m)s=e.coords[m],u[m]=s,g[m]=e,l[m]=s,f[m]=e;for(e=p.next;e!==p;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<u[y]&&(u[y]=s,g[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=g[v],i=f[v],c[0]=n.coords[0]-i.coords[0],c[1]=n.coords[1]-i.coords[1],c[2]=n.coords[2]-i.coords[2],e=p.next;e!==p;e=e.next)d[0]=e.coords[0]-i.coords[0],d[1]=e.coords[1]-i.coords[1],d[2]=e.coords[2]-i.coords[2],h[0]=c[1]*d[2]-c[2]*d[1],h[1]=c[2]*d[0]-c[0]*d[2],h[2]=c[0]*d[1]-c[1]*d[0],o=h[0]*h[0]+h[1]*h[1]+h[2]*h[2],o>a&&(a=o,t[0]=h[0],t[1]=h[1],t[2]=h[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},r.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,n=this.mesh.vHead,i,s=0,o=t.next;o!==t;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(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]}},r.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],n,i,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,i=this.tUnit;var o=this.longAxis_(e);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=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,i);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))},r.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},r.prototype.tessellateMonoRegion_=function(t,e){var n,i;if(n=e.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;ke.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;ke.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(ke.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(ke.edgeGoesLeft(i.Lnext)||ke.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=t.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==n&&(ke.edgeGoesRight(n.Lprev)||ke.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=t.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(i.Lnext===n)throw"Mono region invalid";for(;i.Lnext.Lnext!==n;)s=t.connect(i.Lnext,i),i=s.Sym;return!0},r.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},r.prototype.discardExterior_=function(t){for(var e,n=t.fHead.next;n!==t.fHead;n=e)e=n.next,n.inside||t.zapFace(n)},r.prototype.setWindingNumber_=function(t,e,n){for(var i,s=t.eHead.next;s!==t.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:n?t.delete(s):s.winding=0},r.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},r.prototype.outputPolymesh_=function(t,e,n,i){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===Jt.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*i;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],i>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var h=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[h++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[h++]=-1;if(e===Jt.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[h++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var g=l;g<n;++g)this.elements[h++]=-1}}},r.prototype.outputContours_=function(t,e){var n,i,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){i=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*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,i=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!==i);this.elements[c++]=s,this.elements[c++]=o,s+=o}},r.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new MM),t<2&&(t=2),t>3&&(t=3);for(var n=null,i=0;i<e.length;i+=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[i+0],n.Org.coords[1]=e[i+1],t>2?n.Org.coords[2]=e[i+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},r.prototype.tesselate=function(t,e,n,i,s,o){if(t===void 0&&(t=ft.ODD),e===void 0&&(e=Jt.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,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),rH.computeInterior(this,o);var a=this.mesh;return e===Jt.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===Jt.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,n,i),!0},r}();function Bi(r){var t=r.windingRule,e=t===void 0?ft.ODD:t,n=r.elementType,i=n===void 0?Jt.POLYGONS:n,s=r.polySize,o=s===void 0?3:s,a=r.vertexSize,l=a===void 0?2:a,u=r.normal,c=u===void 0?[0,0,1]:u,d=r.contours,h=d===void 0?[]:d,f=r.strict,g=f===void 0?!0:f,p=r.debug,m=p===void 0?!1:p;if(!h&&g)throw new Error("Contours can't be empty");if(!!h){var y=new iH;r.edgeCreateCallback&&(y.edgeCreateCallback=r.edgeCreateCallback),r.vertexIdCallback&&(y.vertexIdCallback=r.vertexIdCallback);for(var v=0;v<h.length;v++)y.addContour(l||2,h[v]);return y.tesselate(e,i,o,l,c,g),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:m?y.mesh:void 0}}}var Fie=ft.ODD,Uie=ft.NONZERO,Gie=ft.POSITIVE,kie=ft.NEGATIVE,zie=ft.ABS_GEQ_TWO,Vie=Jt.POLYGONS,Hie=Jt.CONNECTED_POLYGONS,Wie=Jt.BOUNDARY_CONTOURS;var cg=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*cg.eSize;this.buffer=new ArrayBuffer(n);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*i,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*i,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*cg.eSize,i=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*t);o+=3*t;let l=new Float32Array(i,o*s,3*t);o+=3*t;let u=new Float32Array(i,o*s,2*t);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}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)}},Eh=cg;Eh.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Mh={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Jx={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},$x={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},Qx=(r,t)=>([e,n])=>(n<e&&(n+=t),(r>=e?r:r+t)<=n),fu=class extends Te{constructor(e,n,i=0,s=12,o=3,a=ft.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=n,this._bevel=i,this._curveSegments=s,this._bevelSegmentsInput=o,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,n/2-1e-12),this._bevelSegments=Math.floor(o));let l=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(T=>{let S=T.extractShapePointsToFlatArray([],s),E=[];for(let M=S.length-1;M>=1;M-=2){let I=S[M-1],P=S[M-0];E.push(I,P)}return E}),c;try{c=Bi({windingRule:a,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]})}catch{c=Mh}let d;try{d=Bi({windingRule:ft.ODD,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{d=Jx}if(!c)throw new Error("error generating geometry");let h=c.elementCount;if(d){c.elementCount+=d.elementCount;for(let T=0;T<d.elements.length;T++){let S=d.elements[T],E=T%2===0?c.vertexCount:0;c.elements.push(S+E)}for(let T=0;T<d.vertexIndices.length;T++){let S=d.vertexIndices[T],E=c.vertexCount;c.vertexIndices.push(S+E)}for(let T=0;T<d.vertices.length;T++){let S=d.vertices[T];c.vertices.push(S)}}let f=1/0,g=-1/0,p=1/0,m=-1/0;for(let T=0,S=c.vertexCount;T<S;T++){let E=T*2,M=c.vertices[E+0],I=c.vertices[E+1];M<f&&(f=M),M>g&&(g=M),I<p&&(p=I),I>m&&(m=I)}this._minX=f,this._minY=p,this._width=g-f,this._height=m-p,this._buffer=new Eh(this._computeBufferEstimatedSize(c));let y=[],v=[];for(let T=c.elementCount-1;T>=0;T--){let S=T>=h,E=T*2,M=c.elements[E+0],I=c.elements[E+1],P=M+I,C={start:M,count:I,normals:[],continuous:[],concave:[]},D=M,B=P-1,k=M+1,X=this._shape.roundedCurves.length;do{let K=D-M,R=c.vertices[B*2+0],U=c.vertices[B*2+1],z=c.vertices[D*2+0],j=c.vertices[D*2+1],G=c.vertices[k*2+0],re=c.vertices[k*2+1],Z=z-R,J=j-U,V=Math.sqrt(Z*Z+J*J);Z/=V,J/=V;let pe=z-G,ie=j-re,ae=Math.sqrt(pe*pe+ie*ie);pe/=ae,ie/=ae,C.normals[K*2+0]=-ie,C.normals[K*2+1]=pe,C.concave[K]=Z*ie-J*pe>0;let fe=c.vertexIndices[D];if(Array.isArray(fe))C.continuous[K]=!1;else{let[xe,me]=this._shape.getCurveIndexFromVertexId(fe-1,!0);if(me>0&&me<1)C.continuous[K]=!0;else{let Me=me===1?xe+1:xe-1;Me=(Me+X)%X;let Pe=me===1?0:1,be=this._shape.roundedCurves[xe].getTangent(me),Fe=this._shape.roundedCurves[Me].getTangent(Pe);C.continuous[K]=be.dot(Fe)>.95}}S&&(C.normals[K*2+0]*=-1,C.normals[K*2+1]*=-1),[B,D,k]=[D,k,k+1],k>=P&&(k-=I)}while(k!==M+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(M*2,P*2),vertexCount:I,vertexIndices:new Array(I).fill(!0).map((K,R)=>[R,R]),elements:[0,I],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(M*2,P*2)});for(let K=1;K<=this._bevelSegments;K++){let R=K/this._bevelSegments*Math.PI/2,U=(1-Math.cos(R))*this._bevelSize,z=[],j=[],G=[],re=[],Z=0;for(let V=0;V<I;V++){let pe=V*2,ie=(V-1+I)%I*2,ae=c.vertices[C.start*2+pe+0],fe=c.vertices[C.start*2+pe+1],xe=-C.normals[ie+0]*U,me=-C.normals[ie+1]*U,Me=-C.normals[pe+0]*U,Pe=-C.normals[pe+1]*U;if(C.concave[V]||!C.concave[V]&&S){let be=Math.atan2(me,xe),Fe=Math.atan2(Pe,Me);Fe>be&&(Fe-=Math.PI*2);let ht=Fe-be;if(C.continuous[V]||S){let L=be+ht/2,O=Math.cos(L)*U,ee=Math.sin(L)*U;z[2*Z+0]=ae+O*(S?-1:1),z[2*Z+1]=fe+ee*(S?-1:1),re[Z]=V,Z++}else{let L=Math.max(1,Math.floor(s/4*Math.abs(ht)/Math.PI));for(let O=0;O<=L;O++){let ee=be+ht*(O/L),he=Math.cos(ee)*U,ge=Math.sin(ee)*U;z[2*Z+0]=ae+he,z[2*Z+1]=fe+ge,re[Z]=V,Z++}}}else z[2*Z+0]=ae+xe,z[2*Z+1]=fe+me,re[Z]=V,j[V]=Z,Z++,z[2*Z+0]=ae,z[2*Z+1]=fe,re[Z]=V,Z++,z[2*Z+0]=ae+Me,z[2*Z+1]=fe+Pe,re[Z]=V,G[V]=Z,Z++}let J=Bi({windingRule:ft.POSITIVE,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[z],edgeCreateCallback:V=>{let ie=V.Org.idx,ae=re[ie],fe=re[(ie+1)%re.length];V.idx=[ae,fe],V.Sym.idx=[fe,ae]},vertexIdCallback:V=>{let pe=V.Lprev.idx;return[pe?pe[1]:0,V.idx?V.idx[0]:0]}});if(!J)throw console.log("Error"),new Error(`error generating bevel geometry for ${K}'th loop`);if(!J.vertexCount)break;for(let V=0;V<J.vertexIndices.length;V++){let[pe,ie]=J.vertexIndices[V];if(pe===ie)continue;let ae=ie;ie<pe&&(ae+=I);for(let fe=pe;fe<ae;fe++){let xe=fe%I,me=(fe+1)%I;if(!C.continuous[xe]||!C.continuous[me]){J.vertexIndices[V]=[pe,xe],J.vertexIndices.splice(V+1,0,[me,ie]),J.vertices.splice((V+1)*2,0,J.vertices[V*2],J.vertices[V*2+1]);break}}}W.push({bevelI:K,angle:R,size:U,boundary:J,reverseMap:re,insetPoints:z})}let q=(K,R,U)=>{let z=0,j=K.boundary.vertexIndices.length;for(;z<j&&U(K.boundary.vertexIndices[R]);)R=(R+1)%j,z++;return z},H=y.length;for(let K=1;K<W.length;K++){let R=W[K-1],U=W[K],z=R.boundary.vertexIndices.length,j=U.boundary.vertexIndices.length;if(!z||!j)break;let G=C.concave.length,re=0,Z=Qx(re,I);for(;!R.boundary.vertexIndices.filter(Z).length||!U.boundary.vertexIndices.filter(Z).length;)re++,Z=Qx(re,I);let J=R.boundary.vertexIndices.findIndex(Z),V=U.boundary.vertexIndices.findIndex(Z);do J=(J+1)%z;while(Z(R.boundary.vertexIndices[J]));do V=(V+1)%j;while(Z(U.boundary.vertexIndices[V]));re=(re+1)%I;let pe=re,ie=this._buildBevelVert(C,R,(J-1+z)%z),ae=this._buildBevelVert(C,U,(V-1+j)%j),fe=ie,xe=ae,me,Me,Pe=!1;do{Z=Qx(re,I);let be=q(R,J,Z),Fe=q(U,V,Z),ht=Pe;if(Pe=!1,be&&!Fe){for(let L=0;L<be;L++)me=this._buildBevelVert(C,R,(J+L)%z,L/(be-1)),y.push(fe.topN,me.topP,xe.topN),y.push(me.bottomP,fe.bottomN,xe.bottomN),fe=me;Pe=!0}else if(!be&&Fe)for(let L=0;L<Fe;L++)Me=this._buildBevelVert(C,U,(V+L)%j,L/(Fe-1)),y.push(xe.topN,fe.topP,Me.topP),y.push(fe.bottomP,xe.bottomN,Me.bottomP),xe=Me;else if(be&&Fe)if(me=this._buildBevelVert(C,R,J,0),Me=this._buildBevelVert(C,U,V,0),ht?(y.push(fe.topN,Me.topP,xe.topN),y.push(fe.topN,me.topP,Me.topP),y.push(Me.bottomP,fe.bottomN,xe.bottomN),y.push(Me.bottomP,me.bottomP,fe.bottomN)):(y.push(xe.topN,fe.topN,me.topP),y.push(xe.topN,me.topP,Me.topP),y.push(me.bottomP,fe.bottomN,xe.bottomN),y.push(me.bottomP,xe.bottomN,Me.bottomP)),fe=me,xe=Me,be===Fe)for(let L=1;L<be;L++)me=this._buildBevelVert(C,R,(J+L)%z,L/(be-1)),Me=this._buildBevelVert(C,U,(V+L)%j,L/(Fe-1)),y.push(fe.topN,me.topP,xe.topN),y.push(xe.topN,me.topP,Me.topP),y.push(me.bottomP,fe.bottomN,xe.bottomN),y.push(me.bottomP,xe.bottomN,Me.bottomP),fe=me,xe=Me;else if(be>Fe){let L=be/Fe,O=0;for(let ee=1;ee<be;ee++)me=this._buildBevelVert(C,R,(J+ee)%z,ee/(be-1)),y.push(fe.topN,me.topP,xe.topN),y.push(me.bottomP,fe.bottomN,xe.bottomN),fe=me,ee>(O+1)*L&&(O++,Me=this._buildBevelVert(C,U,(V+O)%j,O/(Fe-1)),y.push(xe.topN,me.topP,Me.topP),y.push(me.bottomP,xe.bottomN,Me.bottomP),xe=Me)}else{let L=Fe/be,O=0;for(let ee=1;ee<Fe;ee++)Me=this._buildBevelVert(C,U,(V+ee)%j,ee/(Fe-1)),y.push(xe.topN,me.topP,Me.topP),y.push(me.bottomP,xe.bottomN,Me.bottomP),xe=Me,ee>(O+1)*L&&(O++,me=this._buildBevelVert(C,R,(J+O)%z,O/(be-1)),y.push(fe.topN,me.topP,xe.topN),y.push(me.bottomP,fe.bottomN,xe.bottomN),fe=me)}J=(J+be)%z,V=(V+Fe)%j,re=(re+1)%G}while(re!==pe)}if(this._buildWall(W,C,y),S){let K=[];for(let R=y.length-1;R>=H+2;R-=3){let U=y[R-2],z=y[R-1],j=y[R-0];K.push(j,z,U)}y.splice(H,y.length-H,...K)}if(S){let K=[];for(let R=W[W.length-1].boundary.vertices.length-1;R>=1;R-=2){let U=W[W.length-1].boundary.vertices[R-1],z=W[W.length-1].boundary.vertices[R-0];K.push(U,z)}v.push(K)}if(!S){let K=W[W.length-1],R;try{R=Bi({windingRule:W.length>1?ft.POSITIVE:ft.ODD,elementType:Jt.POLYGONS,vertexSize:2,strict:!0,contours:[K.insetPoints,...v]})}catch{R=$x}if(!R)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:y.length});for(let U=0;U<R.elementCount*3;U+=3){let z=this._buildSurfaceVert(R,R.elements[U+0]),j=this._buildSurfaceVert(R,R.elements[U+1]),G=this._buildSurfaceVert(R,R.elements[U+2]);y.push(z.top,j.top,G.top),y.push(G.bottom,j.bottom,z.bottom)}}this.vertexCache={}}this._buffer.shrink();let x=new Be(Uint32Array.from(y),1),b=new Be(this._buffer.positions,3),w=new Be(this._buffer.normals,3),A=new Be(this._buffer.uvs,2);b.needsUpdate=!0,w.needsUpdate=!0,A.needsUpdate=!0,x.needsUpdate=!0,this.setAttribute("position",b),this.setAttribute("normal",w),this.setAttribute("uv",A),this.setIndex(x)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,i){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);i.push(u.topP,l.topN,l.bottomN),i.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,n){let i=n.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=e.vertices[n*2+0],o=e.vertices[n*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,u=this._buffer.get(2),c=u*3,d=u*2,h={top:u+0,bottom:u+1};return this._buffer.positions[c+0]=s,this._buffer.positions[c+1]=o,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[d+0]=a,this._buffer.uvs[d+1]=l,this._buffer.positions[c+3]=s,this._buffer.positions[c+4]=o,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[d+2]=a,this._buffer.uvs[d+3]=l,this.vertexCache[i]=h,h}_buildBevelVert(e,n,i,s=1){let o=`${n.bevelI}:${i}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=n.boundary.vertexIndices[i],u,c,d,h;a!==l?(c=a,u=l,h=!1,d=e.continuous[c]&&e.continuous[u]):(u=a,c=(u-1+e.count)%e.count,h=e.concave[u]&&n.bevelI>0,d=e.continuous[u]||h);let f=Math.cos(n.angle),g=Math.sin(n.angle),p=i*2,m=u*2,y=c*2,v=n.boundary.vertices[p+0],x=n.boundary.vertices[p+1],b=(1-g)*this._bevelSize,w=(v-this._minX)/this._width,A=(x-this._minY)/this._height,T=e.normals[m+0],S=e.normals[m+1],E=e.normals[y+0],M=e.normals[y+1];if(h){let B=E-T,k=M-S;T=T+B*(1-s),S=S+k*(1-s);let X=Math.sqrt(T*T+S*S);T/=X,S/=X}let I=this._buffer.get(d?2:4),P=I*3,C=I*2,D={i,fi:u,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1};return this._buffer.positions[P+0]=v,this._buffer.positions[P+1]=x,this._buffer.positions[P+2]=this._depth-b,this._buffer.normals[P+0]=T*f,this._buffer.normals[P+1]=S*f,this._buffer.normals[P+2]=g,this._buffer.uvs[C+0]=w,this._buffer.uvs[C+1]=A,this._buffer.positions[P+3]=v,this._buffer.positions[P+4]=x,this._buffer.positions[P+5]=b,this._buffer.normals[P+3]=T*f,this._buffer.normals[P+4]=S*f,this._buffer.normals[P+5]=-g,this._buffer.uvs[C+2]=A,this._buffer.uvs[C+3]=w,d||(I+=2,P+=6,C+=4,D.topP=I+0,D.bottomP=I+1,this._buffer.positions[P+0]=v,this._buffer.positions[P+1]=x,this._buffer.positions[P+2]=this._depth-b,this._buffer.normals[P+0]=E*f,this._buffer.normals[P+1]=M*f,this._buffer.normals[P+2]=g,this._buffer.uvs[C+0]=w,this._buffer.uvs[C+1]=A,this._buffer.positions[P+3]=v,this._buffer.positions[P+4]=x,this._buffer.positions[P+5]=b,this._buffer.normals[P+3]=E*f,this._buffer.normals[P+4]=M*f,this._buffer.normals[P+5]=-g,this._buffer.uvs[C+2]=A,this._buffer.uvs[C+3]=w),this.vertexCache[o]=D,D}clone(){let e=new fu(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Ks(this.userData),e}};var pu=class extends Te{constructor(e,n=12,i={}){super();this.type="ShapeGeometry";this.windingRule=ft.ODD;this.elementType=Jt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:ft.ODD,elementType:Jt.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(g=>g.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,d;for(let g=0,p=s.length/2;g<p;g++){let m=g*2,y=s[m+0],v=s[m+1];if(c!==void 0&&y!==c&&(l=!1),d!==void 0&&v!==d&&(u=!1),c=y,d=v,!l&&!u)break}if(!l&&!u)try{a=Bi({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=Mh}let h=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Be(new Float32Array(h*3),3),this._normalAttribute=new Be(new Float32Array(h*3),3),this._uvAttribute=new Be(new Float32Array(h*2),2),this._indexAttribute=new Be(new Uint32Array(f*3),1),a){let g=1/0,p=-1/0,m=1/0,y=-1/0;for(let b=0,w=h;b<w;b++){let A=b*2,T=a.vertices[A+0],S=a.vertices[A+1];T<g&&(g=T),T>p&&(p=T),S<m&&(m=S),S>y&&(y=S)}let v=p-g,x=y-m;for(let b=0,w=h;b<w;b++){let A=b*2,T=a.vertices[A+0],S=a.vertices[A+1],E=(T-g)/v,M=(S-m)/x;this._positionAttribute.setXYZ(b,T,S,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,E,M)}for(let b=0,w=f;b<w;b++){let A=b*3,T=a.elements[A+0],S=a.elements[A+1],E=a.elements[A+2];this._indexAttribute.setX(A+0,T),this._indexAttribute.setX(A+1,S),this._indexAttribute.setX(A+2,E)}}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 pu(this._shape,this._curveSegments);return e.userData=Ks(this.userData),e}};var mu=class extends fu{constructor(e,n,i=0,s=12,o=3,a=ft.ODD){super(e,n,i,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,n,i){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);i.push(u.topP,l.topN,l.bottomN),i.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new mu(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Ks(this.userData),e}};var Ir=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:ft.ODD},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=r.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof St?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new St(n,i).fromJSON(o),r.parameters?.roundness!==void 0&&r.parameters?.roundness>0&&o.update());let l=o??new St(n,i);return{parameters:Object.assign(e,{width:n,height:i,depth:s,roundness:a}),shape:l}}static build(r){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:n,subdivisions:i,roundness:s,windingRule:o}=r.parameters;r.shape.roundness=s;let a;return t<=0?a=new pu(r.shape,i,{windingRule:o}):a=new mu(r.shape,t,e,i,n,o),Object.assign(a,{userData:{...r,type:"VectorGeometry"}})}};var OM=Math.PI*2,yu=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof St?r.shape:new St,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,spikes:n,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u=r.shape,c=t*.5,d=e*.5,h=sH(u,c,d,i*Math.PI/180,n,s);u.isClosed=!0,u.update();let f=Ir.create({shape:u,parameters:{subdivisions:h,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...r,type:"EllipseGeometry"}})}};function sH(r,t,e,n,i,s){if(n>=OM)return i>30||i%4===0?(aH(r,t,e,s),Math.round(i/4)):DM(r,n,i,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=EM({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:n>Math.PI,sweepFlag:!0});return i>30||i%u.length===0?oH(r,o.x,o.y,u,i,t,e,s):DM(r,n,i,t,e,s)}function oH(r,t,e,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint(gu(t,e));for(let u=0,c=n.length;u<c;u++){let d=n[u],h=r.points[u],f=gu(d.x,d.y);h.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),r.addPoint(f)}return a>0?LM(r,s,o,a):r.addPoint(gu(0,0)),l}function DM(r,t,e,n,i,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)*i;r.addPoint(gu(u,c))}return t<OM?s>0?LM(r,n,i,s):r.addPoint(gu(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&RM(r,n,i,s)),1}function aH(r,t,e,n=0,i=0,s=0){let o=.5522847498,a=t*o,l=e*o;r.addPoint(ug(i-t,s,i-t,s-l,i-t,s+l)),r.addPoint(ug(i,s+e,i-a,s+e,i+a,s+e)),r.addPoint(ug(i+t,s,i+t,s+l,i+t,s-l)),r.addPoint(ug(i,s-e,i+a,s-e,i-a,s-e)),n>0&&RM(r,t,e,n)}function gu(r,t){return new Ni(Ve.generateUUID(),new F(r,t))}function ug(r,t,e,n,i,s){let o=gu(r,t);return o.controls[0].position.set(e,n),o.controls[1].position.set(i,s),o}function LM(r,t,e,n){NM(r,t,e,n).forEach(s=>r.addPoint(s))}function RM(r,t,e,n){let i=NM(r,t,e,n),s=new St;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function NM(r,t,e,n){let i=n*t/100,s=i*(Math.abs(e)/Math.abs(t)),o=new F(i/t,s/e),a=r.points.map(l=>{let u=l.clone();return u.uuid=Ve.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 BM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},r.parameters),n=Math.abs(e.width),i=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:i,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(r){let{width:t,height:e,depth:n,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=r.parameters,h=new nl(!1,t,e,n,i,s,o,a,l,u,c,d);return Object.assign(h,{userData:{...r,type:"HelixGeometry"}})}},nl=class extends Te{constructor(t=!0,e=1,n=1,i=1,s=1,o=1,a=1,l=1,u=1,c=1,d=1,h=1,f=!1){super();let g=t&&o===1;g&&(h=0),d>100&&(d=100);let p=()=>new _,m=new _,y=p(),v=p(),x=p(),b,w,A,T,S,E,M,I,P=p(),C=p(),D=p(),B=p(),k=p(),X=p(),W=p(),q=p(),H=n-2*l+.001,K=H/o,R=Math.ceil(a*o),U=R+1,z=H/R,j=-H/2,G=c+1,re=2*Math.PI/c,Z=Math.PI/2/h,J=.01,V=Math.min((1-d/100)*l,l-J),pe=l-V,ie=0,ae=2,fe=h*ae+ae,xe=G*fe/ae,me=xe+G*U,Me=G*(U+fe),[Pe,be,Fe]=[3,3,2].map(_e=>Array(Me*_e).fill(0)),ht=[],L=s-l;function O(_e,Re){let Ne=Math.PI/2;E=Re*z,I=2*Math.PI*(E%K)/K+Ne,E+=j,M=Math.sin(I)*L,S=Math.cos(I)*L,t?_e.set(S,M,E):_e.set(S,E,M)}O(m,-1e-10),O(y,0),P.copy(m),O(m,1);let ee=m.distanceTo(y),he=g?0:pe+V,ge=ee*R+2*he,Ie=V,Ge=ge-he;for(let _e=0;_e<=R;_e++){O(v,_e),q.subVectors(v,P).normalize(),P.copy(v),X.copy(v).setComponent(+t+1,0).normalize(),W.crossVectors(q,X).normalize();let Re=_e===0,Ne=_e===R,pt=Re?3*Math.PI/2:Z,Nt=Re?Ie:Ge,gn=Re?G:me,Y=Re?0:Me-G,se=q.clone().multiplyScalar(Re?-pe:pe).add(v),ye=q.clone().multiplyScalar(Re?-1:1).normalize();for(let Ce=0;Ce<G;Ce++){let Ue=Ce*re;if(C.addVectors(m.copy(X).multiplyScalar(l*Math.cos(Ue)),y.copy(W).multiplyScalar(l*Math.sin(Ue))),D.copy(C).normalize(),Re||Ne){g||(ie=Y+Ce,[0,1,2].forEach(tt=>{Pe[ie*3+tt]=se.getComponent(tt),be[ie*3+tt]=ye.getComponent(tt)}),Fe[ie*2]=+Ne,Fe[ie*2+1]=Ce/c),y.copy(D).multiplyScalar(V),x.addVectors(v,y);for(let tt=0;tt<h;tt++){let $t=tt*Z+pt;B.addVectors(m.copy(q).multiplyScalar(pe*Math.sin($t)),y.copy(D).multiplyScalar(pe*Math.cos($t))),k.copy(B).normalize(),y.addVectors(x,B),B.normalize(),ie=gn+tt*G+Ce,[0,1,2].forEach(ri=>{Pe[ie*3+ri]=y.getComponent(ri),be[ie*3+ri]=k.getComponent(ri)});let Nn=+Re+Math.sin($t);Fe[ie*2]=(Nt+pe*Nn)/ge,Fe[ie*2+1]=Ce/c}}y.addVectors(v,C),ie=xe+_e*G+Ce,[0,1,2].forEach(tt=>{Pe[ie*3+tt]=y.getComponent(tt),be[ie*3+tt]=D.getComponent(tt)}),Fe[ie*2]=(he+_e*ee)/ge,Fe[ie*2+1]=Ce/c}}let De=U+2*h+ae,ue=1,[je,qe]=[+g,De-1];f&&(qe-=1);for(let _e=je;_e<=qe-1;_e++){let Re=g&&_e===qe-1;for(let Ne=0;Ne<G-1;Ne++)b=_e*G+Ne,w=b+1,A=(Re?Ne:b)+G,T=(Re?Ne+1:w)+G,_e===0?ht.push(w,T,A):_e===De-2?ht.push(b,w,A):ht.push(b,w,A,w,T,A)}this.setIndex(ht),this.setAttribute("position",new we(Pe,3)),this.setAttribute("normal",new we(be,3)),this.setAttribute("uv",new we(Fe,2))}};var FM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.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(r){let{width:t,height:e,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new Ch(t*.5,s,o):new Xl(t*.5,i);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...r,type:"IcosahedronGeometry"}})}},Ch=class extends Ko{constructor(t=1,e=.2,n=4){let i=(1+Math.sqrt(5))/2,s=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,n),this.type=a}static fromJSON(t){return new Ch(t.radius,t.corner,t.cornerSides)}};var UM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){(r.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}]},r.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(r){let{points:t,segments:e,verticalSegments:n}=r.parameters,i=new Hs;i.moveTo(t[0].x,t[0].y),i.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new Vl(i.extractPoints(n).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...r,type:"LatheGeometry"}})}};var cs=new de,eb=new ut,dg=new _,Qo=class extends Wt{constructor(){super(),this.uuid=Ve.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 nn().getNormalMatrix(t);for(let n=0,i=this.vertices.length;n<i;n++)this.vertices[n].applyMatrix4(t);for(let n=0,i=this.faces.length;n<i;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 cs.makeRotationX(t),this.applyMatrix4(cs),this}rotateY(t){return cs.makeRotationY(t),this.applyMatrix4(cs),this}rotateZ(t){return cs.makeRotationZ(t),this.applyMatrix4(cs),this}translate(t,e,n){return cs.makeTranslation(t,e,n),this.applyMatrix4(cs),this}scale(t,e,n){return cs.makeScale(t,e,n),this.applyMatrix4(cs),this}lookAt(t){return eb.lookAt(t),eb.updateMatrix(),this.applyMatrix4(eb.matrix),this}fromBufferGeometry(t){let e=this,n=t.index!==null?t.index:void 0,i=t.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,u=i.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let h=0;h<s.count;h++)e.vertices.push(new _().fromBufferAttribute(s,h)),a!==void 0&&e.colors.push(new Le().fromBufferAttribute(a,h));function c(h,f,g,p){let m=a===void 0?[]:[e.colors[h].clone(),e.colors[f].clone(),e.colors[g].clone()],y=o===void 0?[]:[new _().fromBufferAttribute(o,h),new _().fromBufferAttribute(o,f),new _().fromBufferAttribute(o,g)],v=new vu(h,f,g,y,m,p);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new F().fromBufferAttribute(l,h),new F().fromBufferAttribute(l,f),new F().fromBufferAttribute(l,g)]),u!==void 0&&e.faceVertexUvs[1].push([new F().fromBufferAttribute(u,h),new F().fromBufferAttribute(u,f),new F().fromBufferAttribute(u,g)])}let d=t.groups;if(d.length>0)for(let h=0;h<d.length;h++){let f=d[h],g=f.start,p=f.count;for(let m=g,y=g+p;m<y;m+=3)n!==void 0?c(n.getX(m),n.getX(m+1),n.getX(m+2),f.materialIndex):c(m,m+1,m+2,f.materialIndex)}else if(n!==void 0)for(let h=0;h<n.count;h+=3)c(n.getX(h),n.getX(h+1),n.getX(h+2));else for(let h=0;h<s.count;h+=3)c(h,h+1,h+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(dg).negate(),this.translate(dg.x,dg.y,dg.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,n=e===0?1:1/e,i=new de;return i.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(i),this}computeFaceNormals(){let t=new _,e=new _;for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];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,i=this.vertices.length;n<i;n++)e[n]=new _;if(t){let n=new _,i=new _;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];n.subVectors(c,u),i.subVectors(l,u),n.cross(i),e[a.a].add(n),e[a.b].add(n),e[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,i=this.faces.length;n<i;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,i=this.vertices.length;n<i;n++)e[n].normalize();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(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],i=n.vertexNormals;i.length===3?(i[0].copy(n.normal),i[1].copy(n.normal),i[2].copy(n.normal)):(i[0]=n.normal.clone(),i[1]=n.normal.clone(),i[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,n=this.faces.length;e<n;e++){let i=this.faces[e];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let t=new Qo;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 _,c={a:new _,b:new _,c:new _};s.push(u),o.push(c)}}let i=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=i.faceNormals[s],u=i.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let e=0,n=this.faces.length;e<n;e++){let i=this.faces[e];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new xt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Sn),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 i,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(i=new nn().getNormalMatrix(e));for(let h=0,f=a.length;h<f;h++){let p=a[h].clone();e!==void 0&&p.applyMatrix4(e),o.push(p)}for(let h=0,f=d.length;h<f;h++)c.push(d[h].clone());for(let h=0,f=u.length;h<f;h++){let g=u[h],p,m,y=g.vertexNormals,v=g.vertexColors,x=new vu(g.a+s,g.b+s,g.c+s);x.normal.copy(g.normal),i!==void 0&&x.normal.applyMatrix3(i).normalize();for(let b=0,w=y.length;b<w;b++)p=y[b].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),x.vertexNormals.push(p);x.color.copy(g.color);for(let b=0,w=v.length;b<w;b++)m=v[b],x.vertexColors.push(m.clone());x.materialIndex=g.materialIndex+n,l.push(x)}for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let g=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,m=g.length;p<m;p++){let y=g[p],v=[];for(let x=0,b=y.length;x<b;x++)v.push(y[x].clone());this.faceVertexUvs[h].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=[],i=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[d]===void 0?(e[d]=l,n.push(this.vertices[l]),i[l]=n.length-1):i[l]=i[e[d]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=i[c.a],c.b=i[c.b],c.c=i[c.c];let d=[c.a,c.b,c.c];for(let h=0;h<3;h++)if(d[h]===d[(h+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(t){this.vertices=[];for(let e=0,n=t.length;e<n;e++){let i=t[e];this.vertices.push(new _(i.x,i.y,i.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 i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(i[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 g=this.parameters;for(let p in g)g[p]!==void 0&&(t[p]=g[p]);return t}let e=[];for(let g=0;g<this.vertices.length;g++){let p=this.vertices[g];e.push(p.x,p.y,p.z)}let n=[],i=[],s={},o=[],a={},l=[],u={};for(let g=0;g<this.faces.length;g++){let p=this.faces[g],m=!0,y=!1,v=this.faceVertexUvs[0][g]!==void 0,x=p.normal.length()>0,b=p.vertexNormals.length>0,w=p.color.r!==1||p.color.g!==1||p.color.b!==1,A=p.vertexColors.length>0,T=0;if(T=c(T,0,0),T=c(T,1,m),T=c(T,2,y),T=c(T,3,v),T=c(T,4,x),T=c(T,5,b),T=c(T,6,w),T=c(T,7,A),n.push(T),n.push(p.a,p.b,p.c),n.push(p.materialIndex),v){let S=this.faceVertexUvs[0][g];n.push(f(S[0]),f(S[1]),f(S[2]))}if(x&&n.push(d(p.normal)),b){let S=p.vertexNormals;n.push(d(S[0]),d(S[1]),d(S[2]))}if(w&&n.push(h(p.color)),A){let S=p.vertexColors;n.push(h(S[0]),h(S[1]),h(S[2]))}}function c(g,p,m){return m?g|1<<p:g&~(1<<p)}function d(g){let p=g.x.toString()+g.y.toString()+g.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(g.x,g.y,g.z)),s[p]}function h(g){let p=g.r.toString()+g.g.toString()+g.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(g.getHex())),a[p]}function f(g){let p=g.x.toString()+g.y.toString();return u[p]!==void 0||(u[p]=l.length/2,l.push(g.x,g.y)),u[p]}return t.data={},t.data.vertices=e,t.data.normals=i,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=n,t}clone(){return new Qo().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 h=0,f=e.length;h<f;h++)this.vertices.push(e[h].clone());let n=t.colors;for(let h=0,f=n.length;h<f;h++)this.colors.push(n[h].clone());let i=t.faces;for(let h=0,f=i.length;h<f;h++)this.faces.push(i[h].clone());for(let h=0,f=t.faceVertexUvs.length;h<f;h++){let g=t.faceVertexUvs[h];this.faceVertexUvs[h]===void 0&&(this.faceVertexUvs[h]=[]);for(let p=0,m=g.length;p<m;p++){let y=g[p],v=[];for(let x=0,b=y.length;x<b;x++){let w=y[x];v.push(w.clone())}this.faceVertexUvs[h].push(v)}}let s=t.morphTargets;for(let h=0,f=s.length;h<f;h++){let g={};if(g.name=s[h].name,s[h].vertices!==void 0){g.vertices=[];for(let p=0,m=s[h].vertices.length;p<m;p++)g.vertices.push(s[h].vertices[p].clone())}if(s[h].normals!==void 0){g.normals=[];for(let p=0,m=s[h].normals.length;p<m;p++)g.normals.push(s[h].normals[p].clone())}this.morphTargets.push(g)}let o=t.morphNormals;for(let h=0,f=o.length;h<f;h++){let g={};if(o[h].vertexNormals!==void 0){g.vertexNormals=[];for(let p=0,m=o[h].vertexNormals.length;p<m;p++){let y=o[h].vertexNormals[p],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),g.vertexNormals.push(v)}}if(o[h].faceNormals!==void 0){g.faceNormals=[];for(let p=0,m=o[h].faceNormals.length;p<m;p++)g.faceNormals.push(o[h].faceNormals[p].clone())}this.morphNormals.push(g)}let a=t.skinWeights;for(let h=0,f=a.length;h<f;h++)this.skinWeights.push(a[h].clone());let l=t.skinIndices;for(let h=0,f=l.length;h<f;h++)this.skinIndices.push(l[h].clone());let u=t.lineDistances;for(let h=0,f=u.length;h<f;h++)this.lineDistances.push(u[h]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.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 tb().fromGeometry(this),e=new Te,n=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",hg.call(new Be(n,3),t.vertices)),t.normals.length>0){let i=new Float32Array(t.normals.length*3);e.setAttribute("normal",hg.call(new Be(i,3),t.normals))}if(t.colors.length>0){let i=new Float32Array(t.colors.length*3);e.setAttribute("color",GM.call(new Be(i,3),t.colors))}if(t.uvs.length>0){let i=new Float32Array(t.uvs.length*2);e.setAttribute("uv",kM.call(new Be(i,2),t.uvs))}if(t.uvs2.length>0){let i=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",kM.call(new Be(i,2),t.uvs2))}e.groups=t.groups;for(let i in t.morphTargets){let s=[],o=t.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new we(u.data.length*3,3);c.name=u.name,s.push(hg.call(c,u.data))}e.morphAttributes[i]=s}if(t.skinIndices.length>0){let i=new we(t.skinIndices.length*4,4);e.setAttribute("skinIndex",zM.call(i,t.skinIndices))}if(t.skinWeights.length>0){let i=new we(t.skinWeights.length*4,4);e.setAttribute("skinWeight",zM.call(i,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 Te,n=t.geometry;if(t.isPoints||t.isLine){let i=new we(n.vertices.length*3,3),s=new we(n.colors.length*3,3);if(e.setAttribute("position",hg.call(i,n.vertices)),e.setAttribute("color",GM.call(s,n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new we(n.lineDistances.length,1);e.setAttribute("lineDistance",lH.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}};Qo.prototype.isGeometry=!0;var tb=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,i,s,o=t.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=i*3-n.start,e.push(n)),n={start:i*3,materialIndex:s})}n!==void 0&&(n.count=i*3-n.start,e.push(n)),this.groups=e}fromGeometry(t){let e=t.faces,n=t.vertices,i=t.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[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,d=c.length,h;if(d>0){h=[];for(let y=0;y<d;y++)h[y]={name:c[y].name,data:[]};this.morphTargets.normal=h}let f=t.skinIndices,g=t.skinWeights,p=f.length===n.length,m=g.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=i[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 F,new F,new F))}if(o===!0){let w=i[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 F,new F,new F))}for(let w=0;w<l;w++){let A=a[w].vertices;u[w].data.push(A[v.a],A[v.b],A[v.c])}for(let w=0;w<d;w++){let A=c[w].vertexNormals[y];h[w].data.push(A.a,A.b,A.c)}p&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),m&&this.skinWeights.push(g[v.a],g[v.b],g[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}},vu=class{constructor(t,e,n,i,s,o=0){this.a=t,this.b=e,this.c=n,this.normal=i&&i.isVector3?i:new _,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Le,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(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 lH(r){return this.array.set(r),this}function GM(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),s=new Le),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function kM(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),s=new F),t[e++]=s.x,t[e++]=s.y}return this}function hg(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),s=new _),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function zM(r){let t=this.array,e=0;for(let n=0,i=r.length;n<i;n++){let s=r[n];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),s=new Qe),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var cH=["a","b","c"];function uH(r,t){switch(t){case"c":return r.c;case"b":return r.b;case"a":default:return r.a}}function nb(r,t,e){let n=Math.min(r,t),i=Math.max(r,t),s=n+"_"+i;return e.get(s)}function rb(r,t,e,n,i,s){let o=Math.min(r,t),a=Math.max(r,t),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=e[o],d=e[a];u={a:c,b:d,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(i),s[r].edges.push(u),s[t].edges.push(u)}function dH(r,t,e,n){let i,s,o;for(i=0,s=r.length;i<s;i++)e[i]={edges:[]};for(i=0,s=t.length;i<s;i++)o=t[i],rb(o.a,o.b,r,n,o,e),rb(o.b,o.c,r,n,o,e),rb(o.c,o.a,r,n,o,e)}function fg(r,t,e,n,i){r.push(new vu(t,e,n,void 0,void 0,i))}function xu(r,t){return Math.abs(t-r)/2+Math.min(r,t)}function pg(r,t,e,n){r.push([t.clone(),e.clone(),n.clone()])}var mg=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Te?t=new Qo().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 _,n,i,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,h=[],f=new Map;dH(l,u,h,f);let g=[],p,m,y,v,x,b,w;for(let Z of Array.from(f.keys())){for(m=f.get(Z),y=new _,x=3/8,b=1/8,w=m.faces.length,w!=2&&(x=.5,b=0,w!=1),y.addVectors(m.a,m.b).multiplyScalar(x),e.set(0,0,0),o=0;o<w;o++){for(v=m.faces[o],a=0;a<3&&(p=l[uH(v,cH[a])],!(p!==m.a&&p!==m.b));a++);p&&e.add(p)}e.multiplyScalar(b),y.add(e),m.newEdge=g.length,g.push(y)}let A,T,S,E,M,I,P,C=[];for(i=0,s=l.length;i<s;i++){for(I=l[i],M=h[i].edges,n=M.length,n==3?A=3/16:n>3&&(A=3/(8*n)),T=1-n*Number(A),S=A,n<=2&&(n==2?(T=3/4,S=1/8):n==1||n==0),P=I.clone().multiplyScalar(T),e.set(0,0,0),o=0;o<n;o++)E=M[o],p=E.a!==I?E.a:E.b,e.add(p);e.multiplyScalar(Number(S)),P.add(e),C.push(P)}let D=C.concat(g),B=C.length,k,X,W,q=[],H=[],K,R,U,z,j=new F,G=new F,re=new F;for(i=0,s=u.length;i<s;i++)v=u[i],k=Number(nb(v.a,v.b,f).newEdge)+B,X=Number(nb(v.b,v.c,f).newEdge)+B,W=Number(nb(v.c,v.a,f).newEdge)+B,fg(q,k,X,W,v.materialIndex),fg(q,v.a,k,W,v.materialIndex),fg(q,v.b,X,k,v.materialIndex),fg(q,v.c,W,X,v.materialIndex),d&&(K=c[i],R=K[0],U=K[1],z=K[2],j.set(xu(R.x,U.x),xu(R.y,U.y)),G.set(xu(U.x,z.x),xu(U.y,z.y)),re.set(xu(R.x,z.x),xu(R.y,z.y)),pg(H,j,G,re),pg(H,R,j,re),pg(H,U,G,j),pg(H,z,re,G));t.vertices=D,t.faces=q,d&&(t.faceVertexUvs[0]=H)}};var Dn=new _,VM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=r.geometry??t?.geometry??new Te().copy(new Gn(100,100,100)),n;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Dn),n={width:Dn.x,height:Dn.y,depth:Dn.z,subdivisions:0}):n=t.parameters;let i={...n,...r.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:e}}static build(r){let{width:t,height:e,depth:n,subdivisions:i}=r.parameters,s=r.geometry??new Te().copy(new Gn(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Dn)):Dn.set(o.width,o.height,o.depth),(t!==Dn.x||e!==Dn.y||n!==Dn.z)&&s.scale(Dn.x===0?1:t/Dn.x,Dn.y===0?1:e/Dn.y,Dn.z===0?1:n/Dn.z);let a=s.originalGeometry;return i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new mg(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),a!==void 0&&Object.assign(s,{originalGeometry:a}),delete r.geometry,Object.assign(s,{userData:{...r,type:"NonParametricGeometry"}})}static loadFromUrl(r,t,e){new Jl(e).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(Dn);let o=100/Dn.x;Object.assign(s.parameters,{width:100,height:Dn.y*o,depth:Dn.z*o}),t(this.build(s))})}};var gg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters);return{shape:r.shape&&r.shape instanceof St?r.shape:new St,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,spikes:n,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=r.parameters,l=r.shape,u=t*.5,c=e*.5,d=0,h=0,f=2*Math.PI/n;for(let p=0;p<n;p++){let m=f*p,y=d+Math.sin(m)*u,v=h+Math.cos(m)*c;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let p=0,m=l.points.length;p<m;p++)l.points[p].roundness=i;l.roundness=i,l.update();let g=Ir.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(g,{userData:{...r,type:"PolygonGeometry"}})}};var HM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},r.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(r){let{width:t,height:e,depth:n,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=new sb(t*.5,e,i,s,o,a,l);return u.scale(1,1,n/t),Object.assign(u,{userData:{...r,type:"PyramidGeometry"}})}};function Ph(r,t,e){e.x=r.x*t.x,e.y=r.y,e.z=r.x*t.y}function ib(r,t,e,n,i,s){let o=t.clone().sub(r),a=e.clone().sub(r),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===i){let u=o.add(a).normalize();s.copy(r).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(r),s.addScaledVector(o,i/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function hH(r,t,e){let n=r.clone().sub(t),i=e.clone().sub(t);return n.projectOnVector(i),n.add(t)}var sb=class extends Te{constructor(t=.5,e=1,n=4,i=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),i=Math.floor(i),a=Math.floor(a);let l=[],u=[],c=[],d=[],h=0,f=e/2,g=Math.PI/n,p=t*Math.cos(Math.PI/n),m=2*Math.PI/n,y=(n-2)*Math.PI/n,v=Math.PI-y,x=new _(0,-f,0),b=new _(0,f,0),w=new F(t,-f),A=new F(p,-f),T=new F(0,b.y).sub(A),S=new F(0,b.y).sub(w),E=new F(T.y,-T.x).normalize(),M=new F(S.y,-S.x).normalize(),P=t*Math.cos(Math.PI/n)*Math.tan((Math.PI-T.angle())/2)-1e-8;o=Math.min(o,P);let C;{let H=new _(E.x,E.y,0),K=new _(Math.cos(m)*H.x,H.y,Math.sin(m)*H.x);C=H.angleTo(K)}let D=o/Math.tan((Math.PI-T.angle())/2),B=o/Math.tan((Math.PI-C)/2),k=new _;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),d.push(0,0);let H=h++,K=[],R=w.clone(),U=D/Math.cos(Math.PI/n);R.x-=U;for(let z=0;z<n;z++){let j=z/n*Math.PI*2+g,G=new F(Math.sin(j),Math.cos(j));Ph(R,G,k),u.push(k.x,k.y,k.z),c.push(0,-1,0),d.push(0,0),K.push(h++)}for(let z=0;z<K.length;z++)l.push(K[z],H,K[(z+1)%K.length])}let X=[];{let H=new _,K=new _,R=new _,U=new _,z=new _,j=new _;for(let G=0;G<n;G++){let re=G/n*Math.PI*2+g,Z=(G+.5)/n*Math.PI*2+g,J=(G+1)/n*Math.PI*2+g,V=new F(Math.sin(re),Math.cos(re)),pe=new F(Math.sin(Z),Math.cos(Z)),ie=new F(Math.sin(J),Math.cos(J));Ph(w,V,K),Ph(w,ie,R),Ph(E,pe,H),ib(b,K,R,B,B,U),u.push(U.x,U.y,U.z),ib(K,b,R,B,D,z),u.push(z.x,z.y,z.z),ib(R,K,b,D,B,j),u.push(j.x,j.y,j.z),c.push(H.x,H.y,H.z),c.push(H.x,H.y,H.z),c.push(H.x,H.y,H.z),d.push(0,0),d.push(0,0),d.push(0,0);let ae=h++,fe=h++,xe=h++;if(l.push(ae,fe,xe),o>0){{let Pe=K.clone().add(R).multiplyScalar(.5),be=b.clone().sub(Pe).normalize(),ht=x.clone().sub(Pe).normalize().add(be).normalize().multiplyScalar(-1),L=j.clone().sub(z);W(Pe,L,ht,T.angle())}let me,Me;{let Pe=new _;Ph(M,ie,Pe);let be=j.clone().add(U).multiplyScalar(.5);be=hH(be,R,b);let Fe=j.clone().sub(U);[me,Me]=W(be,Fe,Pe,C,U.y)}{let Pe=me,be=Pe.clone().setY(0).normalize(),Fe=new _(0,-1,0),ht=be.clone().cross(Fe);q(Pe,be,Fe,ht)}X.concat(Me);{let Pe=T.angle(),be=Math.PI-Pe,Fe=b.clone();Fe.y-=o/Math.sin(Pe-Math.PI/2);let ht=new _,L=[];for(let ee=0;ee<a;ee++){let he=[],ge=Math.PI/2-be*ee/a,Ie=Math.cos(ge),Ge=Math.sin(ge),De=Z;for(let ue=0;ue<=ee;ue++){let je=Math.cos(De),qe=Math.sin(De);H.x=Ie*qe,H.y=Ge,H.z=Ie*je,ht.copy(Fe).addScaledVector(H,o),u.push(ht.x,ht.y,ht.z),c.push(H.x,H.y,H.z),d.push(0,0),he.push(h++),De+=Math.PI*2/ee/n}L.push(he)}Me.reverse(),L.push(Me);let O=L.length-1;for(let ee=0;ee<O;ee++){let he=L[ee],ge=L[ee+1],Ie=he.length-1;l.push(ge[1],he[0],ge[0]);for(let Ge=1;Ge<=Ie;Ge++)l.push(he[Ge],he[Ge-1],ge[Ge]),l.push(ge[Ge+1],he[Ge],ge[Ge])}}}}}this.setIndex(l),this.setAttribute("position",new we(u,3)),this.setAttribute("normal",new we(c,3)),this.setAttribute("uv",new we(d,2));function W(H,K,R,U,z){let j=-U/2,G=(Math.PI-U)/2,re=K.clone().normalize().cross(R);H.addScaledVector(R,-o/Math.sin(G));let Z=new _,J=new _,V=1,pe=h,ie=[];for(let ae=0;ae<=a;ae++){let fe=j+ae/a*U;J.set(0,0,0),J.addScaledVector(re,Math.sin(fe)),J.addScaledVector(R,Math.cos(fe));for(let xe=0;xe<=V;xe++){let me=xe/V-.5;if(Z.copy(H),Z.addScaledVector(K,me),Z.addScaledVector(J,o),z!=null){let Me=Math.max(0,Z.y-z);Z.addScaledVector(K,-Me/K.y)}u.push(Z.x,Z.y,Z.z),c.push(J.x,J.y,J.z),d.push(0,0),xe===0&&ie.push(h),h++}}for(let ae=0;ae<a;ae++)for(let fe=0;fe<V;fe++){let xe=pe+fe+(V+1)*ae,me=xe+(V+1),Me=me+1,Pe=xe+1;l.push(xe,me,Pe),l.push(me,Me,Pe)}return[H.clone().addScaledVector(K,.5),ie]}function q(H,K,R,U){let z=Math.PI/2,j=S.angle()-z,G=[],re=new _,Z=new _;for(let V=0;V<=a;V++){let pe=[],ie=V/a;for(let ae=0;ae<=V;ae++){let xe=((V?ae/V:0)-.5)*v,me=Math.cos(xe),Me=Math.sin(xe),Pe=Math.atan(Math.tan(j)*me),be=(z+Pe)*ie,Fe=Math.cos(be),ht=Math.sin(be);re.set(0,0,0),re.addScaledVector(K,ht*me),re.addScaledVector(R,Fe),re.addScaledVector(U,ht*Me),Z.copy(H).addScaledVector(re,o),u.push(Z.x,Z.y,Z.z),c.push(re.x,re.y,re.z),d.push(0,0),pe.push(h++)}G.push(pe)}let J=G.length-1;for(let V=0;V<J;V++){let pe=G[V],ie=G[V+1],ae=pe.length-1;l.push(pe[0],ie[1],ie[0]);for(let fe=1;fe<=ae;fe++)l.push(pe[fe-1],pe[fe],ie[fe]),l.push(pe[fe],ie[fe+1],ie[fe])}}}};var yg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters),n=Object.assign(t?.ui??{enabledIndieCorners:!1},r.ui);return{shape:r.shape&&r.shape instanceof St?r.shape:new St,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(r){let t=r.shape,{width:e,height:n,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u={x:e*.5,y:n*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function h(b,w,A){return w>e&&A>n?Math.min(b*e/w,b*n/A):w>e?b*e/w:A>n?b*n/A:b}let f=[];f[0]=i[0]===0?0:h(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:h(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:h(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:h(i[3],i[3]+i[0],i[3]+i[2]);let g=c.x,p=d.x,m=d.y,y=c.y;t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(p,m)),t.addPoint(t.createPoint(p,y)),t.addPoint(t.createPoint(g,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=Ir.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...r,type:"RectangleGeometry"}})}};var WM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},r.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(r){let{width:t=100,height:e=t,depth:n=t,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=r.parameters,c=new Na(.5*t,i,s,o,a,l,u);return c.scale(1,e/t,n/t),Object.assign(c,{userData:{...r,type:"SphereGeometry"}})}};var jM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},r.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(r){let{width:t=100,height:e=t,widthSegments:n=8,heightSegments:i=8}=r.parameters,s=new Vs(t,e,n,i);return s.scale(1,1,1),Object.assign(s,{userData:{...r,type:"PlaneGeometry"}})}};var qM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},r.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(r){let{width:t,height:e,depth:n,angle:i,cornerRadius:s,cornerSegments:o}=r.parameters,a=new ob(t,e,n,i,s,o);return Object.assign(a,{userData:{...r,type:"BackdropGeometry"}})}},ob=class extends Te{constructor(t=1,e=1,n=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-c,i),i*=Math.PI/180;let d=[],h=Math.PI/2,f=(Z=0,J=0,V=0)=>new _(Z,J,V),g=f(),p=f(),[m,y,v]=[e/2,t/2,n/2],x=-y,b=+y,[w,A,T]=[f(x,-m,+v),f(x,-m,-v),f(x,+m,-v)],S=(Z,J=!1)=>Math.sin(Z-Math.PI/(1+ +J)),E=(Z,J=!1)=>Math.cos(Z-Math.PI/(1+ +J));T.y=Math.sin(i)*e-m;let M=Math.cos(i)*e-v,I=w.z-c;i<=h?(T.z=Math.min(M,I),T.z==I&&(T.y-=(M-I)/Math.tan(h-i))):A.z=Math.min(A.z-M-v,w.z-c),g.subVectors(w,A),p.subVectors(T,A);let P=Math.min(g.length(),p.length())*s/100,C=P*Math.tan(i/2),D=P/Math.cos(i/2),B=g.clone().normalize().add(p.normalize()).setLength(D).add(A);g.set(0,S(i,!0),E(i,!0)),d.push([T,g.clone()]);let k=(Math.PI-i)/o;for(let Z=0;Z<=o;Z++){let J=h+i+Z*k;g.set(0,Math.sin(J)*C,Math.cos(J)*C),g.add(B),p.set(0,S(J),E(J)),d.push([g.clone(),p.clone()])}d.push([w,f(0,1,0)]);let X=Math.sin(k/2)*C*2,W=d.length-1,q=d[0][0].distanceTo(d[1][0]),H=d[W-1][0].distanceTo(d[W][0]),K=q+X*o+H;d[0].push(1);for(let Z=0;Z<=o;Z++)d[Z+1].push(1-(q+Z*X)/K);d[W].push(0);let[R,U,z]=d[0],j,G,re;for(let Z=1;Z<d.length;Z++)[j,G,re]=d[Z],a.push(x,R.y,R.z,x,j.y,j.z,b,R.y,R.z,b,R.y,R.z,x,j.y,j.z,b,j.y,j.z),l.push(0,U.y,U.z,0,G.y,G.z,0,U.y,U.z,0,U.y,U.z,0,G.y,G.z,0,G.y,G.z),u.push(0,z,0,re,1,z,1,z,0,re,1,re),[R,U,z]=[j,G,re];this.setAttribute("position",new we(a,3)),this.setAttribute("normal",new we(l,3)),this.setAttribute("uv",new we(u,2))}};var vg=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof St?r.shape:new St,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(r){let{width:t,height:e,innerRadiusPercent:n,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=r.parameters,c=r.shape,d=t*.5,h=e*.5,f=0,g=0,p=o*Math.PI/360/i,m=Math.PI/2*3*-1,y=d*n/100,v=h*n/100;if(i===3&&n===50){p=2*Math.PI/i;for(let b=0;b<i;b++){let w=p*b,A=f+Math.sin(w)*d,T=g+Math.cos(w)*h;c.addPoint(c.createPoint(A,T))}}else for(let b=0;b<i;b++){let w=f+Math.cos(m)*d,A=g+Math.sin(m)*h;c.addPoint(c.createPoint(w,A)),m+=p,w=f+Math.cos(m)*y,A=g+Math.sin(m)*v,b<=i,c.addPoint(c.createPoint(w,A)),m+=p}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=Ir.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...r,type:"StarGeometry"}})}};var XM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},r.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(r){let{width:t,height:e}=r.parameters,n=new Vs(t,e);return Object.assign(n,{userData:{...r,type:"TextFrameGeometry"}})}};var YM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:n,height:i,depth:s})}}static build(r){let{width:t,height:e,depth:n,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=fH(t,e,n,t*.5,o,s,0,0,i,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...r,type:"TorusGeometry"}})}};function fH(r,t,e,n,i,s,o,a,l,u,c){return[t,e]=[e,t],o=t/2,i/=2*Math.PI,i==1&&(u=0),new nl(!0,r,t,e,n,i,s,o,a,l,u,c)}var KM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},r.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(r){let{width:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:o}=r.parameters,a=t*.5;a!==e&&(a-=e);let l=new Yl(a,e,n,i,s,o);return Object.assign(l,{userData:{...r,type:"TorusKnotGeometry"}})}};var ZM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},r.parameters);return{shape:r.shape&&r.shape instanceof St?r.shape:new St,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(r){let{width:t=100,height:e,cornerRadius:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=r.parameters,l=r.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 h=0,f=l.points.length;h<f;h++)l.points[h].roundness=n;l.roundness=n,l.update();let d=Ir.create({shape:l,parameters:{roundness:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(d,{userData:{...r,type:"TriangleGeometry"}})}};function QM(r,t){let e=2*Math.PI;return(r%e+e)%e===(t%e+e)%e}function pH(r,t,e){let n=[new _,new _,new _],i=[new _,new _,new _];return r.extractBasis(n[0],n[1],n[2]),t.extractBasis(i[0],i[1],i[2]),n.forEach((s,o)=>{let a=i[o],l=Ve.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new de().makeBasis(n[0],n[1],n[2])}var JM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters),n=Math.abs(e.width),i=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??yu.create({parameters:hx}).userData.shape;return{path:r.path??Vc.defaultData(),parameters:Object.assign(e,{width:n,height:i,depth:s,extrusion:{...Om,...e.extrusion}}),shapeData:o}}static build(r){if(r.path.points.length>=2){let e=new ab(r);return Object.assign(e,{userData:{...r,type:"PathGeometry"}})}else return Object.assign(new Te,{userData:{...r,type:"PathGeometry"}})}},ab=class extends Te{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)||!QM(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let n=this._computeBasisMatrices(e),{depth:i,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((i+s)*o):Math.ceil(Math.min(1,i+s)*o),u=Math.min(Math.max(2,l-a+1),o+2),c=[],d=[];for(let P=0;P<u;P++){let C=this.inputs.path.isClosed?(P+a)%e.length:Math.min(P+a,e.length-1);c.push(e[C].clone()),d.push(n[C].clone())}let h=(P,C,D)=>{c[P]=c[P].clone().lerp(c[C],D),d[P]=pH(d[P],d[C],D)},f=0,g=s*o%1;(!this.inputs.path.isClosed||i<=1)&&(g||s===0)&&(f=g,h(0,1,f));let p=0,m=(s+i)*o%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&s+i<1)&&m&&(p=m,h(c.length-1,c.length-2,1-p)),i===0){let P=c.length-1;c[P].copy(c[0]),d[P].copy(d[0])}this._applyPathModifiers(d,f,p);let{regions:y,infos:v,vertices:x}=this._computeShapePoints(5),b=0,w=0;v.sort((P,C)=>P.start-C.start),v.forEach(P=>{P.verticesStart=b,P.verticesCount=P.continuous.reduce((C,D,B)=>C+(B===0||!D?2:1),0),w+=P.verticesCount,b=w});let A=w*u,T,S=0;if(this._isOpenEnded()){try{T=Bi({windingRule:ft.ODD,elementType:Jt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:y})}catch{T=$x}S=T.vertexCount}let E=A+2*S,M={positions:new Float32Array(E*3),normals:new Float32Array(E*3),uvs:new Float32Array(E*2)},I=[];v.forEach(P=>{this._extrudeRegion(P,x,d,c,M,I,this._isGeometryClosed()&&!this._isOpenEnded())}),T&&(this._closeEnd(T,A,I,M,d[0],c[0],!1),this._closeEnd(T,A+S,I,M,d[d.length-1],c[c.length-1],!0)),this.setAttribute("position",new Be(M.positions,3)),this.setAttribute("normal",new Be(M.normals,3)),this.setAttribute("uv",new Be(M.uvs,2)),this.setIndex(I)}_extractPathPoints(){let n=sg(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(n.length<2)return[];let i=[n[0]];return n.forEach(o=>{i[i.length-1].distanceToSquared(o)>.001&&i.push(o)}),this.inputs.path.isClosed&&i[i.length-1].distanceTo(i[0])<.001&&i.pop(),i}_computeBasisMatrices(e){let n=[],i=e.length,s=this.inputs.path.isClosed,o=new _,a=new _,l=new _,u=new _,c=new _(0,1,0);for(let m=0;m<i;m++){let y=e[m],v;m===0?v=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):v=e[m-1];let x;m===i-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[m-1]):x=e[m+1];let b=y.clone().sub(v).normalize(),w=x.clone().sub(y).normalize(),A=b.clone().add(w).normalize();l.copy(A),m===0&&(A.equals(c)||A.clone().negate().equals(c))&&c.set(0,0,1);let T=c.clone().cross(A).normalize(),S=A.clone().cross(T).normalize();c.copy(S),u.copy(T),m===0&&(o.copy(S),a.copy(A));let E=new de().makeBasis(T,S,A);n.push(E)}let d=s?a:l,h=s?o:new _(0,1,0),f=d.clone().cross(u).normalize(),g=Math.acos(h.dot(f));if(isNaN(g))return n;let p=h.clone().cross(f);d.dot(p)>0&&(g*=-1);for(let m=1;m<n.length;m++){let y=new de().makeRotationZ(g*m/n.length);n[m].multiply(y)}return n}_applyPathModifiers(e,n,i){let s=e.length,{angle:o,twist:a,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new de,d=new de;return e.forEach((h,f)=>{let g=f===0?0:f===s-1?1:(f-n)/(s-(i===0?0:1)-(n+(1-i)));c.makeRotationZ(Ve.lerp(o,o+a,g));let p=Ve.lerp(l,u,g);d.makeScale(p,p,p),h.multiply(c).multiply(d)}),e}_computeShapePoints(e=12,n=ft.ODD){let i=this.inputs.shapeData,s=i.extractShapePointsToFlatArray([],e),o=i.shapeHoles.map(p=>{let m=p.extractShapePointsToFlatArray([],e),y=[];for(let v=m.length-1;v>=1;v-=2){let x=m[v-1],b=m[v-0];y.push(x,b)}return y}),a;try{a=Bi({windingRule:n,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=Mh}let l;try{l=Bi({windingRule:ft.ODD,elementType:Jt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=Jx}if(!a)throw new Error("error generating geometry");let u=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let p=0;p<l.elements.length;p++){let m=l.elements[p],y=p%2===0?a.vertexCount:0;a.elements.push(m+y)}for(let p=0;p<l.vertexIndices.length;p++){let m=l.vertexIndices[p],y=a.vertexCount;a.vertexIndices.push(m+y)}for(let p=0;p<l.vertices.length;p++){let m=l.vertices[p];a.vertices.push(m)}}let c=1/0,d=-1/0,h=1/0,f=-1/0;for(let p=0,m=a.vertexCount;p<m;p++){let y=p*2,v=a.vertices[y+0],x=a.vertices[y+1];v<c&&(c=v),v>d&&(d=v),x<h&&(h=x),x>f&&(f=x)}let g=[];for(let p=a.elementCount-1;p>=0;p--){let m=p>=u,y=p*2,v=a.elements[y+0],x=a.elements[y+1],b=v+x,w={start:v,count:x,normals:[],isHole:m,continuous:[],verticesStart:0,verticesCount:0};g.push(w);let A=v,T=b-1,S=v+1,E=i.roundedCurves.length;do{let M=A-v,I=a.vertices[T*2+0],P=a.vertices[T*2+1],C=a.vertices[A*2+0],D=a.vertices[A*2+1],B=a.vertices[S*2+0],k=a.vertices[S*2+1],X=C-I,W=D-P,q=Math.sqrt(X*X+W*W);X/=q,W/=q;let H=C-B,K=D-k,R=Math.sqrt(H*H+K*K);H/=R,K/=R,w.normals[M*2+0]=-K,w.normals[M*2+1]=H;let U=a.vertexIndices[A];if(Array.isArray(U))w.continuous[M]=!1;else{let[z,j]=i.getCurveIndexFromVertexId(U-1,!0);if(j>0&&j<1)w.continuous[M]=!0;else{let G=j===1?z+1:z-1;G=(G+E)%E;let re=j===1?0:1,Z=i.roundedCurves[z].getTangent(j),J=i.roundedCurves[G].getTangent(re);w.continuous[M]=Z.dot(J)>.95}}m&&(w.normals[M*2+0]*=-1,w.normals[M*2+1]*=-1),[T,A,S]=[A,S,S+1],S>=b&&(S-=x)}while(S!==v+1)}return{regions:[s,...o],infos:g,vertices:a.vertices}}_insertVertex(e,n,i,s,o){let a=n*2,l=n*3;e.positions[l+0]=i.x,e.positions[l+1]=i.y,e.positions[l+2]=i.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,i,s,o,a,l){let u=new _,c=new _,d=new _,h=new _,f=new F;i.forEach((p,m)=>{let y=s[m],v=e.verticesStart*i.length+e.verticesCount*m;for(let x=0;x<e.count;x++){let b=(e.start+x)*2;if(u.set(n[b+0],n[b+1],0),d.copy(u).applyMatrix4(p).add(y),e.continuous[x])h.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),h.copy(u).sub(c),h.set(-h.y,h.x,0),e.isHole||h.negate()}if(h.applyMatrix4(p).normalize(),f.set(x===0?1:x/e.count,m/(i.length-1)),this._insertVertex(o,v,d,h,f),v++,!e.continuous[x]||x===0){if(x===0)h.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,m/(i.length-1));else{let w=x===e.count-1?e.start*2:b+2;c.set(n[w+0],n[w+1],0),h.copy(c).sub(u),h.set(-h.y,h.x,0),e.isHole||h.negate()}h.applyMatrix4(p).normalize(),this._insertVertex(o,v,d,h,f),v++}}});let g=i.length-1;for(let p=0;p<g;p++){let m=e.verticesStart*i.length+e.verticesCount*p,y=e.verticesStart*i.length+e.verticesCount*(p+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=m+v,A=m+b,T=y+b,S=y+v;e.isHole?a.push(w,T,A,w,S,T):a.push(w,A,T,w,T,S),v++}}}_closeEnd(e,n,i,s,o,a,l){let u=e.vertexCount,c=new _(0,0,l?-1:1).applyMatrix4(o),d=new _,h=new F;for(let g=0;g<u;g++){let p=2*g;d.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(o).add(a),this._insertVertex(s,n+g,d,c,h)}let f=e.elements;for(let g=0;g<e.elementCount;g++){let p=3*g,m=f[p+0]+n,y=f[p+(l?1:2)]+n,v=f[p+(l?2:1)]+n;i.push(m,y,v)}}};function mH(){let r=new Te;return r.setAttribute("position",new Be(new Float32Array([]),3)),r.setIndex(new Be(new Uint16Array([]),1)),r}var gH=12,yH=1,bu=class extends Te{constructor(e,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];this.userData={parameters:e,type:"TextGeometry"};let i=n.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,n).then(()=>{this.update(e),n?.requestRender()})}async updateFont(e,n){let i=n.getFont(e);i&&(this.font=i,await i.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:i,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=e,d=c===2?u.toUpperCase():c===3?u.toLowerCase():u,h=vH(e,n,d),{shapes:f,charWidths:g,charCoords:p}=n.generateShapes(h,e),m=i*.5,y=s*.5,v=f.map(w=>new St().fromShape(w));this.vectorShapes=v;let x=v.map(w=>Ir.create({shape:w,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?ft.NONZERO:ft.ODD,subdivisions:this.isLowResolution&&o>0?yH:gH}})),b=x.length?eo(x):mH();b.translate(-m,y,0),this.dispose(),this.wrappedText=h,this.charCoords=p,this.charWidths=g,this.deleteAttribute("extrudeNormal"),Object.entries(b.attributes).forEach(([w,A])=>{this.setAttribute(w,A)}),this.setIndex(b.index),this.computeBoundingSphere()}clone(){let e=Oi(new Te,bu.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([n,i])=>{this.setAttribute(n,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function vH(r,t,e){e=e??r.text;let n=[""],i="";for(let s of e)i+=s,s===" "||s===`
|
|
3139
3139
|
`?(n[n.length-1]+=i,i="",s===`
|
|
3140
|
-
`&&n.push("")):t.getTextWidth(n[n.length-1]+i,r)>r.width&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+i,r)>r.width&&(i.length===1?(n[n.length-1]+=i,i=""):(n[n.length-1]+=i.slice(0,-1),i=i[i.length-1],n.push(""))));return n[n.length-1]+=i,n}var eC,Su=new Promise(r=>{eC=r}),$M=!1;async function tC(){if($M)return;let t=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.272/build",[e,n]=await Promise.all([import("./process.js"),fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});eC(s),$M=!0}function il(r,t,e){let n={parameters:r,type:r.type};if(r.type==="PathGeometry")n.path=r.path;else if(r.type==="VectorGeometry"){let s=St.createFromState(r.shape,r.width,r.height);n.shape=s}else if(r.type==="NonParametricGeometry")r.data.groups&&r.data.groups.forEach(s=>s.materialIndex=Math.max(s.materialIndex??0,0)),n.geometry=new Jl().parse(r);else{if(r.type==="SubdivGeometry")return new dn(r,e);if(r.type==="TextGeometry")return new bu(r,t)}let i;try{i=lb(n)}catch(s){console.error(s)}if(!i){let s=St.createFromState(zc.defaultData(),100,100);n.shape=s,i=lb(n)}return i}var xH=new de;function Ih(r,t,e,n){let i=r.position.array,s=r.normal.array,o=xH.makeScale(t,e,n).invert().elements,a,l,u;for(var c=0,d=i.length;c<d;c+=3)i[c]*=t,i[c+1]*=e,i[c+2]*=n,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u;r.position.needsUpdate=!0,r.normal.needsUpdate=!0}var xg=new xt,wu=new _,We;Su.then(r=>{We=r});var nC=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),rC=new Uint32Array([0,1,2,3]),iC=new Uint8Array([4]),dn=class extends Te{constructor(e,n){super();this.data=e;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,n){this.freeSubdivPointer();let i=this.data.scaleBaked,s=ss.div(n,i);this.subdividedGeometry&&Ih(this.subdividedGeometry.attributes,...s),this.originalGeometry&&Ih(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(wu.fromArray(s));let a=wu.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,i;try{({originalGeometry:e,subdividedGeometry:n,subdivPointer:i}=dn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Gn(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(dn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Sn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,i=e.boundingSphere.center;xg.setFromBufferAttribute(n),xg.getCenter(i),e.boundingSphere.radius=i.distanceTo(xg.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),xg.getSize(wu);let s={width:wu.x,height:wu.y,depth:wu.z};return this.userData.parameters=s,s}static build(e,n,i,s){let o,a,l,u=e?.phongAngle??35;i===!1&&(u=-1),n&&(We.free_bvh(n),We.free_subdivision_surface(n));try{o=dn.allocate(e,s)}catch(c){console.error(c,e),o=dn.allocate({positionWASM:nC,indexWASM:rC,verticesPerFaceWASM:iC},s)}if(We.set_destination_refinement_level(o,0),a=dn.buildLevel(o,!0,u),e.subdivisions>0)try{We.set_destination_refinement_level(o,e.subdivisions),l=dn.buildLevel(o,!1,u)}catch{try{We.set_destination_refinement_level(o,e.subdivisions-1),l=dn.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,n,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s;if(e.type==="TorusGeometry"&&e.arc===Math.PI*2){let{width:d,height:h,depth:f,arc:g,tubularSegments:p,radialSegments:m}=e;s=new nl(!0,d,f,h,d*.5,g/(2*Math.PI),p,f/2,0,m,0,0,!0)}else s=e.shape!==void 0?n.geometry:il(e,i,!1);let o,a,l,u;({positions:o,triIndices:u}=Dh(s.getAttribute("position"),s.getIndex()));let c;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,h=d+e.radialSegments*3;c=[d,h]}return{indices:a,verticesPerFace:l}=hb(o,u,s,c),{positions:o,indices:a,verticesPerFace:l}}static allocate(e,n){let i,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(i=nC,s=rC,o=iC);let u=i.length,c=s.length,d=o.length,h=i.length+a.length+l.length,f=s.length+o.length,g=h*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,p=h*Float32Array.BYTES_PER_ELEMENT,m=f*Uint32Array.BYTES_PER_ELEMENT,y=We._malloc(g),v=new Float32Array(We.HEAPF32.buffer,y,h),x=new Uint32Array(We.HEAPU32.buffer,y+p,f);v.set(i,0),v.set(a,i.length),v.set(l,i.length+a.length),x.set(s,0),x.set(o,s.length);let b;e?.scaleBaked?.some(A=>A!==1)&&(b=new de().makeScale(...e.scaleBaked)),n&&(b?b.premultiply(n):b=n);let w=b?We.alloc_subdivision_surface2(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d,b.elements):We.alloc_subdivision_surface(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return We._free(y),w}static buildLevel(e,n,i,s,o){let a=o?We.get_mesh_data2(e,n?We.Level.CONTROL:We.Level.REFINED,i,o.elements):We.get_mesh_data(e,n?We.Level.CONTROL:We.Level.REFINED,i),l=8,u=We.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=We.HEAPU32[u[d]>>2],f=We.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let g=We.HEAPU32[u[d]>>2],p=We.HEAPF32.subarray(g>>2,(g>>2)+c[d]);d++;let m=We.HEAPU32[u[d]>>2],y=We.HEAPU32.subarray(m>>2,(m>>2)+c[d]);d++;let v=We.HEAPU32[u[d]>>2],x=We.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let b=new Te;if(b.setIndex(new To(x,1)),b.setAttribute("position",new we(f,3)),b.setAttribute("normal",new we(p,3)),n){b.setAttribute("faceMap",new To(y,1));let w=new Float32Array(p.length/3*4).fill(0);b.setAttribute("color",new Be(w,4))}return We.free_mesh_data(a),b.userData.type="SubdivGeometry",b}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(p),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,We.free_mesh_data(a)}static freeSubdivPointer(e){We.free_bvh(e),We.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,i){let s=We.get_wireframe_data_for_base_level(e),o=4,a=We.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=We.HEAPU32[a[u]>>2],d=We.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=We.HEAPU32[a[u]>>2],f=We.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let g=new Te;g.setAttribute("position",new we(d,3));let p=new Float32Array(d.length);for(let m=0,y=d.length;m<y;)p[m++]=i.r,p[m++]=i.g,p[m++]=i.b;return g.setAttribute("color",new Be(p,3)),g.setIndex(new To(f,1)),We.free_wireframe_data_for_base_level(s),g}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,We.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,i){let s=n===0;s||We.set_destination_refinement_level(e,n);let o=i?We.get_topological_data2(e,s?We.Level.CONTROL:We.Level.REFINED,i.elements):We.get_topological_data(e,s?We.Level.CONTROL:We.Level.REFINED),a=6,l=We.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=We.HEAPU32[l[c]>>2],h=new Float32Array(We.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=We.HEAPU32[l[c]>>2],g=new Uint32Array(We.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let p=We.HEAPU32[l[c]>>2],m=new Uint8Array(We.HEAPU32.subarray(p>>2,(p>>2)+u[c]));return We.free_topological_data(o),{positions:h,indices:g,verticesPerFace:m}}};var sC=["getX","getY","getZ"];function Dh(r,t){let e={},n=t?t.count:r.count,i=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=t?t.getX(u):u,d="";for(let h=0;h<3;h++)d+=`${~~(r[sC[h]](c)*a)},`;if(d in e)s.push(e[d]);else{for(let h=0;h<3;h++)o.push(r[sC[h]](c));e[d]=i,s.push(i),i++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var bg=new _,cb=new _,ub=new _,db=new _;function hb(r,t,e,n){let i=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let o=e.userData.shape.extractShapePointsToFlatArray([]),a=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&a<=24&&a%4===0&&e.userData.parameters.angle>=360){let c=o.length/2/a;o=o.filter((d,h)=>Math.floor(h/2)%c===0)}let l=0;for(let c=0;c<o.length;c+=2)l+=(o[c]-o[(c===0?o.length:c)-2])*(o[c+1]+o[(c===0?o.length:c)-1]);r.length=0;let u=0;if(l<0)for(let c=0;c<o.length;c+=2)r.push(o[c],o[c+1],0),i.push(u++);else for(let c=o.length-2;c>=0;c-=2)r.push(o[c],o[c+1],0),i.push(u++);return s.push(u),{indices:i,verticesPerFace:s}}for(let o=0,a=e.capStartIndex??t.length;o<a;)if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){bg.set(r[t[o]*3],r[t[o]*3+1],r[t[o]*3+2]),cb.set(r[t[o+1]*3],r[t[o+1]*3+1],r[t[o+1]*3+2]),ub.set(r[t[o+4]*3],r[t[o+4]*3+1],r[t[o+4]*3+2]),db.set(r[t[o+5]*3],r[t[o+5]*3+1],r[t[o+5]*3+2]),cb.sub(bg).normalize(),ub.sub(bg).normalize(),db.sub(bg).normalize();let l=cb.cross(ub).dot(db);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(i.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3):(i.push(t[o],t[o+1],t[o+4],t[o+5]),s.push(4),o+=6)}else i.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3;if(e.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([e.userData.parameters.depth])[0];for(let c=0,d=0;c<r.length;c+=3,d++)r[c+2]===0&&(o.push(d),l++),r[c+2]===u&&a.push(d);if(e.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),i.push(...o,...a),s.push(l,l)}return{indices:i,verticesPerFace:s}}var Fi={};yI(Fi,{calcBoolean:()=>wH,calcBooleanTopological:()=>SH,freeMeshSet:()=>TH,getMeshSet:()=>AH,transformMeshSet:()=>_H});var aC,lC=new Promise(r=>{aC=r}),oC=!1;async function cC(){if(oC)return;let t=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.272/build",[e,n]=await Promise.all([import("./boolean.js"),fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});aC(s),oC=!0}var lt,Au;lC.then(r=>lt=r);function bH(r,t,e){let n,{positions:i,triIndices:s}=Dh(r.getAttribute("position"),r.getIndex()),o;if(t&&e){let{indices:a,verticesPerFace:l}=hb(i,s,r);o=l.length,n=[];for(let u=0,c=0;u<o;u++){n.push(l[u]);for(let d=0;d<l[u];d++)n.push(a[c++])}}else{let a=s.length;n=Array(a+a/3),o=0;for(let l=0,u=0;u<n.length;)n[u++]=3,o++,n[u++]=s[l++],n[u++]=s[l++],n[u++]=s[l++]}return{positions:i,faceIndices:n,nFaces:o}}function uC(r){let t=r.length,e=t*Uint32Array.BYTES_PER_ELEMENT,n=t*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?e:n,s=lt._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(lt.HEAPU32.buffer,s,t):new Float32Array(lt.HEAPF32.buffer,s,t)).set(r,0),s}function dC(r){switch(r){case 0:return lt.OP.UNION;case 1:return lt.OP.INTERSECTION;case 2:return lt.OP.A_MINUS_B;case 3:return lt.OP.B_MINUS_A;case 4:return lt.OP.SYMMETRIC_DIFFERENCE;case 5:return lt.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function SH(r,t){Au===void 0&&(Au=lt.init_csg());let e=uC(r),n=lt.csg_calc_topological(Au,e,r.length,dC(t));lt._free(e);let i=6,s=lt.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=lt.HEAPU32[s[a]>>2],u=new Float32Array(lt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=lt.HEAPU32[s[a]>>2],d=new Uint32Array(lt.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let h=lt.HEAPU32[s[a]>>2],f=new Uint8Array(lt.HEAPU32.subarray(h>>2,(h>>2)+o[a]));return lt.free_mesh_data(n),{positions:u,indices:d,verticesPerFace:f}}function wH(r,t,e,n){Au===void 0&&(Au=lt.init_csg());let i=uC(r),s=lt.csg_calc(Au,i,r.length,n,dC(t));lt._free(i);let o=5,a=lt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=lt.HEAPU32[a[u]>>2],d=lt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=lt.HEAPU32[a[u]>>2],f=lt.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let g=l[u];e.setAttribute("position",new we(d,3)),e.setAttribute("normal",new we(f,3));let p=lt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Sn),e.boundingSphere.center.set(p[0],p[1],p[2]),e.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,e.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},lt.free_mesh_data(s),g}function AH(r,t,e){if(lt===void 0)return-1;let n,i,s;if(t&&r.userData.positions!==void 0){let m=r.userData;s=m.verticesPerFace.length,n=m.positions,i=Array(m.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<m.verticesPerFace.length;y++){i[x++]=m.verticesPerFace[y];for(let b=0;b<m.verticesPerFace[y];b++)i[x++]=m.indices[v++]}}else({positions:n,faceIndices:i,nFaces:s}=bH(r,t,e));let o=n.length,a=i.length,l=n.length,u=i.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,h=u*Uint32Array.BYTES_PER_ELEMENT,f=lt._malloc(c),g=new Float32Array(lt.HEAPF32.buffer,f,l),p=new Uint32Array(lt.HEAPU32.buffer,f+d,u);return g.set(n,0),p.set(i,0),lt.get_csg_mesh(f,o,f+d,a,s)}function _H(r,t){lt.transform_csg_mesh(r,t.elements)}function TH(r){lt.free_csg_mesh(r)}var EH={ConeGeometry:cM,CubeGeometry:uM,CylinderGeometry:lM,DodecahedronGeometry:dM,EllipseGeometry:yu,HelixGeometry:BM,IcosahedronGeometry:FM,LatheGeometry:UM,NonParametricGeometry:VM,PolygonGeometry:gg,PyramidGeometry:HM,RectangleGeometry:yg,SphereGeometry:WM,PlaneGeometry:jM,BackdropGeometry:qM,StarGeometry:vg,TextFrameGeometry:XM,TorusGeometry:YM,TorusKnotGeometry:KM,TriangleGeometry:ZM,PathGeometry:JM,VectorGeometry:Ir},lb=r=>EH[r.type].create(r);function Oh(r){return r!==null&&"booleanOp"in r}var _u=class extends og(Un){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new de}updateVisible(){super.updateVisible(),this.visible=!Oh(this.parent)&&this.visible,Oh(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(),Oh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof _u&&(e.freeBooleanPointer(),Oh(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let n=super.updateTransformState(e);return n&&Oh(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}};var Sg=new xt;function Lh(r,t=0,e=r.count,n,i){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let h=r.getX(d),f=r.getY(d),g=r.getZ(d);h<s&&(s=h),f<o&&(o=f),g<a&&(a=g),h>l&&(l=h),f>u&&(u=f),g>c&&(c=g)}Sg.min.set(s,o,a),Sg.max.set(l,u,c),Sg.getCenter(n),Sg.getSize(i).multiplyScalar(.5)}var MH=new Te,CH=new zs,Vt=class extends _u{constructor(t,e){super(MH,CH),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?Lh(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var Rh=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 Xn=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Ve.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 i={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),i}build(t,e,n){e=e??this.getType(t,e);let i=t.getNodeData(n??this);return t.analyzing&&this.appendDepsNode(t,i,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,i,s,o){return""}generate(t,e,n,i,s){return""}parse(t,e,n,i){}appendDepsNode(t,e,n){e.deps=(e.deps||0)+1;let i=t.getTypeLength(n);(i>(e.outputMax||0)||this.getType(t,n))&&(e.outputMax=i,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 Xn&&(t+='"'+e+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)e=this.hashProperties[i],n=this[e],t+='"'+e+'":"'+String(n)+'",';return t+='"id":"'+this.uuid+'"}',t}};var fb=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}},On=new fb;var ze=class extends Xn{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,i,s){if(n=n??this.getType(e),this.getShared(e,n)){let o=this.getUnique(e,n);o&&this.uuid===void 0&&(this.uuid=Ve.generateUUID()),i=e.getUUID(i??this.getUUID(),!o);let a=e.getNodeData(i),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,i)):super.build(e,n,i);if(o)return a.name=a.name||super.build(e,n,i),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,n,i);i=this.getUUID(!1);let u=this.getTemp(e,i);if(u)return e.format(u,l,n);{u=super.generate(e,n,i,a.output,s);let c=this.generate(e,l,i);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,n)}}return super.build(e,n,i)}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 i=e.getVars()[n];return i?i.name:void 0}generate(e,n,i,s,o){return this.getShared(e,n)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,s??this.getType(e),o,this.getLabel()).name}};var Lt=class extends ze{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,i,s,o,a){i=e.getUUID(i??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,n,i,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 Yn=class extends Lt{constructor(e=0,n){super("v2");this.nodeType="Vector2";this.value=e instanceof F?e:new F(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,i,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var er=class extends Lt{constructor(e=0,n,i){super("v3");this.nodeType="Vector3";this.value=e instanceof _?e:new _(e,n,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,n,i,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var Yt=class extends Le{constructor(e,n,i,s){super(e,n,i);this.isColorA=!0;this.a=s}setRGBA(e,n,i,s){super.setRGB(e,n,i),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 i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=i[1],a=i[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 pi=class extends Lt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Yt?e:new Yt(e.r,e.g,e.b,e.a)}generateReadonly(e,n,i,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var PH=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,hC=/[a-z_0-9]+/gi,Ae=class extends ze{constructor(e,n,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,n,i,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,i,s,o){let a,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;a=hC.exec(this.src);)c.push(a);for(let d=0;d<c.length;d++){let h=c[d],f=h[0],g=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&g&&On.containsKeyword(f)){let m=this.keywords[f];if(!m){let y=On.getKeywordData(f);y.cache&&(m=e.keywords[f]),m=m||On.getKeyword(f,e),y.cache&&(e.keywords[f]=m)}p=m.build(e)}f!==p&&u[h.index+l-1]!=="."&&(u=u.substring(0,h.index+l)+p+u.substring(h.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&On.contains(p)&&e.include(On.get(p))}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,i,s){if(this.src=e||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=PH.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(hC);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let d=a[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var IH=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,pb=class extends ze{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||pb.PI,void 0,void 0,void 0,n)}getType(e){return e.getTypeByFormat(this.type)}parse(e,n,i,s,o){this.src=e||"";let a,l,u="",c=IH.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,i,s,o){return e.format(this.name,this.getType(e),n)}},vt=pb;vt.PI="PI",vt.PI2="PI2",vt.RECIPROCAL_PI="RECIPROCAL_PI",vt.RECIPROCAL_PI2="RECIPROCAL_PI2",vt.LOG2="LOG2",vt.EPSILON="EPSILON";var DH=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3140
|
+
`&&n.push("")):t.getTextWidth(n[n.length-1]+i,r)>r.width&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+i,r)>r.width&&(i.length===1?(n[n.length-1]+=i,i=""):(n[n.length-1]+=i.slice(0,-1),i=i[i.length-1],n.push(""))));return n[n.length-1]+=i,n}var eC,Su=new Promise(r=>{eC=r}),$M=!1;async function tC(){if($M)return;let t=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.275/build",[e,n]=await Promise.all([import("./process.js"),fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});eC(s),$M=!0}function il(r,t,e){let n={parameters:r,type:r.type};if(r.type==="PathGeometry")n.path=r.path;else if(r.type==="VectorGeometry"){let s=St.createFromState(r.shape,r.width,r.height);n.shape=s}else if(r.type==="NonParametricGeometry")r.data.groups&&r.data.groups.forEach(s=>s.materialIndex=Math.max(s.materialIndex??0,0)),n.geometry=new Jl().parse(r);else{if(r.type==="SubdivGeometry")return new dn(r,e);if(r.type==="TextGeometry")return new bu(r,t)}let i;try{i=lb(n)}catch(s){console.error(s)}if(!i){let s=St.createFromState(zc.defaultData(),100,100);n.shape=s,i=lb(n)}return i}var xH=new de;function Ih(r,t,e,n){let i=r.position.array,s=r.normal.array,o=xH.makeScale(t,e,n).invert().elements,a,l,u;for(var c=0,d=i.length;c<d;c+=3)i[c]*=t,i[c+1]*=e,i[c+2]*=n,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u;r.position.needsUpdate=!0,r.normal.needsUpdate=!0}var xg=new xt,wu=new _,We;Su.then(r=>{We=r});var nC=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),rC=new Uint32Array([0,1,2,3]),iC=new Uint8Array([4]),dn=class extends Te{constructor(e,n){super();this.data=e;this.flatShading=n;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,n){this.freeSubdivPointer();let i=this.data.scaleBaked,s=ss.div(n,i);this.subdividedGeometry&&Ih(this.subdividedGeometry.attributes,...s),this.originalGeometry&&Ih(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(wu.fromArray(s));let a=wu.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,i;try{({originalGeometry:e,subdividedGeometry:n,subdivPointer:i}=dn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Gn(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=n??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(dn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Sn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,i=e.boundingSphere.center;xg.setFromBufferAttribute(n),xg.getCenter(i),e.boundingSphere.radius=i.distanceTo(xg.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),xg.getSize(wu);let s={width:wu.x,height:wu.y,depth:wu.z};return this.userData.parameters=s,s}static build(e,n,i,s){let o,a,l,u=e?.phongAngle??35;i===!1&&(u=-1),n&&(We.free_bvh(n),We.free_subdivision_surface(n));try{o=dn.allocate(e,s)}catch(c){console.error(c,e),o=dn.allocate({positionWASM:nC,indexWASM:rC,verticesPerFaceWASM:iC},s)}if(We.set_destination_refinement_level(o,0),a=dn.buildLevel(o,!0,u),e.subdivisions>0)try{We.set_destination_refinement_level(o,e.subdivisions),l=dn.buildLevel(o,!1,u)}catch{try{We.set_destination_refinement_level(o,e.subdivisions-1),l=dn.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,n,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s;if(e.type==="TorusGeometry"&&e.arc===Math.PI*2){let{width:d,height:h,depth:f,arc:g,tubularSegments:p,radialSegments:m}=e;s=new nl(!0,d,f,h,d*.5,g/(2*Math.PI),p,f/2,0,m,0,0,!0)}else s=e.shape!==void 0?n.geometry:il(e,i,!1);let o,a,l,u;({positions:o,triIndices:u}=Dh(s.getAttribute("position"),s.getIndex()));let c;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,h=d+e.radialSegments*3;c=[d,h]}return{indices:a,verticesPerFace:l}=hb(o,u,s,c),{positions:o,indices:a,verticesPerFace:l}}static allocate(e,n){let i,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(i=nC,s=rC,o=iC);let u=i.length,c=s.length,d=o.length,h=i.length+a.length+l.length,f=s.length+o.length,g=h*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,p=h*Float32Array.BYTES_PER_ELEMENT,m=f*Uint32Array.BYTES_PER_ELEMENT,y=We._malloc(g),v=new Float32Array(We.HEAPF32.buffer,y,h),x=new Uint32Array(We.HEAPU32.buffer,y+p,f);v.set(i,0),v.set(a,i.length),v.set(l,i.length+a.length),x.set(s,0),x.set(o,s.length);let b;e?.scaleBaked?.some(A=>A!==1)&&(b=new de().makeScale(...e.scaleBaked)),n&&(b?b.premultiply(n):b=n);let w=b?We.alloc_subdivision_surface2(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d,b.elements):We.alloc_subdivision_surface(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return We._free(y),w}static buildLevel(e,n,i,s,o){let a=o?We.get_mesh_data2(e,n?We.Level.CONTROL:We.Level.REFINED,i,o.elements):We.get_mesh_data(e,n?We.Level.CONTROL:We.Level.REFINED,i),l=8,u=We.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=We.HEAPU32[u[d]>>2],f=We.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let g=We.HEAPU32[u[d]>>2],p=We.HEAPF32.subarray(g>>2,(g>>2)+c[d]);d++;let m=We.HEAPU32[u[d]>>2],y=We.HEAPU32.subarray(m>>2,(m>>2)+c[d]);d++;let v=We.HEAPU32[u[d]>>2],x=We.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let b=new Te;if(b.setIndex(new To(x,1)),b.setAttribute("position",new we(f,3)),b.setAttribute("normal",new we(p,3)),n){b.setAttribute("faceMap",new To(y,1));let w=new Float32Array(p.length/3*4).fill(0);b.setAttribute("color",new Be(w,4))}return We.free_mesh_data(a),b.userData.type="SubdivGeometry",b}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(p),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,We.free_mesh_data(a)}static freeSubdivPointer(e){We.free_bvh(e),We.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,i){let s=We.get_wireframe_data_for_base_level(e),o=4,a=We.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=We.HEAPU32[a[u]>>2],d=We.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=We.HEAPU32[a[u]>>2],f=We.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let g=new Te;g.setAttribute("position",new we(d,3));let p=new Float32Array(d.length);for(let m=0,y=d.length;m<y;)p[m++]=i.r,p[m++]=i.g,p[m++]=i.b;return g.setAttribute("color",new Be(p,3)),g.setIndex(new To(f,1)),We.free_wireframe_data_for_base_level(s),g}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,We.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,i){let s=n===0;s||We.set_destination_refinement_level(e,n);let o=i?We.get_topological_data2(e,s?We.Level.CONTROL:We.Level.REFINED,i.elements):We.get_topological_data(e,s?We.Level.CONTROL:We.Level.REFINED),a=6,l=We.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=We.HEAPU32[l[c]>>2],h=new Float32Array(We.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=We.HEAPU32[l[c]>>2],g=new Uint32Array(We.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let p=We.HEAPU32[l[c]>>2],m=new Uint8Array(We.HEAPU32.subarray(p>>2,(p>>2)+u[c]));return We.free_topological_data(o),{positions:h,indices:g,verticesPerFace:m}}};var sC=["getX","getY","getZ"];function Dh(r,t){let e={},n=t?t.count:r.count,i=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=t?t.getX(u):u,d="";for(let h=0;h<3;h++)d+=`${~~(r[sC[h]](c)*a)},`;if(d in e)s.push(e[d]);else{for(let h=0;h<3;h++)o.push(r[sC[h]](c));e[d]=i,s.push(i),i++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var bg=new _,cb=new _,ub=new _,db=new _;function hb(r,t,e,n){let i=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let o=e.userData.shape.extractShapePointsToFlatArray([]),a=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&a<=24&&a%4===0&&e.userData.parameters.angle>=360){let c=o.length/2/a;o=o.filter((d,h)=>Math.floor(h/2)%c===0)}let l=0;for(let c=0;c<o.length;c+=2)l+=(o[c]-o[(c===0?o.length:c)-2])*(o[c+1]+o[(c===0?o.length:c)-1]);r.length=0;let u=0;if(l<0)for(let c=0;c<o.length;c+=2)r.push(o[c],o[c+1],0),i.push(u++);else for(let c=o.length-2;c>=0;c-=2)r.push(o[c],o[c+1],0),i.push(u++);return s.push(u),{indices:i,verticesPerFace:s}}for(let o=0,a=e.capStartIndex??t.length;o<a;)if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){bg.set(r[t[o]*3],r[t[o]*3+1],r[t[o]*3+2]),cb.set(r[t[o+1]*3],r[t[o+1]*3+1],r[t[o+1]*3+2]),ub.set(r[t[o+4]*3],r[t[o+4]*3+1],r[t[o+4]*3+2]),db.set(r[t[o+5]*3],r[t[o+5]*3+1],r[t[o+5]*3+2]),cb.sub(bg).normalize(),ub.sub(bg).normalize(),db.sub(bg).normalize();let l=cb.cross(ub).dot(db);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(i.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3):(i.push(t[o],t[o+1],t[o+4],t[o+5]),s.push(4),o+=6)}else i.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3;if(e.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([e.userData.parameters.depth])[0];for(let c=0,d=0;c<r.length;c+=3,d++)r[c+2]===0&&(o.push(d),l++),r[c+2]===u&&a.push(d);if(e.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),i.push(...o,...a),s.push(l,l)}return{indices:i,verticesPerFace:s}}var Fi={};yI(Fi,{calcBoolean:()=>wH,calcBooleanTopological:()=>SH,freeMeshSet:()=>TH,getMeshSet:()=>AH,transformMeshSet:()=>_H});var aC,lC=new Promise(r=>{aC=r}),oC=!1;async function cC(){if(oC)return;let t=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.275/build",[e,n]=await Promise.all([import("./boolean.js"),fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),i=e.default,s=await i({wasmBinary:n});aC(s),oC=!0}var lt,Au;lC.then(r=>lt=r);function bH(r,t,e){let n,{positions:i,triIndices:s}=Dh(r.getAttribute("position"),r.getIndex()),o;if(t&&e){let{indices:a,verticesPerFace:l}=hb(i,s,r);o=l.length,n=[];for(let u=0,c=0;u<o;u++){n.push(l[u]);for(let d=0;d<l[u];d++)n.push(a[c++])}}else{let a=s.length;n=Array(a+a/3),o=0;for(let l=0,u=0;u<n.length;)n[u++]=3,o++,n[u++]=s[l++],n[u++]=s[l++],n[u++]=s[l++]}return{positions:i,faceIndices:n,nFaces:o}}function uC(r){let t=r.length,e=t*Uint32Array.BYTES_PER_ELEMENT,n=t*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?e:n,s=lt._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(lt.HEAPU32.buffer,s,t):new Float32Array(lt.HEAPF32.buffer,s,t)).set(r,0),s}function dC(r){switch(r){case 0:return lt.OP.UNION;case 1:return lt.OP.INTERSECTION;case 2:return lt.OP.A_MINUS_B;case 3:return lt.OP.B_MINUS_A;case 4:return lt.OP.SYMMETRIC_DIFFERENCE;case 5:return lt.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function SH(r,t){Au===void 0&&(Au=lt.init_csg());let e=uC(r),n=lt.csg_calc_topological(Au,e,r.length,dC(t));lt._free(e);let i=6,s=lt.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=lt.HEAPU32[s[a]>>2],u=new Float32Array(lt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=lt.HEAPU32[s[a]>>2],d=new Uint32Array(lt.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let h=lt.HEAPU32[s[a]>>2],f=new Uint8Array(lt.HEAPU32.subarray(h>>2,(h>>2)+o[a]));return lt.free_mesh_data(n),{positions:u,indices:d,verticesPerFace:f}}function wH(r,t,e,n){Au===void 0&&(Au=lt.init_csg());let i=uC(r),s=lt.csg_calc(Au,i,r.length,n,dC(t));lt._free(i);let o=5,a=lt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=lt.HEAPU32[a[u]>>2],d=lt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=lt.HEAPU32[a[u]>>2],f=lt.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let g=l[u];e.setAttribute("position",new we(d,3)),e.setAttribute("normal",new we(f,3));let p=lt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Sn),e.boundingSphere.center.set(p[0],p[1],p[2]),e.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,e.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},lt.free_mesh_data(s),g}function AH(r,t,e){if(lt===void 0)return-1;let n,i,s;if(t&&r.userData.positions!==void 0){let m=r.userData;s=m.verticesPerFace.length,n=m.positions,i=Array(m.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<m.verticesPerFace.length;y++){i[x++]=m.verticesPerFace[y];for(let b=0;b<m.verticesPerFace[y];b++)i[x++]=m.indices[v++]}}else({positions:n,faceIndices:i,nFaces:s}=bH(r,t,e));let o=n.length,a=i.length,l=n.length,u=i.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,h=u*Uint32Array.BYTES_PER_ELEMENT,f=lt._malloc(c),g=new Float32Array(lt.HEAPF32.buffer,f,l),p=new Uint32Array(lt.HEAPU32.buffer,f+d,u);return g.set(n,0),p.set(i,0),lt.get_csg_mesh(f,o,f+d,a,s)}function _H(r,t){lt.transform_csg_mesh(r,t.elements)}function TH(r){lt.free_csg_mesh(r)}var EH={ConeGeometry:cM,CubeGeometry:uM,CylinderGeometry:lM,DodecahedronGeometry:dM,EllipseGeometry:yu,HelixGeometry:BM,IcosahedronGeometry:FM,LatheGeometry:UM,NonParametricGeometry:VM,PolygonGeometry:gg,PyramidGeometry:HM,RectangleGeometry:yg,SphereGeometry:WM,PlaneGeometry:jM,BackdropGeometry:qM,StarGeometry:vg,TextFrameGeometry:XM,TorusGeometry:YM,TorusKnotGeometry:KM,TriangleGeometry:ZM,PathGeometry:JM,VectorGeometry:Ir},lb=r=>EH[r.type].create(r);function Oh(r){return r!==null&&"booleanOp"in r}var _u=class extends og(Un){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new de}updateVisible(){super.updateVisible(),this.visible=!Oh(this.parent)&&this.visible,Oh(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(),Oh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof _u&&(e.freeBooleanPointer(),Oh(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let n=super.updateTransformState(e);return n&&Oh(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}};var Sg=new xt;function Lh(r,t=0,e=r.count,n,i){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let h=r.getX(d),f=r.getY(d),g=r.getZ(d);h<s&&(s=h),f<o&&(o=f),g<a&&(a=g),h>l&&(l=h),f>u&&(u=f),g>c&&(c=g)}Sg.min.set(s,o,a),Sg.max.set(l,u,c),Sg.getCenter(n),Sg.getSize(i).multiplyScalar(.5)}var MH=new Te,CH=new zs,Vt=class extends _u{constructor(t,e){super(MH,CH),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?Lh(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var Rh=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 Xn=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Ve.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 i={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),i}build(t,e,n){e=e??this.getType(t,e);let i=t.getNodeData(n??this);return t.analyzing&&this.appendDepsNode(t,i,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,i,s,o){return""}generate(t,e,n,i,s){return""}parse(t,e,n,i){}appendDepsNode(t,e,n){e.deps=(e.deps||0)+1;let i=t.getTypeLength(n);(i>(e.outputMax||0)||this.getType(t,n))&&(e.outputMax=i,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 Xn&&(t+='"'+e+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)e=this.hashProperties[i],n=this[e],t+='"'+e+'":"'+String(n)+'",';return t+='"id":"'+this.uuid+'"}',t}};var fb=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}},On=new fb;var ze=class extends Xn{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,i,s){if(n=n??this.getType(e),this.getShared(e,n)){let o=this.getUnique(e,n);o&&this.uuid===void 0&&(this.uuid=Ve.generateUUID()),i=e.getUUID(i??this.getUUID(),!o);let a=e.getNodeData(i),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,i)):super.build(e,n,i);if(o)return a.name=a.name||super.build(e,n,i),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,n,i);i=this.getUUID(!1);let u=this.getTemp(e,i);if(u)return e.format(u,l,n);{u=super.generate(e,n,i,a.output,s);let c=this.generate(e,l,i);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,n)}}return super.build(e,n,i)}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 i=e.getVars()[n];return i?i.name:void 0}generate(e,n,i,s,o){return this.getShared(e,n)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,s??this.getType(e),o,this.getLabel()).name}};var Lt=class extends ze{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,i,s,o,a){i=e.getUUID(i??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,n,i,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 Yn=class extends Lt{constructor(e=0,n){super("v2");this.nodeType="Vector2";this.value=e instanceof F?e:new F(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,i,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var er=class extends Lt{constructor(e=0,n,i){super("v3");this.nodeType="Vector3";this.value=e instanceof _?e:new _(e,n,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,n,i,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var Yt=class extends Le{constructor(e,n,i,s){super(e,n,i);this.isColorA=!0;this.a=s}setRGBA(e,n,i,s){super.setRGB(e,n,i),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 i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=i[1],a=i[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 pi=class extends Lt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Yt?e:new Yt(e.r,e.g,e.b,e.a)}generateReadonly(e,n,i,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var PH=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,hC=/[a-z_0-9]+/gi,Ae=class extends ze{constructor(e,n,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,n,i,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,i,s,o){let a,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;a=hC.exec(this.src);)c.push(a);for(let d=0;d<c.length;d++){let h=c[d],f=h[0],g=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&g&&On.containsKeyword(f)){let m=this.keywords[f];if(!m){let y=On.getKeywordData(f);y.cache&&(m=e.keywords[f]),m=m||On.getKeyword(f,e),y.cache&&(e.keywords[f]=m)}p=m.build(e)}f!==p&&u[h.index+l-1]!=="."&&(u=u.substring(0,h.index+l)+p+u.substring(h.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&On.contains(p)&&e.include(On.get(p))}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,i,s){if(this.src=e||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=PH.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(hC);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let d=a[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var IH=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,pb=class extends ze{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||pb.PI,void 0,void 0,void 0,n)}getType(e){return e.getTypeByFormat(this.type)}parse(e,n,i,s,o){this.src=e||"";let a,l,u="",c=IH.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,i,s,o){return e.format(this.name,this.getType(e),n)}},vt=pb;vt.PI="PI",vt.PI2="PI2",vt.RECIPROCAL_PI="RECIPROCAL_PI",vt.RECIPROCAL_PI2="RECIPROCAL_PI2",vt.LOG2="LOG2",vt.EPSILON="EPSILON";var DH=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3141
3141
|
)*?)}`,"gim"),OH=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Tu=class extends ze{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,i,s,o){return n==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),n)}parse(e=""){this.src=e,this.inputs=[];let n=DH.exec(e);if(n){let i=n[2],s;for(;s=OH.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=n[1]}else this.name="";this.type=this.name}};var Eu=class extends ze{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,n){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",s=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(s,this.getType(e),n)}};On.addKeyword("uv",function(){return new Eu});On.addKeyword("uv2",function(){return new Eu(1)});var sl=class extends ze{constructor(e,n){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=n??sl.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case jr:return["Linear"];case Xe:return["sRGB"];default:return[]}}generate(e,n){let i=this.input.build(e,"v4"),s=this.getType(e),o=sl.Nodes[this.method],a=e.include(o);if(a===sl.LINEAR_TO_LINEAR)return e.format(i,s,n);if(o.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+i+", "+l+" )",s,n)}else return e.format(a+"( "+i+" )",s,n)}fromEncoding(e){let n=sl.getEncodingComponents(e);this.method="LinearTo"+n[0],this.factor=n[1]}fromDecoding(e){let n=sl.getEncodingComponents(e);this.method=n[0]+"ToLinear",this.factor=n[1]}},br=sl;br.Nodes={LinearToLinear:new Ae(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3142
3142
|
`)),sRGBToLinear:new Ae(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
|
|
3143
3143
|
`)),LinearTosRGB:new Ae(["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(`
|
|
@@ -4468,7 +4468,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
|
|
|
4468
4468
|
|
|
4469
4469
|
return color.xyz;
|
|
4470
4470
|
|
|
4471
|
-
}`,[sr.simplex,e,i,o])}}();function yC(r,t,e){r.setUvTransform(e[0],e[1],t[0],t[1],0,0,0)}var Ig=class extends Pu{constructor(e,n){super(new nn);this.repeat=e;this.offset=n;yC(this.value,e,n)}updateMatrix(){yC(this.value,this.repeat,this.offset)}};var ps=class{constructor(t,e,n,i){this.id=t;this.uuid=e;this.data=n;this.uniforms={};for(let s in i)this.uniforms[`f${this.id}_${s}`]=i[s];for(let s in n)Pb(s,this,n)}get type(){return this.data.type}static create(t,e,n,i){if(n.type==="light")return ms.createLigherLayer(t,e,n,i);if(n.type==="texture"||n.type==="video"){let s=n.type==="texture"?i.image(n.texture.image):i.video(n.texture.video),o=new ll(s,n.texture.wrapping),a=new Pg(s),l=new Ig(n.texture.repeat,n.texture.offset),u=new Ee(n.crop?1:0),c=new dt(n.projection??0),d=new dt(["x","y","z"].indexOf(n.axis)??0),h=new dt(n.side??0),f=new Yn(n.size?new F(n.size[0],n.size[1]):new F(100,100)),g=new Ee(n.alpha??1),p=new dt(n.mode??0),m=new Kh(o,a,u,c,d,h,f,l,g,p),y=new Tt(m.calpha,"f");return new wn(t,e,n,{texture:o,textureSize:a,crop:u,projection:c,axis:d,side:h,size:f,mat:l,alpha:g,mode:p},m,p,y)}else if(n.type==="matcap"){let s=i.image(n.texture.image),o=new ll(s,n.texture.wrapping),a=new Ee(n.alpha??1),l=new dt(n.mode??0),u=new Jh(o,a,l),c=new Tt(u.calpha,"f");return new wn(t,e,n,{texture:o,alpha:a,mode:l},u,l,c)}else if(n.type==="displace")if(n.displacementType==="noise"){let s=new er(new _(...n.offset)),o=new Ee(n.scale??10),a=new Ee(n.intensity??8),l=new Ee(n.movement??1),u=new dt(n.noiseType??0),c=new Xh(a,l,s,o,u);return new ef(t,e,n,{offset:s,scale:o,intensity:a,movement:l,noiseType:u},c)}else throw new Error;else return ZH(t,e,n,i)}updateByOp(t,e,n){let i=t;if(i.path[0]===void 0){if(i.type===0)return"type"in i.props||"category"in i.props?(n.scene?.markNeedsUpdateRendererDirty(),!0):gC(i.props,n.shared,this,e)}else if(i.path[0]==="texture")return"texture"in e||"video"in e?Cb(i.props,n.shared,this):!0;return!1}dispose(){if(YH(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof mi||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}},wn=class extends ps{constructor(e,n,i,s,o,a,l){super(e,n,i,s);this.params=s;this.color=o;this.mode=a;this.alpha=l}},ef=class extends ps{constructor(e,n,i,s,o){super(e,n,i,s);this.position=o}},ms=class extends ps{constructor(e,n,i,s,o){super(e,n,i,o);this.node=s}static createLigherLayer(e,n,i,s){let o,a=new Ee(i.alpha),l=new dt(i.mode),u;if(!i.visible)o=new al,u={};else if(i.category==="lambert"){o=new Bh;let c=new Et(s.color(i.emissive)??0);u={emissive:c},o.emissive=c}else if(i.category==="toon"){o=new Uh;let c=new Ee(i.shininess??30),d=new Et(s.color(i.specular)??1118481);u={shininess:c,specular:d},o.shininess=c,o.specular=d}else if(i.category==="physical"){o=new Fh;let c=new Ee(i.roughness??.3),d=new Ee(i.metalness??0),h=new Ee(i.reflectivity??.5);u={roughness:c,metalness:d,reflectivity:h},o.roughness=c,o.metalness=d,o.reflectivity=h}else{o=new Tg;let c=new Ee(i.shininess??30),d=new Et(i.specular!==void 0?s.color(i.specular)??1118481:1118481);u={shininess:c,specular:d},o.shininess=c,o.specular=d}return o.alpha=new Ee(1),o.shadingAlpha=a,o.shadingBlend=l,u.alpha=o.shadingAlpha,u.mode=o.shadingBlend,new ms(e,n,i,o,u)}get category(){return this.node.category}};function YH(r){let t=r instanceof ps?r.type:r;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function KH(r,t,e,n){switch(r.type){case"color":{let i=new Et(n.color??5855577),s=new Ee(n.alpha??1),o=new Tt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");o.keywords.alpha=s;let a=new dt(n.mode??0);return i.alpha=s,new wn(t,e,r,{color:i,alpha:s,mode:a},i,a,o)}case"fresnel":{let i=new Et(n.color??16777215),s=new Ee(n.bias??.1),o=new Ee(n.scale??1),a=new Ee(n.intensity??2),l=new Ee(n.factor??1),u=new Ee(n.alpha??1),c=new dt(n.mode??0),d=new zh(i,s,o,a,l,u,c),h=new Tt(d.calpha,"f");return new wn(t,e,r,{color:i,bias:s,scale:o,intensity:a,factor:l,alpha:u,mode:c},d,c,h)}case"rainbow":{let i=new Ee(n.filmThickness??30),s=new Ee(n.movement??0),o=new er(n.wavelengths??new _(0,0,0)),a=new Ee(n.noiseStrength??0),l=new Ee(n.noiseScale??1),u=new er(n.offset??new _(0,0,0)),c=new Ee(n.alpha??1),d=new Vh(i,s,o,a,l,u,c),h=new Tt(d.calpha,"f"),f=new dt(n.mode??0);return new wn(t,e,r,{filmThickness:i,movement:s,wavelengths:o,noiseStrength:a,noiseScale:l,offset:u,alpha:c,mode:f},d,f,h)}case"transmission":{let i=new Ee(n.thickness??10),s=new Ee(n.ior??1.5),o=new Ee(n.roughness??.5),a=Dt.transmissionSize,l=Dt.transmissionRenderTarget,u=Dt.transmissionRenderTargetDepth,c=window.innerWidth,d=window.innerHeight,h=c>=d?new Yn(d/c,1):new Yn(1,c/d),f=new Ee(n.alpha??1),g=new Wh(i,s,o,a,l,u,h,f),p=new Tt(g.calpha,"f"),m=new dt(n.mode??0);return new wn(t,e,r,{thickness:i,ior:s,roughness:o,aspectRatio:h,alpha:f,mode:m},g,m,p)}case"toon":{let i=new dt(n.positioning??0),s;n.colors?s=new ki(n.colors.length,n.colors):(s=new ki(10,new Qe(0,0,0,1)),s.value[1]=new Qe(1,1,1,1));let o;n.steps?o=new Gi(n.steps.length,n.steps):(o=new Gi(10,1),o.value[0]=0);let a=new er(n.source??new _(0,0,0)),l=new Jo(n.isWorldSpace??!0),u=new Ee(n.noiseStrength??0),c=new Ee(n.noiseScale??1),d=new pi(n.shadowColor),h=new er(n.offset??new _(0,0,0)),f=new Ee(n.alpha??1),g=new $h(i,s,o,a,l,u,c,d,h,f),p=new Tt(g.calpha,"f"),m=new dt(n.mode??0);return new wn(t,e,r,{positioning:i,colors:s,steps:o,source:a,isWorldSpace:l,noiseStrength:u,noiseScale:c,shadowColor:d,offset:h,alpha:f,mode:m},g,m,p)}case"outline":{let i=new Et(n.outlineColor??16777215),s=new Et(n.contourColor??16777215),o=new Ee(n.outlineWidth??.1),a=new Ee(n.contourWidth??.1),l=new Ee(n.outlineThreshold??.1),u=new Ee(n.contourThreshold??.1),c=new Ee(n.outlineSmoothing??.1),d=new Ee(n.contourFrequency??.1),h=new er(n.contourDirection??new _(0,1,0)),f=new Jo(n.positionalLines??!1),g=new Jo(n.compensation??!0),p=Dt.normalRenderTarget,m=Dt.normalRenderTargetDepth,y=Dt.pixelRatioNode,v=Dt.resolution,x=new Ee(n.alpha??1),b=new Hh(i,s,o,a,l,u,c,d,h,f,g,v,p,m,y,x),w=new Tt(b.calpha,"f"),A=new dt(n.mode??0);return new wn(t,e,r,{outlineColor:i,contourColor:s,outlineWidth:o,contourWidth:a,outlineThreshold:l,contourThreshold:u,outlineSmoothing:c,contourFrequency:d,contourDirection:h,positionalLines:f,compensation:g,alpha:x,mode:A},b,A,w)}case"depth":{let i=new dt(n.gradientType??0),s=new Jo(n.smooth??!1),o=new Ee(n.near??50),a=new Ee(n.far??200),l=new Ee(n.isVector??1),u=new Ee(n.isWorldSpace??0),c=new er(n.origin??new _),d=new er(n.direction??new _),h;n.colors?h=new ki(n.colors.length,n.colors):(h=new ki(2,new Qe(0,0,0,1)),h.value[1]=new Qe(1,1,1,1));let f;n.steps?f=new Gi(n.steps.length,n.steps):(f=new Gi(2,1),f.value[0]=0);let g=new Ee(n.alpha??1),p=new dt(n.mode??0),m=new jh(i,s,o,a,l,u,c,d,h,f,g),y=new Tt(m.calpha,"f");return new wn(t,e,r,{gradientType:i,smooth:s,near:o,far:a,isVector:l,isWorldSpace:u,origin:c,direction:d,colors:h,steps:f,alpha:g,mode:p},m,p,y)}case"noise":{let i=new Ee(n.scale??1),s=new er(n.size??new _(100,100,100)),o=new Ee(n.move??1),a=new Yn(n.fA??new F(1.7,9.2)),l=new Yn(n.fB??new F(8.3,2.8)),u=new Yn(n.distortion??new F(1,1)),c=new pi(n.colorA),d=new pi(n.colorB),h=new pi(n.colorC),f=new pi(n.colorD),g=new Ee(n.alpha??1),p=new dt(n.mode??0),m=new dt(n.noiseType??0),y=new kh(i,s,o,a,l,u,c,d,h,f,g,m),v=new Tt(y.calpha,"f");return new wn(t,e,r,{scale:i,size:s,move:o,fA:a,fB:l,distortion:u,colorA:c,colorB:d,colorC:h,colorD:f,alpha:g,mode:p,noiseType:m},y,p,v)}case"normal":{let i=new er(n.cnormal??new _(1,1,1)),s=new Ee(n.alpha??1),o=new dt(n.mode??0),a=new Qh(i,s),l=new Tt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return l.keywords.alpha=s,new wn(t,e,r,{cnormal:i,alpha:s,mode:o},a,o,l)}case"gradient":{let i=new dt(n.gradientType??0),s=new Jo(n.smooth??!1),o;n.colors?o=new ki(n.colors.length,n.colors):(o=new ki(10,new Qe(0,0,0,1)),o.value[1]=new Qe(1,1,1,1));let a;n.steps?a=new Gi(n.steps.length,n.steps):(a=new Gi(10,1),a.value[0]=0);let l=new Yn(n.offset??new F(0,0)),u=new Yn(n.morph??new F(0,0)),c=new Ee(n.angle??0),d=new Ee(n.alpha??1),h=new dt(n.mode??0),f=new Yh(i,s,o,a,l,u,c,d),g=new Tt(f.calpha,"f");return new wn(t,e,r,{gradientType:i,smooth:s,colors:o,steps:a,offset:l,morph:u,angle:c,alpha:d,mode:h},f,h,g)}default:{let i=new Et(1,0,0,1),s=new Ee(1),o=new Tt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");o.keywords.alpha=s;let a=new dt(0);return i.alpha=s,new wn(t,e,r,{color:i,alpha:s,mode:a},i,a,o)}}}function ZH(r,t,e,n){let i=pC(e,n);return KH(e,r,t,i)}function Pb(r,t,e){if(e.type==="displace"&&(r==="intensity"||r==="visible")){let n=t.uniforms[`f${t.id}_intensity`];return n?(n.value=e.intensity*(e.visible?1:0),n):void 0}if(e.type!=="displace"&&(r==="alpha"||r==="visible")){let n=t.uniforms[`f${t.id}_alpha`];if(!n)return;if(n.value=e.alpha*(e.visible?1:0),e.type==="outline"&&r==="visible"){let i=t.uniforms[`f${t.id}_compensation`];i&&(i.value=e.compensation&&e.visible)}return n}}function tf(r,t){let e=0;for(let n of r.layers)if(n.data.type!=="displace"&&"alpha"in n.data&&n.data.type!=="light"&&n.data.type!=="fresnel"&&n.data.type!=="texture"&&n.data.type!=="matcap"&&n.data.type!=="rainbow"&&n.data.type!=="outline"){let i=n.data.visible?n.data.alpha:0;if(i===1&&n.data.type==="depth"||n.data.type==="gradient"){for(let s of n.data.colors)if(s[3]<1){i=s[3];break}}else if(i===1&&n.data.type==="noise"){let s=t.color(n.data.colorA).a,o=t.color(n.data.colorB).a,a=t.color(n.data.colorC).a,l=t.color(n.data.colorD).a,u=Math.min(s,Math.min(o,Math.min(a,l)));u<1&&(i=u)}e+=(1-e)*i}return e<1}var Rr=class extends bt{constructor(){super(void 0);this.flatShading=!1;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},Ob=class extends Rr{constructor(e,n,i,s){super();this.flatShading=e;this.side=n;this.wireframe=i;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}getFlavor(e,n,i){return this.root.getFlavor(e,n,i)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,n,i){this.root.updateByOp(e,n,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},Ou=class extends Rr{constructor(e,n){super();this.data=e;this.layerIdGen=0;this.flavors=[];this.type="NodeMaterial";this.updaters=[],this.reset0(e,n)}get nodeMaterial(){return this}getFlavor(e,n,i){let s=i?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 Ob(e,n,i,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}reset(e,n){this.data!==e&&this.reset0(e,n)}reset0(e,n){this.data=e;let i=e.layers??qn.defaultTwoLayerData("phong").layers;this.layers=i.map(s=>ps.create(this.layerIdGen++,s.id,s.data,n.shared)),this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(),this.transparent=tf(e,n.shared)}getLayersOfType(e){return this.layers.filter(n=>n.type===e)}getLayerByUuid(e){return this.layers.find(n=>n.uuid===e)}onUpdate(){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(e=>e instanceof ms),this.lightLayer===void 0&&(this.lightLayer=new ms(0,"",{...vr.defaultData("light","phong"),visible:!1},new al,{})),this.nodeMaterialDispose(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(e,n,i){if(this.data=n,this.transparent=tf(n,i.shared),e.path[0]==="layers"){this.data=n;let s=i.shared,o=e.path[1];if(o===void 0){if(this.layers.reverse(),e.type===4){let a=ps.create(this.layerIdGen++,e.id,e.data,i.shared);this.layers.splice(e.localIndex,0,a),i.scene?.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),i.scene?.markNeedsUpdateRendererDirty();else if(e.type===6){let 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),i.scene?.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate()}else{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,i)){let c=ps.create(this.layerIdGen++,o,l,s);this.layers.splice(this.layers.findIndex(d=>d.uuid===o),1,c),this.onUpdate()}}}}else this.reset(n,i)}blendColors(){let e=this.layers.findIndex(i=>i instanceof wn),n=this.layers.findIndex(i=>i instanceof ms);if(e!==-1&&e<n){let i=this.layers[e].color;for(let s=e+1;s<n;++s){let o=this.layers[s];o instanceof wn&&(i=new qh(i,o.color,o.alpha,o.mode))}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new Tt("outgoingLight","f"),n=this.layers.findIndex(i=>i instanceof ms);if(this.layers.length>n+1){for(let i=n+1;i<this.layers.length;++i){let s=this.layers[i];s instanceof wn&&(e=new qh(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 ef);if(e.length>0){let n=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(n=new Or(n,e[i].position,Or.ADD),n=new Or(n,new Ee(.5).setReadonly(!0),Or.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 i=(s,o,a)=>Math.min(Math.max(s,o),a);for(let s of this.layers)if(s.type==="displace"){let o=i(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 i=(Eb[n.type]??[]).map(a=>n[a]),s=(Mb[n.type]??[]).map(a=>n[a]?.length??0),o=[...i,...s];o.length?e+=`["${n.type}", "${o.join('","')}"],`:e+=`"${n.type}",`}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 _g;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 wn){let n=e.params.texture;if(n instanceof ll&&!n.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(Rr.prototype,{properties:{get:function(){return this.fragment.properties}}});var cl=class extends Ou{};var SC=dd(vC());var xC=new Map;function bC(r){if(typeof r=="string")return r;let t=xC.get(r);return t||(t={url:URL.createObjectURL(new Blob([r]))},xC.set(r,t)),t.url}var io=class{constructor({src:t,volume:e,delay:n,loop:i}){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:bC(t),format:"wav"},this.sound=new SC.Howl(s),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),n!==void 0&&(this.delay=n),i!==void 0&&(this.loop=i)}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 Og=class{constructor(){this.type="ShapePath";this.color=new Le;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Oa,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,i){return this.currentPath?.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,s,o){return this.currentPath?.bezierCurveTo(t,e,n,i,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 i(p,m,y,v){let x=p.x,b=m.x,w=y.x,A=v.x,T=p.y,S=m.y,E=y.y,M=v.y,I=(A-w)*(T-E)-(M-E)*(x-w),P=(b-x)*(T-E)-(S-T)*(x-w),C=(M-E)*(b-x)-(A-w)*(S-T),D=I/C,B=P/C;if(C===0&&I!==0||D<=0||D>=1||B<0||B>1)return null;if(I===0&&C===0){for(let k=0;k<2;k++)if(s(k===0?y:v,p,m),n.loc===e.ORIGIN){let X=k===0?y:v;return{x:X.x,y:X.y,t:n.t}}else if(n.loc===e.BETWEEN){let X=+(x+n.t*(b-x)).toPrecision(10),W=+(T+n.t*(S-T)).toPrecision(10);return{x:X,y:W,t:n.t}}return null}else{for(let W=0;W<2;W++)if(s(W===0?y:v,p,m),n.loc===e.ORIGIN){let q=W===0?y:v;return{x:q.x,y:q.y,t:n.t}}let k=+(x+D*(b-x)).toPrecision(10),X=+(T+D*(S-T)).toPrecision(10);return{x:k,y:X,t:D}}}function s(p,m,y){let v=y.x-m.x,x=y.y-m.y,b=p.x-m.x,w=p.y-m.y,A=v*w-b*x;if(p.x===m.x&&p.y===m.y){n.loc=e.ORIGIN,n.t=0;return}if(p.x===y.x&&p.y===y.y){n.loc=e.DESTINATION,n.t=1;return}if(A<-Number.EPSILON){n.loc=e.LEFT;return}if(A>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 T;v!==0?T=b/v:T=w/x,n.loc=e.BETWEEN,n.t=T}function o(p,m){let y=[],v=[];for(let x=1;x<p.length;x++){let b=p[x-1],w=p[x];for(let A=1;A<m.length;A++){let T=m[A-1],S=m[A],E=i(b,w,T,S);E!==null&&y.find(M=>M.t<=E.t+Number.EPSILON&&M.t>=E.t-Number.EPSILON)===void 0&&(y.push(E),v.push(new F(E.x,E.y)))}}return v}function a(p,m,y){let v=new F;m.getCenter(v);let x=[];return y.forEach(b=>{b.boundingBox.containsPoint(v)&&o(p,b.points).forEach(A=>{x.push({identifier:b.identifier,isCW:b.isCW,point:A})})}),x.sort((b,w)=>b.point.x-w.point.x),x}function l(p,m,y,v,x){(x==null||x==="")&&(x="nonzero");let b=new F;p.boundingBox.getCenter(b);let w=[new F(y,b.y),new F(v,b.y)],A=a(w,p.boundingBox,m);A.sort((P,C)=>P.point.x-C.point.x);let T=[],S=[];A.forEach(P=>{P.identifier===p.identifier?T.push(P):S.push(P)});let E=T[0].point.x,M=[],I=0;for(;I<S.length&&S[I].point.x<E;)M.length>0&&M[M.length-1]===S[I].identifier?M.pop():M.push(S[I].identifier),I++;if(M.push(p.identifier),x==="evenodd"){let P=M.length%2===0,C=M[M.length-2];return{identifier:p.identifier,isHole:P,for:C}}else if(x==="nonzero"){let P=!0,C=null,D=null;for(let B=0;B<M.length;B++){let k=M[B];m[k]&&(P?(D=m[k].isCW,P=!1,C=k):D!==m[k].isCW&&(D=m[k].isCW,P=!0))}return{identifier:p.identifier,isHole:P,for:C}}else console.warn('fill-rule: "'+x+'" is currently not implemented.')}let u=0,c=999999999,d=-999999999,h=[];this.subPaths.forEach(p=>{let m=p.getPoints(),y=-999999999,v=999999999,x=-999999999,b=999999999;for(let w=0;w<m.length;w++){let A=m[w];A.y>y&&(y=A.y),A.y<v&&(v=A.y),A.x>x&&(x=A.x),A.x<b&&(b=A.x)}d<=x&&(d=x+1),c>=b&&(c=b-1),m.length&&h.push({curves:p.curves,points:m,isCW:ql.isClockWise(m),identifier:u++,boundingBox:new Ap(new F(b,v),new F(x,y))})});let f=h.map(p=>l(p,h,c,d,this.userData?.style.fillRule)),g=[];return h.forEach(p=>{let m=f[p.identifier];if(m&&!m.isHole){let y=new Hs;y.curves=p.curves,f.filter(x=>x?.isHole&&x.for===p.identifier).forEach(x=>{if(x){let b=h[x.identifier],w=new Oa;w.curves=b.curves,y.holes.push(w)}}),g.push(y)}}),g}};var AC,Lb=new Promise(r=>{AC=r}),wC=!1;async function _C(){if(wC)return;let r=await import("./opentype.js");AC(r),wC=!0}var nf=class{async load(t,e,n=()=>{}){let{load:i}=await Lb;i(t,(s,o)=>{s||!o?n(s??"Something went wrong"):e(o)})}async parse(t){let{parse:e,Bidi:n}=await Lb;try{let i=e(t),s=new n,o=a=>i.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,o),s.applyFeatures(i,i.defaultRenderOptions.features),{font:i,bidi:s}}catch(i){console.error(i)}}};async function QH(r){return await(await fetch(r)).arrayBuffer()}var JH=new nf;async function Rb(r){let t,e,n=!1;if(r.url?(t=await QH(r.url),e=r.url,n=r.url.startsWith("/")):r.data&&(t=r.data.buffer),t){let i=await JH.parse(t);if(i)return{font:i.font,url:e,intercepted:n,arr:t,bidi:i.bidi}}}function $H(r,t){return t.state.glyphIndex===r||t.state.fina===r||t.state.medi===r||t.state.init===r}var Lg=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=Rb(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=Rb(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 i=this._bidi;i.getTextGlyphs(e);let s=i.tokenizer.tokens,o=[],a=0,l=n.length===s.length;for(let u=0;u<n.length;u++){let c=n[u].index,d=String.fromCharCode(n[u].unicode),h=s[a];if($H(c,h)||l)o.push({char:d,index:c,replacements:[h.state.glyphIndex],replacementChars:[h.char]}),a++;else{let f=h.char,g="",p=[h.state.glyphIndex],m=[],y=!1;for(;!y;)a++,g=e.charAt(a),f+=g,p.push(t.charToGlyphIndex(g)),m=t.stringToGlyphs(f),m.length===1&&m[0].index===c&&(y=!0),a>e.length&&(y=!0);o.push({char:d,index:c,replacements:p,replacementChars:Array.from(f)}),a++}}return o}generateShapes(t,e){if(!this._isLoaded)return;let n=this.font,i=e.fontSize/this.unitsPerEm,s=e.fontSize*e.lineHeight,o=t.map(v=>this.getTextWidth(v,e)),a=e.width,l=this.getCharWidth(`
|
|
4471
|
+
}`,[sr.simplex,e,i,o])}}();function yC(r,t,e){r.setUvTransform(e[0],e[1],t[0],t[1],0,0,0)}var Ig=class extends Pu{constructor(e,n){super(new nn);this.repeat=e;this.offset=n;yC(this.value,e,n)}updateMatrix(){yC(this.value,this.repeat,this.offset)}};var ps=class{constructor(t,e,n,i){this.id=t;this.uuid=e;this.data=n;this.uniforms={};for(let s in i)this.uniforms[`f${this.id}_${s}`]=i[s];for(let s in n)Pb(s,this,n)}get type(){return this.data.type}static create(t,e,n,i){if(n.type==="light")return ms.createLigherLayer(t,e,n,i);if(n.type==="texture"||n.type==="video"){let s=n.type==="texture"?i.image(n.texture.image):i.video(n.texture.video),o=new ll(s,n.texture.wrapping),a=new Pg(s),l=new Ig(n.texture.repeat,n.texture.offset),u=new Ee(n.crop?1:0),c=new dt(n.projection??0),d=new dt(["x","y","z"].indexOf(n.axis)??0),h=new dt(n.side??0),f=new Yn(n.size?new F(n.size[0],n.size[1]):new F(100,100)),g=new Ee(n.alpha??1),p=new dt(n.mode??0),m=new Kh(o,a,u,c,d,h,f,l,g,p),y=new Tt(m.calpha,"f");return new wn(t,e,n,{texture:o,textureSize:a,crop:u,projection:c,axis:d,side:h,size:f,mat:l,alpha:g,mode:p},m,p,y)}else if(n.type==="matcap"){let s=i.image(n.texture.image),o=new ll(s,n.texture.wrapping),a=new Ee(n.alpha??1),l=new dt(n.mode??0),u=new Jh(o,a,l),c=new Tt(u.calpha,"f");return new wn(t,e,n,{texture:o,alpha:a,mode:l},u,l,c)}else if(n.type==="displace")if(n.displacementType==="noise"){let s=new er(new _(...n.offset)),o=new Ee(n.scale??10),a=new Ee(n.intensity??8),l=new Ee(n.movement??1),u=new dt(n.noiseType??0),c=new Xh(a,l,s,o,u);return new ef(t,e,n,{offset:s,scale:o,intensity:a,movement:l,noiseType:u},c)}else throw new Error;else return ZH(t,e,n,i)}updateByOp(t,e,n){let i=t;if(i.path[0]===void 0){if(i.type===0)return"type"in i.props||"category"in i.props?(n.scene?.markNeedsUpdateRendererDirty(),!0):gC(i.props,n.shared,this,e)}else if(i.path[0]==="texture")return"texture"in e||"video"in e?Cb(i.props,n.shared,this):!0;return!1}dispose(){if(YH(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof mi||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}},wn=class extends ps{constructor(e,n,i,s,o,a,l){super(e,n,i,s);this.params=s;this.color=o;this.mode=a;this.alpha=l}},ef=class extends ps{constructor(e,n,i,s,o){super(e,n,i,s);this.position=o}},ms=class extends ps{constructor(e,n,i,s,o){super(e,n,i,o);this.node=s}static createLigherLayer(e,n,i,s){let o,a=new Ee(i.alpha),l=new dt(i.mode),u;if(!i.visible)o=new al,u={};else if(i.category==="lambert"){o=new Bh;let c=new Et(s.color(i.emissive)??0);u={emissive:c},o.emissive=c}else if(i.category==="toon"){o=new Uh;let c=new Ee(i.shininess??30),d=new Et(s.color(i.specular)??1118481);u={shininess:c,specular:d},o.shininess=c,o.specular=d}else if(i.category==="physical"){o=new Fh;let c=new Ee(i.roughness??.3),d=new Ee(i.metalness??0),h=new Ee(i.reflectivity??.5);u={roughness:c,metalness:d,reflectivity:h},o.roughness=c,o.metalness=d,o.reflectivity=h}else{o=new Tg;let c=new Ee(i.shininess??30),d=new Et(i.specular!==void 0?s.color(i.specular)??1118481:1118481);u={shininess:c,specular:d},o.shininess=c,o.specular=d}return o.alpha=new Ee(1),o.shadingAlpha=a,o.shadingBlend=l,u.alpha=o.shadingAlpha,u.mode=o.shadingBlend,new ms(e,n,i,o,u)}get category(){return this.node.category}};function YH(r){let t=r instanceof ps?r.type:r;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function KH(r,t,e,n){switch(r.type){case"color":{let i=new Et(n.color??5855577),s=new Ee(n.alpha??1),o=new Tt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");o.keywords.alpha=s;let a=new dt(n.mode??0);return i.alpha=s,new wn(t,e,r,{color:i,alpha:s,mode:a},i,a,o)}case"fresnel":{let i=new Et(n.color??16777215),s=new Ee(n.bias??.1),o=new Ee(n.scale??1),a=new Ee(n.intensity??2),l=new Ee(n.factor??1),u=new Ee(n.alpha??1),c=new dt(n.mode??0),d=new zh(i,s,o,a,l,u,c),h=new Tt(d.calpha,"f");return new wn(t,e,r,{color:i,bias:s,scale:o,intensity:a,factor:l,alpha:u,mode:c},d,c,h)}case"rainbow":{let i=new Ee(n.filmThickness??30),s=new Ee(n.movement??0),o=new er(n.wavelengths??new _(0,0,0)),a=new Ee(n.noiseStrength??0),l=new Ee(n.noiseScale??1),u=new er(n.offset??new _(0,0,0)),c=new Ee(n.alpha??1),d=new Vh(i,s,o,a,l,u,c),h=new Tt(d.calpha,"f"),f=new dt(n.mode??0);return new wn(t,e,r,{filmThickness:i,movement:s,wavelengths:o,noiseStrength:a,noiseScale:l,offset:u,alpha:c,mode:f},d,f,h)}case"transmission":{let i=new Ee(n.thickness??10),s=new Ee(n.ior??1.5),o=new Ee(n.roughness??.5),a=Dt.transmissionSize,l=Dt.transmissionRenderTarget,u=Dt.transmissionRenderTargetDepth,c=window.innerWidth,d=window.innerHeight,h=c>=d?new Yn(d/c,1):new Yn(1,c/d),f=new Ee(n.alpha??1),g=new Wh(i,s,o,a,l,u,h,f),p=new Tt(g.calpha,"f"),m=new dt(n.mode??0);return new wn(t,e,r,{thickness:i,ior:s,roughness:o,aspectRatio:h,alpha:f,mode:m},g,m,p)}case"toon":{let i=new dt(n.positioning??0),s;n.colors?s=new ki(n.colors.length,n.colors):(s=new ki(10,new Qe(0,0,0,1)),s.value[1]=new Qe(1,1,1,1));let o;n.steps?o=new Gi(n.steps.length,n.steps):(o=new Gi(10,1),o.value[0]=0);let a=new er(n.source??new _(0,0,0)),l=new Jo(n.isWorldSpace??!0),u=new Ee(n.noiseStrength??0),c=new Ee(n.noiseScale??1),d=new pi(n.shadowColor),h=new er(n.offset??new _(0,0,0)),f=new Ee(n.alpha??1),g=new $h(i,s,o,a,l,u,c,d,h,f),p=new Tt(g.calpha,"f"),m=new dt(n.mode??0);return new wn(t,e,r,{positioning:i,colors:s,steps:o,source:a,isWorldSpace:l,noiseStrength:u,noiseScale:c,shadowColor:d,offset:h,alpha:f,mode:m},g,m,p)}case"outline":{let i=new Et(n.outlineColor??16777215),s=new Et(n.contourColor??16777215),o=new Ee(n.outlineWidth??.1),a=new Ee(n.contourWidth??.1),l=new Ee(n.outlineThreshold??.1),u=new Ee(n.contourThreshold??.1),c=new Ee(n.outlineSmoothing??.1),d=new Ee(n.contourFrequency??.1),h=new er(n.contourDirection??new _(0,1,0)),f=new Jo(n.positionalLines??!1),g=new Jo(n.compensation??!0),p=Dt.normalRenderTarget,m=Dt.normalRenderTargetDepth,y=Dt.pixelRatioNode,v=Dt.resolution,x=new Ee(n.alpha??1),b=new Hh(i,s,o,a,l,u,c,d,h,f,g,v,p,m,y,x),w=new Tt(b.calpha,"f"),A=new dt(n.mode??0);return new wn(t,e,r,{outlineColor:i,contourColor:s,outlineWidth:o,contourWidth:a,outlineThreshold:l,contourThreshold:u,outlineSmoothing:c,contourFrequency:d,contourDirection:h,positionalLines:f,compensation:g,alpha:x,mode:A},b,A,w)}case"depth":{let i=new dt(n.gradientType??0),s=new Jo(n.smooth??!1),o=new Ee(n.near??50),a=new Ee(n.far??200),l=new Ee(n.isVector??1),u=new Ee(n.isWorldSpace??0),c=new er(n.origin??new _),d=new er(n.direction??new _),h;n.colors?h=new ki(n.colors.length,n.colors):(h=new ki(2,new Qe(0,0,0,1)),h.value[1]=new Qe(1,1,1,1));let f;n.steps?f=new Gi(n.steps.length,n.steps):(f=new Gi(2,1),f.value[0]=0);let g=new Ee(n.alpha??1),p=new dt(n.mode??0),m=new jh(i,s,o,a,l,u,c,d,h,f,g),y=new Tt(m.calpha,"f");return new wn(t,e,r,{gradientType:i,smooth:s,near:o,far:a,isVector:l,isWorldSpace:u,origin:c,direction:d,colors:h,steps:f,alpha:g,mode:p},m,p,y)}case"noise":{let i=new Ee(n.scale??1),s=new er(n.size??new _(100,100,100)),o=new Ee(n.move??1),a=new Yn(n.fA??new F(1.7,9.2)),l=new Yn(n.fB??new F(8.3,2.8)),u=new Yn(n.distortion??new F(1,1)),c=new pi(n.colorA),d=new pi(n.colorB),h=new pi(n.colorC),f=new pi(n.colorD),g=new Ee(n.alpha??1),p=new dt(n.mode??0),m=new dt(n.noiseType??0),y=new kh(i,s,o,a,l,u,c,d,h,f,g,m),v=new Tt(y.calpha,"f");return new wn(t,e,r,{scale:i,size:s,move:o,fA:a,fB:l,distortion:u,colorA:c,colorB:d,colorC:h,colorD:f,alpha:g,mode:p,noiseType:m},y,p,v)}case"normal":{let i=new er(n.cnormal??new _(1,1,1)),s=new Ee(n.alpha??1),o=new dt(n.mode??0),a=new Qh(i,s),l=new Tt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return l.keywords.alpha=s,new wn(t,e,r,{cnormal:i,alpha:s,mode:o},a,o,l)}case"gradient":{let i=new dt(n.gradientType??0),s=new Jo(n.smooth??!1),o;n.colors?o=new ki(n.colors.length,n.colors):(o=new ki(10,new Qe(0,0,0,1)),o.value[1]=new Qe(1,1,1,1));let a;n.steps?a=new Gi(n.steps.length,n.steps):(a=new Gi(10,1),a.value[0]=0);let l=new Yn(n.offset??new F(0,0)),u=new Yn(n.morph??new F(0,0)),c=new Ee(n.angle??0),d=new Ee(n.alpha??1),h=new dt(n.mode??0),f=new Yh(i,s,o,a,l,u,c,d),g=new Tt(f.calpha,"f");return new wn(t,e,r,{gradientType:i,smooth:s,colors:o,steps:a,offset:l,morph:u,angle:c,alpha:d,mode:h},f,h,g)}default:{let i=new Et(1,0,0,1),s=new Ee(1),o=new Tt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");o.keywords.alpha=s;let a=new dt(0);return i.alpha=s,new wn(t,e,r,{color:i,alpha:s,mode:a},i,a,o)}}}function ZH(r,t,e,n){let i=pC(e,n);return KH(e,r,t,i)}function Pb(r,t,e){if(e.type==="displace"&&(r==="intensity"||r==="visible")){let n=t.uniforms[`f${t.id}_intensity`];return n?(n.value=e.intensity*(e.visible?1:0),n):void 0}if(e.type!=="displace"&&(r==="alpha"||r==="visible")){let n=t.uniforms[`f${t.id}_alpha`];if(!n)return;if(n.value=e.alpha*(e.visible?1:0),e.type==="outline"&&r==="visible"){let i=t.uniforms[`f${t.id}_compensation`];i&&(i.value=e.compensation&&e.visible)}return n}}function tf(r,t){let e=0;for(let n of r.layers)if(n.data.type!=="displace"&&"alpha"in n.data&&n.data.type!=="light"&&n.data.type!=="fresnel"&&n.data.type!=="texture"&&n.data.type!=="matcap"&&n.data.type!=="rainbow"&&n.data.type!=="outline"){let i=n.data.visible?n.data.alpha:0;if(i===1&&n.data.type==="depth"||n.data.type==="gradient"){for(let s of n.data.colors)if(s[3]<1){i=s[3];break}}else if(i===1&&n.data.type==="noise"){let s=t.color(n.data.colorA).a,o=t.color(n.data.colorB).a,a=t.color(n.data.colorC).a,l=t.color(n.data.colorD).a,u=Math.min(s,Math.min(o,Math.min(a,l)));u<1&&(i=u)}e+=(1-e)*i}return e<1}var Rr=class extends bt{constructor(){super(void 0);this.flatShading=!1;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},Ob=class extends Rr{constructor(e,n,i,s){super();this.flatShading=e;this.side=n;this.wireframe=i;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}getFlavor(e,n,i){return this.root.getFlavor(e,n,i)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,n,i){this.root.updateByOp(e,n,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},Ou=class extends Rr{constructor(e,n){super();this.data=e;this.layerIdGen=0;this.flavors=[];this.type="NodeMaterial";this.updaters=[],this.reset0(e,n)}get nodeMaterial(){return this}getFlavor(e,n,i){let s=i?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 Ob(e,n,i,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}reset(e,n){this.data!==e&&this.reset0(e,n)}reset0(e,n){this.data=e;let i=e.layers??qn.defaultTwoLayerData("phong").layers;this.layers=i.map(s=>ps.create(this.layerIdGen++,s.id,s.data,n.shared)),this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(),this.transparent=tf(e,n.shared)}getLayersOfType(e){return this.layers.filter(n=>n.type===e)}getLayerByUuid(e){return this.layers.find(n=>n.uuid===e)}onUpdate(){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(e=>e instanceof ms),this.lightLayer===void 0&&(this.lightLayer=new ms(0,"",{...vr.defaultData("light","phong"),visible:!1},new al,{})),this.dispose();for(let e of this.flavors)e&&e.dispose();this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(e,n,i){if(this.data=n,this.transparent=tf(n,i.shared),e.path[0]==="layers"){this.data=n;let s=i.shared,o=e.path[1];if(o===void 0){if(this.layers.reverse(),e.type===4){let a=ps.create(this.layerIdGen++,e.id,e.data,i.shared);this.layers.splice(e.localIndex,0,a),i.scene?.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),i.scene?.markNeedsUpdateRendererDirty();else if(e.type===6){let 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),i.scene?.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate()}else{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,i)){let c=ps.create(this.layerIdGen++,o,l,s);this.layers.splice(this.layers.findIndex(d=>d.uuid===o),1,c),this.onUpdate()}}}}else this.reset(n,i)}blendColors(){let e=this.layers.findIndex(i=>i instanceof wn),n=this.layers.findIndex(i=>i instanceof ms);if(e!==-1&&e<n){let i=this.layers[e].color;for(let s=e+1;s<n;++s){let o=this.layers[s];o instanceof wn&&(i=new qh(i,o.color,o.alpha,o.mode))}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new Tt("outgoingLight","f"),n=this.layers.findIndex(i=>i instanceof ms);if(this.layers.length>n+1){for(let i=n+1;i<this.layers.length;++i){let s=this.layers[i];s instanceof wn&&(e=new qh(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 ef);if(e.length>0){let n=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(n=new Or(n,e[i].position,Or.ADD),n=new Or(n,new Ee(.5).setReadonly(!0),Or.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 i=(s,o,a)=>Math.min(Math.max(s,o),a);for(let s of this.layers)if(s.type==="displace"){let o=i(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 i=(Eb[n.type]??[]).map(a=>n[a]),s=(Mb[n.type]??[]).map(a=>n[a]?.length??0),o=[...i,...s];o.length?e+=`["${n.type}", "${o.join('","')}"],`:e+=`"${n.type}",`}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 _g;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 wn){let n=e.params.texture;if(n instanceof ll&&!n.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(Rr.prototype,{properties:{get:function(){return this.fragment.properties}}});var cl=class extends Ou{};var SC=dd(vC());var xC=new Map;function bC(r){if(typeof r=="string")return r;let t=xC.get(r);return t||(t={url:URL.createObjectURL(new Blob([r]))},xC.set(r,t)),t.url}var io=class{constructor({src:t,volume:e,delay:n,loop:i}){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:bC(t),format:"wav"},this.sound=new SC.Howl(s),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),n!==void 0&&(this.delay=n),i!==void 0&&(this.loop=i)}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 Og=class{constructor(){this.type="ShapePath";this.color=new Le;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Oa,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,i){return this.currentPath?.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,s,o){return this.currentPath?.bezierCurveTo(t,e,n,i,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 i(p,m,y,v){let x=p.x,b=m.x,w=y.x,A=v.x,T=p.y,S=m.y,E=y.y,M=v.y,I=(A-w)*(T-E)-(M-E)*(x-w),P=(b-x)*(T-E)-(S-T)*(x-w),C=(M-E)*(b-x)-(A-w)*(S-T),D=I/C,B=P/C;if(C===0&&I!==0||D<=0||D>=1||B<0||B>1)return null;if(I===0&&C===0){for(let k=0;k<2;k++)if(s(k===0?y:v,p,m),n.loc===e.ORIGIN){let X=k===0?y:v;return{x:X.x,y:X.y,t:n.t}}else if(n.loc===e.BETWEEN){let X=+(x+n.t*(b-x)).toPrecision(10),W=+(T+n.t*(S-T)).toPrecision(10);return{x:X,y:W,t:n.t}}return null}else{for(let W=0;W<2;W++)if(s(W===0?y:v,p,m),n.loc===e.ORIGIN){let q=W===0?y:v;return{x:q.x,y:q.y,t:n.t}}let k=+(x+D*(b-x)).toPrecision(10),X=+(T+D*(S-T)).toPrecision(10);return{x:k,y:X,t:D}}}function s(p,m,y){let v=y.x-m.x,x=y.y-m.y,b=p.x-m.x,w=p.y-m.y,A=v*w-b*x;if(p.x===m.x&&p.y===m.y){n.loc=e.ORIGIN,n.t=0;return}if(p.x===y.x&&p.y===y.y){n.loc=e.DESTINATION,n.t=1;return}if(A<-Number.EPSILON){n.loc=e.LEFT;return}if(A>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 T;v!==0?T=b/v:T=w/x,n.loc=e.BETWEEN,n.t=T}function o(p,m){let y=[],v=[];for(let x=1;x<p.length;x++){let b=p[x-1],w=p[x];for(let A=1;A<m.length;A++){let T=m[A-1],S=m[A],E=i(b,w,T,S);E!==null&&y.find(M=>M.t<=E.t+Number.EPSILON&&M.t>=E.t-Number.EPSILON)===void 0&&(y.push(E),v.push(new F(E.x,E.y)))}}return v}function a(p,m,y){let v=new F;m.getCenter(v);let x=[];return y.forEach(b=>{b.boundingBox.containsPoint(v)&&o(p,b.points).forEach(A=>{x.push({identifier:b.identifier,isCW:b.isCW,point:A})})}),x.sort((b,w)=>b.point.x-w.point.x),x}function l(p,m,y,v,x){(x==null||x==="")&&(x="nonzero");let b=new F;p.boundingBox.getCenter(b);let w=[new F(y,b.y),new F(v,b.y)],A=a(w,p.boundingBox,m);A.sort((P,C)=>P.point.x-C.point.x);let T=[],S=[];A.forEach(P=>{P.identifier===p.identifier?T.push(P):S.push(P)});let E=T[0].point.x,M=[],I=0;for(;I<S.length&&S[I].point.x<E;)M.length>0&&M[M.length-1]===S[I].identifier?M.pop():M.push(S[I].identifier),I++;if(M.push(p.identifier),x==="evenodd"){let P=M.length%2===0,C=M[M.length-2];return{identifier:p.identifier,isHole:P,for:C}}else if(x==="nonzero"){let P=!0,C=null,D=null;for(let B=0;B<M.length;B++){let k=M[B];m[k]&&(P?(D=m[k].isCW,P=!1,C=k):D!==m[k].isCW&&(D=m[k].isCW,P=!0))}return{identifier:p.identifier,isHole:P,for:C}}else console.warn('fill-rule: "'+x+'" is currently not implemented.')}let u=0,c=999999999,d=-999999999,h=[];this.subPaths.forEach(p=>{let m=p.getPoints(),y=-999999999,v=999999999,x=-999999999,b=999999999;for(let w=0;w<m.length;w++){let A=m[w];A.y>y&&(y=A.y),A.y<v&&(v=A.y),A.x>x&&(x=A.x),A.x<b&&(b=A.x)}d<=x&&(d=x+1),c>=b&&(c=b-1),m.length&&h.push({curves:p.curves,points:m,isCW:ql.isClockWise(m),identifier:u++,boundingBox:new Ap(new F(b,v),new F(x,y))})});let f=h.map(p=>l(p,h,c,d,this.userData?.style.fillRule)),g=[];return h.forEach(p=>{let m=f[p.identifier];if(m&&!m.isHole){let y=new Hs;y.curves=p.curves,f.filter(x=>x?.isHole&&x.for===p.identifier).forEach(x=>{if(x){let b=h[x.identifier],w=new Oa;w.curves=b.curves,y.holes.push(w)}}),g.push(y)}}),g}};var AC,Lb=new Promise(r=>{AC=r}),wC=!1;async function _C(){if(wC)return;let r=await import("./opentype.js");AC(r),wC=!0}var nf=class{async load(t,e,n=()=>{}){let{load:i}=await Lb;i(t,(s,o)=>{s||!o?n(s??"Something went wrong"):e(o)})}async parse(t){let{parse:e,Bidi:n}=await Lb;try{let i=e(t),s=new n,o=a=>i.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,o),s.applyFeatures(i,i.defaultRenderOptions.features),{font:i,bidi:s}}catch(i){console.error(i)}}};async function QH(r){return await(await fetch(r)).arrayBuffer()}var JH=new nf;async function Rb(r){let t,e,n=!1;if(r.url?(t=await QH(r.url),e=r.url,n=r.url.startsWith("/")):r.data&&(t=r.data.buffer),t){let i=await JH.parse(t);if(i)return{font:i.font,url:e,intercepted:n,arr:t,bidi:i.bidi}}}function $H(r,t){return t.state.glyphIndex===r||t.state.fina===r||t.state.medi===r||t.state.init===r}var Lg=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=Rb(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=Rb(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 i=this._bidi;i.getTextGlyphs(e);let s=i.tokenizer.tokens,o=[],a=0,l=n.length===s.length;for(let u=0;u<n.length;u++){let c=n[u].index,d=String.fromCharCode(n[u].unicode),h=s[a];if($H(c,h)||l)o.push({char:d,index:c,replacements:[h.state.glyphIndex],replacementChars:[h.char]}),a++;else{let f=h.char,g="",p=[h.state.glyphIndex],m=[],y=!1;for(;!y;)a++,g=e.charAt(a),f+=g,p.push(t.charToGlyphIndex(g)),m=t.stringToGlyphs(f),m.length===1&&m[0].index===c&&(y=!0),a>e.length&&(y=!0);o.push({char:d,index:c,replacements:p,replacementChars:Array.from(f)}),a++}}return o}generateShapes(t,e){if(!this._isLoaded)return;let n=this.font,i=e.fontSize/this.unitsPerEm,s=e.fontSize*e.lineHeight,o=t.map(v=>this.getTextWidth(v,e)),a=e.width,l=this.getCharWidth(`
|
|
4472
4472
|
`,e),u=e.horizontalAlign===1?l:0,c=this.computeSpaceWidthForLine(t,0,e),d=this.getLineInitialOffsetX(o[0],a,e.horizontalAlign,t[0],l),h=this.getLineInitialOffsetY(s,t.length,e.height,i,e.verticalAlign),f=[],g=t.map(v=>[]),p=t.map(v=>[]),m;for(let v=0;v<t.length;v++){let x=t[v],b={features:{liga:!0}},w=[];try{w=n.stringToGlyphs(x,b)}catch(T){console.warn(T)}d=this.getLineInitialOffsetX(o[v],a,e.horizontalAlign,x,l);let A=[];try{A=this.reverseLigaturesTable(n,x,w)}catch(T){console.warn(T)}c=this.computeSpaceWidthForLine(t,v,e);for(let T=0;T<w.length;T++){let S=w[T],E=S.index===0?`
|
|
4473
4473
|
`:S.unicode?String.fromCharCode(S.unicode):void 0,M=A[T],I=0,P=0;T===0&&e.horizontalAlign===2&&S.leftSideBearing!==void 0&&(P=-S.leftSideBearing*i),m&&(I=n.getKerningValue(S,m)*i),d+=P+I;let C=0;if(E===`
|
|
4474
4474
|
`)C=u;else if(E===" ")C=c;else{let D=this.createPath(S,i,d,h,e);D&&(C=D.offsetX-(I+P),f.push(D.path))}if(M.replacements.length===1)p[v].push([d,h]),g[v].push(C);else{let D=M.replacements.map(W=>(n.glyphs.get(W).advanceWidth??0)*i),B=D.reduce((W,q)=>W+=q,0),k=D.map(W=>W/B),X=d;for(let W=0;W<k.length;W++){let q=C*k[W];p[v].push([X,h]),g[v].push(q),X+=q}}d+=C,m=S}h-=s}let y=[];for(let v=0,x=f.length;v<x;v++)y.push(...f[v].toShapes());return{shapes:y,charWidths:g,lineWidths:o,charCoords:p}}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,i,s){return(n===3||n===2)&&i.indexOf(`
|
|
@@ -4909,7 +4909,7 @@ float contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5;
|
|
|
4909
4909
|
vec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4);
|
|
4910
4910
|
gl_FragColor = vec4(resultColor, vColor.r);
|
|
4911
4911
|
}
|
|
4912
|
-
`,Kg=new bt({vertexShader:T5,fragmentShader:E5,uniforms:{depthContrast:{value:1}}});var Zg=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,i)=>{let s=[i,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 Qg=new zs;Qg.wireframe=!0;var oP=new _,Kb=class extends pr{constructor(e,n){super();this.data=e;this.backupFog=new kl(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.bgColor=new Yt(1,1,1,1);this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Zg;this.needsRecomputeInstances=!1;this.ambientLight=new vp(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,n),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=nP(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=tP(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let n=e.identity.join("-"),i=this.entityIdentityToEntity[n];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[n]=e,this.entityByUuid[e.uuid]=e}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}getWithSortKey(e){let n=this.find(e);if(n===void 0)return;let i=[],s=n;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);i.splice(0,0,a)}return{entity:n,sortKey:i}}getAllSorted(e){let n=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&n.push(s)}return n.sort((i,s)=>gE(i.sortKey,s.sortKey)),n.map(i=>i.entity)}nonExistOrDescendantOf(e,n){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===n)return!0;i=i.parent}return!1}find(e){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}updateTreeByOp(e,n){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,i,e.localIndex,n);s.updateVisible(),s.resetBBoxNeedsUpdate(),Jr(s)&&$r(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s)}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let s=i.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(i),i.parent.remove(i),$r(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Jr(i)&&(i.freeBooleanPointer(),s instanceof vi&&s.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof ia&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid)}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let s=i.parent;this.markNeedsRecomputeInstancesForAncessors(s),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");o.add(i),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(),i.resetBBoxNeedsUpdate();let a=e.localIndex;o.children.splice(a,0,o.children.pop()),Jr(i)&&(i.invalidateUpstreamBooleanData(),$r(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof vi&&s.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(e,n,i,s){if(n.type===0){if(("overrides"in n.props||"component"in n.props)&&this.markNeedsRecomputeInstances(),n.path.includes("overrides")&&"states"in n.props){let{states:a,rest:l}=n.props;n={...n,props:l},this.markNeedsRecomputeInstances()}n.path[0]==="pathSnapping"&&n.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,n.props.pathId)}let o=this.find(e);if(o)try{JC(o,n,i,{scene:this,shared:s}),o instanceof Kt&&o.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,n){if(this.createChildrenObjects(e.objects,this,n),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Sr(e.backgroundColor,n)),this.updateFog(e.fog,n),this.updateAmbientLight(e.environment.ambientLight,n),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let i=this.find(e.publish.playCamera);i instanceof Zt&&this.switchActiveCamera(i)}this.expandInstances(n,!0),this.traverseEntity(i=>{$r(i)&&i.recomputeBoolean(),i instanceof Zt&&i.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){Pt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(n=>{Pt.is(n)&&n.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,n,i,s,o,a,l){e&&e!==s.uuid&&s.find(e)&&o.forInstancesRec(c=>{c.isInstanceRoot||(c.data=Fc(c.data,d=>{let h=d.events.data(l.id),f=c.goUp(a);if(f){let g=[...Bm(f.identity),e].join("-"),p=this.entityIdentityToEntity[g];if(p){let m=p.uuid;gr.zoom(h,n)[i]=m}else{if(!1)debugger;console.warn("cannot find instance")}}}).data)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Hi&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((n,i)=>{n.data.events.forEach(s=>{s.data.type==="GameControl"?n.forInstancesRec(o=>{o.isInstanceRoot||(o.data=Fc(o.data,a=>{a.events.delete(s.id)}).data)}):s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",e,n,i,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",e,n,i,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",e,n,i,s):s.data.condition.type==="Comparison"&&(s.data.condition.lOperand.type==="Property"&&this.relativeizeInner(s.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,n,i,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,n,i,s)),s.data.inActions.forEach(o=>{o.data.type==="Transition"&&this.relativeizeInner(o.data.object,["inActions",o.id],"object",e,n,i,s)}),s.data.outActions.forEach(o=>{o.data.type==="Transition"&&this.relativeizeInner(o.data.object,["outActions",o.id],"object",e,n,i,s)})):"actions"in s.data&&s.data.actions.forEach(o=>{o.data.type==="Transition"&&this.relativeizeInner(o.data.object,["actions",o.id],"object",e,n,i,s)})})}),!0})}expandInstances(e,n){let i=new Set;this.traverseEntity(s=>{if(s instanceof Hi&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),n||s.resetBBoxNeedsUpdate(),!0});for(let s of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Xg(s)}recomputeInstances(e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(n=>{n instanceof Hi&&n.isInstanceRoot&&(n.component=void 0)}),this.expandInstances(e,!1))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(n=>{let i=typeof n.identity=="string"?n.identity:n.identity.join("-");this.entityIdentityToEntity[i]===n&&(delete this.entityByUuid[n.uuid],delete this.entityIdentityToEntity[i]),n.dispose()})}clearScene(){for(let e of this.children)Pt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,n){this.init(e,n)}createPersonalCamera(){let e=new Zt(Kb.PERSONAL_CAMERA_ID,{...Wc.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(e),e}raycast(e){let n=[],i=s=>{for(let o of s.children){let a=o.cloner;Pt.is(o)&&!o.raycastLock&&(o.visible||a?.object.data.visible)&&((Jr(o)||qC(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,n),rP(o,e,n)),i(o))}};return i(this),n}forEachEntity(e){for(let n of this.children)Pt.is(n)&&e(n)}traverseEntity(e){for(let n of this.children)Pt.is(n)&&n.traverseEntity(e)}traverseObject(e){for(let n of this.children)xh.is(n)&&n.traverseObject(e)}traverseVisibleEntity(e){for(let n of this.children)Pt.is(n)&&n.visible&&n.traverseVisibleEntity(e)}updateFog(e,n){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Sr(e.color,n),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,n){e.color!==void 0&&(this.ambientLight.color=Sr(e.color,n)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.groundColor!==void 0&&(this.ambientLight.groundColor=Sr(e.groundColor,n)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}createChildrenObjects(e,n,i){let s=0;for(let o of e)this.createObject(o.id,o.data,o.children,n,s,i),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,i,s,o,a){let l={scene:this,shared:a},u=Yg(e,n,l);return u&&(this.entityByUuid[e]=u,s.add(u),s.children.splice(o,0,s.children.pop()),i.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,u,a)),u.updateState(n,l),u instanceof Kt&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),n.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,n.pathSnapping.pathId)),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 i=new xt;return i.setFromPoints(n),i.getCenter(oP),oP}copyMatrixWorld(e,n){if(e===null){n.identity();return}let i=this.find(e);i?n.copy(i.matrixWorld):n.identity()}copyParentMatrixWorld(e,n){if(e===null){n.identity();return}let i=this.find(e)?.parent;i?n.copy(i.matrixWorld):n.identity()}traverseMaterial(e){this.traverseEntity(n=>{if(n instanceof Vt)if(Array.isArray(n.material))for(let i=0;i<n.material.length;i++)n.material[i]instanceof Rr&&e(n.material[i]);else n.material instanceof Rr&&e(n.material)})}updateCanvasSize(e,n){this.activeCamera.setViewplaneSize(e,n);let i,s;e>=n?(i=n/e,s=1):(i=1,s=e/n),this.traverseMaterial(o=>{o.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=s})})}},ti=Kb;ti.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var df=(r,t)=>{let e=t.x-r.x,n=t.y-r.y;return Math.sqrt(e*e+n*n)},aP=(r,t)=>{let e=t.x-r.x,n=t.y-r.y;return M5(Math.atan2(n,e))},lP=(r,t,e)=>{let n={x:0,y:0};return e=Jg(e),n.x=r.x-t*Math.cos(e),n.y=r.y-t*Math.sin(e),n},Jg=r=>r*(Math.PI/180),M5=r=>r*(180/Math.PI),cP=r=>isNaN(r.buttons)?r.pressure!==0:r.buttons!==0,Zb=new Map,Qb=r=>{Zb.has(r)&&clearTimeout(Zb.get(r)),Zb.set(r,setTimeout(r,100))},Vu=(r,t,e)=>{let n=t.split(/[ ,]+/g),i;for(let s=0;s<n.length;s+=1)i=n[s],r.addEventListener?r.addEventListener(i,e,!1):r.attachEvent&&r.attachEvent(i,e)},Jb=(r,t,e)=>{let n=t.split(/[ ,]+/g),i;for(let s=0;s<n.length;s+=1)i=n[s],r.removeEventListener?r.removeEventListener(i,e):r.detachEvent&&r.detachEvent(i,e)};var $g=r=>(r.preventDefault(),r.type.match(/^touch/)?r.changedTouches:r),$b=()=>{if(typeof window>"u")return;let r=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:r,y:t}},ey=(r,t)=>{t.top||t.right||t.bottom||t.left?(r.style.top=t.top,r.style.right=t.right,r.style.bottom=t.bottom,r.style.left=t.left):(r.style.left=t.x+"px",r.style.top=t.y+"px")},ty=(r,t,e)=>{let n=dP(r);for(let i in n)if(n.hasOwnProperty(i))if(typeof t=="string")n[i]=t+" "+e;else{let s="";for(let o=0,a=t.length;o<a;o+=1)s+=t[o]+" "+e+", ";n[i]=s.slice(0,-2)}return n},uP=(r,t)=>{let e=dP(r);for(let n in e)e.hasOwnProperty(n)&&(e[n]=t);return e},dP=r=>{let t={};return t[r]="",["webkit","Moz","o"].forEach(function(n){t[n+r.charAt(0).toUpperCase()+r.slice(1)]=""}),t},ny=(r,t)=>{for(let e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);return r},hP=(r,t)=>{let e={};for(let n in r)r.hasOwnProperty(n)&&t.hasOwnProperty(n)?e[n]=t[n]:r.hasOwnProperty(n)&&(e[n]=r[n]);return e},hf=(r,t)=>{if(r.length)for(let e=0,n=r.length;e<n;e+=1)t(r[e]);else t(r)},fP=(r,t,e)=>({x:Math.min(Math.max(r.x,t.x-e),t.x+e),y:Math.min(Math.max(r.y,t.y-e),t.y+e)});typeof window<"u"&&(pP="ontouchstart"in window,mP=!!window.PointerEvent,gP=!!window.MSPointerEvent);var pP,mP,gP,ff={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"}},Hu,pf={};mP?Hu=ff.pointer:gP?Hu=ff.MSPointer:pP?(Hu=ff.touch,pf=ff.mouse):Hu=ff.mouse;function fl(){}fl.prototype.on=function(r,t){var e=this,n=r.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],e._handlers_[i]=e._handlers_[i]||[],e._handlers_[i].push(t);return e};fl.prototype.off=function(r,t){var e=this;return e._handlers_=e._handlers_||{},r===void 0?e._handlers_={}:t===void 0?e._handlers_[r]=null:e._handlers_[r]&&e._handlers_[r].indexOf(t)>=0&&e._handlers_[r].splice(e._handlers_[r].indexOf(t),1),e};fl.prototype.trigger=function(r,t){var e=this,n=r.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],e._handlers_[i]&&e._handlers_[i].length&&e._handlers_[i].forEach(function(o){o.call(e,{type:i,target:e},t)})};fl.prototype.config=function(r){var t=this;t.options=t.defaults||{},r&&(t.options=hP(t.options,r))};fl.prototype.bindEvt=function(r,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.')},Vu(r,Hu[t],e._domHandlers_[t]),pf[t]&&Vu(r,pf[t],e._domHandlers_[t]),e};fl.prototype.unbindEvt=function(r,t){var e=this;return e._domHandlers_=e._domHandlers_||{},Jb(r,Hu[t],e._domHandlers_[t]),pf[t]&&Jb(r,pf[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var Wu=fl;function Ln(r,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=r,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Ln.id,Ln.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}Ln.prototype=new Wu;Ln.constructor=Ln;Ln.id=0;Ln.prototype.buildEl=function(r){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};Ln.prototype.stylize=function(){if(this.options.dataOnly)return this;var r=this.options.fadeTime+"ms",t=uP("borderRadius","50%"),e=ty("transition","opacity",r),n={};return n.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},n.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},n.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},ny(n.el,e),this.options.shape==="circle"&&ny(n.back,t),ny(n.front,t),this.applyStyles(n),this};Ln.prototype.applyStyles=function(r){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var e in r[t])this.ui[t].style[e]=r[t][e];return this};Ln.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Ln.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Ln.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Ln.prototype.show=function(r){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 r=="function"&&r.call(this)},t.options.fadeTime)),t};Ln.prototype.hide=function(r){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 r=="function"&&r.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(r,n)}return t};Ln.prototype.setPosition=function(r,t){var e=this;e.frontPosition={x:t.x,y:t.y};var n=e.options.fadeTime+"ms",i={};i.front=ty("transition",["top","left"],n);var s={front:{}};s.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(i),e.applyStyles(s),e.restTimeout=setTimeout(function(){typeof r=="function"&&r.call(e),e.restCallback()},e.options.fadeTime)};Ln.prototype.restCallback=function(){var r=this,t={};t.front=ty("transition","none",""),r.applyStyles(t),r.trigger("rested",r.instance)};Ln.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Ln.prototype.computeDirection=function(r){var t=r.angle.radian,e=Math.PI/4,n=Math.PI/2,i,s,o;if(t>e&&t<e*3&&!r.lockX?i="up":t>-e&&t<=e&&!r.lockY?i="left":t>-e*3&&t<=-e&&!r.lockX?i="down":r.lockY||(i="right"),r.lockY||(t>-n&&t<n?s="left":s="right"),r.lockX||(t>0?o="up":o="down"),r.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var u={};this.direction={x:s,y:o,angle:i},r.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(u[l]=!0);if(u.x&&u.y&&u.angle)return r;(!u.x||!u.y)&&this.trigger("plain",r),u.x||this.trigger("plain:"+s,r),u.y||this.trigger("plain:"+o,r),u.angle||this.trigger("dir dir:"+i,r)}else this.resetDirection();return r};var yP=Ln;function hn(r,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=r,e.id=hn.id,hn.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}hn.prototype=new Wu;hn.constructor=hn;hn.id=0;hn.prototype.prepareNipples=function(){var r=this,t=r.nipples;t.on=r.on.bind(r),t.off=r.off.bind(r),t.options=r.options,t.destroy=r.destroy.bind(r),t.ids=r.ids,t.id=r.id,t.processOnMove=r.processOnMove.bind(r),t.processOnEnd=r.processOnEnd.bind(r),t.get=function(e){if(e===void 0)return t[0];for(var n=0,i=t.length;n<i;n+=1)if(t[n].identifier===e)return t[n];return!1}};hn.prototype.bindings=function(){var r=this;r.bindEvt(r.options.zone,"start"),r.options.zone.style.touchAction="none",r.options.zone.style.msTouchAction="none"};hn.prototype.begin=function(){var r=this,t=r.options;if(t.mode==="static"){var e=r.createNipple(t.position,r.manager.getIdentifier());e.add(),r.idles.push(e)}};hn.prototype.createNipple=function(r,t){var e=this,n=e.manager.scroll,i={},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(r.x&&r.y)i={x:r.x-o.x,y:r.y-o.y};else if(r.top||r.right||r.bottom||r.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=r.top,a.style.right=r.right,a.style.bottom=r.bottom,a.style.left=r.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),i=r,r={x:l.left+n.x,y:l.top+n.y}}var u=new yP(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:r,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(ey(u.ui.el,i),ey(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};hn.prototype.updateBox=function(){var r=this;r.box=r.options.zone.getBoundingClientRect()};hn.prototype.bindNipple=function(r){var t=this,e,n=function(i,s){e=i.type+" "+s.id+":"+i.type,t.trigger(e,s)};r.on("destroyed",t.onDestroyed.bind(t)),r.on("shown hidden rested dir plain",n),r.on("dir:up dir:right dir:down dir:left",n),r.on("plain:up plain:right plain:down plain:left",n)};hn.prototype.pressureFn=function(r,t,e){var n=this,i=0;clearInterval(n.pressureIntervals[e]),n.pressureIntervals[e]=setInterval(function(){var s=r.force||r.pressure||r.webkitForce||0;s!==i&&(t.trigger("pressure",s),n.trigger("pressure "+t.identifier+":pressure",s),i=s)}.bind(n),100)};hn.prototype.onstart=function(r){var t=this,e=t.options,n=r;r=$g(r),t.updateBox();var i=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=[r[0]];a.identifier=o,t.processOnEnd(a)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(s))};return hf(r,i),t.manager.bindDocument(),!1};hn.prototype.processOnStart=function(r){var t=this,e=t.options,n,i=t.manager.getIdentifier(r),s=r.force||r.pressure||r.webkitForce||0,o={x:r.pageX,y:r.pageY},a=t.getOrCreate(i,o);a.identifier!==i&&t.manager.removeIdentifier(a.identifier),a.identifier=i;var l=function(c){c.trigger("start",c),t.trigger("start "+c.id+":start",c),c.show(),s>0&&t.pressureFn(r,c,c.identifier),t.processOnMove(r)};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=df(o,a.position);if(u<=e.catchDistance)l(a);else{a.destroy(),t.processOnStart(r);return}}return a};hn.prototype.getOrCreate=function(r,t){var e=this,n=e.options,i;return/(semi|static)/.test(n.mode)?(i=e.idles[0],i?(e.idles.splice(0,1),i):n.mode==="semi"?e.createNipple(t,r):(console.warn("Coudln't find the needed nipple."),!1)):(i=e.createNipple(t,r),i)};hn.prototype.processOnMove=function(r){var t=this,e=t.options,n=t.manager.getIdentifier(r),i=t.nipples.get(n),s=t.manager.scroll;if(!cP(r)){this.processOnEnd(r);return}if(!i){console.error("Found zombie joystick with ID "+n),t.manager.removeIdentifier(n);return}if(e.dynamicPage){var o=i.el.getBoundingClientRect();i.position={x:s.x+o.left,y:s.y+o.top}}i.identifier=n;var a=i.options.size/2,l={x:r.pageX,y:r.pageY};e.lockX&&(l.y=i.position.y),e.lockY&&(l.x=i.position.x);var u=df(l,i.position),c=aP(l,i.position),d=Jg(c),h=u/a,f={distance:u,position:l},g,p;if(i.options.shape==="circle"?(g=Math.min(u,a),p=lP(i.position,g,c)):(p=fP(l,i.position,a),g=df(p,i.position)),e.follow){if(u>a){let x=l.x-p.x,b=l.y-p.y;i.position.x+=x,i.position.y+=b,i.el.style.top=i.position.y-(t.box.top+s.y)+"px",i.el.style.left=i.position.x-(t.box.left+s.x)+"px",u=df(l,i.position)}}else l=p,u=g;var m=l.x-i.position.x,y=l.y-i.position.y;i.frontPosition={x:m,y},e.dataOnly||ey(i.ui.front,i.frontPosition);var v={identifier:i.identifier,position:l,force:h,pressure:r.force||r.pressure||r.webkitForce||0,distance:u,angle:{radian:d,degree:c},vector:{x:m/a,y:-y/a},raw:f,instance:i,lockX:e.lockX,lockY:e.lockY};v=i.computeDirection(v),v.angle={radian:Jg(180-c),degree:180-c},i.trigger("move",v),t.trigger("move "+i.id+":move",v)};hn.prototype.processOnEnd=function(r){var t=this,e=t.options,n=t.manager.getIdentifier(r),i=t.nipples.get(n),s=t.manager.removeIdentifier(i.identifier);!i||(e.dataOnly||i.hide(function(){e.mode==="dynamic"&&(i.trigger("removed",i),t.trigger("removed "+i.id+":removed",i),t.manager.trigger("removed "+i.id+":removed",i),i.destroy())}),clearInterval(t.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),t.trigger("end "+i.id+":end",i),t.ids.indexOf(i.identifier)>=0&&t.ids.splice(t.ids.indexOf(i.identifier),1),t.actives.indexOf(i)>=0&&t.actives.splice(t.actives.indexOf(i),1),/(semi|static)/.test(e.mode)?t.idles.push(i):t.nipples.indexOf(i)>=0&&t.nipples.splice(t.nipples.indexOf(i),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[s.id]=s.identifier))};hn.prototype.onDestroyed=function(r,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()};hn.prototype.destroy=function(){var r=this;r.unbindEvt(r.options.zone,"start"),r.nipples.forEach(function(e){e.destroy()});for(var t in r.pressureIntervals)r.pressureIntervals.hasOwnProperty(t)&&clearInterval(r.pressureIntervals[t]);r.trigger("destroyed",r.nipples),r.manager.unbindDocument(),r.off()};var vP=hn;function Zn(r){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=$b(),t.config(r),t.prepareCollections();var e=function(){var i;t.collections.forEach(function(s){s.forEach(function(o){i=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+i.left,y:t.scroll.y+i.top}})})};if(typeof window>"u")return t.collections;Vu(window,"resize",function(){Qb(e)});var n=function(){t.scroll=$b()};return Vu(window,"scroll",function(){Qb(n)}),t.collections}Zn.prototype=new Wu;Zn.constructor=Zn;Zn.prototype.prepareCollections=function(){var r=this;r.collections.create=r.create.bind(r),r.collections.on=r.on.bind(r),r.collections.off=r.off.bind(r),r.collections.destroy=r.destroy.bind(r),r.collections.get=function(t){var e;return r.collections.every(function(n){return e=n.get(t),!e}),e}};Zn.prototype.create=function(r){return this.createCollection(r)};Zn.prototype.createCollection=function(r){var t=this,e=new vP(t,r);return t.bindCollection(e),t.collections.push(e),e};Zn.prototype.bindCollection=function(r){var t=this,e,n=function(i,s){e=i.type+" "+s.id+":"+i.type,t.trigger(e,s)};r.on("destroyed",t.onDestroyed.bind(t)),r.on("shown hidden rested dir plain",n),r.on("dir:up dir:right dir:down dir:left",n),r.on("plain:up plain:right plain:down plain:left",n)};Zn.prototype.bindDocument=function(){var r=this;r.binded||(r.bindEvt(document,"move").bindEvt(document,"end"),r.binded=!0)};Zn.prototype.unbindDocument=function(r){var t=this;(!Object.keys(t.ids).length||r===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};Zn.prototype.getIdentifier=function(r){var t;return r?(t=r.identifier===void 0?r.pointerId:r.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]};Zn.prototype.removeIdentifier=function(r){var t={};for(var e in this.ids)if(this.ids[e]===r){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};Zn.prototype.onmove=function(r){var t=this;return t.onAny("move",r),!1};Zn.prototype.onend=function(r){var t=this;return t.onAny("end",r),!1};Zn.prototype.oncancel=function(r){var t=this;return t.onAny("end",r),!1};Zn.prototype.onAny=function(r,t){var e=this,n,i="processOn"+r.charAt(0).toUpperCase()+r.slice(1);t=$g(t);var s=function(a,l,u){u.ids.indexOf(l)>=0&&(u[i](a),a._found_=!0)},o=function(a){n=e.getIdentifier(a),hf(e.collections,s.bind(null,a,n)),a._found_||e.removeIdentifier(n)};return hf(t,o),!1};Zn.prototype.destroy=function(){var r=this;r.unbindDocument(!0),r.ids={},r.index=0,r.collections.forEach(function(t){t.destroy()}),r.off()};Zn.prototype.onDestroyed=function(r,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1)};var xP=Zn;var bP=new xP,SP={create:function(r){return bP.create(r)},factory:bP};var wP=dd(Rx());function pl(r,t){let e=new Te;if(!r.getAttribute("position"))return e.setAttribute("position",new we([],3)),e.setIndex([]),e;let{positions:n,triIndices:i}=Dh(r.getAttribute("position"),r.getIndex());return e.setAttribute("position",new we(n,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}var C5=new de,P5=new de,bs=[[0,0,0],[0,0,0],[0,0,0]];function eS(r){let t=r.elements;bs[0][0]=t[0],bs[0][1]=t[4],bs[0][2]=t[8],bs[1][0]=t[1],bs[1][1]=t[5],bs[1][2]=t[9],bs[2][0]=t[2],bs[2][1]=t[6],bs[2][2]=t[10];let{u:e,v:n}=(0,wP.SVD)(bs),i=C5.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=P5.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1);return i.multiply(s.transpose())}var iy=class extends $l{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(i=>{i.visible&&this.intersectObject(i,e,n)}),n}createRaycastLineHelper(){let t=new ai({color:65280,linewidth:10}),e=new _(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new _(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),i=this.camera.far-this.camera.near,s=new _().addVectors(e,n.multiplyScalar(i)),o=new Te;return o.setFromPoints([e,s]),new Pa(o,t)}};var AP=r=>r instanceof hl||r instanceof Hi;function I5(r,t){return r.distance-t.distance}function _P(r,t,e){if(!(!ro(t)||!t.visible)){Jr(t)&&t.raycast(r,e);for(let n of t.children)_P(r,n,e)}}function mf(r,t,e){if(!e.some(i=>ju(r,i)!==void 0))return[];let n=[];return t.children.forEach(i=>_P(r,i,n)),n.sort(I5),n}function gf(r){let t=[];if(r.length){let e=r[0].object;ro(e)&&t.push(e);let n=e.parent;for(;n;)AP(n)&&t.push(n),n=n.parent}return t}function ju(r,t){if(Jr(t)){if(t.visible){let e=[];return t.raycast(r,e),e.length?e[0]:void 0}}else if(AP(t))return TP(r,t)}function TP(r,t){if(!(!ro(t)||!t.visible)){if(Jr(t)){let e=[];if(t.raycast(r,e),e.length)return e[0]}for(let e of t.children){let n=TP(r,e);if(n)return n}}}function D5(r,t,e){return{x:(r-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}var sy=class{constructor(t,e,n,i,s,o){this.isExport=o;this.raycaster=new iy;this.raycasterNeedsUpdate=!0;this.stopRaycast=!1;this._useWindowEvents=!1;this.sharedAssets=new so(Kc.emptyData());this.scene=new ti({...zm.defaultData},this.sharedAssets);this.camera=new Zt;this.renderer=t,this._useWindowEvents=e.data.publish.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement,this.stopRaycast=s,this.sharedAssets=i,this.scene=e,this.camera=n}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!==void 0&&t.touches.length>0?t.touches[0]:t,i=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(D5(e,n,i),this.camera)}};var tS=(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))(tS||{}),Qn=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var EP=new Map,yf=new Map,co=class{constructor(t,e,n,i){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"?i.getAudio(s).src:s.data;this.audioPlayer=new io({src:u,volume:o,delay:a,loop:l}),yf.has(n.uuid)?yf.get(n.uuid).push(this):yf.set(n.uuid,[this]),EP.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()}},qu=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=EP.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=yf.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=[...yf.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}},Ss=class{constructor(t,e,n,i){this.data=e;if(e.interaction==="play")this.interaction=new co(t,e,n,i);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new qu(e);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof co?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof co?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(t){this.interaction instanceof co&&(t==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};function MP(r,t){let e=r.material.layers.find(n=>n.uuid===t);return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var CP=new Map,vf=new Map,sa=class{constructor(t,e,n){this.data=e;this.delay=0;this.status="stopped";let{layerId:i,loop:s,volume:o,delay:a}=e;if(this.object=n,i===void 0)throw new Error("Missing property");let l=MP(n,i);if(l)this.videoElement=l,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,o!==void 0&&(this.videoElement.volume=o);else throw new Error("Missing property");a!==void 0&&(this.delay=a),vf.has(n.uuid)?vf.get(n.uuid).push(this):vf.set(n.uuid,[this]),CP.set(t,this),this.pause()}mute(){this.videoElement.muted=!0}unMute(){this.videoElement.muted=!1}play(t){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(()=>{this.videoElement.play(),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){this.videoElement.pause(),this.status="paused"}stop(){this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay()}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){this.stop(),this.videoElement.muted=!0}},Xu=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=CP.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=vf.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=[...vf.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}},oa=class{constructor(t,e,n){this.data=e;if(e.interaction==="play")this.interaction=new sa(t,e,n);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Xu(e);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof sa?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof sa?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var O5="text/plain",L5="us-ascii",PP=(r,t)=>t.some(e=>e instanceof RegExp?e.test(r):e===r),R5=(r,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(r);if(!e)throw new Error(`Invalid URL: ${r}`);let{type:n,data:i,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(d=>{let[h,f=""]=d.split("=").map(g=>g.trim());return h==="charset"&&(f=f.toLowerCase(),f===L5)?"":`${h}${f?`=${f}`:""}`}).filter(Boolean)];return a&&c.push("base64"),(c.length>0||l&&l!==O5)&&c.unshift(l),`data:${c.join(";")},${a?i.trim():i}${s?`#${s}`:""}`};function nS(r,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},r=r.trim(),/^data:/i.test(r))return R5(r,t);if(/^view-source:/i.test(r))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=r.startsWith("//");!e&&/^\.*\//.test(r)||(r=r.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let i=new URL(r);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&i.protocol==="https:"&&(i.protocol="http:"),t.forceHttps&&i.protocol==="http:"&&(i.protocol="https:"),t.stripAuthentication&&(i.username="",i.password=""),t.stripHash?i.hash="":t.stripTextFragment&&(i.hash=i.hash.replace(/#?:~:text.*?$/i,"")),i.pathname){let o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let c=o.exec(i.pathname);if(!c)break;let d=c[0],h=c.index,f=i.pathname.slice(a,h);l+=f.replace(/\/{2,}/g,"/"),l+=d,a=h+d.length}let u=i.pathname.slice(a,i.pathname.length);l+=u.replace(/\/{2,}/g,"/"),i.pathname=l}if(i.pathname)try{i.pathname=decodeURI(i.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let o=i.pathname.split("/"),a=o[o.length-1];PP(a,t.removeDirectoryIndex)&&(o=o.slice(0,-1),i.pathname=o.slice(1).join("/")+"/")}if(i.hostname&&(i.hostname=i.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(i.hostname)&&(i.hostname=i.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let o of[...i.searchParams.keys()])PP(o,t.removeQueryParameters)&&i.searchParams.delete(o);if(t.removeQueryParameters===!0&&(i.search=""),t.sortQueryParameters){i.searchParams.sort();try{i.search=decodeURIComponent(i.search)}catch{}}t.removeTrailingSlash&&(i.pathname=i.pathname.replace(/\/$/,""));let s=r;return r=i.toString(),!t.removeSingleSlash&&i.pathname==="/"&&!s.endsWith("/")&&i.hash===""&&(r=r.replace(/\/$/,"")),(t.removeTrailingSlash||i.pathname==="/")&&i.hash===""&&t.removeSingleSlash&&(r=r.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(r=r.replace(/^http:\/\//,"//")),t.stripProtocol&&(r=r.replace(/^(?:https?:)?\/\//,"")),r}var oy=class{constructor({url:t,context:e},n){this.managers=n;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:nS(t,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=e??"tab"}dispatch(){ch?window.location.assign(this.url):(this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.managers.controlsManager.orbitControls?.onPointerUp(Je[0]),vE())}};var ay=class{constructor(t,e,n,i){this.scene=e,this.sharedAssets=n,this.sceneData=t,this.managers=i}dispatch(){ly(this.sceneData,this.scene,this.sharedAssets,!0),this.managers.eventManager?.reset(),this.managers.controlsManager.orbitControls?.reset(),this.managers.controlsManager?.gameControls.forEach(t=>t.reset(!0))}};var NP={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},oS={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},N5=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],uy={CSS:{},springs:{}};function ws(r,t,e){return Math.min(Math.max(r,t),e)}function xf(r,t){return r.indexOf(t)>-1}function rS(r,t){return r.apply(null,t)}var Ke={arr:function(r){return Array.isArray(r)},obj:function(r){return xf(Object.prototype.toString.call(r),"Object")},pth:function(r){return Ke.obj(r)&&r.hasOwnProperty("totalLength")},svg:function(r){return r instanceof SVGElement},inp:function(r){return r instanceof HTMLInputElement},dom:function(r){return!("isNode"in r)&&(r.nodeType||Ke.svg(r))},str:function(r){return typeof r=="string"},fnc:function(r){return typeof r=="function"},und:function(r){return typeof r>"u"},hex:function(r){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(r)},rgb:function(r){return/^rgb/.test(r)},hsl:function(r){return/^hsl/.test(r)},col:function(r){return Ke.hex(r)||Ke.rgb(r)||Ke.hsl(r)},key:function(r){return!NP.hasOwnProperty(r)&&!oS.hasOwnProperty(r)&&r!=="targets"&&r!=="keyframes"}};function BP(r){var t=/\(([^)]+)\)/.exec(r);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function FP(r,t){var e=BP(r),n=ws(Ke.und(e[0])?1:e[0],.1,100),i=ws(Ke.und(e[1])?100:e[1],.1,100),s=ws(Ke.und(e[2])?10:e[2],.1,100),o=ws(Ke.und(e[3])?0:e[3],.1,100),a=Math.sqrt(i/n),l=s/(2*Math.sqrt(i*n)),u=l<1?a*Math.sqrt(1-l*l):0,c=1,d=l<1?(l*a+-o)/u:-o+a;function h(g){var p=t?t*g/1e3:g;return l<1?p=Math.exp(-p*l*a)*(c*Math.cos(u*p)+d*Math.sin(u*p)):p=(c+d*p)*Math.exp(-p*a),g===0||g===1?g:1-p}function f(){var g=uy.springs[r];if(g)return g;for(var p=1/6,m=0,y=0;;)if(m+=p,h(m)===1){if(y++,y>=16)break}else y=0;var v=m*p*1e3;return uy.springs[r]=v,v}return t?h:f}function B5(r){return r===void 0&&(r=10),function(t){return Math.ceil(ws(t,1e-6,1)*r)*(1/r)}}var F5=function(){var r=11,t=1/(r-1);function e(c,d){return 1-3*d+3*c}function n(c,d){return 3*d-6*c}function i(c){return 3*c}function s(c,d,h){return((e(d,h)*c+n(d,h))*c+i(d))*c}function o(c,d,h){return 3*e(d,h)*c*c+2*n(d,h)*c+i(d)}function a(c,d,h,f,g){var p,m,y=0;do m=d+(h-d)/2,p=s(m,f,g)-c,p>0?h=m:d=m;while(Math.abs(p)>1e-7&&++y<10);return m}function l(c,d,h,f){for(var g=0;g<4;++g){var p=o(d,h,f);if(p===0)return d;var m=s(d,h,f)-c;d-=m/p}return d}function u(c,d,h,f){if(!(0<=c&&c<=1&&0<=h&&h<=1))return;var g=new Float32Array(r);if(c!==d||h!==f)for(var p=0;p<r;++p)g[p]=s(p*t,c,h);function m(y){for(var v=0,x=1,b=r-1;x!==b&&g[x]<=y;++x)v+=t;--x;var w=(y-g[x])/(g[x+1]-g[x]),A=v+w*t,T=o(A,c,h);return T>=.001?l(y,A,c,h):T===0?A:a(y,v,v+t,c,h)}return function(y){return c===d&&h===f||y===0||y===1?y:s(m(y),d,f)}}return u}(),UP=function(){var r={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 i,s=4;n<((i=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((i*3-2)/22-n,2)}},Elastic:function(n,i){n===void 0&&(n=1),i===void 0&&(i=.5);var s=ws(n,1,10),o=ws(i,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},e=["Quad","Cubic","Quart","Quint","Expo"];return e.forEach(function(n,i){t[n]=function(){return function(s){return Math.pow(s,i+2)}}}),Object.keys(t).forEach(function(n){var i=t[n];r["easeIn"+n]=i,r["easeOut"+n]=function(s,o){return function(a){return 1-i(s,o)(1-a)}},r["easeInOut"+n]=function(s,o){return function(a){return a<.5?i(s,o)(a*2)/2:1-i(s,o)(a*-2+2)/2}}}),r}();function aS(r,t){if(Ke.fnc(r))return r;var e=r.split("(")[0],n=UP[e],i=BP(r);switch(e){case"spring":return FP(r,t);case"cubicBezier":return rS(F5,i);case"steps":return rS(B5,i);default:return rS(n,i)}}function GP(r){try{var t=document.querySelectorAll(r);return t}catch{return}}function dy(r,t){for(var e=r.length,n=arguments.length>=2?arguments[1]:void 0,i=[],s=0;s<e;s++)if(s in r){var o=r[s];t.call(n,o,s,r)&&i.push(o)}return i}function hy(r){return r.reduce(function(t,e){return t.concat(Ke.arr(e)?hy(e):e)},[])}function IP(r){return Ke.arr(r)?r:(Ke.str(r)&&(r=GP(r)||r),r instanceof NodeList||r instanceof HTMLCollection?[].slice.call(r):[r])}function lS(r,t){return r.some(function(e){return e===t})}function cS(r){var t={};for(var e in r)t[e]=r[e];return t}function iS(r,t){var e=cS(r);for(var n in r)e[n]=t.hasOwnProperty(n)?t[n]:r[n];return e}function fy(r,t){var e=cS(r);for(var n in t)e[n]=Ke.und(r[n])?t[n]:r[n];return e}function U5(r){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(r);return t?"rgba("+t[1]+",1)":r}function G5(r){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=r.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),i=parseInt(n[1],16),s=parseInt(n[2],16),o=parseInt(n[3],16);return"rgba("+i+","+s+","+o+",1)"}function k5(r){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(r)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(r),e=parseInt(t[1],10)/360,n=parseInt(t[2],10)/100,i=parseInt(t[3],10)/100,s=t[4]||1;function o(h,f,g){return g<0&&(g+=1),g>1&&(g-=1),g<1/6?h+(f-h)*6*g:g<1/2?f:g<2/3?h+(f-h)*(2/3-g)*6:h}var a,l,u;if(n==0)a=l=u=i;else{var c=i<.5?i*(1+n):i+n-i*n,d=2*i-c;a=o(d,c,e+1/3),l=o(d,c,e),u=o(d,c,e-1/3)}return"rgba("+a*255+","+l*255+","+u*255+","+s+")"}function z5(r){if(Ke.rgb(r))return U5(r);if(Ke.hex(r))return G5(r);if(Ke.hsl(r))return k5(r)}function uo(r){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(r);if(t)return t[1]}function V5(r){if(xf(r,"translate")||r==="perspective")return"px";if(xf(r,"rotate")||xf(r,"skew"))return"deg"}function sS(r,t){return Ke.fnc(r)?r(t.target,t.id,t.total):r}function As(r,t){return r.getAttribute(t)}function uS(r,t,e){var n=uo(t);if(lS([e,"deg","rad","turn"],n))return t;var i=uy.CSS[t+e];if(!Ke.und(i))return i;var s=100,o=document.createElement(r.tagName),a=r.parentNode&&r.parentNode!==document?r.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+e;var l=s/o.offsetWidth;a.removeChild(o);var u=l*parseFloat(t);return uy.CSS[t+e]=u,u}function kP(r,t,e){if(t in r.style){var n=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=r.style[t]||getComputedStyle(r).getPropertyValue(n)||"0";return e?uS(r,i,e):i}}function dS(r,t){if(Ke.dom(r)&&!Ke.inp(r)&&(As(r,t)||Ke.svg(r)&&r[t]))return"attribute";if(Ke.dom(r)&&lS(N5,t))return"transform";if(Ke.dom(r)&&t!=="transform"&&kP(r,t))return"css";if(r[t]!=null)return"object"}function zP(r){if(!!Ke.dom(r)){for(var t=r.style.transform||"",e=/(\w+)\(([^)]*)\)/g,n=new Map,i;i=e.exec(t);)n.set(i[1],i[2]);return n}}function H5(r,t,e,n){var i=xf(t,"scale")?1:0+V5(t),s=zP(r).get(t)||i;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),n?uS(r,s,n):s}function hS(r,t,e,n){switch(dS(r,t)){case"transform":return H5(r,t,n,e);case"css":return kP(r,t,e);case"attribute":return As(r,t);default:return r[t]||0}}function fS(r,t){var e=/^(\*=|\+=|-=)/.exec(r);if(!e)return r;var n=uo(r)||0,i=parseFloat(t),s=parseFloat(r.replace(e[0],""));switch(e[0][0]){case"+":return i+s+n;case"-":return i-s+n;case"*":return i*s+n}}function VP(r,t){if(Ke.col(r))return z5(r);if(/\s/g.test(r))return r;var e=uo(r),n=e?r.substr(0,r.length-e.length):r;return t?n+t:n}function pS(r,t){return Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2))}function W5(r){return Math.PI*2*As(r,"r")}function j5(r){return As(r,"width")*2+As(r,"height")*2}function q5(r){return pS({x:As(r,"x1"),y:As(r,"y1")},{x:As(r,"x2"),y:As(r,"y2")})}function HP(r){for(var t=r.points,e=0,n,i=0;i<t.numberOfItems;i++){var s=t.getItem(i);i>0&&(e+=pS(n,s)),n=s}return e}function X5(r){var t=r.points;return HP(r)+pS(t.getItem(t.numberOfItems-1),t.getItem(0))}function WP(r){if(r.getTotalLength)return r.getTotalLength();switch(r.tagName.toLowerCase()){case"circle":return W5(r);case"rect":return j5(r);case"line":return q5(r);case"polyline":return HP(r);case"polygon":return X5(r)}}function Y5(r){var t=WP(r);return r.setAttribute("stroke-dasharray",t),t}function K5(r){for(var t=r.parentNode;Ke.svg(t)&&Ke.svg(t.parentNode);)t=t.parentNode;return t}function jP(r,t){var e=t||{},n=e.el||K5(r),i=n.getBoundingClientRect(),s=As(n,"viewBox"),o=i.width,a=i.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 Z5(r,t){var e=Ke.str(r)?GP(r)[0]:r,n=t||100;return function(i){return{property:i,el:e,svg:jP(e),totalLength:WP(e)*(n/100)}}}function Q5(r,t){function e(a){a===void 0&&(a=0);var l=t+a>=1?t+a:0;return r.el.getPointAtLength(l)}var n=jP(r.el,r.svg),i=e(),s=e(-1),o=e(1);switch(r.property){case"x":return(i.x-n.x)*n.w;case"y":return(i.y-n.y)*n.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function DP(r,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,n=VP(Ke.pth(r)?r.totalLength:r,t)+"";return{original:n,numbers:n.match(e)?n.match(e).map(Number):[0],strings:Ke.str(r)||t?n.split(e):[]}}function qP(r){var t=r?hy(Ke.arr(r)?r.map(IP):IP(r)):[];return dy(t,function(e,n,i){return i.indexOf(e)===n})}function XP(r){var t=qP(r);return t.map(function(e,n){return{target:e,id:n,total:t.length,transforms:{list:zP(e)}}})}function J5(r,t){var e=cS(t);if(/^spring/.test(e.easing)&&(e.duration=FP(e.easing)),Ke.arr(r)){var n=r.length,i=n===2&&!Ke.obj(r[0]);i?r={value:r}:Ke.fnc(t.duration)||(e.duration=t.duration/n)}var s=Ke.arr(r)?r:[r];return s.map(function(o,a){var l=Ke.obj(o)&&!Ke.pth(o)?o:{value:o};return Ke.und(l.delay)&&(l.delay=a?0:t.delay),Ke.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return fy(o,e)})}function $5(r){for(var t=dy(hy(r.map(function(s){return Object.keys(s)})),function(s){return Ke.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]=r.map(function(a){var l={};for(var u in a)Ke.key(u)?u==o&&(l.value=a[u]):l[u]=a[u];return l})},i=0;i<t.length;i++)n(i);return e}function eW(r,t){var e=[],n=t.keyframes;n&&(t=fy($5(n),t));for(var i in t)Ke.key(i)&&e.push({name:i,tweens:J5(t[i],r)});return e}function tW(r,t){var e={};for(var n in r){var i=sS(r[n],t);Ke.arr(i)&&(i=i.map(function(s){return sS(s,t)}),i.length===1&&(i=i[0])),e[n]=i}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function nW(r,t){var e;return r.tweens.map(function(n){var i=tW(n,t),s=i.value,o=Ke.arr(s)?s[1]:s,a=uo(o),l=hS(t.target,r.name,a,t),u=e?e.to.original:l,c=Ke.arr(s)?s[0]:u,d=uo(c)||uo(l),h=a||d;return Ke.und(o)&&(o=u),i.from=DP(c,h),i.to=DP(fS(o,c),h),i.start=e?e.end:0,i.end=i.start+i.delay+i.duration+i.endDelay,i.easing=aS(i.easing,i.duration),i.isPath=Ke.pth(s),i.isColor=Ke.col(i.from.original),i.isColor&&(i.round=1),e=i,i})}var YP={css:function(r,t,e){return r.style[t]=e},attribute:function(r,t,e){return r.setAttribute(t,e)},object:function(r,t,e){return r[t]=e},transform:function(r,t,e,n,i){if(n.list.set(t,e),t===n.last||i){var s="";n.list.forEach(function(o,a){s+=a+"("+o+") "}),r.style.transform=s}}};function KP(r,t){var e=XP(r);e.forEach(function(n){for(var i in t){var s=sS(t[i],n),o=n.target,a=uo(s),l=hS(o,i,a,n),u=a||uo(l),c=fS(VP(s,u),l),d=dS(o,i);YP[d](o,i,c,n.transforms,!0)}})}function rW(r,t){var e=dS(r.target,t.name);if(e){var n=nW(t,r),i=n[n.length-1];return{type:e,property:t.name,animatable:r,tweens:n,duration:i.end,delay:n[0].delay,endDelay:i.endDelay}}}function iW(r,t){return dy(hy(r.map(function(e){return t.map(function(n){return rW(e,n)})})),function(e){return!Ke.und(e)})}function ZP(r,t){var e=r.length,n=function(s){return s.timelineOffset?s.timelineOffset:0},i={};return i.duration=e?Math.max.apply(Math,r.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.duration*(s.loop??1)})):t.duration,i.delay=e?Math.min.apply(Math,r.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.delay})):t.delay,i.endDelay=e?i.duration-Math.max.apply(Math,r.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.duration*(s.loop??1)-s.endDelay})):t.endDelay,i}var OP=0;function sW(r){var t=iS(NP,r),e=iS(oS,r),n=eW(e,r),i=XP(r.targets),s=iW(i,n),o=ZP(s,e),a=OP;return OP++,fy(t,{id:a,children:[],animatables:i,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:e.startOnceDelay,pingPongDelayCorrection:e.pingPongDelayCorrection})}var xi=[],LP=[],cy,oW=function(){function r(){cy=requestAnimationFrame(t)}function t(e){var n=xi.length;if(n){for(var i=0;i<n;){var s=xi[i];s.paused?(xi.splice(i,1),n-=1):(s.tick(e),i++)}r()}else cy=cancelAnimationFrame(cy)}return r}();function aW(r){document.hidden?(xi.forEach(function(t){return t.pause(r.timeStamp)}),LP=xi.slice(0),fn.running=xi=[]):LP.forEach(function(t){return t.play(r.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",aW);function fn(r){r===void 0&&(r={});var t=0,e=0,n=0,i,s,o=0,a=null;function l(b){var w=window.Promise&&new Promise(function(A){return a=A});return b.finished=w,w}var u=sW(r),c=l(u);function d(){var b=u.direction;b!=="alternate"&&(u.direction=b!=="normal"?"normal":"reverse"),u.reversed=!u.reversed,s.forEach(function(w){return w.reversed=u.reversed})}function h(b){return u.reversed?u.duration-b:b}function f(){t=0,e=h(u.currentTime)*(1/fn.speed)}function g(b,w){w&&(u.reversed?w.seek(w.duration*w.loop-(b-w.timelineOffset-w.pingPongDelayCorrection)):w.seek(b-w.timelineOffset-w.startOnceDelay-w.pingPongDelayCorrection))}function p(b){if(u.reversed)for(var A=o;A--;)g(b,s[A]);else for(var w=0;w<o;w++)g(b,s[w])}function m(b){var w=0,A=u.animations,T=A.length;for(u.reversePlayback===!0&&u.rewind===!1&&(b=u.duration+u.delay-u.endDelay-b);w<T;){var S=A[w],E=S.animatable,M=S.tweens,I=M.length-1,P=M[I];I&&(P=dy(M,function(J){return b<J.end})[0]||P);for(var C=ws(b-P.start-P.delay,0,P.duration)/P.duration,D=isNaN(C)?1:P.easing(C),B=P.to.strings,k=P.round,X=[],W=P.to.numbers.length,q=void 0,H=0;H<W;H++){var K=void 0;if(u.reversePlayback===!0&&u.rewind===!1)var R=P.to.numbers[H],U=P.from.numbers[H]||0;else var U=P.to.numbers[H],R=P.from.numbers[H]||0;P.isPath?K=Q5(P.value,D*U):K=R+D*(U-R),k&&(P.isColor&&H>2||(K=Math.round(K*k)/k)),X.push(K)}var z=B.length;if(!z)q=X[0];else{q=B[0];for(var j=0;j<z;j++){var G=B[j],re=B[j+1],Z=X[j];isNaN(Z)||(re?q+=Z+re:q+=Z+" ")}}YP[S.type](E.target,S.property,q,E.transforms),S.currentValue=q,w++}}function y(b){u[b]&&!u.passThrough&&u[b](u)}function v(){u.remaining&&u.remaining!==!0&&u.remaining--}function x(b){var w=u.duration,A=u.delay,T=w-u.endDelay,S=h(b);if(u.progress=ws(S/w*100,0,100),u.reversePlayback=S<u.currentTime,o&&p(S),!u.began&&u.currentTime>=0&&(u.began=!0,y("begin")),!u.loopBegan&&u.currentTime>0&&(u.loopBegan=!0,y("loopBegin")),(u.reversed||S>=0)&&S<=A&&u.currentTime!==0&&(m(0),y("change")),(S>=T&&u.currentTime!==w||!w)&&(m(w),y("change")),S>A&&S<T?(u.changeBegan||(u.changeBegan=!0,u.changeCompleted=!1,y("changeBegin")),m(S),y("change")):u.changeBegan?(u.changeCompleted=!0,u.changeBegan=!1,y("change"),o&&y("timelineChangeComplete")):u.began&&S>T&&y("changeComplete"),u.currentTime=ws(S,0,w),u.began&&y("update"),b>=w)if(v(),!u.remaining)u.paused=!0,u.completed||(u.completed=!0,y("loopComplete"),y("complete"),!u.passThrough&&"Promise"in window&&(a(),c=l(u)));else{o?t+=u.duration/fn.speed:t+=u.duration;for(let E of s)E.setStartTime(0),E.remaining=E.loop;y("loopComplete"),u.loopBegan=!1,u.direction==="alternate"&&d()}}return u.reset=function(){var b=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=b==="reverse",u.remaining=u.loop,s=u.children,o=s.length;for(var w=o;w--;)u.children[w].reset();(u.reversed&&u.loop!==!0||b==="alternate"&&u.loop===1)&&u.remaining++,m(u.reversed?u.duration:0)},u.setStartTime=function(b){t=b},u.set=function(b,w){return KP(b,w),u},u.tick=function(b){n=b,t||(t=n),x((n+(e-t))*fn.speed)},u.seek=function(b){x(b-t)},u.pause=function(b){u.paused=!0,o&&(i=b??performance.now())},u.play=function(b){!u.paused||(u.completed&&u.reset(),u.paused=!1,xi.push(u),o&&i!==void 0&&(t+=(b??performance.now())-i),cy||oW())},u.reverse=function(){d(),u.completed=!u.reversed,f()},u.restart=function(){u.reset(),u.play()},u.reset(),u.autoplay&&u.play(),u}function RP(r,t){for(var e=t.length;e--;)lS(r,t[e].animatable.target)&&t.splice(e,1)}function lW(r){for(var t=qP(r),e=xi.length;e--;){var n=xi[e],i=n.animations,s=n.children;RP(t,i);for(var o=s.length;o--;){var a=s[o],l=a.animations;RP(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!i.length&&!s.length&&n.pause()}}function cW(r,t){t===void 0&&(t={});var e=t.direction||"normal",n=t.easing?aS(t.easing):null,i=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",u=o==="last",c=Ke.arr(r),d=parseFloat(c?r[0]:r),h=c?parseFloat(r[1]):0,f=uo(c?r[1]:r)||0,g=t.start||0+(c?d:0),p=[],m=0;return function(y,v,x){if(a&&(o=0),l&&(o=(x-1)/2),u&&(o=x-1),!p.length){for(var b=0;b<x;b++){if(!i)p.push(Math.abs(o-b));else{var w=l?(i[0]-1)/2:o%i[0],A=l?(i[1]-1)/2:Math.floor(o/i[0]),T=b%i[0],S=Math.floor(b/i[0]),E=w-T,M=A-S,I=Math.sqrt(E*E+M*M);s==="x"&&(I=-E),s==="y"&&(I=-M),p.push(I)}m=Math.max.apply(Math,p)}n&&(p=p.map(function(C){return n(C/m)*m})),e==="reverse"&&(p=p.map(function(C){return s?C<0?C*-1:-C:Math.abs(m-C)}))}var P=c?(h-d)/m:d;return g+P*(Math.round(p[v]*100)/100)+f}}function uW(r){r===void 0&&(r={});var t=fn(r);return t.duration=0,t.add=function(e,n){var i=xi.indexOf(t),s=t.children;i>-1&&xi.splice(i,1);function o(h){h.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=fy(e,iS(oS,r));l.targets=l.targets||r.targets;var u=t.duration;l.autoplay=!1,l.timelineOffset=Ke.und(n)?u:fS(n,u),o(t);var c=fn(l);o(c),s.push(c);var d=ZP(s,r);return t.delay=d.delay,t.endDelay=d.endDelay,t.duration=d.duration,c.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}fn.version="3.2.0";fn.speed=1;fn.running=xi;fn.remove=lW;fn.get=hS;fn.set=KP;fn.convertPx=uS;fn.path=Z5;fn.setDashoffset=Y5;fn.stagger=cW;fn.timeline=uW;fn.easing=aS;fn.penner=UP;fn.random=function(r,t){return Math.floor(Math.random()*(t-r+1))+r};var QP=fn;var JP=new _,$P=new _,e2=new rt;function t2(r,t,e,n){if(n===0)return e.copy(r);if(n===1)return e.copy(t);let i=r.w*t.w+r.x*t.x+r.y*t.y+r.z*t.z;if(i>=1)return e.copy(r);let s=1-i*i;if(s<=Number.EPSILON){let c=1-n;return e.w=c*r.w+n*t.w,e.x=c*r.x+n*t.x,e.y=c*r.y+n*t.y,e.z=c*r.z+n*t.z,e.normalize(),e}let o=Math.sqrt(s),a=Math.atan2(o,i),l=Math.sin((1-n)*a)/o,u=Math.sin(n*a)/o;return e.w=r.w*l+t.w*u,e.x=r.x*l+t.x*u,e.y=r.y*l+t.y*u,e.z=r.z*l+t.z*u,e}function Wi(r,t,e,n,i){let s=e[r]?e[r]:void 0,o=n[r];if(o==null)return;let a=s??t[r],l=o;if(a!==l)return{update:u=>{let c=Ve.lerp(a,l,u);i?t[r]=Math.trunc(c):t[r]=c},start:()=>{t[r]=a},end:()=>{t[r]=l}}}function mS(r,t,e,n,i){let s=e[r]?e[r]:void 0,o=n[r];if(!o)return;let a=t[r],l=[...s??a],u=[...o];if(!(l.length!==u.length||Va(l,u)))return{update:c=>{l.forEach((d,h)=>{let f=Ve.lerp(d,u[h],c);t[r][h]=i?Math.trunc(f):f})},start:()=>{Object.assign(t[r],l)},end:()=>{Object.assign(t[r],u)}}}function gS(r,t,e,n){let i=e[r]?e[r]:void 0,s=n[r];if(!s)return;let o=t[r],a=i?new _().fromArray(i):o.clone(),l=new _().fromArray(s);if(!a.equals(l))return{update:u=>{o.lerpVectors(a,l,u)},start:()=>{o.copy(a)},end:()=>{o.copy(l)}}}function n2(r,t,e,n){let i=e[r]?e[r]:void 0,s=n[r];if(!s)return;let o=t[r],a=i?new de().fromArray(i):o.clone(),l=new _,u=new rt,c=new _;a.decompose(l,u,c);let d=new de().fromArray(s),h=new _,f=new rt,g=new _;if(d.decompose(h,f,g),!a.equals(d))return{update:p=>{e2.slerpQuaternions(u,f,p),JP.lerpVectors(l,h,p),$P.lerpVectors(c,g,p),o.compose(JP,e2,$P)},start:()=>{o.compose(l,u,c)},end:()=>{o.compose(h,f,g)}}}function r2(r,t,e,n,i){let s=e[r]?e[r]:void 0,o=n[r];if(!o)return;let a=t[r],l=s?typeof s=="string"?i.getColor(s).clone():new Le().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Le().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return t[r]=c,{update:d=>{c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function _s(r,t,e,n){if(typeof t[r]=="number")return Wi(r,t,e??{},n);if(Array.isArray(t[r]))return mS(r,t,e??{},n)}function i2(r,t,e){let n=[],i=r.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,s=r.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(s!==void 0){let o=i??r.zoom,a=s;o!==a&&n.push({update:l=>{r.zoom=Ve.lerp(o,a,l),r.updateProjectionMatrix()},start:()=>{r.zoom=o,r.updateProjectionMatrix()},end:()=>{r.zoom=a,r.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let o=Wi("targetOffset",r,t,e);o&&n.push(o)}return n}function dW(r,t,e,n){if(e.scaleBaked===void 0)return;let i=t.scaleBaked??r.data.geometry.scaleBaked,s=e.scaleBaked;if(ss.isEqual(i,s))return;let o=[];return o.push({update:a=>{r.updateGeometryInteractions({scaleBaked:[Ve.lerp(i[0],s[0],a),Ve.lerp(i[1],s[1],a),Ve.lerp(i[2],s[2],a)]},n),r.invalidateDownstreamBooleanData()},start:()=>{r.updateGeometryInteractions({scaleBaked:i},n),r.invalidateDownstreamBooleanData()},end:()=>{r.updateGeometryInteractions({scaleBaked:s},n),r.invalidateDownstreamBooleanData()}}),o}function hW(r,t,e){if(!e.extrusion)return;let n=r.extrusion,i=t.extrusion??{},s=e.extrusion,o=[];return fx.forEach(a=>{let l=_s(a,n,i,s);l&&o.push(l)}),o}function s2(r,t,e,n){let i=[];if(!("geometry"in e))return i;let s=r.geometry.userData.parameters,o="geometry"in t?t.geometry:{},a=e.geometry;if(r instanceof zi){let l=dW(r,o,a,n);l&&i.push(...l)}else{let l={};if(Object.assign(l,Uo(s,px)),px.forEach(u=>{let c=_s(u,l,o,a);c&&i.push(c)}),r instanceof ia){Object.assign(l,{extrusion:{...s.extrusion}});let u=hW(l,o,a);u&&i.push(...u)}i.length&&i.push({update:u=>{r.updateGeometryInteractions(l,n),r.updateGeometryGroupsIfNeeded()},start:u=>{r.updateGeometryInteractions(l,n),r.updateGeometryGroupsIfNeeded()},end:u=>{r.updateGeometryInteractions(l,n),r.updateGeometryGroupsIfNeeded()}})}return i}function o2(r,t,e,n){let i=[];if(e.intensity!==void 0){let s=Wi("intensity",r,t,e);s&&i.push(s)}if(e.color!==void 0){let s=r2("color",r,t,e,n);s&&i.push(s)}return i}function l2(r,t,e,n){let i=[];if(Array.isArray(r.material)){if(!("materials"in e&&e.materials))return i;let s="materials"in t&&t.materials?t.materials:[],o=e.materials;r.material.forEach((a,l)=>{if(!o[l])return;let u=s[l]??{},c=o[l];typeof u=="string"||typeof c=="string"||i.push(...a2(a,u,c,n))})}else{if(!("material"in e&&e.material))return i;let s="material"in t&&t.material?t.material:{},o=e.material;if(typeof s=="string"||typeof o=="string")return i;i.push(...a2(r.material,s,o,n))}return i}function a2(r,t,e,n){let i=[],s=tf(e,n)||!!t.layers&&tf(t,n);i.push(SW(r,s));for(let o of r.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=>!Im.some(d=>c.includes(d)));for(let c of u)try{let d=o.getValue(c),h;if(c==="colors")h=xW(o,a,l,c);else if(Array.isArray(d))c==="steps"&&(h=vW(o,a,l,c));else if(typeof d=="number")h=fW(o,a,l,c);else{if(typeof d=="boolean")continue;d instanceof F?h=pW(o,a,l,c):d instanceof _?h=mW(o,a,l,c):d instanceof Yt?h=yW(o,a,l,c,n):d instanceof Le?h=gW(o,a,l,c,n):"isTexture"in d&&(h=bW(o,a,l,c))}h&&(Array.isArray(h)?i.push(...h):i.push(h))}catch(d){console.error(`lerpMaterial: unexpected material layer for ${c}`,d)}}return i}function fW(r,t,e,n){if(!r.hasValue(n)||!(n in e))return;let i=t?t[n]:r.getValue(n),s=e[n];if(i!==s)return{update:o=>{r.setValue(n,Ve.lerp(i,s,o))},start:()=>{r.setValue(n,i)},end:()=>{r.setValue(n,s)}}}function pW(r,t,e,n){if(!r.hasValue(n)||!(n in e))return;let i=r.getValue(n),s=t?new F().fromArray(t[n]):i.clone(),o=new F().fromArray(e[n]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function mW(r,t,e,n){if(!r.hasValue(n)||!(n in e))return;let i=r.getValue(n),s=t?new _().fromArray(t[n]):i.clone(),o=new _().fromArray(e[n]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function gW(r,t,e,n,i){if(!r.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=r.getValue(n),l=s?typeof s=="string"?i.getColor(s).clone():new Le().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Le().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return r.setValue(n,c),{update:d=>{c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function yW(r,t,e,n,i){if(!r.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=r.getValue(n),l=s?typeof s=="string"?i.getColor(s).clone():new Le().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Yt(o.r,o.g,o.b,o.a);if(l.equals(u))return;let c=a.clone();return r.setValue(n,c),{update:d=>{c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function vW(r,t,e,n="steps"){if(!r.hasValue(n)||!(n in e))return;let i=[],s=r.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&&i.push({update:d=>{s[l]=Ve.lerp(u,c,d)},start:()=>{s[l]=u},end:()=>{s[l]=c}})}return i.length?i:void 0}function xW(r,t,e,n="colors"){if(!r.hasValue(n)||!(n in e))return;let i=[],s=r.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]];sh.isEqual(u,c)||i.push({update:d=>{s[l].fromArray(sh.lerp(u,c,d))},start:()=>{s[l].fromArray(u)},end:()=>{s[l].fromArray(c)}})}return i.length?i:void 0}function bW(r,t,e,n="texture"){if(!r.hasValue(n)||!(n in e))return;let i=r.getNode("mat");if(!i)return;let s=t?t[n]:i,o=e[n],a=[...s.repeat],l=[...s.offset],u=[...o.repeat],c=[...o.offset];if(!qa.isEqual(a,u)||!qa.isEqual(l,c))return{update:d=>{i.repeat=qa.lerp(a,u,d),i.offset=qa.lerp(l,c,d),i.updateMatrix()},start:()=>{i.repeat=[...a],i.offset=[...l],i.updateMatrix()},end:()=>{i.repeat=[...u],i.offset=[...c],i.updateMatrix()}}}function SW(r,t){return{update:()=>{r.transparent=t}}}var yS=new _,c2=new jt;function u2(r,t,e,n){let i=[],s,o,a,l,u,c,d={slide:(t.pathSnapping??r.dataPatched.pathSnapping).slide,offset:(t.pathSnapping??r.dataPatched.pathSnapping).offset};if(u=Wi("slide",d,t.pathSnapping??r.dataPatched.pathSnapping,e.pathSnapping??r.dataPatched.pathSnapping),u&&i.push(u),c=Wi("offset",d,t.pathSnapping??r.dataPatched.pathSnapping,e.pathSnapping??r.dataPatched.pathSnapping),c&&i.push(c),console.log(i.length,"cbbbbbbbbbbbbbbb"),!u&&!c&&(s=gS("position",r,t,e),s&&i.push(s),o=gS("scale",r,t,e),o&&i.push(o),a=wW(r,t,e,n),a&&i.push(a),l=n2("hiddenMatrix",r,t,e),l&&i.push(l)),s||o||a||l||u||c){let h=()=>{r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldSVD()),r.parent?.matrixWorldFusedFalse&&(r.matrixWorld.multiplyMatrices(r.parent.matrixWorldFusedFalse,r.matrix),r.matrixWorldNeedsUpdate=!1),Jr(r)&&$r(r.parent)&&r.invalidateDownstreamBooleanData(!0),r.updatePathSnapping(Object.assign({},t.pathSnapping,d))};i.push({update:h,start:h,end:h})}return i}function wW(r,t,e,n){let i=t?.rotation?t.rotation:void 0,s=e.rotation;if(!s)return;let o=i?new _().fromArray(i):new _().setFromEuler(r.rotation),a=new _().fromArray(s);if(o.equals(a))return;let l=yS.subVectors(a,o);if(n&&l.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new rt().setFromEuler(c2.setFromVector3(o)),c=new rt().setFromEuler(c2.setFromVector3(a));return{update:d=>{t2(u,c,r.quaternion,d)},start:()=>{r.rotation.setFromVector3(o)},end:()=>{r.rotation.setFromVector3(a)}}}else return{update:u=>{yS.lerpVectors(o,a,u),r.rotation.setFromVector3(yS)},start:()=>{r.rotation.setFromVector3(o)},end:()=>{r.rotation.setFromVector3(a)}}}function d2(r,t,e){let n=[];if(!("cloner"in e)||!r.cloner)return n;let i=r.cloner,s="cloner"in t?t.cloner:{},o=e.cloner;ix.forEach(h=>{let f;h==="count"?f=Wi("count",i.parameters,s,o,!0):f=_s(h,i.parameters,s??{},o),f&&n.push(f)});let a=AW(i,s,o);a?.length&&n.push(...a);let l=_W(i,s,o);l?.length&&n.push(...l);let u=TW(i,s,o);u?.length&&n.push(...u);let c=EW(i,s,o);c?.length&&n.push(...c);let d=MW(i,s,o);return d?.length&&n.push(...d),n.length&&n.push({update:()=>{i.update()}}),n}function AW(r,t,e){if(r.parameters.type!=="radial")return;let n=t.radial,i=e.radial;if(!i)return;let s=r.parameters.radial,o=[];return sx.forEach(a=>{let l=_s(a,s,n??{},i);l&&o.push(l)}),o}function _W(r,t,e){if(r.parameters.type!=="linear")return;let n=t.linear,i=e.linear;if(!i)return;let s=[],o=r.parameters.linear;return ox.forEach(a=>{let l=_s(a,o,n??{},i);l&&s.push(l)}),s}function TW(r,t,e){if(r.parameters.type!=="grid")return;let n=t.grid,i=e.grid;if(!i)return;let s=[],o=r.parameters.grid;return ax.forEach(a=>{let l;a==="count"?l=mS(a,o,n??{},i,!0):l=_s(a,o,n??{},i),l&&s.push(l)}),s}function EW(r,t,e){if(r.parameters.type!=="toObject")return;let n=t.toObject,i=e.toObject;if(!i)return;let s=[],o=r.parameters.toObject;return lx.forEach(a=>{let l;a==="count"?l=Wi(a,o,n??{},i,!0):l=_s(a,o,n??{},i),l&&s.push(l)}),s}function MW(r,t,e){if(!r.parameters.randomness)return;let n=t.randomnessObject,i=e.randomnessObject;if(!i)return;let s=[],o=r.parameters.randomnessObject;return cx.forEach(a=>{let l=_s(a,o,n??{},i);l&&s.push(l)}),s}function vS(r,t,e,n,i){let s=[];return r.data.visible&&s.push(...u2(r,t,e,i)),r.data.visible&&s.push(...d2(r,t,e)),Jr(r)?(r instanceof Kt&&r.data.visible&&s.push(...s2(r,t,e,n)),r.data.visible&&s.push(...l2(r,t,e,n))):jC(r)?r.data.visible&&s.push(...o2(r,t,e,n)):WC(r)&&s.push(...i2(r,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 h2=new _;function ly(r,t,e,n=!1){let i=[];t.traverseObject(s=>{if(n&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(h2,!0),s.rigidBody?.setAngvel(h2,!0)),!Pt.is(s))return;let o=s.uuid,a=s.data;if(delete s.states,!a.states)return;let l=!1;i.some(u=>r.objects.isDescendantOf(o,u))?l=!0:a.physics?.fusedBody===!0&&a.physics.rigidBody==="dynamic"&&i.push(o),s.data=a,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let u of a.states)r.environment.usePhysics===!0&&a.physics&&(a.physics.rigidBody==="dynamic"||l)&&(u.data.position!==void 0||u.data.rotation!==void 0||u.data.hiddenMatrix!==void 0)||(s.states||(s.states={}),s.states[u.id]=Js.patch(a,u.data));CW(t,s,null,e,a.events.find(u=>u.data.type==="Follow"||u.data.type==="LookAt")!==void 0)})}function CW(r,t,e,n,i=!1){t instanceof Kt&&t.removeInteractionGeometry(),t.changeSelectedState(e,{scene:r,shared:n},i),t instanceof Kt&&t.updateGeometryGroupsIfNeeded()}function PW(r){let t;switch(r.easing){case 0:t="cubicBezier( 0, 0, 1, 1 )";break;case 1:t="cubicBezier( .25, .1, .25, 1 )";break;case 2:t="cubicBezier( .42, 0, 1, 1 )";break;case 3:t="cubicBezier( 0, 0, .58, 1 )";break;case 4:t="cubicBezier( .42, 0, .58, 1 )";break;case 5:let{control1:e,control2:n}=r;t=`cubicBezier(
|
|
4912
|
+
`,Kg=new bt({vertexShader:T5,fragmentShader:E5,uniforms:{depthContrast:{value:1}}});var Zg=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,i)=>{let s=[i,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 Qg=new zs;Qg.wireframe=!0;var oP=new _,Kb=class extends pr{constructor(e,n){super();this.data=e;this.backupFog=new kl(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.bgColor=new Yt(1,1,1,1);this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Zg;this.needsRecomputeInstances=!1;this.ambientLight=new vp(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,n),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=nP(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=tP(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let n=e.identity.join("-"),i=this.entityIdentityToEntity[n];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[n]=e,this.entityByUuid[e.uuid]=e}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}getWithSortKey(e){let n=this.find(e);if(n===void 0)return;let i=[],s=n;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);i.splice(0,0,a)}return{entity:n,sortKey:i}}getAllSorted(e){let n=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&n.push(s)}return n.sort((i,s)=>gE(i.sortKey,s.sortKey)),n.map(i=>i.entity)}nonExistOrDescendantOf(e,n){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===n)return!0;i=i.parent}return!1}find(e){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}updateTreeByOp(e,n){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,i,e.localIndex,n);s.updateVisible(),s.resetBBoxNeedsUpdate(),Jr(s)&&$r(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s)}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let s=i.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(i),i.parent.remove(i),$r(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Jr(i)&&(i.freeBooleanPointer(),s instanceof vi&&s.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof ia&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid)}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let s=i.parent;this.markNeedsRecomputeInstancesForAncessors(s),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");o.add(i),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(),i.resetBBoxNeedsUpdate();let a=e.localIndex;o.children.splice(a,0,o.children.pop()),Jr(i)&&(i.invalidateUpstreamBooleanData(),$r(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof vi&&s.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(e,n,i,s){if(n.type===0){if(("overrides"in n.props||"component"in n.props)&&this.markNeedsRecomputeInstances(),n.path.includes("overrides")&&"states"in n.props){let{states:a,rest:l}=n.props;n={...n,props:l},this.markNeedsRecomputeInstances()}n.path[0]==="pathSnapping"&&n.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,n.props.pathId)}let o=this.find(e);if(o)try{JC(o,n,i,{scene:this,shared:s}),o instanceof Kt&&o.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,n){if(this.createChildrenObjects(e.objects,this,n),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Sr(e.backgroundColor,n)),this.updateFog(e.fog,n),this.updateAmbientLight(e.environment.ambientLight,n),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let i=this.find(e.publish.playCamera);i instanceof Zt&&this.switchActiveCamera(i)}this.expandInstances(n,!0),this.traverseEntity(i=>{$r(i)&&i.recomputeBoolean(),i instanceof Zt&&i.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){Pt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(n=>{Pt.is(n)&&n.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,n,i,s,o,a,l){e&&e!==s.uuid&&s.find(e)&&o.forInstancesRec(c=>{c.isInstanceRoot||(c.data=Fc(c.data,d=>{let h=d.events.data(l.id),f=c.goUp(a);if(f){let g=[...Bm(f.identity),e].join("-"),p=this.entityIdentityToEntity[g];if(p){let m=p.uuid;gr.zoom(h,n)[i]=m}else{if(!1)debugger;console.warn("cannot find instance")}}}).data)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Hi&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((n,i)=>{n.data.events.forEach(s=>{s.data.type==="GameControl"?n.forInstancesRec(o=>{o.isInstanceRoot||(o.data=Fc(o.data,a=>{a.events.delete(s.id)}).data)}):s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",e,n,i,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",e,n,i,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",e,n,i,s):s.data.condition.type==="Comparison"&&(s.data.condition.lOperand.type==="Property"&&this.relativeizeInner(s.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,n,i,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,n,i,s)),s.data.inActions.forEach(o=>{o.data.type==="Transition"&&this.relativeizeInner(o.data.object,["inActions",o.id],"object",e,n,i,s)}),s.data.outActions.forEach(o=>{o.data.type==="Transition"&&this.relativeizeInner(o.data.object,["outActions",o.id],"object",e,n,i,s)})):"actions"in s.data&&s.data.actions.forEach(o=>{o.data.type==="Transition"&&this.relativeizeInner(o.data.object,["actions",o.id],"object",e,n,i,s)})})}),!0})}expandInstances(e,n){let i=new Set;this.traverseEntity(s=>{if(s instanceof Hi&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),n||s.resetBBoxNeedsUpdate(),!0});for(let s of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Xg(s)}recomputeInstances(e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(n=>{n instanceof Hi&&n.isInstanceRoot&&(n.component=void 0)}),this.expandInstances(e,!1))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(n=>{let i=typeof n.identity=="string"?n.identity:n.identity.join("-");this.entityIdentityToEntity[i]===n&&(delete this.entityByUuid[n.uuid],delete this.entityIdentityToEntity[i]),n.dispose()})}clearScene(){for(let e of this.children)Pt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,n){this.init(e,n)}createPersonalCamera(){let e=new Zt(Kb.PERSONAL_CAMERA_ID,{...Wc.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(e),e}raycast(e){let n=[],i=s=>{for(let o of s.children){let a=o.cloner;Pt.is(o)&&!o.raycastLock&&(o.visible||a?.object.data.visible)&&((Jr(o)||qC(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,n),rP(o,e,n)),i(o))}};return i(this),n}forEachEntity(e){for(let n of this.children)Pt.is(n)&&e(n)}traverseEntity(e){for(let n of this.children)Pt.is(n)&&n.traverseEntity(e)}traverseObject(e){for(let n of this.children)xh.is(n)&&n.traverseObject(e)}traverseVisibleEntity(e){for(let n of this.children)Pt.is(n)&&n.visible&&n.traverseVisibleEntity(e)}updateFog(e,n){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Sr(e.color,n),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,n){e.color!==void 0&&(this.ambientLight.color=Sr(e.color,n)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.groundColor!==void 0&&(this.ambientLight.groundColor=Sr(e.groundColor,n)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}createChildrenObjects(e,n,i){let s=0;for(let o of e)this.createObject(o.id,o.data,o.children,n,s,i),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,i,s,o,a){let l={scene:this,shared:a},u=Yg(e,n,l);return u&&(this.entityByUuid[e]=u,s.add(u),s.children.splice(o,0,s.children.pop()),i.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,u,a)),u.updateState(n,l),u instanceof Kt&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),n.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,n.pathSnapping.pathId)),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 i=new xt;return i.setFromPoints(n),i.getCenter(oP),oP}copyMatrixWorld(e,n){if(e===null){n.identity();return}let i=this.find(e);i?n.copy(i.matrixWorld):n.identity()}copyParentMatrixWorld(e,n){if(e===null){n.identity();return}let i=this.find(e)?.parent;i?n.copy(i.matrixWorld):n.identity()}traverseMaterial(e){this.traverseEntity(n=>{if(n instanceof Vt)if(Array.isArray(n.material))for(let i=0;i<n.material.length;i++)n.material[i]instanceof Rr&&e(n.material[i]);else n.material instanceof Rr&&e(n.material)})}updateCanvasSize(e,n){this.activeCamera.setViewplaneSize(e,n);let i,s;e>=n?(i=n/e,s=1):(i=1,s=e/n),this.traverseMaterial(o=>{o.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=s})})}},ti=Kb;ti.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var df=(r,t)=>{let e=t.x-r.x,n=t.y-r.y;return Math.sqrt(e*e+n*n)},aP=(r,t)=>{let e=t.x-r.x,n=t.y-r.y;return M5(Math.atan2(n,e))},lP=(r,t,e)=>{let n={x:0,y:0};return e=Jg(e),n.x=r.x-t*Math.cos(e),n.y=r.y-t*Math.sin(e),n},Jg=r=>r*(Math.PI/180),M5=r=>r*(180/Math.PI),cP=r=>isNaN(r.buttons)?r.pressure!==0:r.buttons!==0,Zb=new Map,Qb=r=>{Zb.has(r)&&clearTimeout(Zb.get(r)),Zb.set(r,setTimeout(r,100))},Vu=(r,t,e)=>{let n=t.split(/[ ,]+/g),i;for(let s=0;s<n.length;s+=1)i=n[s],r.addEventListener?r.addEventListener(i,e,!1):r.attachEvent&&r.attachEvent(i,e)},Jb=(r,t,e)=>{let n=t.split(/[ ,]+/g),i;for(let s=0;s<n.length;s+=1)i=n[s],r.removeEventListener?r.removeEventListener(i,e):r.detachEvent&&r.detachEvent(i,e)};var $g=r=>(r.preventDefault(),r.type.match(/^touch/)?r.changedTouches:r),$b=()=>{if(typeof window>"u")return;let r=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:r,y:t}},ey=(r,t)=>{t.top||t.right||t.bottom||t.left?(r.style.top=t.top,r.style.right=t.right,r.style.bottom=t.bottom,r.style.left=t.left):(r.style.left=t.x+"px",r.style.top=t.y+"px")},ty=(r,t,e)=>{let n=dP(r);for(let i in n)if(n.hasOwnProperty(i))if(typeof t=="string")n[i]=t+" "+e;else{let s="";for(let o=0,a=t.length;o<a;o+=1)s+=t[o]+" "+e+", ";n[i]=s.slice(0,-2)}return n},uP=(r,t)=>{let e=dP(r);for(let n in e)e.hasOwnProperty(n)&&(e[n]=t);return e},dP=r=>{let t={};return t[r]="",["webkit","Moz","o"].forEach(function(n){t[n+r.charAt(0).toUpperCase()+r.slice(1)]=""}),t},ny=(r,t)=>{for(let e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);return r},hP=(r,t)=>{let e={};for(let n in r)r.hasOwnProperty(n)&&t.hasOwnProperty(n)?e[n]=t[n]:r.hasOwnProperty(n)&&(e[n]=r[n]);return e},hf=(r,t)=>{if(r.length)for(let e=0,n=r.length;e<n;e+=1)t(r[e]);else t(r)},fP=(r,t,e)=>({x:Math.min(Math.max(r.x,t.x-e),t.x+e),y:Math.min(Math.max(r.y,t.y-e),t.y+e)});typeof window<"u"&&(pP="ontouchstart"in window,mP=!!window.PointerEvent,gP=!!window.MSPointerEvent);var pP,mP,gP,ff={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"}},Hu,pf={};mP?Hu=ff.pointer:gP?Hu=ff.MSPointer:pP?(Hu=ff.touch,pf=ff.mouse):Hu=ff.mouse;function fl(){}fl.prototype.on=function(r,t){var e=this,n=r.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],e._handlers_[i]=e._handlers_[i]||[],e._handlers_[i].push(t);return e};fl.prototype.off=function(r,t){var e=this;return e._handlers_=e._handlers_||{},r===void 0?e._handlers_={}:t===void 0?e._handlers_[r]=null:e._handlers_[r]&&e._handlers_[r].indexOf(t)>=0&&e._handlers_[r].splice(e._handlers_[r].indexOf(t),1),e};fl.prototype.trigger=function(r,t){var e=this,n=r.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],e._handlers_[i]&&e._handlers_[i].length&&e._handlers_[i].forEach(function(o){o.call(e,{type:i,target:e},t)})};fl.prototype.config=function(r){var t=this;t.options=t.defaults||{},r&&(t.options=hP(t.options,r))};fl.prototype.bindEvt=function(r,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.')},Vu(r,Hu[t],e._domHandlers_[t]),pf[t]&&Vu(r,pf[t],e._domHandlers_[t]),e};fl.prototype.unbindEvt=function(r,t){var e=this;return e._domHandlers_=e._domHandlers_||{},Jb(r,Hu[t],e._domHandlers_[t]),pf[t]&&Jb(r,pf[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var Wu=fl;function Ln(r,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=r,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Ln.id,Ln.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}Ln.prototype=new Wu;Ln.constructor=Ln;Ln.id=0;Ln.prototype.buildEl=function(r){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};Ln.prototype.stylize=function(){if(this.options.dataOnly)return this;var r=this.options.fadeTime+"ms",t=uP("borderRadius","50%"),e=ty("transition","opacity",r),n={};return n.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},n.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},n.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},ny(n.el,e),this.options.shape==="circle"&&ny(n.back,t),ny(n.front,t),this.applyStyles(n),this};Ln.prototype.applyStyles=function(r){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var e in r[t])this.ui[t].style[e]=r[t][e];return this};Ln.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Ln.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Ln.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Ln.prototype.show=function(r){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 r=="function"&&r.call(this)},t.options.fadeTime)),t};Ln.prototype.hide=function(r){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 r=="function"&&r.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(r,n)}return t};Ln.prototype.setPosition=function(r,t){var e=this;e.frontPosition={x:t.x,y:t.y};var n=e.options.fadeTime+"ms",i={};i.front=ty("transition",["top","left"],n);var s={front:{}};s.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(i),e.applyStyles(s),e.restTimeout=setTimeout(function(){typeof r=="function"&&r.call(e),e.restCallback()},e.options.fadeTime)};Ln.prototype.restCallback=function(){var r=this,t={};t.front=ty("transition","none",""),r.applyStyles(t),r.trigger("rested",r.instance)};Ln.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Ln.prototype.computeDirection=function(r){var t=r.angle.radian,e=Math.PI/4,n=Math.PI/2,i,s,o;if(t>e&&t<e*3&&!r.lockX?i="up":t>-e&&t<=e&&!r.lockY?i="left":t>-e*3&&t<=-e&&!r.lockX?i="down":r.lockY||(i="right"),r.lockY||(t>-n&&t<n?s="left":s="right"),r.lockX||(t>0?o="up":o="down"),r.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var u={};this.direction={x:s,y:o,angle:i},r.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(u[l]=!0);if(u.x&&u.y&&u.angle)return r;(!u.x||!u.y)&&this.trigger("plain",r),u.x||this.trigger("plain:"+s,r),u.y||this.trigger("plain:"+o,r),u.angle||this.trigger("dir dir:"+i,r)}else this.resetDirection();return r};var yP=Ln;function hn(r,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=r,e.id=hn.id,hn.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}hn.prototype=new Wu;hn.constructor=hn;hn.id=0;hn.prototype.prepareNipples=function(){var r=this,t=r.nipples;t.on=r.on.bind(r),t.off=r.off.bind(r),t.options=r.options,t.destroy=r.destroy.bind(r),t.ids=r.ids,t.id=r.id,t.processOnMove=r.processOnMove.bind(r),t.processOnEnd=r.processOnEnd.bind(r),t.get=function(e){if(e===void 0)return t[0];for(var n=0,i=t.length;n<i;n+=1)if(t[n].identifier===e)return t[n];return!1}};hn.prototype.bindings=function(){var r=this;r.bindEvt(r.options.zone,"start"),r.options.zone.style.touchAction="none",r.options.zone.style.msTouchAction="none"};hn.prototype.begin=function(){var r=this,t=r.options;if(t.mode==="static"){var e=r.createNipple(t.position,r.manager.getIdentifier());e.add(),r.idles.push(e)}};hn.prototype.createNipple=function(r,t){var e=this,n=e.manager.scroll,i={},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(r.x&&r.y)i={x:r.x-o.x,y:r.y-o.y};else if(r.top||r.right||r.bottom||r.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=r.top,a.style.right=r.right,a.style.bottom=r.bottom,a.style.left=r.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),i=r,r={x:l.left+n.x,y:l.top+n.y}}var u=new yP(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:r,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(ey(u.ui.el,i),ey(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};hn.prototype.updateBox=function(){var r=this;r.box=r.options.zone.getBoundingClientRect()};hn.prototype.bindNipple=function(r){var t=this,e,n=function(i,s){e=i.type+" "+s.id+":"+i.type,t.trigger(e,s)};r.on("destroyed",t.onDestroyed.bind(t)),r.on("shown hidden rested dir plain",n),r.on("dir:up dir:right dir:down dir:left",n),r.on("plain:up plain:right plain:down plain:left",n)};hn.prototype.pressureFn=function(r,t,e){var n=this,i=0;clearInterval(n.pressureIntervals[e]),n.pressureIntervals[e]=setInterval(function(){var s=r.force||r.pressure||r.webkitForce||0;s!==i&&(t.trigger("pressure",s),n.trigger("pressure "+t.identifier+":pressure",s),i=s)}.bind(n),100)};hn.prototype.onstart=function(r){var t=this,e=t.options,n=r;r=$g(r),t.updateBox();var i=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=[r[0]];a.identifier=o,t.processOnEnd(a)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(s))};return hf(r,i),t.manager.bindDocument(),!1};hn.prototype.processOnStart=function(r){var t=this,e=t.options,n,i=t.manager.getIdentifier(r),s=r.force||r.pressure||r.webkitForce||0,o={x:r.pageX,y:r.pageY},a=t.getOrCreate(i,o);a.identifier!==i&&t.manager.removeIdentifier(a.identifier),a.identifier=i;var l=function(c){c.trigger("start",c),t.trigger("start "+c.id+":start",c),c.show(),s>0&&t.pressureFn(r,c,c.identifier),t.processOnMove(r)};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=df(o,a.position);if(u<=e.catchDistance)l(a);else{a.destroy(),t.processOnStart(r);return}}return a};hn.prototype.getOrCreate=function(r,t){var e=this,n=e.options,i;return/(semi|static)/.test(n.mode)?(i=e.idles[0],i?(e.idles.splice(0,1),i):n.mode==="semi"?e.createNipple(t,r):(console.warn("Coudln't find the needed nipple."),!1)):(i=e.createNipple(t,r),i)};hn.prototype.processOnMove=function(r){var t=this,e=t.options,n=t.manager.getIdentifier(r),i=t.nipples.get(n),s=t.manager.scroll;if(!cP(r)){this.processOnEnd(r);return}if(!i){console.error("Found zombie joystick with ID "+n),t.manager.removeIdentifier(n);return}if(e.dynamicPage){var o=i.el.getBoundingClientRect();i.position={x:s.x+o.left,y:s.y+o.top}}i.identifier=n;var a=i.options.size/2,l={x:r.pageX,y:r.pageY};e.lockX&&(l.y=i.position.y),e.lockY&&(l.x=i.position.x);var u=df(l,i.position),c=aP(l,i.position),d=Jg(c),h=u/a,f={distance:u,position:l},g,p;if(i.options.shape==="circle"?(g=Math.min(u,a),p=lP(i.position,g,c)):(p=fP(l,i.position,a),g=df(p,i.position)),e.follow){if(u>a){let x=l.x-p.x,b=l.y-p.y;i.position.x+=x,i.position.y+=b,i.el.style.top=i.position.y-(t.box.top+s.y)+"px",i.el.style.left=i.position.x-(t.box.left+s.x)+"px",u=df(l,i.position)}}else l=p,u=g;var m=l.x-i.position.x,y=l.y-i.position.y;i.frontPosition={x:m,y},e.dataOnly||ey(i.ui.front,i.frontPosition);var v={identifier:i.identifier,position:l,force:h,pressure:r.force||r.pressure||r.webkitForce||0,distance:u,angle:{radian:d,degree:c},vector:{x:m/a,y:-y/a},raw:f,instance:i,lockX:e.lockX,lockY:e.lockY};v=i.computeDirection(v),v.angle={radian:Jg(180-c),degree:180-c},i.trigger("move",v),t.trigger("move "+i.id+":move",v)};hn.prototype.processOnEnd=function(r){var t=this,e=t.options,n=t.manager.getIdentifier(r),i=t.nipples.get(n),s=t.manager.removeIdentifier(i.identifier);!i||(e.dataOnly||i.hide(function(){e.mode==="dynamic"&&(i.trigger("removed",i),t.trigger("removed "+i.id+":removed",i),t.manager.trigger("removed "+i.id+":removed",i),i.destroy())}),clearInterval(t.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),t.trigger("end "+i.id+":end",i),t.ids.indexOf(i.identifier)>=0&&t.ids.splice(t.ids.indexOf(i.identifier),1),t.actives.indexOf(i)>=0&&t.actives.splice(t.actives.indexOf(i),1),/(semi|static)/.test(e.mode)?t.idles.push(i):t.nipples.indexOf(i)>=0&&t.nipples.splice(t.nipples.indexOf(i),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[s.id]=s.identifier))};hn.prototype.onDestroyed=function(r,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()};hn.prototype.destroy=function(){var r=this;r.unbindEvt(r.options.zone,"start"),r.nipples.forEach(function(e){e.destroy()});for(var t in r.pressureIntervals)r.pressureIntervals.hasOwnProperty(t)&&clearInterval(r.pressureIntervals[t]);r.trigger("destroyed",r.nipples),r.manager.unbindDocument(),r.off()};var vP=hn;function Zn(r){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=$b(),t.config(r),t.prepareCollections();var e=function(){var i;t.collections.forEach(function(s){s.forEach(function(o){i=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+i.left,y:t.scroll.y+i.top}})})};if(typeof window>"u")return t.collections;Vu(window,"resize",function(){Qb(e)});var n=function(){t.scroll=$b()};return Vu(window,"scroll",function(){Qb(n)}),t.collections}Zn.prototype=new Wu;Zn.constructor=Zn;Zn.prototype.prepareCollections=function(){var r=this;r.collections.create=r.create.bind(r),r.collections.on=r.on.bind(r),r.collections.off=r.off.bind(r),r.collections.destroy=r.destroy.bind(r),r.collections.get=function(t){var e;return r.collections.every(function(n){return e=n.get(t),!e}),e}};Zn.prototype.create=function(r){return this.createCollection(r)};Zn.prototype.createCollection=function(r){var t=this,e=new vP(t,r);return t.bindCollection(e),t.collections.push(e),e};Zn.prototype.bindCollection=function(r){var t=this,e,n=function(i,s){e=i.type+" "+s.id+":"+i.type,t.trigger(e,s)};r.on("destroyed",t.onDestroyed.bind(t)),r.on("shown hidden rested dir plain",n),r.on("dir:up dir:right dir:down dir:left",n),r.on("plain:up plain:right plain:down plain:left",n)};Zn.prototype.bindDocument=function(){var r=this;r.binded||(r.bindEvt(document,"move").bindEvt(document,"end"),r.binded=!0)};Zn.prototype.unbindDocument=function(r){var t=this;(!Object.keys(t.ids).length||r===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};Zn.prototype.getIdentifier=function(r){var t;return r?(t=r.identifier===void 0?r.pointerId:r.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]};Zn.prototype.removeIdentifier=function(r){var t={};for(var e in this.ids)if(this.ids[e]===r){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};Zn.prototype.onmove=function(r){var t=this;return t.onAny("move",r),!1};Zn.prototype.onend=function(r){var t=this;return t.onAny("end",r),!1};Zn.prototype.oncancel=function(r){var t=this;return t.onAny("end",r),!1};Zn.prototype.onAny=function(r,t){var e=this,n,i="processOn"+r.charAt(0).toUpperCase()+r.slice(1);t=$g(t);var s=function(a,l,u){u.ids.indexOf(l)>=0&&(u[i](a),a._found_=!0)},o=function(a){n=e.getIdentifier(a),hf(e.collections,s.bind(null,a,n)),a._found_||e.removeIdentifier(n)};return hf(t,o),!1};Zn.prototype.destroy=function(){var r=this;r.unbindDocument(!0),r.ids={},r.index=0,r.collections.forEach(function(t){t.destroy()}),r.off()};Zn.prototype.onDestroyed=function(r,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1)};var xP=Zn;var bP=new xP,SP={create:function(r){return bP.create(r)},factory:bP};var wP=dd(Rx());function pl(r,t){let e=new Te;if(!r.getAttribute("position"))return e.setAttribute("position",new we([],3)),e.setIndex([]),e;let{positions:n,triIndices:i}=Dh(r.getAttribute("position"),r.getIndex());return e.setAttribute("position",new we(n,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}var C5=new de,P5=new de,bs=[[0,0,0],[0,0,0],[0,0,0]];function eS(r){let t=r.elements;bs[0][0]=t[0],bs[0][1]=t[4],bs[0][2]=t[8],bs[1][0]=t[1],bs[1][1]=t[5],bs[1][2]=t[9],bs[2][0]=t[2],bs[2][1]=t[6],bs[2][2]=t[10];let{u:e,v:n}=(0,wP.SVD)(bs),i=C5.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=P5.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1);return i.multiply(s.transpose())}var iy=class extends $l{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(i=>{i.visible&&this.intersectObject(i,e,n)}),n}createRaycastLineHelper(){let t=new ai({color:65280,linewidth:10}),e=new _(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new _(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),i=this.camera.far-this.camera.near,s=new _().addVectors(e,n.multiplyScalar(i)),o=new Te;return o.setFromPoints([e,s]),new Pa(o,t)}};var AP=r=>r instanceof hl||r instanceof Hi;function I5(r,t){return r.distance-t.distance}function _P(r,t,e){if(!(!ro(t)||!t.visible)){Jr(t)&&t.raycast(r,e);for(let n of t.children)_P(r,n,e)}}function mf(r,t,e){if(!e.some(i=>ju(r,i)!==void 0))return[];let n=[];return t.children.forEach(i=>_P(r,i,n)),n.sort(I5),n}function gf(r){let t=[];if(r.length){let e=r[0].object;ro(e)&&t.push(e);let n=e.parent;for(;n;)AP(n)&&t.push(n),n=n.parent}return t}function ju(r,t){if(Jr(t)){if(t.visible){let e=[];return t.raycast(r,e),e.length?e[0]:void 0}}else if(AP(t))return TP(r,t)}function TP(r,t){if(!(!ro(t)||!t.visible)){if(Jr(t)){let e=[];if(t.raycast(r,e),e.length)return e[0]}for(let e of t.children){let n=TP(r,e);if(n)return n}}}function D5(r,t,e){return{x:(r-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}var sy=class{constructor(t,e,n,i,s,o){this.isExport=o;this.raycaster=new iy;this.raycasterNeedsUpdate=!0;this.stopRaycast=!1;this._useWindowEvents=!1;this.sharedAssets=new so(Kc.emptyData());this.scene=new ti({...zm.defaultData},this.sharedAssets);this.camera=new Zt;this.renderer=t,this._useWindowEvents=e.data.publish.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement,this.stopRaycast=s,this.sharedAssets=i,this.scene=e,this.camera=n}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!==void 0&&t.touches.length>0?t.touches[0]:t,i=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(D5(e,n,i),this.camera)}};var tS=(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))(tS||{}),Qn=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var EP=new Map,yf=new Map,co=class{constructor(t,e,n,i){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"?i.getAudio(s).src:s.data;this.audioPlayer=new io({src:u,volume:o,delay:a,loop:l}),yf.has(n.uuid)?yf.get(n.uuid).push(this):yf.set(n.uuid,[this]),EP.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()}},qu=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=EP.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=yf.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=[...yf.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}},Ss=class{constructor(t,e,n,i){this.data=e;if(e.interaction==="play")this.interaction=new co(t,e,n,i);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new qu(e);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof co?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof co?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(t){this.interaction instanceof co&&(t==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};function MP(r,t){let e=r.material.layers.find(n=>n.uuid===t);return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var CP=new Map,vf=new Map,sa=class{constructor(t,e,n){this.data=e;this.delay=0;this.status="stopped";let{layerId:i,loop:s,volume:o,delay:a}=e;if(this.object=n,i===void 0)throw new Error("Missing property");let l=MP(n,i);if(l)this.videoElement=l,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,o!==void 0&&(this.videoElement.volume=o);else throw new Error("Missing property");a!==void 0&&(this.delay=a),vf.has(n.uuid)?vf.get(n.uuid).push(this):vf.set(n.uuid,[this]),CP.set(t,this),this.pause()}mute(){this.videoElement.muted=!0}unMute(){this.videoElement.muted=!1}play(t){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(()=>{this.videoElement.play(),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){this.videoElement.pause(),this.status="paused"}stop(){this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay()}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){this.stop(),this.videoElement.muted=!0}},Xu=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=CP.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=vf.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=[...vf.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}},oa=class{constructor(t,e,n){this.data=e;if(e.interaction==="play")this.interaction=new sa(t,e,n);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Xu(e);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof sa?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof sa?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var O5="text/plain",L5="us-ascii",PP=(r,t)=>t.some(e=>e instanceof RegExp?e.test(r):e===r),R5=(r,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(r);if(!e)throw new Error(`Invalid URL: ${r}`);let{type:n,data:i,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(d=>{let[h,f=""]=d.split("=").map(g=>g.trim());return h==="charset"&&(f=f.toLowerCase(),f===L5)?"":`${h}${f?`=${f}`:""}`}).filter(Boolean)];return a&&c.push("base64"),(c.length>0||l&&l!==O5)&&c.unshift(l),`data:${c.join(";")},${a?i.trim():i}${s?`#${s}`:""}`};function nS(r,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},r=r.trim(),/^data:/i.test(r))return R5(r,t);if(/^view-source:/i.test(r))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=r.startsWith("//");!e&&/^\.*\//.test(r)||(r=r.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let i=new URL(r);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&i.protocol==="https:"&&(i.protocol="http:"),t.forceHttps&&i.protocol==="http:"&&(i.protocol="https:"),t.stripAuthentication&&(i.username="",i.password=""),t.stripHash?i.hash="":t.stripTextFragment&&(i.hash=i.hash.replace(/#?:~:text.*?$/i,"")),i.pathname){let o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let c=o.exec(i.pathname);if(!c)break;let d=c[0],h=c.index,f=i.pathname.slice(a,h);l+=f.replace(/\/{2,}/g,"/"),l+=d,a=h+d.length}let u=i.pathname.slice(a,i.pathname.length);l+=u.replace(/\/{2,}/g,"/"),i.pathname=l}if(i.pathname)try{i.pathname=decodeURI(i.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let o=i.pathname.split("/"),a=o[o.length-1];PP(a,t.removeDirectoryIndex)&&(o=o.slice(0,-1),i.pathname=o.slice(1).join("/")+"/")}if(i.hostname&&(i.hostname=i.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(i.hostname)&&(i.hostname=i.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let o of[...i.searchParams.keys()])PP(o,t.removeQueryParameters)&&i.searchParams.delete(o);if(t.removeQueryParameters===!0&&(i.search=""),t.sortQueryParameters){i.searchParams.sort();try{i.search=decodeURIComponent(i.search)}catch{}}t.removeTrailingSlash&&(i.pathname=i.pathname.replace(/\/$/,""));let s=r;return r=i.toString(),!t.removeSingleSlash&&i.pathname==="/"&&!s.endsWith("/")&&i.hash===""&&(r=r.replace(/\/$/,"")),(t.removeTrailingSlash||i.pathname==="/")&&i.hash===""&&t.removeSingleSlash&&(r=r.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(r=r.replace(/^http:\/\//,"//")),t.stripProtocol&&(r=r.replace(/^(?:https?:)?\/\//,"")),r}var oy=class{constructor({url:t,context:e},n){this.managers=n;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:nS(t,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=e??"tab"}dispatch(){ch?window.location.assign(this.url):(this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.managers.controlsManager.orbitControls?.onPointerUp(Je[0]),vE())}};var ay=class{constructor(t,e,n,i){this.scene=e,this.sharedAssets=n,this.sceneData=t,this.managers=i}dispatch(){ly(this.sceneData,this.scene,this.sharedAssets,!0),this.managers.eventManager?.reset(),this.managers.controlsManager.orbitControls?.reset(),this.managers.controlsManager?.gameControls.forEach(t=>t.reset(!0))}};var NP={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},oS={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},N5=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],uy={CSS:{},springs:{}};function ws(r,t,e){return Math.min(Math.max(r,t),e)}function xf(r,t){return r.indexOf(t)>-1}function rS(r,t){return r.apply(null,t)}var Ke={arr:function(r){return Array.isArray(r)},obj:function(r){return xf(Object.prototype.toString.call(r),"Object")},pth:function(r){return Ke.obj(r)&&r.hasOwnProperty("totalLength")},svg:function(r){return r instanceof SVGElement},inp:function(r){return r instanceof HTMLInputElement},dom:function(r){return!("isNode"in r)&&(r.nodeType||Ke.svg(r))},str:function(r){return typeof r=="string"},fnc:function(r){return typeof r=="function"},und:function(r){return typeof r>"u"},hex:function(r){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(r)},rgb:function(r){return/^rgb/.test(r)},hsl:function(r){return/^hsl/.test(r)},col:function(r){return Ke.hex(r)||Ke.rgb(r)||Ke.hsl(r)},key:function(r){return!NP.hasOwnProperty(r)&&!oS.hasOwnProperty(r)&&r!=="targets"&&r!=="keyframes"}};function BP(r){var t=/\(([^)]+)\)/.exec(r);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function FP(r,t){var e=BP(r),n=ws(Ke.und(e[0])?1:e[0],.1,100),i=ws(Ke.und(e[1])?100:e[1],.1,100),s=ws(Ke.und(e[2])?10:e[2],.1,100),o=ws(Ke.und(e[3])?0:e[3],.1,100),a=Math.sqrt(i/n),l=s/(2*Math.sqrt(i*n)),u=l<1?a*Math.sqrt(1-l*l):0,c=1,d=l<1?(l*a+-o)/u:-o+a;function h(g){var p=t?t*g/1e3:g;return l<1?p=Math.exp(-p*l*a)*(c*Math.cos(u*p)+d*Math.sin(u*p)):p=(c+d*p)*Math.exp(-p*a),g===0||g===1?g:1-p}function f(){var g=uy.springs[r];if(g)return g;for(var p=1/6,m=0,y=0;;)if(m+=p,h(m)===1){if(y++,y>=16)break}else y=0;var v=m*p*1e3;return uy.springs[r]=v,v}return t?h:f}function B5(r){return r===void 0&&(r=10),function(t){return Math.ceil(ws(t,1e-6,1)*r)*(1/r)}}var F5=function(){var r=11,t=1/(r-1);function e(c,d){return 1-3*d+3*c}function n(c,d){return 3*d-6*c}function i(c){return 3*c}function s(c,d,h){return((e(d,h)*c+n(d,h))*c+i(d))*c}function o(c,d,h){return 3*e(d,h)*c*c+2*n(d,h)*c+i(d)}function a(c,d,h,f,g){var p,m,y=0;do m=d+(h-d)/2,p=s(m,f,g)-c,p>0?h=m:d=m;while(Math.abs(p)>1e-7&&++y<10);return m}function l(c,d,h,f){for(var g=0;g<4;++g){var p=o(d,h,f);if(p===0)return d;var m=s(d,h,f)-c;d-=m/p}return d}function u(c,d,h,f){if(!(0<=c&&c<=1&&0<=h&&h<=1))return;var g=new Float32Array(r);if(c!==d||h!==f)for(var p=0;p<r;++p)g[p]=s(p*t,c,h);function m(y){for(var v=0,x=1,b=r-1;x!==b&&g[x]<=y;++x)v+=t;--x;var w=(y-g[x])/(g[x+1]-g[x]),A=v+w*t,T=o(A,c,h);return T>=.001?l(y,A,c,h):T===0?A:a(y,v,v+t,c,h)}return function(y){return c===d&&h===f||y===0||y===1?y:s(m(y),d,f)}}return u}(),UP=function(){var r={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 i,s=4;n<((i=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((i*3-2)/22-n,2)}},Elastic:function(n,i){n===void 0&&(n=1),i===void 0&&(i=.5);var s=ws(n,1,10),o=ws(i,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},e=["Quad","Cubic","Quart","Quint","Expo"];return e.forEach(function(n,i){t[n]=function(){return function(s){return Math.pow(s,i+2)}}}),Object.keys(t).forEach(function(n){var i=t[n];r["easeIn"+n]=i,r["easeOut"+n]=function(s,o){return function(a){return 1-i(s,o)(1-a)}},r["easeInOut"+n]=function(s,o){return function(a){return a<.5?i(s,o)(a*2)/2:1-i(s,o)(a*-2+2)/2}}}),r}();function aS(r,t){if(Ke.fnc(r))return r;var e=r.split("(")[0],n=UP[e],i=BP(r);switch(e){case"spring":return FP(r,t);case"cubicBezier":return rS(F5,i);case"steps":return rS(B5,i);default:return rS(n,i)}}function GP(r){try{var t=document.querySelectorAll(r);return t}catch{return}}function dy(r,t){for(var e=r.length,n=arguments.length>=2?arguments[1]:void 0,i=[],s=0;s<e;s++)if(s in r){var o=r[s];t.call(n,o,s,r)&&i.push(o)}return i}function hy(r){return r.reduce(function(t,e){return t.concat(Ke.arr(e)?hy(e):e)},[])}function IP(r){return Ke.arr(r)?r:(Ke.str(r)&&(r=GP(r)||r),r instanceof NodeList||r instanceof HTMLCollection?[].slice.call(r):[r])}function lS(r,t){return r.some(function(e){return e===t})}function cS(r){var t={};for(var e in r)t[e]=r[e];return t}function iS(r,t){var e=cS(r);for(var n in r)e[n]=t.hasOwnProperty(n)?t[n]:r[n];return e}function fy(r,t){var e=cS(r);for(var n in t)e[n]=Ke.und(r[n])?t[n]:r[n];return e}function U5(r){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(r);return t?"rgba("+t[1]+",1)":r}function G5(r){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=r.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),i=parseInt(n[1],16),s=parseInt(n[2],16),o=parseInt(n[3],16);return"rgba("+i+","+s+","+o+",1)"}function k5(r){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(r)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(r),e=parseInt(t[1],10)/360,n=parseInt(t[2],10)/100,i=parseInt(t[3],10)/100,s=t[4]||1;function o(h,f,g){return g<0&&(g+=1),g>1&&(g-=1),g<1/6?h+(f-h)*6*g:g<1/2?f:g<2/3?h+(f-h)*(2/3-g)*6:h}var a,l,u;if(n==0)a=l=u=i;else{var c=i<.5?i*(1+n):i+n-i*n,d=2*i-c;a=o(d,c,e+1/3),l=o(d,c,e),u=o(d,c,e-1/3)}return"rgba("+a*255+","+l*255+","+u*255+","+s+")"}function z5(r){if(Ke.rgb(r))return U5(r);if(Ke.hex(r))return G5(r);if(Ke.hsl(r))return k5(r)}function uo(r){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(r);if(t)return t[1]}function V5(r){if(xf(r,"translate")||r==="perspective")return"px";if(xf(r,"rotate")||xf(r,"skew"))return"deg"}function sS(r,t){return Ke.fnc(r)?r(t.target,t.id,t.total):r}function As(r,t){return r.getAttribute(t)}function uS(r,t,e){var n=uo(t);if(lS([e,"deg","rad","turn"],n))return t;var i=uy.CSS[t+e];if(!Ke.und(i))return i;var s=100,o=document.createElement(r.tagName),a=r.parentNode&&r.parentNode!==document?r.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+e;var l=s/o.offsetWidth;a.removeChild(o);var u=l*parseFloat(t);return uy.CSS[t+e]=u,u}function kP(r,t,e){if(t in r.style){var n=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=r.style[t]||getComputedStyle(r).getPropertyValue(n)||"0";return e?uS(r,i,e):i}}function dS(r,t){if(Ke.dom(r)&&!Ke.inp(r)&&(As(r,t)||Ke.svg(r)&&r[t]))return"attribute";if(Ke.dom(r)&&lS(N5,t))return"transform";if(Ke.dom(r)&&t!=="transform"&&kP(r,t))return"css";if(r[t]!=null)return"object"}function zP(r){if(!!Ke.dom(r)){for(var t=r.style.transform||"",e=/(\w+)\(([^)]*)\)/g,n=new Map,i;i=e.exec(t);)n.set(i[1],i[2]);return n}}function H5(r,t,e,n){var i=xf(t,"scale")?1:0+V5(t),s=zP(r).get(t)||i;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),n?uS(r,s,n):s}function hS(r,t,e,n){switch(dS(r,t)){case"transform":return H5(r,t,n,e);case"css":return kP(r,t,e);case"attribute":return As(r,t);default:return r[t]||0}}function fS(r,t){var e=/^(\*=|\+=|-=)/.exec(r);if(!e)return r;var n=uo(r)||0,i=parseFloat(t),s=parseFloat(r.replace(e[0],""));switch(e[0][0]){case"+":return i+s+n;case"-":return i-s+n;case"*":return i*s+n}}function VP(r,t){if(Ke.col(r))return z5(r);if(/\s/g.test(r))return r;var e=uo(r),n=e?r.substr(0,r.length-e.length):r;return t?n+t:n}function pS(r,t){return Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2))}function W5(r){return Math.PI*2*As(r,"r")}function j5(r){return As(r,"width")*2+As(r,"height")*2}function q5(r){return pS({x:As(r,"x1"),y:As(r,"y1")},{x:As(r,"x2"),y:As(r,"y2")})}function HP(r){for(var t=r.points,e=0,n,i=0;i<t.numberOfItems;i++){var s=t.getItem(i);i>0&&(e+=pS(n,s)),n=s}return e}function X5(r){var t=r.points;return HP(r)+pS(t.getItem(t.numberOfItems-1),t.getItem(0))}function WP(r){if(r.getTotalLength)return r.getTotalLength();switch(r.tagName.toLowerCase()){case"circle":return W5(r);case"rect":return j5(r);case"line":return q5(r);case"polyline":return HP(r);case"polygon":return X5(r)}}function Y5(r){var t=WP(r);return r.setAttribute("stroke-dasharray",t),t}function K5(r){for(var t=r.parentNode;Ke.svg(t)&&Ke.svg(t.parentNode);)t=t.parentNode;return t}function jP(r,t){var e=t||{},n=e.el||K5(r),i=n.getBoundingClientRect(),s=As(n,"viewBox"),o=i.width,a=i.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 Z5(r,t){var e=Ke.str(r)?GP(r)[0]:r,n=t||100;return function(i){return{property:i,el:e,svg:jP(e),totalLength:WP(e)*(n/100)}}}function Q5(r,t){function e(a){a===void 0&&(a=0);var l=t+a>=1?t+a:0;return r.el.getPointAtLength(l)}var n=jP(r.el,r.svg),i=e(),s=e(-1),o=e(1);switch(r.property){case"x":return(i.x-n.x)*n.w;case"y":return(i.y-n.y)*n.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function DP(r,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,n=VP(Ke.pth(r)?r.totalLength:r,t)+"";return{original:n,numbers:n.match(e)?n.match(e).map(Number):[0],strings:Ke.str(r)||t?n.split(e):[]}}function qP(r){var t=r?hy(Ke.arr(r)?r.map(IP):IP(r)):[];return dy(t,function(e,n,i){return i.indexOf(e)===n})}function XP(r){var t=qP(r);return t.map(function(e,n){return{target:e,id:n,total:t.length,transforms:{list:zP(e)}}})}function J5(r,t){var e=cS(t);if(/^spring/.test(e.easing)&&(e.duration=FP(e.easing)),Ke.arr(r)){var n=r.length,i=n===2&&!Ke.obj(r[0]);i?r={value:r}:Ke.fnc(t.duration)||(e.duration=t.duration/n)}var s=Ke.arr(r)?r:[r];return s.map(function(o,a){var l=Ke.obj(o)&&!Ke.pth(o)?o:{value:o};return Ke.und(l.delay)&&(l.delay=a?0:t.delay),Ke.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return fy(o,e)})}function $5(r){for(var t=dy(hy(r.map(function(s){return Object.keys(s)})),function(s){return Ke.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]=r.map(function(a){var l={};for(var u in a)Ke.key(u)?u==o&&(l.value=a[u]):l[u]=a[u];return l})},i=0;i<t.length;i++)n(i);return e}function eW(r,t){var e=[],n=t.keyframes;n&&(t=fy($5(n),t));for(var i in t)Ke.key(i)&&e.push({name:i,tweens:J5(t[i],r)});return e}function tW(r,t){var e={};for(var n in r){var i=sS(r[n],t);Ke.arr(i)&&(i=i.map(function(s){return sS(s,t)}),i.length===1&&(i=i[0])),e[n]=i}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function nW(r,t){var e;return r.tweens.map(function(n){var i=tW(n,t),s=i.value,o=Ke.arr(s)?s[1]:s,a=uo(o),l=hS(t.target,r.name,a,t),u=e?e.to.original:l,c=Ke.arr(s)?s[0]:u,d=uo(c)||uo(l),h=a||d;return Ke.und(o)&&(o=u),i.from=DP(c,h),i.to=DP(fS(o,c),h),i.start=e?e.end:0,i.end=i.start+i.delay+i.duration+i.endDelay,i.easing=aS(i.easing,i.duration),i.isPath=Ke.pth(s),i.isColor=Ke.col(i.from.original),i.isColor&&(i.round=1),e=i,i})}var YP={css:function(r,t,e){return r.style[t]=e},attribute:function(r,t,e){return r.setAttribute(t,e)},object:function(r,t,e){return r[t]=e},transform:function(r,t,e,n,i){if(n.list.set(t,e),t===n.last||i){var s="";n.list.forEach(function(o,a){s+=a+"("+o+") "}),r.style.transform=s}}};function KP(r,t){var e=XP(r);e.forEach(function(n){for(var i in t){var s=sS(t[i],n),o=n.target,a=uo(s),l=hS(o,i,a,n),u=a||uo(l),c=fS(VP(s,u),l),d=dS(o,i);YP[d](o,i,c,n.transforms,!0)}})}function rW(r,t){var e=dS(r.target,t.name);if(e){var n=nW(t,r),i=n[n.length-1];return{type:e,property:t.name,animatable:r,tweens:n,duration:i.end,delay:n[0].delay,endDelay:i.endDelay}}}function iW(r,t){return dy(hy(r.map(function(e){return t.map(function(n){return rW(e,n)})})),function(e){return!Ke.und(e)})}function ZP(r,t){var e=r.length,n=function(s){return s.timelineOffset?s.timelineOffset:0},i={};return i.duration=e?Math.max.apply(Math,r.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.duration*(s.loop??1)})):t.duration,i.delay=e?Math.min.apply(Math,r.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.delay})):t.delay,i.endDelay=e?i.duration-Math.max.apply(Math,r.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return n(s)+o+a+s.duration*(s.loop??1)-s.endDelay})):t.endDelay,i}var OP=0;function sW(r){var t=iS(NP,r),e=iS(oS,r),n=eW(e,r),i=XP(r.targets),s=iW(i,n),o=ZP(s,e),a=OP;return OP++,fy(t,{id:a,children:[],animatables:i,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:e.startOnceDelay,pingPongDelayCorrection:e.pingPongDelayCorrection})}var xi=[],LP=[],cy,oW=function(){function r(){cy=requestAnimationFrame(t)}function t(e){var n=xi.length;if(n){for(var i=0;i<n;){var s=xi[i];s.paused?(xi.splice(i,1),n-=1):(s.tick(e),i++)}r()}else cy=cancelAnimationFrame(cy)}return r}();function aW(r){document.hidden?(xi.forEach(function(t){return t.pause(r.timeStamp)}),LP=xi.slice(0),fn.running=xi=[]):LP.forEach(function(t){return t.play(r.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",aW);function fn(r){r===void 0&&(r={});var t=0,e=0,n=0,i,s,o=0,a=null;function l(b){var w=window.Promise&&new Promise(function(A){return a=A});return b.finished=w,w}var u=sW(r),c=l(u);function d(){var b=u.direction;b!=="alternate"&&(u.direction=b!=="normal"?"normal":"reverse"),u.reversed=!u.reversed,s.forEach(function(w){return w.reversed=u.reversed})}function h(b){return u.reversed?u.duration-b:b}function f(){t=0,e=h(u.currentTime)*(1/fn.speed)}function g(b,w){w&&(u.reversed?w.seek(w.duration*w.loop-(b-w.timelineOffset-w.pingPongDelayCorrection)):w.seek(b-w.timelineOffset-w.startOnceDelay-w.pingPongDelayCorrection))}function p(b){if(u.reversed)for(var A=o;A--;)g(b,s[A]);else for(var w=0;w<o;w++)g(b,s[w])}function m(b){var w=0,A=u.animations,T=A.length;for(u.reversePlayback===!0&&u.rewind===!1&&(b=u.duration+u.delay-u.endDelay-b);w<T;){var S=A[w],E=S.animatable,M=S.tweens,I=M.length-1,P=M[I];I&&(P=dy(M,function(J){return b<J.end})[0]||P);for(var C=ws(b-P.start-P.delay,0,P.duration)/P.duration,D=isNaN(C)?1:P.easing(C),B=P.to.strings,k=P.round,X=[],W=P.to.numbers.length,q=void 0,H=0;H<W;H++){var K=void 0;if(u.reversePlayback===!0&&u.rewind===!1)var R=P.to.numbers[H],U=P.from.numbers[H]||0;else var U=P.to.numbers[H],R=P.from.numbers[H]||0;P.isPath?K=Q5(P.value,D*U):K=R+D*(U-R),k&&(P.isColor&&H>2||(K=Math.round(K*k)/k)),X.push(K)}var z=B.length;if(!z)q=X[0];else{q=B[0];for(var j=0;j<z;j++){var G=B[j],re=B[j+1],Z=X[j];isNaN(Z)||(re?q+=Z+re:q+=Z+" ")}}YP[S.type](E.target,S.property,q,E.transforms),S.currentValue=q,w++}}function y(b){u[b]&&!u.passThrough&&u[b](u)}function v(){u.remaining&&u.remaining!==!0&&u.remaining--}function x(b){var w=u.duration,A=u.delay,T=w-u.endDelay,S=h(b);if(u.progress=ws(S/w*100,0,100),u.reversePlayback=S<u.currentTime,o&&p(S),!u.began&&u.currentTime>=0&&(u.began=!0,y("begin")),!u.loopBegan&&u.currentTime>0&&(u.loopBegan=!0,y("loopBegin")),(u.reversed||S>=0)&&S<=A&&u.currentTime!==0&&(m(0),y("change")),(S>=T&&u.currentTime!==w||!w)&&(m(w),y("change")),S>A&&S<T?(u.changeBegan||(u.changeBegan=!0,u.changeCompleted=!1,y("changeBegin")),m(S),y("change")):u.changeBegan?(u.changeCompleted=!0,u.changeBegan=!1,y("change"),o&&y("timelineChangeComplete")):u.began&&S>T&&y("changeComplete"),u.currentTime=ws(S,0,w),u.began&&y("update"),b>=w)if(v(),!u.remaining)u.paused=!0,u.completed||(u.completed=!0,y("loopComplete"),y("complete"),!u.passThrough&&"Promise"in window&&(a(),c=l(u)));else{o?t+=u.duration/fn.speed:t+=u.duration;for(let E of s)E.setStartTime(0),E.remaining=E.loop;y("loopComplete"),u.loopBegan=!1,u.direction==="alternate"&&d()}}return u.reset=function(){var b=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=b==="reverse",u.remaining=u.loop,s=u.children,o=s.length;for(var w=o;w--;)u.children[w].reset();(u.reversed&&u.loop!==!0||b==="alternate"&&u.loop===1)&&u.remaining++,m(u.reversed?u.duration:0)},u.setStartTime=function(b){t=b},u.set=function(b,w){return KP(b,w),u},u.tick=function(b){n=b,t||(t=n),x((n+(e-t))*fn.speed)},u.seek=function(b){x(b-t)},u.pause=function(b){u.paused=!0,o&&(i=b??performance.now())},u.play=function(b){!u.paused||(u.completed&&u.reset(),u.paused=!1,xi.push(u),o&&i!==void 0&&(t+=(b??performance.now())-i),cy||oW())},u.reverse=function(){d(),u.completed=!u.reversed,f()},u.restart=function(){u.reset(),u.play()},u.reset(),u.autoplay&&u.play(),u}function RP(r,t){for(var e=t.length;e--;)lS(r,t[e].animatable.target)&&t.splice(e,1)}function lW(r){for(var t=qP(r),e=xi.length;e--;){var n=xi[e],i=n.animations,s=n.children;RP(t,i);for(var o=s.length;o--;){var a=s[o],l=a.animations;RP(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!i.length&&!s.length&&n.pause()}}function cW(r,t){t===void 0&&(t={});var e=t.direction||"normal",n=t.easing?aS(t.easing):null,i=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",u=o==="last",c=Ke.arr(r),d=parseFloat(c?r[0]:r),h=c?parseFloat(r[1]):0,f=uo(c?r[1]:r)||0,g=t.start||0+(c?d:0),p=[],m=0;return function(y,v,x){if(a&&(o=0),l&&(o=(x-1)/2),u&&(o=x-1),!p.length){for(var b=0;b<x;b++){if(!i)p.push(Math.abs(o-b));else{var w=l?(i[0]-1)/2:o%i[0],A=l?(i[1]-1)/2:Math.floor(o/i[0]),T=b%i[0],S=Math.floor(b/i[0]),E=w-T,M=A-S,I=Math.sqrt(E*E+M*M);s==="x"&&(I=-E),s==="y"&&(I=-M),p.push(I)}m=Math.max.apply(Math,p)}n&&(p=p.map(function(C){return n(C/m)*m})),e==="reverse"&&(p=p.map(function(C){return s?C<0?C*-1:-C:Math.abs(m-C)}))}var P=c?(h-d)/m:d;return g+P*(Math.round(p[v]*100)/100)+f}}function uW(r){r===void 0&&(r={});var t=fn(r);return t.duration=0,t.add=function(e,n){var i=xi.indexOf(t),s=t.children;i>-1&&xi.splice(i,1);function o(h){h.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=fy(e,iS(oS,r));l.targets=l.targets||r.targets;var u=t.duration;l.autoplay=!1,l.timelineOffset=Ke.und(n)?u:fS(n,u),o(t);var c=fn(l);o(c),s.push(c);var d=ZP(s,r);return t.delay=d.delay,t.endDelay=d.endDelay,t.duration=d.duration,c.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}fn.version="3.2.0";fn.speed=1;fn.running=xi;fn.remove=lW;fn.get=hS;fn.set=KP;fn.convertPx=uS;fn.path=Z5;fn.setDashoffset=Y5;fn.stagger=cW;fn.timeline=uW;fn.easing=aS;fn.penner=UP;fn.random=function(r,t){return Math.floor(Math.random()*(t-r+1))+r};var QP=fn;var JP=new _,$P=new _,e2=new rt;function t2(r,t,e,n){if(n===0)return e.copy(r);if(n===1)return e.copy(t);let i=r.w*t.w+r.x*t.x+r.y*t.y+r.z*t.z;if(i>=1)return e.copy(r);let s=1-i*i;if(s<=Number.EPSILON){let c=1-n;return e.w=c*r.w+n*t.w,e.x=c*r.x+n*t.x,e.y=c*r.y+n*t.y,e.z=c*r.z+n*t.z,e.normalize(),e}let o=Math.sqrt(s),a=Math.atan2(o,i),l=Math.sin((1-n)*a)/o,u=Math.sin(n*a)/o;return e.w=r.w*l+t.w*u,e.x=r.x*l+t.x*u,e.y=r.y*l+t.y*u,e.z=r.z*l+t.z*u,e}function Wi(r,t,e,n,i){let s=e[r]?e[r]:void 0,o=n[r];if(o==null)return;let a=s??t[r],l=o;if(a!==l)return{update:u=>{let c=Ve.lerp(a,l,u);i?t[r]=Math.trunc(c):t[r]=c},start:()=>{t[r]=a},end:()=>{t[r]=l}}}function mS(r,t,e,n,i){let s=e[r]?e[r]:void 0,o=n[r];if(!o)return;let a=t[r],l=[...s??a],u=[...o];if(!(l.length!==u.length||Va(l,u)))return{update:c=>{l.forEach((d,h)=>{let f=Ve.lerp(d,u[h],c);t[r][h]=i?Math.trunc(f):f})},start:()=>{Object.assign(t[r],l)},end:()=>{Object.assign(t[r],u)}}}function gS(r,t,e,n){let i=e[r]?e[r]:void 0,s=n[r];if(!s)return;let o=t[r],a=i?new _().fromArray(i):o.clone(),l=new _().fromArray(s);if(!a.equals(l))return{update:u=>{o.lerpVectors(a,l,u)},start:()=>{o.copy(a)},end:()=>{o.copy(l)}}}function n2(r,t,e,n){let i=e[r]?e[r]:void 0,s=n[r];if(!s)return;let o=t[r],a=i?new de().fromArray(i):o.clone(),l=new _,u=new rt,c=new _;a.decompose(l,u,c);let d=new de().fromArray(s),h=new _,f=new rt,g=new _;if(d.decompose(h,f,g),!a.equals(d))return{update:p=>{e2.slerpQuaternions(u,f,p),JP.lerpVectors(l,h,p),$P.lerpVectors(c,g,p),o.compose(JP,e2,$P)},start:()=>{o.compose(l,u,c)},end:()=>{o.compose(h,f,g)}}}function r2(r,t,e,n,i){let s=e[r]?e[r]:void 0,o=n[r];if(!o)return;let a=t[r],l=s?typeof s=="string"?i.getColor(s).clone():new Le().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Le().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return t[r]=c,{update:d=>{c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function _s(r,t,e,n){if(typeof t[r]=="number")return Wi(r,t,e??{},n);if(Array.isArray(t[r]))return mS(r,t,e??{},n)}function i2(r,t,e){let n=[],i=r.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,s=r.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(s!==void 0){let o=i??r.zoom,a=s;o!==a&&n.push({update:l=>{r.zoom=Ve.lerp(o,a,l),r.updateProjectionMatrix()},start:()=>{r.zoom=o,r.updateProjectionMatrix()},end:()=>{r.zoom=a,r.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let o=Wi("targetOffset",r,t,e);o&&n.push(o)}return n}function dW(r,t,e,n){if(e.scaleBaked===void 0)return;let i=t.scaleBaked??r.data.geometry.scaleBaked,s=e.scaleBaked;if(ss.isEqual(i,s))return;let o=[];return o.push({update:a=>{r.updateGeometryInteractions({scaleBaked:[Ve.lerp(i[0],s[0],a),Ve.lerp(i[1],s[1],a),Ve.lerp(i[2],s[2],a)]},n),r.invalidateDownstreamBooleanData()},start:()=>{r.updateGeometryInteractions({scaleBaked:i},n),r.invalidateDownstreamBooleanData()},end:()=>{r.updateGeometryInteractions({scaleBaked:s},n),r.invalidateDownstreamBooleanData()}}),o}function hW(r,t,e){if(!e.extrusion)return;let n=r.extrusion,i=t.extrusion??{},s=e.extrusion,o=[];return fx.forEach(a=>{let l=_s(a,n,i,s);l&&o.push(l)}),o}function s2(r,t,e,n){let i=[];if(!("geometry"in e))return i;let s=r.geometry.userData.parameters,o="geometry"in t?t.geometry:{},a=e.geometry;if(r instanceof zi){let l=dW(r,o,a,n);l&&i.push(...l)}else{let l={};if(Object.assign(l,Uo(s,px)),px.forEach(u=>{let c=_s(u,l,o,a);c&&i.push(c)}),r instanceof ia){Object.assign(l,{extrusion:{...s.extrusion}});let u=hW(l,o,a);u&&i.push(...u)}i.length&&i.push({update:u=>{r.updateGeometryInteractions(l,n),r.updateGeometryGroupsIfNeeded()},start:u=>{r.updateGeometryInteractions(l,n),r.updateGeometryGroupsIfNeeded()},end:u=>{r.updateGeometryInteractions(l,n),r.updateGeometryGroupsIfNeeded()}})}return i}function o2(r,t,e,n){let i=[];if(e.intensity!==void 0){let s=Wi("intensity",r,t,e);s&&i.push(s)}if(e.color!==void 0){let s=r2("color",r,t,e,n);s&&i.push(s)}return i}function l2(r,t,e,n){let i=[];if(Array.isArray(r.material)){if(!("materials"in e&&e.materials))return i;let s="materials"in t&&t.materials?t.materials:[],o=e.materials;r.material.forEach((a,l)=>{if(!o[l])return;let u=s[l]??{},c=o[l];typeof u=="string"||typeof c=="string"||i.push(...a2(a,u,c,n))})}else{if(!("material"in e&&e.material))return i;let s="material"in t&&t.material?t.material:{},o=e.material;if(typeof s=="string"||typeof o=="string")return i;i.push(...a2(r.material,s,o,n))}return i}function a2(r,t,e,n){let i=[],s=tf(e,n)||!!t.layers&&tf(t,n);i.push(SW(r,s));for(let o of r.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=>!Im.some(d=>c.includes(d)));for(let c of u)try{let d=o.getValue(c),h;if(c==="colors")h=xW(o,a,l,c);else if(Array.isArray(d))c==="steps"&&(h=vW(o,a,l,c));else if(typeof d=="number")h=fW(o,a,l,c);else{if(typeof d=="boolean")continue;d instanceof F?h=pW(o,a,l,c):d instanceof _?h=mW(o,a,l,c):d instanceof Yt?h=yW(o,a,l,c,n):d instanceof Le?h=gW(o,a,l,c,n):"isTexture"in d&&(h=bW(o,a,l,c))}h&&(Array.isArray(h)?i.push(...h):i.push(h))}catch(d){console.error(`lerpMaterial: unexpected material layer for ${c}`,d)}}return i}function fW(r,t,e,n){if(!r.hasValue(n)||!(n in e))return;let i=t?t[n]:r.getValue(n),s=e[n];if(i!==s)return{update:o=>{r.setValue(n,Ve.lerp(i,s,o))},start:()=>{r.setValue(n,i)},end:()=>{r.setValue(n,s)}}}function pW(r,t,e,n){if(!r.hasValue(n)||!(n in e))return;let i=r.getValue(n),s=t?new F().fromArray(t[n]):i.clone(),o=new F().fromArray(e[n]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function mW(r,t,e,n){if(!r.hasValue(n)||!(n in e))return;let i=r.getValue(n),s=t?new _().fromArray(t[n]):i.clone(),o=new _().fromArray(e[n]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function gW(r,t,e,n,i){if(!r.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=r.getValue(n),l=s?typeof s=="string"?i.getColor(s).clone():new Le().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Le().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return r.setValue(n,c),{update:d=>{c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function yW(r,t,e,n,i){if(!r.hasValue(n)||!(n in e))return;let s=t?t[n]:void 0,o=e[n],a=r.getValue(n),l=s?typeof s=="string"?i.getColor(s).clone():new Le().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Yt(o.r,o.g,o.b,o.a);if(l.equals(u))return;let c=a.clone();return r.setValue(n,c),{update:d=>{c.lerpColors(l,u,d)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function vW(r,t,e,n="steps"){if(!r.hasValue(n)||!(n in e))return;let i=[],s=r.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&&i.push({update:d=>{s[l]=Ve.lerp(u,c,d)},start:()=>{s[l]=u},end:()=>{s[l]=c}})}return i.length?i:void 0}function xW(r,t,e,n="colors"){if(!r.hasValue(n)||!(n in e))return;let i=[],s=r.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]];sh.isEqual(u,c)||i.push({update:d=>{s[l].fromArray(sh.lerp(u,c,d))},start:()=>{s[l].fromArray(u)},end:()=>{s[l].fromArray(c)}})}return i.length?i:void 0}function bW(r,t,e,n="texture"){if(!r.hasValue(n)||!(n in e))return;let i=r.getNode("mat");if(!i)return;let s=t?t[n]:i,o=e[n],a=[...s.repeat],l=[...s.offset],u=[...o.repeat],c=[...o.offset];if(!qa.isEqual(a,u)||!qa.isEqual(l,c))return{update:d=>{i.repeat=qa.lerp(a,u,d),i.offset=qa.lerp(l,c,d),i.updateMatrix()},start:()=>{i.repeat=[...a],i.offset=[...l],i.updateMatrix()},end:()=>{i.repeat=[...u],i.offset=[...c],i.updateMatrix()}}}function SW(r,t){return{update:()=>{r.transparent=t}}}var yS=new _,c2=new jt;function u2(r,t,e,n){let i=[],s,o,a,l,u,c,d={slide:(t.pathSnapping??r.dataPatched.pathSnapping).slide,offset:(t.pathSnapping??r.dataPatched.pathSnapping).offset};if(u=Wi("slide",d,t.pathSnapping??r.dataPatched.pathSnapping,e.pathSnapping??r.dataPatched.pathSnapping),u&&i.push(u),c=Wi("offset",d,t.pathSnapping??r.dataPatched.pathSnapping,e.pathSnapping??r.dataPatched.pathSnapping),c&&i.push(c),!u&&!c&&(s=gS("position",r,t,e),s&&i.push(s),o=gS("scale",r,t,e),o&&i.push(o),a=wW(r,t,e,n),a&&i.push(a),l=n2("hiddenMatrix",r,t,e),l&&i.push(l)),s||o||a||l||u||c){let h=()=>{r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldSVD()),r.parent?.matrixWorldFusedFalse&&(r.matrixWorld.multiplyMatrices(r.parent.matrixWorldFusedFalse,r.matrix),r.matrixWorldNeedsUpdate=!1),Jr(r)&&$r(r.parent)&&r.invalidateDownstreamBooleanData(!0),r.updatePathSnapping(Object.assign({},t.pathSnapping,d))};i.push({update:h,start:h,end:h})}return i}function wW(r,t,e,n){let i=t?.rotation?t.rotation:void 0,s=e.rotation;if(!s)return;let o=i?new _().fromArray(i):new _().setFromEuler(r.rotation),a=new _().fromArray(s);if(o.equals(a))return;let l=yS.subVectors(a,o);if(n&&l.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new rt().setFromEuler(c2.setFromVector3(o)),c=new rt().setFromEuler(c2.setFromVector3(a));return{update:d=>{t2(u,c,r.quaternion,d)},start:()=>{r.rotation.setFromVector3(o)},end:()=>{r.rotation.setFromVector3(a)}}}else return{update:u=>{yS.lerpVectors(o,a,u),r.rotation.setFromVector3(yS)},start:()=>{r.rotation.setFromVector3(o)},end:()=>{r.rotation.setFromVector3(a)}}}function d2(r,t,e){let n=[];if(!("cloner"in e)||!r.cloner)return n;let i=r.cloner,s="cloner"in t?t.cloner:{},o=e.cloner;ix.forEach(h=>{let f;h==="count"?f=Wi("count",i.parameters,s,o,!0):f=_s(h,i.parameters,s??{},o),f&&n.push(f)});let a=AW(i,s,o);a?.length&&n.push(...a);let l=_W(i,s,o);l?.length&&n.push(...l);let u=TW(i,s,o);u?.length&&n.push(...u);let c=EW(i,s,o);c?.length&&n.push(...c);let d=MW(i,s,o);return d?.length&&n.push(...d),n.length&&n.push({update:()=>{i.update()}}),n}function AW(r,t,e){if(r.parameters.type!=="radial")return;let n=t.radial,i=e.radial;if(!i)return;let s=r.parameters.radial,o=[];return sx.forEach(a=>{let l=_s(a,s,n??{},i);l&&o.push(l)}),o}function _W(r,t,e){if(r.parameters.type!=="linear")return;let n=t.linear,i=e.linear;if(!i)return;let s=[],o=r.parameters.linear;return ox.forEach(a=>{let l=_s(a,o,n??{},i);l&&s.push(l)}),s}function TW(r,t,e){if(r.parameters.type!=="grid")return;let n=t.grid,i=e.grid;if(!i)return;let s=[],o=r.parameters.grid;return ax.forEach(a=>{let l;a==="count"?l=mS(a,o,n??{},i,!0):l=_s(a,o,n??{},i),l&&s.push(l)}),s}function EW(r,t,e){if(r.parameters.type!=="toObject")return;let n=t.toObject,i=e.toObject;if(!i)return;let s=[],o=r.parameters.toObject;return lx.forEach(a=>{let l;a==="count"?l=Wi(a,o,n??{},i,!0):l=_s(a,o,n??{},i),l&&s.push(l)}),s}function MW(r,t,e){if(!r.parameters.randomness)return;let n=t.randomnessObject,i=e.randomnessObject;if(!i)return;let s=[],o=r.parameters.randomnessObject;return cx.forEach(a=>{let l=_s(a,o,n??{},i);l&&s.push(l)}),s}function vS(r,t,e,n,i){let s=[];return r.data.visible&&s.push(...u2(r,t,e,i)),r.data.visible&&s.push(...d2(r,t,e)),Jr(r)?(r instanceof Kt&&r.data.visible&&s.push(...s2(r,t,e,n)),r.data.visible&&s.push(...l2(r,t,e,n))):jC(r)?r.data.visible&&s.push(...o2(r,t,e,n)):WC(r)&&s.push(...i2(r,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 h2=new _;function ly(r,t,e,n=!1){let i=[];t.traverseObject(s=>{if(n&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(h2,!0),s.rigidBody?.setAngvel(h2,!0)),!Pt.is(s))return;let o=s.uuid,a=s.data;if(delete s.states,!a.states)return;let l=!1;i.some(u=>r.objects.isDescendantOf(o,u))?l=!0:a.physics?.fusedBody===!0&&a.physics.rigidBody==="dynamic"&&i.push(o),s.data=a,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let u of a.states)r.environment.usePhysics===!0&&a.physics&&(a.physics.rigidBody==="dynamic"||l)&&(u.data.position!==void 0||u.data.rotation!==void 0||u.data.hiddenMatrix!==void 0)||(s.states||(s.states={}),s.states[u.id]=Js.patch(a,u.data));CW(t,s,null,e,a.events.find(u=>u.data.type==="Follow"||u.data.type==="LookAt")!==void 0)})}function CW(r,t,e,n,i=!1){t instanceof Kt&&t.removeInteractionGeometry(),t.changeSelectedState(e,{scene:r,shared:n},i),t instanceof Kt&&t.updateGeometryGroupsIfNeeded()}function PW(r){let t;switch(r.easing){case 0:t="cubicBezier( 0, 0, 1, 1 )";break;case 1:t="cubicBezier( .25, .1, .25, 1 )";break;case 2:t="cubicBezier( .42, 0, 1, 1 )";break;case 3:t="cubicBezier( 0, 0, .58, 1 )";break;case 4:t="cubicBezier( .42, 0, .58, 1 )";break;case 5:let{control1:e,control2:n}=r;t=`cubicBezier(
|
|
4913
4913
|
${e[0]}, ${e[1]}, ${n[0]}, ${n[1]}
|
|
4914
4914
|
)`;break;case 6:let{mass:i,stiffness:s,damping:o,velocity:a}=r;t=`spring( ${i}, ${s}, ${o}, ${a} )`;break;default:t="linear"}return{duration:r.duration,easing:t}}function f2(r){let t={delay:0,loop:r.repeat===-1?!0:r.repeat+1};if(r.repeat===0)t.direction="normal",t.rewind=r.direction==="pingpong-rewind";else switch(r.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,r.delayDirection){case"start-once":t.startOnceDelay=r.delay;break;case"start":t.delay=r.delay;break;case"end":t.endDelay=r.delay;break;case"start-end":case void 0:t.delay=r.delay,t.endDelay=r.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,t.delay!==0&&(t.pingPongDelayCorrection=t.delay)),t}var IW={type:"beginState"},DW={type:"completeState",isfromEntity:!1},my=class{constructor(t,e,n,i,s,o){this.object=t;this.data=i;this.sharedAssets=s;this.allowSlerp=o;this.targets={t:0};this.firstLoop=!0;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))};this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let 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 Zt&&e.dispatchEvent(IW)})};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 Zt&&e.dispatchEvent(DW)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=vS(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=py(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=py(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(n===void 0)throw new Error("Missing property");{let a=py(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,...f2(i),...PW(i),change:this.onChange},this.callback=vS(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}},Ts=class extends Wt{constructor(e,n,i){super();this.data=e;this.scene=n;this.sharedAssets=i;this.toggleIsForward=!1;this.timelineNeedsRebuild=!1;this.useToggle=!1;this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,isRebuild:!0}),this.timeline.play())};if(!e.object)throw new Error("Missing property");let s=n.find(e.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,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=py(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 i=f2(this.data.tweens[0].data),s=i.loop;n&&typeof i.loop=="number"&&i.loop--,this.timeline?.pause(),this.timeline=QP.timeline({autoplay:!1,...i,...s===!0||s>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(this.timelineNeedsRebuild=o!==-1&&(s===!0||s>1),i.pingPongDelayCorrection&&n===!1&&(this.timelineNeedsRebuild=!0),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],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Zt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new my(this.object,d,c.data.state===void 0?this.currentState:c.data.state,c.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l]=h,this.timeline.add(h.params,this.timeline.duration+(l===a?i.delay:0)+(l===a&&!n?i.pingPongDelayCorrection:0))}this.timeline.duration+=i.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let u=this.data.tweens[l],c=this.data.tweens[l-1],d;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(d=void 0,this.object instanceof Zt&&(this.object.wasMovedByUser=!1)):d=u.data.state===void 0?this.currentState:u.data.state;let h=new my(this.object,d,c.data.state===void 0?this.currentState:c.data.state,u.data,this.sharedAssets,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(h.params,{startOnceDelay:0}),this.tweens[l-1]=h,this.timeline.add(h.params,this.timeline.duration+(l===a?i.endDelay:0))}this.timeline.duration+=i.delay+(n?0:i.pingPongDelayCorrection)}}catch(i){i instanceof Error&&console.error(i.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(e){e instanceof Error&&console.error(e.message)}},this.startOnceDelay)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.scene,shared:this.sharedAssets}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration)}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function py(r,t){let e,n;if(typeof t=="string"?(e=t,n=r.states?.[e]):t===null&&(e=null,n=r.data),!(e===void 0||n===void 0))return{id:e,data:n}}function Nr(r,t,e,n,i,s){let o={Audio:[],Video:[],Link:[],Reset:[],Transition:[]};return t.forEach(({id:a,data:l})=>{try{l.type==="Audio"?Gc[r.type].includes("Audio")&&o.Audio.push(new Ss(a,l,e,i)):l.type==="Video"?Gc[r.type].includes("Video")&&o.Video.push(new oa(a,l,e)):l.type==="Link"?Gc[r.type].includes("Link")&&o.Link.push(new oy(l,s)):l.type==="Reset"?Gc[r.type].includes("Reset")&&o.Reset.push(new ay(n.data,n,i,s)):l.type==="Transition"&&Gc[r.type].includes("Transition")&&o.Transition.push(new Ts(l,n,i))}catch{}}),o}function Br(r){Object.values(r).forEach(t=>{t.forEach(e=>{(e instanceof Ss||e instanceof oa||e instanceof Ts)&&e.dispose()})})}var xS=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],p2=r=>xS.find(([t,e])=>e===r)?.[0],aa=r=>xS.find(([t])=>t===r)?.[1],OW=(r,t)=>{let e=p2(r);if(e){let n=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(n,"target",{writable:!1,value:t}),n}},gy=class extends Qn{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[p2(e.eventName)]?.[e.target.uuid];if(!n)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(n,{deltaY:e.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(n)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{if(!!i.data?.events.length){for(let[s,o]of xS)if(i.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(i):this.objectsPerEvents.set(s,[i]);let a={id:i.uuid,name:i.name},l=OW(o,a),u=this.splineEvents[s];u?u[i.uuid]=l:this.splineEvents[s]={[i.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 bS=class{constructor(t,e,n,i,s,o){this.id=t;this.data=e;this.object=n;this.entered=!1;if(this.useToggle=e.toggle,(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=Nr(e,e.actions,n,i,s,o)}disconnect(){Br(this.actions)}dispatch(){let t=new Set;this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.useToggle===!1&&t.add(e)}),this.useToggle?this.actions.Transition.forEach(e=>{e.toggle()}):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent())):this.actions.Transition.some(n=>n.playing)||this.actions.Transition.forEach(n=>{t.has(n)===!1&&n.play()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()})}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(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.Transition.forEach(e=>e.playFromCurrent()),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()})}},yy=class extends Qn{constructor(e,n,i){super(e);this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]};this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}};this.heldKeys={};this.heldKeysPress={};this._prevObjects=[];this.onMouseDown=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||this.handleKeyEvent(e,"KeyDown"),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp")};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]||this.handleKeyEvent(e,"KeyPress"),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:i})=>{if(!e||!n)return;let s=aa(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent(i)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{scene:s,sharedAssets:o}=this.eventContext;s.traverseEntity(a=>{if(!a.data?.events.length)return;let l=a.visible?["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"]:["KeyDown","KeyUp","KeyPress"];for(let u of l){let c=this.eventsPerObjects[u];a.data.events.filter(({data:d})=>d.type===u&&d.disabled!==!0).forEach(({id:d,data:h})=>{try{let f=new bS(d,h,a,s,o,{controlsManager:n,eventManager:i});f.actions.Video.length&&(this.hasVideoAction=!0),c[a.uuid]?c[a.uuid].push(f):c[a.uuid]=[f]}catch{}}),c[a.uuid]?.length&&this.objectsPerTypes[u].push(a)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([n,i])=>{i.forEach(s=>{s.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},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(i=>{i.forEach(s=>{s.disconnect()})})}),Object.entries(this.objectsPerTypes).forEach(([n,i])=>{i.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:n,raycaster:i,scene:s}=this.eventContext,o=this.objectsPerTypes[e];if(!!o.length)if(n){let a=mf(i,s,o);gf(a).forEach(l=>{this.eventsPerObjects[e][l.uuid]&&this.handleObjectMouseEventDispatch(l,e)})}else o.forEach(a=>{ju(i,a)&&this.handleObjectMouseEventDispatch(a,e)})}handleMousePressEvent(e=!1){let n="MousePress",i=this.objectsPerTypes[n],s=[];if(!!i.length){if(!e){let{stopRaycast:o,raycaster:a,scene:l}=this.eventContext;if(o){let u=mf(a,l,i);s=gf(u)}else i.forEach(u=>{ju(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(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,n){e.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,n,i=!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&&(i?a.dispatchRelease():a.dispatch())})})}};var LW=new _,RW=new _;var vy=class{constructor(t,e,n,i){this.actionsIn=Nr(t,t.inActions,e,n,i),this.actionsOut=Nr(t,t.outActions,e,n,i)}disconnect(){Br(this.actionsIn),Br(this.actionsOut)}};var SS=class extends vy{constructor(e,n,i,s,o){super(n,i,s,o);this.id=e;this.data=n;this.object=i;this.stage="out";this.objects=[];this.onUpdateMatrix=()=>{let e=LW.setFromMatrixPosition(this.objects[0].matrixWorld),n=RW.setFromMatrixPosition(this.objects[1].matrixWorld),i=e.distanceTo(n)<=this.distance?"in":"out";if(this.stage!==i){let s=i==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),this.stage=i}};let{distance:a,fromObject:l,toObject:u}=n.condition;this.distance=a;for(let c of[l,u]){if(!c)throw new Error("Missing property");let d=s.find(c);if(!d)throw new Error("Missing property");this.objects.push(d)}}connect(){this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},wS=class extends vy{constructor(e,n,i,s,o){super(n,i,s,o);this.id=e;this.data=n;this.object=i;this.onBegin=({target:e,state:n})=>{this.toState!==n&&(this.actionsOut.Audio.forEach(i=>i.dispatchConditional()),this.actionsOut.Video.forEach(i=>i.dispatchConditional()),this.actionsIn.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(i=>i.play()))};this.onComplete=({target:e,state:n})=>{this.toState===n&&(this.actionsIn.Audio.forEach(i=>i.dispatchConditional()),this.actionsIn.Video.forEach(i=>i.dispatchConditional()),this.actionsOut.Transition.forEach(i=>i.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(i=>i.play()))};let{condition:a}=n;if(!a.object)throw new Error("Missing property");let l=s.find(a.object);if(!l)throw new Error("Missing property");if(this.toObject=l,a.state&&!this.toObject.states?.[a.state])throw new Error("Missing property");this.toState=a.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Transition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsIn.Transition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Transition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsIn.Transition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},xy=class extends Qn{constructor(e){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length){for(let{id:o,data:a}of s.data.events)if(!a.disabled&&a.type==="Conditional")try{let l;a.condition.type==="Comparison"||(a.condition.type==="Distance"?l=new SS(o,a,s,n,i):a.condition.type==="State"&&(l=new wS(o,a,s,n,i))),l&&(this.eventsPerConditions[a.condition.type].push(l),(l.actionsIn.Video.length||l.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(n=>n.disconnect()))}};var Yu=new _,AS=new _,ho=new _,fo=new _,m2=new Tn,NW=.01,BW={type:"requestRender"},FW=function(){let r=new _,t=new _;return(e,n,i)=>i>0?(r.subVectors(e,n),r.length()<=i?e:t.copy(n).add(r.normalize().multiplyScalar(i))):n}(),g2=function(){let r=new de;return(t,e)=>{t.position.copy(e),t.parent!==null&&(r.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(r)),r.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(r),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Vt&&$r(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),_S=class{constructor(t,e,n){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new _;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Am.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(t.target==="personal camera"?this.target=n.find(ti.PERSONAL_CAMERA_ID):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)}},by=class extends Qn{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(Je.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{scene:n}=this.eventContext;n.traverseEntity(i=>{let s=i.data?.events.find(o=>o.data.type==="Follow"&&!o.data.disabled);s&&(!n.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new _S(s.data,i,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),In&&(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 i of this.events)if(i.target!==void 0){let s=i.target,o=this.onTargetChange(i);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(),In&&e.removeEventListener("pointerdown",this.onMouseMove),n.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,s]of this.pairOfEventListeners)i.removeEventListener("requestRender",s);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{plane:n,limitDistance:i,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition(ho),e.isReset)fo.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(fo);else{let{camera:a,raycaster:l}=this.eventContext;if(n==="custom"?(a.getWorldDirection(AS),AS.negate(),Yu.copy(AS)):n==="xy"?Yu.set(0,0,1):n==="xz"?Yu.set(0,1,0):n==="yz"&&Yu.set(1,0,0),m2.setFromNormalAndCoplanarPoint(Yu,ho),!l.ray.intersectPlane(m2,fo))return}if(!e.isReset){if(fo.distanceTo(e.worldPosition0)>i&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)fo.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&&(fo.x=ho.x),e.data.enabledTranslation[1]===!1&&(fo.y=ho.y),e.data.enabledTranslation[2]===!1&&(fo.z=ho.z);let o=FW(ho,fo,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let a=Yu.subVectors(o,ho).divideScalar(e.currentDampingFactor);ho.add(a),g2(e.object,ho),e.paused=a.length()<NW}else g2(e.object,o),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(BW)}};var bf=new _,Sy=new _,Sf=new de,Ku=new rt,la=new rt,wf=new _,Af=new _,ml=new _,po=new _,TS=new Tn,UW=1e-6,GW={type:"requestRender"},kW={type:"changeRotation"},v2=function(){let r=new de;return function(e,n){e.parent!==null?r.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):r.copy(e.hiddenMatrix),n.premultiply(eS(r).invert()),e.rotation.setFromRotationMatrix(n),e.updateMatrix(),e instanceof Vt&&$r(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),ES=class{constructor(t,e,n){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new rt;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={..._m.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(t.target==="personal camera"?this.target=n.find(ti.PERSONAL_CAMERA_ID):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}},wy=class extends Qn{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(Je.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)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{let s=i.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!n.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new ES(s.data,i,n))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:n}=this.eventContext;this.domEventsNeeded.clear(),In&&(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 i of this.events)if(i.target!==void 0){let s=i.target,o=this.onTargetChange(i);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(),In&&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[i,s]of this.pairOfEventListeners)i.removeEventListener("requestRender",s);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:n,axis:i,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:u}=e.data,{camera:c,raycaster:d}=this.eventContext,{object:h,target:f}=e;if(h.getWorldPosition(wf),!e.isReset)if(e.target)e.target.getWorldPosition(Af);else{if(o==="custom"?(c.getWorldDirection(Sy),Sy.negate(),TS.setFromNormalAndCoplanarPoint(Sy,wf)):(o==="xy"?bf.set(0,0,1):o==="xz"?bf.set(0,1,0):o==="yz"&&bf.set(1,0,0),TS.setFromNormalAndCoplanarPoint(bf,wf)),!d.ray.intersectPlane(TS,Af))return;s>0&&(o==="custom"||o===void 0)&&Af.addScaledVector(Sy,s)}if(e.isReset||(f?n==="target"?ml.copy(f.up).applyMatrix4(Sf.extractRotation(f.matrixWorld)).normalize():l.some(g=>g===!1)?(i==="x"?(po.set(0,0,1),l[2]===!1&&po.set(0,1,0)):i==="y"?(po.set(1,0,0),l[0]===!1&&po.set(0,0,1)):(po.set(0,1,0),l[1]===!1&&po.set(1,0,0)),ml.copy(po).applyQuaternion(e.worldQuaternion0).normalize()):ml.set(0,1,0):o==="custom"?ml.set(0,1,0):ml.copy(bf)),e.isReset)la.copy(e.worldQuaternion0);else if(wf.distanceTo(Af)>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)la.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;zW(Sf,Af,wf,ml,i,po),la.setFromRotationMatrix(Sf),Ku.setFromUnitVectors(po.applyQuaternion(la),ml),l.some(g=>g===!1)&&n!=="target"&&la.premultiply(Ku).normalize()}e.currentDampingFactor>1?(h.updateWorldMatrix(!0,!1),Ku.setFromRotationMatrix(eS(h.matrixWorld)),Ku.slerp(la,1/e.currentDampingFactor),v2(h,Sf.makeRotationFromQuaternion(Ku)),e.paused=8*(1-Ku.dot(la))<UW):(v2(h,Sf.makeRotationFromQuaternion(la)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),h.dispatchEvent(GW),h.dispatchEvent(kW)}},bi=new _,Rn=new _,pn=new _;function zW(r,t,e,n,i,s){let o=r.elements;pn.subVectors(t,e),pn.lengthSq()===0&&(pn.z=1),pn.normalize(),Rn.crossVectors(n,pn),Rn.lengthSq()===0&&(Math.abs(n.z)===1?pn.x+=1e-4:pn.z+=1e-4,pn.normalize(),Rn.crossVectors(n,pn)),Rn.normalize(),bi.crossVectors(pn,Rn),i==="x"?s.z===1?[Rn,bi,pn]=[pn,Rn,bi]:(Rn.negate(),[Rn,pn]=[pn,Rn]):i==="y"?s.x===1?[Rn,bi,pn]=[bi,pn,Rn]:(Rn.negate(),[bi,pn]=[pn,bi]):s.x===1&&(Rn.negate(),[Rn,bi]=[bi,Rn]),o[0]=Rn.x,o[4]=bi.x,o[8]=pn.x,o[1]=Rn.y,o[5]=bi.y,o[9]=pn.y,o[2]=Rn.z,o[6]=bi.z,o[10]=pn.z}var MS=class{constructor(t,e,n,i,s){this.id=t;this.data=e;this.object=n;this.entered=!1;this.actions=Nr(e,e.actions,n,i,s)}disconnect(){Br(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()))}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()))}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.Transition.forEach(e=>e.playFromCurrent())}},Ay=class extends Qn{constructor(e){super(e);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{Je.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{Je.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:n,reverse:i})=>{if(!e||!n)return;let s=aa(e);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(o=>o.dispatchUserEvent(i)))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:o,data:a}of s.data.events)if(!a.disabled&&a.type==="MouseHover")try{let l=new MS(o,a,s,n,i);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(l):this.eventsPerObjects[s.uuid]=[l]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),In&&(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(),In&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(n=>{n.forEach(i=>{i.disconnect()})}),this.objects.forEach(n=>{n.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let n=[];if(!e){let{stopRaycast:i,raycaster:s,scene:o}=this.eventContext;if(i){let a=mf(s,o,this.objects);n=gf(a)}else this.objects.forEach(a=>{ju(s,a)&&n.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{n.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchLeave()))}),n.length&&n.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=n}};var CS=class{constructor(t,e,n,i,s){this.id=t;this.data=e;this.object=n;this.scrollCounter=0;this.actions=Nr(e,e.actions,n,i,s)}connect(){this.scrollCounter=0}disconnect(){Br(this.actions)}dispatch(t){this.actions.Transition.forEach(i=>{i.object.currentTransitionEvent!==this&&(i.object.currentTransitionEvent=this,i.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(i=>i.seek(n))}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.Transition.forEach(e=>{e.playFromCurrent()})}},PS=class{constructor(t,e,n,i,s,o){this.id=t;this.data=e;this.object=n;this.domElement=o;this.scrollStart=0;this.scrollEnd=0;this.actions=Nr(e,e.actions,n,i,s)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,n=document.documentElement,i=window.pageYOffset||n.scrollTop||e.scrollTop,s=n.clientTop||e.clientTop||0,o=Math.round(t.top+i-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.dispatch({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){Br(this.actions)}handleResize(){this.computeScrollBounds()}dispatch({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,i=Math.min(1,Math.max(0,(e-this.scrollStart)/n));this.actions.Transition.forEach(s=>s.seek(i))}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.Transition.forEach(e=>{e.playFromCurrent()})}},_y=class extends Qn{constructor(e){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let n={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([i,s])=>{i.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,i])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),i.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:n,reverse:i})=>{if(!e||!n)return;let s=aa(e);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:n,sharedAssets:i,domElement:s,isExport:o}=this.eventContext;n.traverseEntity(a=>{if(!!a.data?.events.length){for(let{id:l,data:u}of a.data.events)if(!u.disabled&&u.type==="Scroll")if(u.trigger==="load"||!o){let c=new CS(l,u,a,n,i);this.wheelEventsPerObject.has(a)?this.wheelEventsPerObject.get(a)?.push(c):this.wheelEventsPerObject.set(a,[c])}else{let c=new PS(l,u,a,n,i,s);this.scrollEventsPerObject.has(a)?this.scrollEventsPerObject.get(a)?.push(c):this.scrollEventsPerObject.set(a,[c])}}}),this.intersectionObserver=new IntersectionObserver(a=>{let l=a[0];l&&(this.isInview=l.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,n])=>{n.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var IS=class{constructor(t,e,n,i,s){this.id=t;this.data=e;this.object=n;this.actions=Nr(e,e.actions,n,i,s)}disconnect(){Br(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof co?e.interaction.audioPlayer.play():e.interaction instanceof qu&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let n=e.interaction.data.triggerAfter??"autoplay";n===t&&(e.interaction instanceof sa?e.interaction.play(n==="autoplay"):e.interaction instanceof Xu&&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.Transition.forEach(e=>e.playFromCurrent()),this.actions.Audio.forEach(e=>{e.interaction instanceof co?e.interaction.audioPlayer.play():e.interaction instanceof qu&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof sa?e.interaction.play():e.interaction instanceof Xu&&e.interaction.dispatch()})}},Ty=class extends Qn{constructor(e){super(e);this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.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.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:n,reverse:i})=>{if(!e||!n)return;let s=aa(e);s&&s==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}),this.eventsAfterPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length)for(let{id:o,data:a}of s.data.events){if(a.disabled||a.type!=="Start")continue;let l=new IS(o,a,s,n,i);l.actions.Transition.length&&(this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(l):this.eventsPerObject.set(s,[l])),l.actions.Audio.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l])),l.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l]))}})}connect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:n}=this.eventContext,i=n?document:e;i.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),i.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.addEventListener("userEvent",this.onUserEvent)}),this.onPlay()}[...this.eventsPerObject.entries()].forEach(([e,n])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>i.dispatch()),e.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:n}=this.eventContext,i=n?document:e;i.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([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(i=>i.disconnect())})}};var Ey=class{constructor(t,e,n,i,s){this.id=t;this.data=e;this.object=n;this.disabled=!0;this.actions=Nr(e,e.actions,n,i,s),this.target=e.target,this.useToggle=e.toggle}disconnect(){Br(this.actions)}dispatch(){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?this.actions.Transition.forEach(t=>{t.toggle()}):this.actions.Transition.forEach(t=>{t.play()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}))}};var an;TT.then(r=>an=r);var Fr=new _,ca=new rt,gl=new _,DS=new jt(0,0,0,"YXZ"),VW={type:"updateMatrix"},OS={type:"beginEvent",eventName:"Collision"};function S2(r){if(r.scene.environment.usePhysics)return!0;let t=!1;return r.scene.objects.traverse((e,n)=>{for(let i of n.events)if(i.data.disabled!==!0&&i.data.type==="GameControl"&&i.data.collisionEnabled){t=!0;break}}),t}var x2=r=>r.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0),b2=r=>r.events.find(t=>t.data.disabled!==!0&&t.data.type==="Follow"),My=class{constructor(t,e,n,i,s,o=!1){this.scene=e;this.sharedAssets=s;this.isExport=o;this.orbitControlsNeedsUpdate=!0;this.gameControls=[];this.gameControlStates=[];this.joysticks=[];this.joystickToGameControls=[];this.sharedGameControlGlobals={entitiesWithTransformAnim:[],eventsPerObjects:{},colliderToEntity:{},gamePads:[]};this.needsCollisionDetection=!1;this.initializationCounter=-1;this.rigidBodyToMesh=new Map;this.nActiveRigidBodies=0;this.collisionEvents=[];this.processRigidBody=t=>{if(t.bodyType()!==an.RigidBodyType.Dynamic)return;t.isSleeping()||this.nActiveRigidBodies++;let[e,n,i]=this.rigidBodyToMesh.get(t.handle);if(Fr.copy(t.translation()).multiplyScalar(this.pixelsPerMeter),ca.copy(t.rotation()),e.matrixWorld.compose(Fr,ca,n),e.hasNonUniformScale&&e.matrixWorld.multiply(e.shearScale),e.dispatchEvent(VW),i){let s=e.cloner;if(s&&s.objectForSample===void 0){s.matrixWorld.copy(e.matrixWorld);for(let o of s.children)o.updateMatrixWorld(!0)}for(let o of e.children)o.updateMatrixWorld(!0)}};this.handleCollisionEvents=(t,e,n)=>{if(n!==!1)if(this.gameControls.some(i=>i.object===this.sharedGameControlGlobals.colliderToEntity[t])){let i=this.sharedGameControlGlobals.colliderToEntity[e],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s===void 0)return;for(let o of s)o.data.target==="character"&&this.dispatchCollisionEvent(o,i)}else if(this.gameControls.some(i=>i.object===this.sharedGameControlGlobals.colliderToEntity[e])){let i=this.sharedGameControlGlobals.colliderToEntity[t],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s===void 0)return;for(let o of s)o.data.target==="character"&&this.dispatchCollisionEvent(o,i)}else{let i=this.sharedGameControlGlobals.colliderToEntity[t],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s!==void 0)for(let l of s)l.data.target==="scene"&&this.dispatchCollisionEvent(l,i);let o=this.sharedGameControlGlobals.colliderToEntity[e],a=this.sharedGameControlGlobals.eventsPerObjects[o?.uuid];if(a!==void 0)for(let l of a)l.data.target==="scene"&&this.dispatchCollisionEvent(l,o)}};this.domElement=n.domElement;let a;t.scene.publish.playCamera===null?a=ti.PERSONAL_CAMERA_ID:a=t.scene.publish.playCamera;let l=this.scene.find(a),u=!1,c,d=5,h=8,f=9,g="drag";if(this.usePhysics=t.scene.environment.usePhysics??xr.defaultData.usePhysics,this.pixelsPerMeter=t.scene.environment.pixelsPerMeter??xr.defaultData.pixelsPerMeter,t.scene.objects.data(t.scene.publish.gameControlObject)?.events.forEach(y=>{y.data.disabled!==!0&&y.data.type==="GameControl"&&(c=y.data.keyAssignments,d=y.data.joystickPosLoc,h=y.data.joystickRotLoc,f=y.data.jumpTouchButtonLoc,g=y.data.rotByTouch)}),this.scene.traverseEntity(y=>{y.dataPatched.events.forEach(v=>{if(v.data.disabled||v.data.type!=="GameControl")return;let x=y;for(;(x=x.parent)?.parent!==null;)if(x.dataPatched.physics?.fusedBody)return;v.data.collisionEnabled&&(this.needsCollisionDetection=!0),this.gameControlStates.push([y,v.data])})}),this.usePhysics&&this.initPhysics(t.scene.environment.gravity??xr.defaultData.gravity),this.gameControlStates.forEach(([y,v])=>{u=u||v.camera===l.uuid||y.uuid===l.uuid;let x=new _f(y,n.domElement,{...v,keyAssignments:c},t.scene.environment,this.sharedGameControlGlobals,y.uuid!==l.uuid&&v.camera===l.uuid,l,this.scene,s);x.addEventListener("change",i),x.addEventListener("end",i),x.addEventListener("start",i),this.gameControls.push(x),In&&v.touchControl&&(this.joystickToGameControls[d]!==void 0?this.joystickToGameControls[d].push([x,"pos"]):this.joystickToGameControls[d]=[[x,"pos"]],v.moveMode==="walk"&&(this.joystickToGameControls[f]!==void 0?this.joystickToGameControls[f].push([x,"jmp"]):this.joystickToGameControls[f]=[[x,"jmp"]]),g==="joystick"&&(this.joystickToGameControls[h]!==void 0?this.joystickToGameControls[h].push([x,"rot"]):this.joystickToGameControls[h]=[[x,"rot"]]))}),u===!1){let{enableRotate:y,enablePan:v,enableZoom:x,autoRotate:b,hoverRotatePanMode:w}=t.scene.publish.orbitControls;(y||v||x||b||w!==0)&&(this.orbitControls=new Zu(l,n.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",i),this.orbitControls.addEventListener("end",i),this.orbitControls.addEventListener("start",i),this.orbitControls.fromJSON(t.scene.publish.orbitControls,t.scene.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let p=n.domElement.width/n.getPixelRatio(),m=n.domElement.height/n.getPixelRatio();this.joystickToGameControls.forEach((y,v)=>{let x=document.body.appendChild(document.createElement("div")),[b,w,A]=(t.scene.publish.joystickSizeAndXYOffset??$s.defaultData.joystickSizeAndXYOffset)[v],T=(p-5*b)/4+b,S={},E=y.some(C=>C[1]==="jmp"),M=E?0:b;v<10?(v<5?S.top=M/2:S.bottom=M/2,S.left=M/2+v%5*T):v===10?(S.left=M/2,S.top=m/2):(S.right=M/2,S.top=m/2),S.top?S.top-=w[1]:S.bottom+=w[1],S.left?S.left+=w[0]:S.right-=w[0];for(let C in S)S[C]+="px";if(E){let C=x.appendChild(document.createElement("div"));Object.assign(C.style,S,{position:"absolute",width:b+"px",height:b+"px",backgroundColor:`rgba(255,255,255,${A==="show"?.4:0})`,zIndex:"9999",borderRadius:b+"px",border:A==="show"?"solid 2px rgba(0, 0, 0, .1)":"none",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"none"});let D=b/16*16*.4;A==="show"&&(C.innerHTML=`
|
|
4915
4915
|
<svg width="${D}" height="${b*.4}" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -5209,4 +5209,4 @@ outputColor=vec4(color,inputColor.a);}`,Ny={DEFAULT:0,ESKIL:1},$2=class extends
|
|
|
5209
5209
|
void main() {
|
|
5210
5210
|
gl_FragColor = vec4(0.0);
|
|
5211
5211
|
}
|
|
5212
|
-
`}),cd=class extends Gr{constructor(e,n){super("OpaquePass",e??eI,n);this.hasTransmissionPass=!1;this.clear=!0;this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??eI}getScene(){return this.scene}render(e,n){this.originalMaterials.clear(),this.camera.layers.enable(3),this.hasTransmissionPass&&this.scene.traverse(s=>{s.layers.isEnabled(3)&&s instanceof Vt&&(this.originalMaterials.set(s.id,s.material),s.material=x6)}),this.camera.layers.enable(8),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0;let i=this.renderToScreen?null:n;e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),this.hasTransmissionPass&&this.originalMaterials.forEach((s,o)=>{let a=this.scene.getObjectById(o);a&&(a.material=s)})}};function tI(r,t){return t&&t.enabled&&r.push(t.effect),r}var b6=r=>Object.values(ot).includes(r)?r:ot.NORMAL,Mf=class extends Wt{constructor(e){super();this.postprocessingState=Ya.defaultData;this._scene=new pr;this._camera=new Zt;this.effects=new Map;this._renderToScreen=!0;this.clock=new wp,this.renderer=e,this.debug=!1,this.effects.set("bloom",new ed),this.effects.set("chromaticAberration",new nd),this.effects.set("vignette",new od),this.effects.set("noise",new sd),this.effects.set("colorAverage",new rd),this.effects.set("hueSaturation",new id),this.effects.set("brightnessContrast",new td),this.effects.set("depthOfField",new ad),this.effects.set("pixelation",new ld),this.effectComposer=new H2(this.renderer),this.opaquePass=new cd(this.scene,this.camera),this.transmissionPass=new Uy(this.scene,this.camera,this.renderer),this.helperPass=new cd(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Ef(!1,!0,!1),this.helperPassOnTop=new cd(void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this._initCopyPass(),this._initSmaa(),this._initPasses()}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}disableHelpers(){this.helperPass.enabled=!1,this.helperClearPass.enabled=!1,this.helperPassOnTop.enabled=!1}enableHelpers(){this.helperPass.enabled=!0,this.helperClearPass.enabled=!0,this.helperPassOnTop.enabled=!0}_initSmaa(){let e=new J2({preset:yl.ULTRA,edgeDetectionMode:By.COLOR}),n=()=>{e.removeEventListener("load",n),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",n),e.edgeDetectionMaterial.predicationMode=qS.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new Fy(this.camera,e)}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(tI,[]);e.length>0&&(this.uvEffectPass=new Fy(this.camera,...e),this.effectComposer.addPass(this.uvEffectPass));let n=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(tI,[]);n.length>0&&(this.effectPass=new Fy(this.camera,...n),this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.helperClearPass),this.effectComposer.addPass(this.helperPassOnTop),this.effectComposer.addPass(this.smaaPass)}_initCopyPass(){if(this._savePass)return;let e=new F;this.renderer.getDrawingBufferSize(e),this._rt=new At(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:Fl,wrapT:Fl}),this._rt.samples=0,this._savePass=new $u(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let n=this.effectComposer;!n||(e===!0?(n.removePass(this._savePass),n.passes[n.passes.length-1].renderToScreen=!0,n.autoRenderToScreen=!0):(n.autoRenderToScreen=!1,n.passes[n.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.postprocessingState.enabled||(this._savePass.needsDepthTexture=!0),n.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:n,...i}=e,s=!1;n!==this.postprocessingState.enabled&&(s=!0);for(let o of Object.entries(i)){let a=o[1],l=this.effects.get(o[0]);if(l){l.enabled!==a.enabled&&(s=!0),l.enabled=a.enabled;for(let[u,c]of Object.entries(a))u==="blendFunction"?l.blendFunction=b6(c):l[u]=c}}this.postprocessingState=e,s&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,n,i,s){e instanceof Qe?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,n,i,s),this.effectComposer.outputBuffer.scissor.set(e,n,i,s));let o=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(o),this.effectComposer.outputBuffer.scissor.multiplyScalar(o),this.renderer.setScissor(e,n,i,s)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,n,i,s){e instanceof Qe?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,n,i,s),this.effectComposer.outputBuffer.viewport.set(e,n,i,s))}resize(e,n,i){if(this.effectComposer.setSize(e,n,i),this._rt){let s=this.renderer.getPixelRatio();this._rt.setSize(e*s,n*s)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}};var nI=new Gt,Gy=class extends v0{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new F;this.pipeline=new Mf(this);this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let n=this.setPixelRatio.bind(this),i=this.setSize.bind(this),s=this.getContext();if(s&&"drawingBufferColorSpace"in s)try{s.drawingBufferColorSpace="display-p3"}catch(o){console.warn(o)}this.setPixelRatio=o=>{this._pixelRatio=o,n(o)},this.setSize=(o,a,l=!0)=>{(this.viewportWidth!==o||this.viewportHeight!==a)&&(this.viewportWidth=o,this.viewportHeight=a,i(o,a,l),this.normalRenderTarget?.setSize(o*this._pixelRatio,a*this._pixelRatio),this.transmissionRenderTarget?.setSize(o*this._pixelRatio/2,a*this._pixelRatio/2),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}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new At(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{generateMipmaps:!0,minFilter:Ta,magFilter:st,wrapS:hr,wrapT:hr,depthBuffer:!1}),this.transmissionDepthTarget=new At(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Bt,magFilter:Bt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new At(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Bt,magFilter:Bt,type:Zi,depthTexture:new Eo(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,n){this.normalRenderTarget&&(this.setClearColor(0),n.layers.enable(8),n.layers.disable(0),n.layers.disable(3),this.setRenderTarget(this.normalRenderTarget),this.clear(),n instanceof Zt?Kg.uniforms.depthContrast.value=(n.far-n.near)/1e4:Kg.uniforms.depthContrast.value=1,e.overrideMaterial=Kg,this.render(e,n),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?Qg:null,n.layers.enable(0),n.layers.enable(3))}renderSplineScene(e,n,i,s,o){this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((l,u)=>{Dt.penumbraSize.value[u]=l}),Dt.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Dt.resolution.value.set(this.resolution.x,this.resolution.y):Dt.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(Dt.normalRenderTarget.value=this.overrideNormal,Dt.normalRenderTargetDepth.value=nI):e.needsNormal()&&(this.createNormalRenderTarget(),Dt.normalRenderTarget.value=this.normalRenderTarget.texture,Dt.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,n));let a=!1;if(this.overrideTransmission!==void 0)Dt.transmissionRenderTarget.value=this.overrideTransmission,Dt.transmissionRenderTargetDepth.value=nI,this.pipeline.setTransmissionPassEnabled(!1);else{let l=e.needsTransmission();l&&(this.transmissionRenderTarget===void 0&&(a=!0),this.createTransmissionRenderTarget(),Dt.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Dt.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(l)}n.layers.enable(3),n.layers.enable(8),this.pipeline.sceneHelpers=s,this.pipeline.sceneHelpersOnTop=o,this.pipeline.scene=e,this.pipeline.camera=n,a&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&this.pipeline.updatePostprocessing(e.postprocessing),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?Qg:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var ky=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new so(t.shared,e),this.scene=new ti(t.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof Kt&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var zy=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 S6(r){let t;if(!!r.index)for(let e=0;e<r.index.array.length;e+=3)t=r.index.array[e],r.index.array[e]=r.index.array[e+2],r.index.array[e+2]=t}function Cf(r){return r instanceof zi?"SubdivObject":r.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function w6(r,t){let e={};return r.traverseEntity(n=>{if(!n.visible||!(n instanceof Vt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let i=n.parent;for(;i;){if(i instanceof Vt&&n.states&&Object.keys(n.states).length)return;i=i.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!qn.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!qn.isMergable(u.material))return;s=qn.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][Cf(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][Cf(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][Cf(n)].push(u)}),e}function A6(r){let t=0;return Object.values(r).forEach(e=>{Object.values(e).forEach(n=>{let i=n.length;i>t&&(t=i)})}),t}function rI(r,t){let e=w6(t,r),n=A6(e),i=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),u=0,c=new Array(n),d=0;for(let[h,f]of Object.entries(e))for(let g of Object.values(f)){if(a=0,u=0,g.forEach(m=>{m instanceof Vt&&(o[a++]=m.geometry.clone(),l[u++]=m)}),u<2)continue;for(let m=0;m<u;m++)l[m].updateWorldMatrix(!0,!1),o[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&S6(o[m]);let p=eo(o.slice(0,a),!1);if(p){let m;switch(h){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new Un(p,l[0].material);break}default:{m=new Un(p,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let y=v=>{d=0;for(let x of v)x.children&&y(x.children),x instanceof Vt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][Cf(x)]&&e[x.material.uuid][Cf(x)].length>1||(c[d++]=x));for(let x=0;x<d;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),i[s++]=x}}}for(let h=0;h<s;h++)i[h].removeFromParent()}var aI=dd(sI(),1);var _6=new F;function T6(r){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";r.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(t)}var oI=class{constructor(t,{renderOnDemand:e=!0}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._lastTime=performance.now();this.time=performance.now();this.dt=0;this._skipRender=!1;this.renderOnDemand=!0;this.disposed=!1;this.requestRender=()=>{this._skipRender=!1};this.render=t=>{!this._renderer||(this._rafId=requestAnimationFrame(this.render),this.time=t,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!(this.renderOnDemand&&this._skipRender)&&(this._skipRender=this._controls?.update(this.dt)??!0,this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1)),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this._perfs?.end()))};this._resize=Qd(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=_6.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.requestRender())},10);this.canvas=t,this.renderOnDemand=e,window.location.search.includes("perfs")&&(this._perfs=new zy({x:10,y:10})),SE(t)}async load(t,e){T6(t),this.disposed=!1;let i=await(await fetch(t,e)).arrayBuffer();await this.start(i)}async start(t,{interactive:e=!0}={}){if(this.disposed)return;let n=await O2(t);this._data=n,n.version&&(0,aI.default)(n.version,"0.9.272")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([Yb(n)&&cC(),EC(n)&&tC(),n.scene.environment.usePhysics&&ET(),Gb(n)&&_C()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let i=new ky(n);if(this._scene=i.scene,this._sharedAssetsManager=i.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let s=performance.now();rI(n,i.scene);let o=performance.now();console.log("Merged geometries in ",o-s," ms")}if(Yb(n)&&this._scene.traverse(s=>{$r(s)&&s.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this.requestRender(),this._scene?.traverse(s=>{s instanceof lo&&s.pendingMediaLoad&&s.update()})}),Gb(n)&&S2(n)){let o=Object.keys(n.shared.fonts).map(a=>this._sharedAssetsManager.getFont(a)).map(a=>a.loadingPromise);await Promise.all(o)}if(this._scene.rewriteEventsBeforeGoToPlayMode(),ly(n.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new Gy({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this.requestRender),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=n.scene.environment.ambientLight.softShadows?Cp:p0,sP(n.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let s=Object.values(n.frames)[0];s.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=s.size[0],this._viewportHeight=s.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 Ly(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight))}if(e&&(this._scene.updateMatrixWorld(!0),this._controls=new My(n,this._scene,this._renderer,this.requestRender,this._sharedAssetsManager,!0),this._eventManager=new Oy(this._renderer,this._scene,this._camera,n.scene.publish.stopRaycast,n.scene.publish.preventScroll,n.scene.publish.preventTouchScroll,n.scene.publish.hideCursor,this._sharedAssetsManager,this.requestRender,this._controls,!0)),this._resize(),!this._resizeObserver&&this.canvas.parentElement){let s=!0;this._resizeObserver=new ResizeObserver(()=>{if(s){s=!1;return}this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._resize()}),this._resizeObserver.observe(this.canvas.parentElement)}this._rafId===void 0?this.render(performance.now()):this.requestRender()}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}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 Zu&&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:i,a:s}={r:0,g:0,b:0,a:1},o=new Yt(e,n,i,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.setBackgroundColor(o),this.requestRender()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._rafId&&cancelAnimationFrame(this._rafId),this._proxyObjectCache.forEach(t=>{D0.unsubscribe(t)}),this._renderer?.dispose(),this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.dispose(),wE(this.canvas)}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={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,emitEvent(i){t.dispatchEvent({type:"userEvent",eventName:i})},emitEventReverse(i){t.dispatchEvent({type:"userEvent",eventName:i,reverse:!0})}},n=D0(e,(i,s)=>{typeof t[i]!="object"&&Object.getOwnPropertyDescriptor(t,i)?.writable&&(t[i]=s),this.requestRender(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,n),n}};export{oI as Application};
|
|
5212
|
+
`}),cd=class extends Gr{constructor(e,n){super("OpaquePass",e??eI,n);this.hasTransmissionPass=!1;this.clear=!0;this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??eI}getScene(){return this.scene}render(e,n){this.originalMaterials.clear(),this.camera.layers.enable(3),this.hasTransmissionPass&&this.scene.traverse(s=>{s.layers.isEnabled(3)&&s instanceof Vt&&(this.originalMaterials.set(s.id,s.material),s.material=x6)}),this.camera.layers.enable(8),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0;let i=this.renderToScreen?null:n;e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),this.hasTransmissionPass&&this.originalMaterials.forEach((s,o)=>{let a=this.scene.getObjectById(o);a&&(a.material=s)})}};function tI(r,t){return t&&t.enabled&&r.push(t.effect),r}var b6=r=>Object.values(ot).includes(r)?r:ot.NORMAL,Mf=class extends Wt{constructor(e){super();this.postprocessingState=Ya.defaultData;this._scene=new pr;this._camera=new Zt;this.effects=new Map;this._renderToScreen=!0;this.clock=new wp,this.renderer=e,this.debug=!1,this.effects.set("bloom",new ed),this.effects.set("chromaticAberration",new nd),this.effects.set("vignette",new od),this.effects.set("noise",new sd),this.effects.set("colorAverage",new rd),this.effects.set("hueSaturation",new id),this.effects.set("brightnessContrast",new td),this.effects.set("depthOfField",new ad),this.effects.set("pixelation",new ld),this.effectComposer=new H2(this.renderer),this.opaquePass=new cd(this.scene,this.camera),this.transmissionPass=new Uy(this.scene,this.camera,this.renderer),this.helperPass=new cd(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Ef(!1,!0,!1),this.helperPassOnTop=new cd(void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this._initCopyPass(),this._initSmaa(),this._initPasses()}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}disableHelpers(){this.helperPass.enabled=!1,this.helperClearPass.enabled=!1,this.helperPassOnTop.enabled=!1}enableHelpers(){this.helperPass.enabled=!0,this.helperClearPass.enabled=!0,this.helperPassOnTop.enabled=!0}_initSmaa(){let e=new J2({preset:yl.ULTRA,edgeDetectionMode:By.COLOR}),n=()=>{e.removeEventListener("load",n),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",n),e.edgeDetectionMaterial.predicationMode=qS.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new Fy(this.camera,e)}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(tI,[]);e.length>0&&(this.uvEffectPass=new Fy(this.camera,...e),this.effectComposer.addPass(this.uvEffectPass));let n=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(tI,[]);n.length>0&&(this.effectPass=new Fy(this.camera,...n),this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.helperClearPass),this.effectComposer.addPass(this.helperPassOnTop),this.effectComposer.addPass(this.smaaPass)}_initCopyPass(){if(this._savePass)return;let e=new F;this.renderer.getDrawingBufferSize(e),this._rt=new At(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:Fl,wrapT:Fl}),this._rt.samples=0,this._savePass=new $u(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let n=this.effectComposer;!n||(e===!0?(n.removePass(this._savePass),n.passes[n.passes.length-1].renderToScreen=!0,n.autoRenderToScreen=!0):(n.autoRenderToScreen=!1,n.passes[n.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.postprocessingState.enabled||(this._savePass.needsDepthTexture=!0),n.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:n,...i}=e,s=!1;n!==this.postprocessingState.enabled&&(s=!0);for(let o of Object.entries(i)){let a=o[1],l=this.effects.get(o[0]);if(l){l.enabled!==a.enabled&&(s=!0),l.enabled=a.enabled;for(let[u,c]of Object.entries(a))u==="blendFunction"?l.blendFunction=b6(c):l[u]=c}}this.postprocessingState=e,s&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,n,i,s){e instanceof Qe?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,n,i,s),this.effectComposer.outputBuffer.scissor.set(e,n,i,s));let o=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(o),this.effectComposer.outputBuffer.scissor.multiplyScalar(o),this.renderer.setScissor(e,n,i,s)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,n,i,s){e instanceof Qe?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,n,i,s),this.effectComposer.outputBuffer.viewport.set(e,n,i,s))}resize(e,n,i){if(this.effectComposer.setSize(e,n,i),this._rt){let s=this.renderer.getPixelRatio();this._rt.setSize(e*s,n*s)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}};var nI=new Gt,Gy=class extends v0{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new F;this.pipeline=new Mf(this);this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let n=this.setPixelRatio.bind(this),i=this.setSize.bind(this),s=this.getContext();if(s&&"drawingBufferColorSpace"in s)try{s.drawingBufferColorSpace="display-p3"}catch(o){console.warn(o)}this.setPixelRatio=o=>{this._pixelRatio=o,n(o)},this.setSize=(o,a,l=!0)=>{(this.viewportWidth!==o||this.viewportHeight!==a)&&(this.viewportWidth=o,this.viewportHeight=a,i(o,a,l),this.normalRenderTarget?.setSize(o*this._pixelRatio,a*this._pixelRatio),this.transmissionRenderTarget?.setSize(o*this._pixelRatio/2,a*this._pixelRatio/2),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}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new At(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{generateMipmaps:!0,minFilter:Ta,magFilter:st,wrapS:hr,wrapT:hr,depthBuffer:!1}),this.transmissionDepthTarget=new At(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Bt,magFilter:Bt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new At(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Bt,magFilter:Bt,type:Zi,depthTexture:new Eo(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,n){this.normalRenderTarget&&(this.setClearColor(0),n.layers.enable(8),n.layers.disable(0),n.layers.disable(3),this.setRenderTarget(this.normalRenderTarget),this.clear(),n instanceof Zt?Kg.uniforms.depthContrast.value=(n.far-n.near)/1e4:Kg.uniforms.depthContrast.value=1,e.overrideMaterial=Kg,this.render(e,n),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?Qg:null,n.layers.enable(0),n.layers.enable(3))}renderSplineScene(e,n,i,s,o){this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((l,u)=>{Dt.penumbraSize.value[u]=l}),Dt.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Dt.resolution.value.set(this.resolution.x,this.resolution.y):Dt.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(Dt.normalRenderTarget.value=this.overrideNormal,Dt.normalRenderTargetDepth.value=nI):e.needsNormal()&&(this.createNormalRenderTarget(),Dt.normalRenderTarget.value=this.normalRenderTarget.texture,Dt.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,n));let a=!1;if(this.overrideTransmission!==void 0)Dt.transmissionRenderTarget.value=this.overrideTransmission,Dt.transmissionRenderTargetDepth.value=nI,this.pipeline.setTransmissionPassEnabled(!1);else{let l=e.needsTransmission();l&&(this.transmissionRenderTarget===void 0&&(a=!0),this.createTransmissionRenderTarget(),Dt.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Dt.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(l)}n.layers.enable(3),n.layers.enable(8),this.pipeline.sceneHelpers=s,this.pipeline.sceneHelpersOnTop=o,this.pipeline.scene=e,this.pipeline.camera=n,a&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&this.pipeline.updatePostprocessing(e.postprocessing),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?Qg:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var ky=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new so(t.shared,e),this.scene=new ti(t.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof Kt&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var zy=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 S6(r){let t;if(!!r.index)for(let e=0;e<r.index.array.length;e+=3)t=r.index.array[e],r.index.array[e]=r.index.array[e+2],r.index.array[e+2]=t}function Cf(r){return r instanceof zi?"SubdivObject":r.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function w6(r,t){let e={};return r.traverseEntity(n=>{if(!n.visible||!(n instanceof Vt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let i=n.parent;for(;i;){if(i instanceof Vt&&n.states&&Object.keys(n.states).length)return;i=i.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!qn.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!qn.isMergable(u.material))return;s=qn.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][Cf(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][Cf(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][Cf(n)].push(u)}),e}function A6(r){let t=0;return Object.values(r).forEach(e=>{Object.values(e).forEach(n=>{let i=n.length;i>t&&(t=i)})}),t}function rI(r,t){let e=w6(t,r),n=A6(e),i=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),u=0,c=new Array(n),d=0;for(let[h,f]of Object.entries(e))for(let g of Object.values(f)){if(a=0,u=0,g.forEach(m=>{m instanceof Vt&&(o[a++]=m.geometry.clone(),l[u++]=m)}),u<2)continue;for(let m=0;m<u;m++)l[m].updateWorldMatrix(!0,!1),o[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&S6(o[m]);let p=eo(o.slice(0,a),!1);if(p){let m;switch(h){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new Un(p,l[0].material);break}default:{m=new Un(p,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let y=v=>{d=0;for(let x of v)x.children&&y(x.children),x instanceof Vt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][Cf(x)]&&e[x.material.uuid][Cf(x)].length>1||(c[d++]=x));for(let x=0;x<d;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),i[s++]=x}}}for(let h=0;h<s;h++)i[h].removeFromParent()}var aI=dd(sI(),1);var _6=new F;function T6(r){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";r.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(t)}var oI=class{constructor(t,{renderOnDemand:e=!0}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._lastTime=performance.now();this.time=performance.now();this.dt=0;this._skipRender=!1;this.renderOnDemand=!0;this.disposed=!1;this.requestRender=()=>{this._skipRender=!1};this.render=t=>{!this._renderer||(this._rafId=requestAnimationFrame(this.render),this.time=t,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!(this.renderOnDemand&&this._skipRender)&&(this._skipRender=this._controls?.update(this.dt)??!0,this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1)),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this._perfs?.end()))};this._resize=Qd(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=_6.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.requestRender())},10);this.canvas=t,this.renderOnDemand=e,window.location.search.includes("perfs")&&(this._perfs=new zy({x:10,y:10})),SE(t)}async load(t,e){T6(t),this.disposed=!1;let i=await(await fetch(t,e)).arrayBuffer();await this.start(i)}async start(t,{interactive:e=!0}={}){if(this.disposed)return;let n=await O2(t);this._data=n,n.version&&(0,aI.default)(n.version,"0.9.275")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([Yb(n)&&cC(),EC(n)&&tC(),n.scene.environment.usePhysics&&ET(),Gb(n)&&_C()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let i=new ky(n);if(this._scene=i.scene,this._sharedAssetsManager=i.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let s=performance.now();rI(n,i.scene);let o=performance.now();console.log("Merged geometries in ",o-s," ms")}if(Yb(n)&&this._scene.traverse(s=>{$r(s)&&s.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this.requestRender(),this._scene?.traverse(s=>{s instanceof lo&&s.pendingMediaLoad&&s.update()})}),Gb(n)&&S2(n)){let o=Object.keys(n.shared.fonts).map(a=>this._sharedAssetsManager.getFont(a)).map(a=>a.loadingPromise);await Promise.all(o)}if(this._scene.rewriteEventsBeforeGoToPlayMode(),ly(n.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new Gy({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this.requestRender),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=n.scene.environment.ambientLight.softShadows?Cp:p0,sP(n.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let s=Object.values(n.frames)[0];s.preset==="fullscreen"?(this._viewportMode=1,this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=s.size[0],this._viewportHeight=s.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 Ly(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight))}if(e&&(this._scene.updateMatrixWorld(!0),this._controls=new My(n,this._scene,this._renderer,this.requestRender,this._sharedAssetsManager,!0),this._eventManager=new Oy(this._renderer,this._scene,this._camera,n.scene.publish.stopRaycast,n.scene.publish.preventScroll,n.scene.publish.preventTouchScroll,n.scene.publish.hideCursor,this._sharedAssetsManager,this.requestRender,this._controls,!0)),this._resize(),!this._resizeObserver&&this.canvas.parentElement){let s=!0;this._resizeObserver=new ResizeObserver(()=>{if(s){s=!1;return}this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._resize()}),this._resizeObserver.observe(this.canvas.parentElement)}this._rafId===void 0?this.render(performance.now()):this.requestRender()}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}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 Zu&&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:i,a:s}={r:0,g:0,b:0,a:1},o=new Yt(e,n,i,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.setBackgroundColor(o),this.requestRender()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._rafId&&cancelAnimationFrame(this._rafId),this._proxyObjectCache.forEach(t=>{D0.unsubscribe(t)}),this._renderer?.dispose(),this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.dispose(),wE(this.canvas)}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={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,emitEvent(i){t.dispatchEvent({type:"userEvent",eventName:i})},emitEventReverse(i){t.dispatchEvent({type:"userEvent",eventName:i,reverse:!0})}},n=D0(e,(i,s)=>{typeof t[i]!="object"&&Object.getOwnPropertyDescriptor(t,i)?.writable&&(t[i]=s),this.requestRender(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,n),n}};export{oI as Application};
|