@splinetool/runtime 0.9.339 → 0.9.341

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/runtime.cjs CHANGED
@@ -3137,7 +3137,7 @@ void main() {
3137
3137
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3138
3138
  }`;function ON(r,t,e){let n=new kd,i=new F,s=new F,o=new $e,a=new Vd({depthPacking:C0}),l=new i0,u={},c=e.maxTextureSize,d={[Kr]:_n,[_n]:Kr,[br]:br},h=new St({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new F},radius:{value:4}},vertexShader:DN,fragmentShader:IN}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let g=new _e;g.setAttribute("position",new Fe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new qn(g,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Gp,this.render=function(S,w,E){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;let _=r.getRenderTarget(),b=r.getActiveCubeFace(),T=r.getActiveMipmapLevel(),M=r.state;M.setBlending(Gt),M.buffers.color.setClear(1,1,1,1),M.buffers.depth.setTest(!0),M.setScissorTest(!1);for(let D=0,P=S.length;D<P;D++){let C=S[D],I=C.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",C,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;i.copy(I.mapSize);let R=I.getFrameExtents();if(i.multiply(R),s.copy(I.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/R.x),i.x=s.x*R.x,I.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/R.y),i.y=s.y*R.y,I.mapSize.y=s.y)),I.map===null){let Y=this.type!==Pd?{minFilter:Ut,magFilter:Ut}:{};I.map=new Et(i.x,i.y,Y),I.map.texture.name=C.name+".shadowMap",I.camera.updateProjectionMatrix()}r.setRenderTarget(I.map),r.clear();let G=I.getViewportCount();for(let Y=0;Y<G;Y++){let W=I.getViewport(Y);o.set(s.x*W.x,s.y*W.y,s.x*W.z,s.y*W.w),M.viewport(o),I.updateMatrices(C,Y),n=I.getFrustum(),x(w,E,I.camera,C,this.type)}I.isPointLightShadow!==!0&&this.type===Pd&&y(I,E),I.needsUpdate=!1}m.needsUpdate=!1,r.setRenderTarget(_,b,T)};function y(S,w){let E=t.update(p);h.defines.VSM_SAMPLES!==S.blurSamples&&(h.defines.VSM_SAMPLES=S.blurSamples,f.defines.VSM_SAMPLES=S.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),S.mapPass===null&&(S.mapPass=new Et(i.x,i.y)),h.uniforms.shadow_pass.value=S.map.texture,h.uniforms.resolution.value=S.mapSize,h.uniforms.radius.value=S.radius,r.setRenderTarget(S.mapPass),r.clear(),r.renderBufferDirect(w,null,E,h,p,null),f.uniforms.shadow_pass.value=S.mapPass.texture,f.uniforms.resolution.value=S.mapSize,f.uniforms.radius.value=S.radius,r.setRenderTarget(S.map),r.clear(),r.renderBufferDirect(w,null,E,f,p,null)}function v(S,w,E,_,b,T){let M=null,D=E.isPointLight===!0?S.customDistanceMaterial:S.customDepthMaterial;if(D!==void 0)M=D;else if(M=E.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,I=u[P];I===void 0&&(I={},u[P]=I);let R=I[C];R===void 0&&(R=M.clone(),I[C]=R),M=R}return M.visible=w.visible,M.wireframe=w.wireframe,T===Pd?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,E.isPointLight===!0&&M.isMeshDistanceMaterial===!0&&(M.referencePosition.setFromMatrixPosition(E.matrixWorld),M.nearDistance=_,M.farDistance=b),M}function x(S,w,E,_,b){if(S.visible===!1)return;if(S.layers.test(w.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&b===Pd)&&(!S.frustumCulled||n.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,S.matrixWorld);let D=t.update(S),P=S.material;if(Array.isArray(P)){let C=D.groups;for(let I=0,R=C.length;I<R;I++){let G=C[I],Y=P[G.materialIndex];if(Y&&Y.visible){let W=v(S,Y,_,E.near,E.far,b);r.renderBufferDirect(E,null,D,W,S,G)}}}else if(P.visible){let C=v(S,P,_,E.near,E.far,b);r.renderBufferDirect(E,null,D,C,S,null)}}let M=S.children;for(let D=0,P=M.length;D<P;D++)x(M[D],w,E,_,b)}}function LN(r,t,e){let n=e.isWebGL2;function i(){let Q=!1,ie=new $e,pe=null,Re=new $e(0,0,0,0);return{setMask:function(Oe){pe!==Oe&&!Q&&(r.colorMask(Oe,Oe,Oe,Oe),pe=Oe)},setLocked:function(Oe){Q=Oe},setClear:function(Oe,pt,Sn,ln,Aa){Aa===!0&&(Oe*=ln,pt*=ln,Sn*=ln),ie.set(Oe,pt,Sn,ln),Re.equals(ie)===!1&&(r.clearColor(Oe,pt,Sn,ln),Re.copy(ie))},reset:function(){Q=!1,pe=null,Re.set(-1,0,0,0)}}}function s(){let Q=!1,ie=null,pe=null,Re=null;return{setTest:function(Oe){Oe?re(2929):K(2929)},setMask:function(Oe){ie!==Oe&&!Q&&(r.depthMask(Oe),ie=Oe)},setFunc:function(Oe){if(pe!==Oe){switch(Oe){case l2:r.depthFunc(512);break;case c2:r.depthFunc(519);break;case u2:r.depthFunc(513);break;case Hv:r.depthFunc(515);break;case d2:r.depthFunc(514);break;case h2:r.depthFunc(518);break;case f2:r.depthFunc(516);break;case p2:r.depthFunc(517);break;default:r.depthFunc(515)}pe=Oe}},setLocked:function(Oe){Q=Oe},setClear:function(Oe){Re!==Oe&&(r.clearDepth(Oe),Re=Oe)},reset:function(){Q=!1,ie=null,pe=null,Re=null}}}function o(){let Q=!1,ie=null,pe=null,Re=null,Oe=null,pt=null,Sn=null,ln=null,Aa=null;return{setTest:function(Xt){Q||(Xt?re(2960):K(2960))},setMask:function(Xt){ie!==Xt&&!Q&&(r.stencilMask(Xt),ie=Xt)},setFunc:function(Xt,Rs,li){(pe!==Xt||Re!==Rs||Oe!==li)&&(r.stencilFunc(Xt,Rs,li),pe=Xt,Re=Rs,Oe=li)},setOp:function(Xt,Rs,li){(pt!==Xt||Sn!==Rs||ln!==li)&&(r.stencilOp(Xt,Rs,li),pt=Xt,Sn=Rs,ln=li)},setLocked:function(Xt){Q=Xt},setClear:function(Xt){Aa!==Xt&&(r.clearStencil(Xt),Aa=Xt)},reset:function(){Q=!1,ie=null,pe=null,Re=null,Oe=null,pt=null,Sn=null,ln=null,Aa=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,S=null,w=null,E=null,_=null,b=null,T=!1,M=null,D=null,P=null,C=null,I=null,R=r.getParameter(35661),G=!1,Y=0,W=r.getParameter(7938);W.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(W)[1]),G=Y>=1):W.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(W)[1]),G=Y>=2);let q=null,j={},X=r.getParameter(3088),N=r.getParameter(2978),U=new $e().fromArray(X),z=new $e().fromArray(N);function H(Q,ie,pe){let Re=new Uint8Array(4),Oe=r.createTexture();r.bindTexture(Q,Oe),r.texParameteri(Q,10241,9728),r.texParameteri(Q,10240,9728);for(let pt=0;pt<pe;pt++)r.texImage2D(ie+pt,0,6408,1,1,0,6408,5121,Re);return Oe}let V={};V[3553]=H(3553,3553,1),V[34067]=H(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),re(2929),l.setFunc(Hv),ge(!1),Ae(bw),re(2884),me(Gt);function re(Q){h[Q]!==!0&&(r.enable(Q),h[Q]=!0)}function K(Q){h[Q]!==!1&&(r.disable(Q),h[Q]=!1)}function Z(Q,ie){return f[Q]!==ie?(r.bindFramebuffer(Q,ie),f[Q]=ie,n&&(Q===36009&&(f[36160]=ie),Q===36160&&(f[36009]=ie)),!0):!1}function k(Q,ie){let pe=p,Re=!1;if(Q)if(pe=g.get(ie),pe===void 0&&(pe=[],g.set(ie,pe)),Q.isWebGLMultipleRenderTargets){let Oe=Q.texture;if(pe.length!==Oe.length||pe[0]!==36064){for(let pt=0,Sn=Oe.length;pt<Sn;pt++)pe[pt]=36064+pt;pe.length=Oe.length,Re=!0}}else pe[0]!==36064&&(pe[0]=36064,Re=!0);else pe[0]!==1029&&(pe[0]=1029,Re=!0);Re&&(e.isWebGL2?r.drawBuffers(pe):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(pe))}function ue(Q){return m!==Q?(r.useProgram(Q),m=Q,!0):!1}let he={[Vl]:32774,[ZI]:32778,[JI]:32779};if(n)he[Ew]=32775,he[_w]=32776;else{let Q=t.get("EXT_blend_minmax");Q!==null&&(he[Ew]=Q.MIN_EXT,he[_w]=Q.MAX_EXT)}let ae={[$I]:0,[e2]:1,[t2]:768,[J1]:770,[a2]:776,[s2]:774,[r2]:772,[n2]:769,[$1]:771,[o2]:775,[i2]:773};function me(Q,ie,pe,Re,Oe,pt,Sn,ln){if(Q===Gt){y===!0&&(K(3042),y=!1);return}if(y===!1&&(re(3042),y=!0),Q!==KI){if(Q!==v||ln!==T){if((x!==Vl||E!==Vl)&&(r.blendEquation(32774),x=Vl,E=Vl),ln)switch(Q){case Wl:r.blendFuncSeparate(1,771,1,771);break;case Sw:r.blendFunc(1,1);break;case ww:r.blendFuncSeparate(0,769,0,1);break;case Aw:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}else switch(Q){case Wl:r.blendFuncSeparate(770,771,1,771);break;case Sw:r.blendFunc(770,1);break;case ww:r.blendFuncSeparate(0,769,0,1);break;case Aw:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}S=null,w=null,_=null,b=null,v=Q,T=ln}return}Oe=Oe||ie,pt=pt||pe,Sn=Sn||Re,(ie!==x||Oe!==E)&&(r.blendEquationSeparate(he[ie],he[Oe]),x=ie,E=Oe),(pe!==S||Re!==w||pt!==_||Sn!==b)&&(r.blendFuncSeparate(ae[pe],ae[Re],ae[pt],ae[Sn]),S=pe,w=Re,_=pt,b=Sn),v=Q,T=!1}function be(Q,ie){Q.side===br?K(2884):re(2884);let pe=Q.side===_n;ie&&(pe=!pe),ge(pe),Q.blending===Wl&&Q.transparent===!1?me(Gt):me(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.premultipliedAlpha),l.setFunc(Q.depthFunc),l.setTest(Q.depthTest),l.setMask(Q.depthWrite),a.setMask(Q.colorWrite);let Re=Q.stencilWrite;u.setTest(Re),Re&&(u.setMask(Q.stencilWriteMask),u.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),u.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),xe(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?re(32926):K(32926)}function ge(Q){M!==Q&&(Q?r.frontFace(2304):r.frontFace(2305),M=Q)}function Ae(Q){Q!==YI?(re(2884),Q!==D&&(Q===bw?r.cullFace(1029):Q===QI?r.cullFace(1028):r.cullFace(1032))):K(2884),D=Q}function Me(Q){Q!==P&&(G&&r.lineWidth(Q),P=Q)}function xe(Q,ie,pe){Q?(re(32823),(C!==ie||I!==pe)&&(r.polygonOffset(ie,pe),C=ie,I=pe)):K(32823)}function Ge(Q){Q?re(3089):K(3089)}function ht(Q){Q===void 0&&(Q=33984+R-1),q!==Q&&(r.activeTexture(Q),q=Q)}function L(Q,ie,pe){pe===void 0&&(q===null?pe=33984+R-1:pe=q);let Re=j[pe];Re===void 0&&(Re={type:void 0,texture:void 0},j[pe]=Re),(Re.type!==Q||Re.texture!==ie)&&(q!==pe&&(r.activeTexture(pe),q=pe),r.bindTexture(Q,ie||V[Q]),Re.type=Q,Re.texture=ie)}function O(){let Q=j[q];Q!==void 0&&Q.type!==void 0&&(r.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function ee(){try{r.compressedTexImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function fe(){try{r.compressedTexImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ye(){try{r.texSubImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ce(){try{r.texSubImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ke(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Pe(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ce(){try{r.texStorage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function je(){try{r.texStorage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Le(){try{r.texImage2D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function De(){try{r.texImage3D.apply(r,arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Be(Q){U.equals(Q)===!1&&(r.scissor(Q.x,Q.y,Q.z,Q.w),U.copy(Q))}function qe(Q){z.equals(Q)===!1&&(r.viewport(Q.x,Q.y,Q.z,Q.w),z.copy(Q))}function ft(Q,ie){let pe=d.get(ie);pe===void 0&&(pe=new WeakMap,d.set(ie,pe));let Re=pe.get(Q);Re===void 0&&(Re=r.getUniformBlockIndex(ie,Q.name),pe.set(Q,Re))}function Ft(Q,ie){let Re=d.get(ie).get(Q);c.get(ie)!==Re&&(r.uniformBlockBinding(ie,Re,Q.__bindingPointIndex),c.set(ie,Re))}function bn(){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,j={},f={},g=new WeakMap,p=[],m=null,y=!1,v=null,x=null,S=null,w=null,E=null,_=null,b=null,T=!1,M=null,D=null,P=null,C=null,I=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:K,bindFramebuffer:Z,drawBuffers:k,useProgram:ue,setBlending:me,setMaterial:be,setFlipSided:ge,setCullFace:Ae,setLineWidth:Me,setPolygonOffset:xe,setScissorTest:Ge,activeTexture:ht,bindTexture:L,unbindTexture:O,compressedTexImage2D:ee,compressedTexImage3D:fe,texImage2D:Le,texImage3D:De,updateUBOMapping:ft,uniformBlockBinding:Ft,texStorage2D:ce,texStorage3D:je,texSubImage2D:ye,texSubImage3D:Ce,compressedTexSubImage2D:ke,compressedTexSubImage3D:Pe,scissor:Be,viewport:qe,reset:bn}}function RN(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):xp("canvas")}function x(L,O,ee,fe){let ye=1;if((L.width>fe||L.height>fe)&&(ye=fe/Math.max(L.width,L.height)),ye<1||O===!0)if(typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&L instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&L instanceof ImageBitmap){let Ce=O?vp:Math.floor,ke=Ce(ye*L.width),Pe=Ce(ye*L.height);p===void 0&&(p=v(ke,Pe));let ce=ee?v(ke,Pe):p;return ce.width=ke,ce.height=Pe,ce.getContext("2d").drawImage(L,0,0,ke,Pe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+L.width+"x"+L.height+") to ("+ke+"x"+Pe+")."),ce}else return"data"in L&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+L.width+"x"+L.height+")."),L;return L}function S(L){return Qv(L.width)&&Qv(L.height)}function w(L){return a?!1:L.wrapS!==xr||L.wrapT!==xr||L.minFilter!==Ut&&L.minFilter!==it}function E(L,O){return L.generateMipmaps&&O&&L.minFilter!==Ut&&L.minFilter!==it}function _(L){r.generateMipmap(L)}function b(L,O,ee,fe,ye=!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 Ce=O;return O===6403&&(ee===5126&&(Ce=33326),ee===5131&&(Ce=33325),ee===5121&&(Ce=33321)),O===33319&&(ee===5126&&(Ce=33328),ee===5131&&(Ce=33327),ee===5121&&(Ce=33323)),O===6408&&(ee===5126&&(Ce=34836),ee===5131&&(Ce=34842),ee===5121&&(Ce=fe===Ye&&ye===!1?35907:32856),ee===32819&&(Ce=32854),ee===32820&&(Ce=32855)),(Ce===33325||Ce===33326||Ce===33327||Ce===33328||Ce===34842||Ce===34836)&&t.get("EXT_color_buffer_float"),Ce}function T(L,O,ee){return E(L,ee)===!0||L.isFramebufferTexture&&L.minFilter!==Ut&&L.minFilter!==it?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===Ut||L===Tw||L===ov?9728:9729}function D(L){let O=L.target;O.removeEventListener("dispose",D),C(O),O.isVideoTexture&&g.delete(O)}function P(L){let O=L.target;O.removeEventListener("dispose",P),R(O)}function C(L){let O=n.get(L);if(O.__webglInit===void 0)return;let ee=L.source,fe=m.get(ee);if(fe){let ye=fe[O.__cacheKey];ye.usedTimes--,ye.usedTimes===0&&I(L),Object.keys(fe).length===0&&m.delete(ee)}n.remove(L)}function I(L){let O=n.get(L);r.deleteTexture(O.__webglTexture);let ee=L.source,fe=m.get(ee);delete fe[O.__cacheKey],o.memory.textures--}function R(L){let O=L.texture,ee=n.get(L),fe=n.get(O);if(fe.__webglTexture!==void 0&&(r.deleteTexture(fe.__webglTexture),o.memory.textures--),L.depthTexture&&L.depthTexture.dispose(),L.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++)r.deleteFramebuffer(ee.__webglFramebuffer[ye]),ee.__webglDepthbuffer&&r.deleteRenderbuffer(ee.__webglDepthbuffer[ye]);else{if(r.deleteFramebuffer(ee.__webglFramebuffer),ee.__webglDepthbuffer&&r.deleteRenderbuffer(ee.__webglDepthbuffer),ee.__webglMultisampledFramebuffer&&r.deleteFramebuffer(ee.__webglMultisampledFramebuffer),ee.__webglColorRenderbuffer)for(let ye=0;ye<ee.__webglColorRenderbuffer.length;ye++)ee.__webglColorRenderbuffer[ye]&&r.deleteRenderbuffer(ee.__webglColorRenderbuffer[ye]);ee.__webglDepthRenderbuffer&&r.deleteRenderbuffer(ee.__webglDepthRenderbuffer)}if(L.isWebGLMultipleRenderTargets)for(let ye=0,Ce=O.length;ye<Ce;ye++){let ke=n.get(O[ye]);ke.__webglTexture&&(r.deleteTexture(ke.__webglTexture),o.memory.textures--),n.remove(O[ye])}n.remove(O),n.remove(L)}let G=0;function Y(){G=0}function W(){let L=G;return L>=l&&console.warn("THREE.WebGLTextures: Trying to use "+L+" texture units while this GPU supports only "+l),G+=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 j(L,O){let ee=n.get(L);if(L.isVideoTexture&&Ge(L),L.isRenderTargetTexture===!1&&L.version>0&&ee.__version!==L.version){let fe=L.image;if(fe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(fe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{K(ee,L,O);return}}e.bindTexture(3553,ee.__webglTexture,33984+O)}function X(L,O){let ee=n.get(L);if(L.version>0&&ee.__version!==L.version){K(ee,L,O);return}e.bindTexture(35866,ee.__webglTexture,33984+O)}function N(L,O){let ee=n.get(L);if(L.version>0&&ee.__version!==L.version){K(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){Z(ee,L,O);return}e.bindTexture(34067,ee.__webglTexture,33984+O)}let z={[ql]:10497,[xr]:33071,[qv]:33648},H={[Ut]:9728,[Tw]:9984,[ov]:9986,[it]:9729,[w2]:9985,[Ra]:9987};function V(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,H[O.magFilter]),r.texParameteri(L,10241,H[O.minFilter])):(r.texParameteri(L,10242,33071),r.texParameteri(L,10243,33071),(L===32879||L===35866)&&r.texParameteri(L,32882,33071),(O.wrapS!==xr||O.wrapT!==xr)&&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!==Ut&&O.minFilter!==it&&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 fe=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===Ut||O.minFilter!==ov&&O.minFilter!==Ra||O.type===ns&&t.has("OES_texture_float_linear")===!1||a===!1&&O.type===Bd&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||n.get(O).__currentAnisotropy)&&(r.texParameterf(L,fe.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",D));let fe=O.source,ye=m.get(fe);ye===void 0&&(ye={},m.set(fe,ye));let Ce=q(O);if(Ce!==L.__cacheKey){ye[Ce]===void 0&&(ye[Ce]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),ye[Ce].usedTimes++;let ke=ye[L.__cacheKey];ke!==void 0&&(ye[L.__cacheKey].usedTimes--,ke.usedTimes===0&&I(O)),L.__cacheKey=Ce,L.__webglTexture=ye[Ce].texture}return ee}function K(L,O,ee){let fe=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(fe=35866),O.isData3DTexture&&(fe=32879);let ye=re(L,O),Ce=O.source;e.bindTexture(fe,L.__webglTexture,33984+ee);let ke=n.get(Ce);if(Ce.version!==ke.__version||ye===!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 Pe=w(O)&&S(O.image)===!1,ce=x(O.image,Pe,!1,c);ce=ht(O,ce);let je=S(ce)||a,Le=s.convert(O.format,O.encoding),De=s.convert(O.type),Be=b(O.internalFormat,Le,De,O.encoding,O.isVideoTexture);V(fe,O,je);let qe,ft=O.mipmaps,Ft=a&&O.isVideoTexture!==!0,bn=ke.__version===void 0||ye===!0,Q=T(O,ce,je);if(O.isDepthTexture)Be=6402,a?O.type===ns?Be=36012:O.type===Hs?Be=33190:O.type===Do?Be=35056:Be=33189:O.type===ns&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===Oa&&Be===6402&&O.type!==nA&&O.type!==Hs&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=Hs,De=s.convert(O.type)),O.format===Lo&&Be===6402&&(Be=34041,O.type!==Do&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=Do,De=s.convert(O.type))),bn&&(Ft?e.texStorage2D(3553,1,Be,ce.width,ce.height):e.texImage2D(3553,0,Be,ce.width,ce.height,0,Le,De,null));else if(O.isDataTexture)if(ft.length>0&&je){Ft&&bn&&e.texStorage2D(3553,Q,Be,ft[0].width,ft[0].height);for(let ie=0,pe=ft.length;ie<pe;ie++)qe=ft[ie],Ft?e.texSubImage2D(3553,ie,0,0,qe.width,qe.height,Le,De,qe.data):e.texImage2D(3553,ie,Be,qe.width,qe.height,0,Le,De,qe.data);O.generateMipmaps=!1}else Ft?(bn&&e.texStorage2D(3553,Q,Be,ce.width,ce.height),e.texSubImage2D(3553,0,0,0,ce.width,ce.height,Le,De,ce.data)):e.texImage2D(3553,0,Be,ce.width,ce.height,0,Le,De,ce.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Ft&&bn&&e.texStorage3D(35866,Q,Be,ft[0].width,ft[0].height,ce.depth);for(let ie=0,pe=ft.length;ie<pe;ie++)qe=ft[ie],O.format!==ui?Le!==null?Ft?e.compressedTexSubImage3D(35866,ie,0,0,0,qe.width,qe.height,ce.depth,Le,qe.data,0,0):e.compressedTexImage3D(35866,ie,Be,qe.width,qe.height,ce.depth,0,qe.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ft?e.texSubImage3D(35866,ie,0,0,0,qe.width,qe.height,ce.depth,Le,De,qe.data):e.texImage3D(35866,ie,Be,qe.width,qe.height,ce.depth,0,Le,De,qe.data)}else{Ft&&bn&&e.texStorage2D(3553,Q,Be,ft[0].width,ft[0].height);for(let ie=0,pe=ft.length;ie<pe;ie++)qe=ft[ie],O.format!==ui?Le!==null?Ft?e.compressedTexSubImage2D(3553,ie,0,0,qe.width,qe.height,Le,qe.data):e.compressedTexImage2D(3553,ie,Be,qe.width,qe.height,0,qe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ft?e.texSubImage2D(3553,ie,0,0,qe.width,qe.height,Le,De,qe.data):e.texImage2D(3553,ie,Be,qe.width,qe.height,0,Le,De,qe.data)}else if(O.isDataArrayTexture)Ft?(bn&&e.texStorage3D(35866,Q,Be,ce.width,ce.height,ce.depth),e.texSubImage3D(35866,0,0,0,0,ce.width,ce.height,ce.depth,Le,De,ce.data)):e.texImage3D(35866,0,Be,ce.width,ce.height,ce.depth,0,Le,De,ce.data);else if(O.isData3DTexture)Ft?(bn&&e.texStorage3D(32879,Q,Be,ce.width,ce.height,ce.depth),e.texSubImage3D(32879,0,0,0,0,ce.width,ce.height,ce.depth,Le,De,ce.data)):e.texImage3D(32879,0,Be,ce.width,ce.height,ce.depth,0,Le,De,ce.data);else if(O.isFramebufferTexture){if(bn)if(Ft)e.texStorage2D(3553,Q,Be,ce.width,ce.height);else{let ie=ce.width,pe=ce.height;for(let Re=0;Re<Q;Re++)e.texImage2D(3553,Re,Be,ie,pe,0,Le,De,null),ie>>=1,pe>>=1}}else if(ft.length>0&&je){Ft&&bn&&e.texStorage2D(3553,Q,Be,ft[0].width,ft[0].height);for(let ie=0,pe=ft.length;ie<pe;ie++)qe=ft[ie],Ft?e.texSubImage2D(3553,ie,0,0,Le,De,qe):e.texImage2D(3553,ie,Be,Le,De,qe);O.generateMipmaps=!1}else Ft?(bn&&e.texStorage2D(3553,Q,Be,ce.width,ce.height),e.texSubImage2D(3553,0,0,0,Le,De,ce)):e.texImage2D(3553,0,Be,Le,De,ce);E(O,je)&&_(fe),ke.__version=Ce.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function Z(L,O,ee){if(O.image.length!==6)return;let fe=re(L,O),ye=O.source;e.bindTexture(34067,L.__webglTexture,33984+ee);let Ce=n.get(ye);if(ye.version!==Ce.__version||fe===!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 ke=O.isCompressedTexture||O.image[0].isCompressedTexture,Pe=O.image[0]&&O.image[0].isDataTexture,ce=[];for(let ie=0;ie<6;ie++)!ke&&!Pe?ce[ie]=x(O.image[ie],!1,!0,u):ce[ie]=Pe?O.image[ie].image:O.image[ie],ce[ie]=ht(O,ce[ie]);let je=ce[0],Le=S(je)||a,De=s.convert(O.format,O.encoding),Be=s.convert(O.type),qe=b(O.internalFormat,De,Be,O.encoding),ft=a&&O.isVideoTexture!==!0,Ft=Ce.__version===void 0||fe===!0,bn=T(O,je,Le);V(34067,O,Le);let Q;if(ke){ft&&Ft&&e.texStorage2D(34067,bn,qe,je.width,je.height);for(let ie=0;ie<6;ie++){Q=ce[ie].mipmaps;for(let pe=0;pe<Q.length;pe++){let Re=Q[pe];O.format!==ui?De!==null?ft?e.compressedTexSubImage2D(34069+ie,pe,0,0,Re.width,Re.height,De,Re.data):e.compressedTexImage2D(34069+ie,pe,qe,Re.width,Re.height,0,Re.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ft?e.texSubImage2D(34069+ie,pe,0,0,Re.width,Re.height,De,Be,Re.data):e.texImage2D(34069+ie,pe,qe,Re.width,Re.height,0,De,Be,Re.data)}}}else{Q=O.mipmaps,ft&&Ft&&(Q.length>0&&bn++,e.texStorage2D(34067,bn,qe,ce[0].width,ce[0].height));for(let ie=0;ie<6;ie++)if(Pe){ft?e.texSubImage2D(34069+ie,0,0,0,ce[ie].width,ce[ie].height,De,Be,ce[ie].data):e.texImage2D(34069+ie,0,qe,ce[ie].width,ce[ie].height,0,De,Be,ce[ie].data);for(let pe=0;pe<Q.length;pe++){let Oe=Q[pe].image[ie].image;ft?e.texSubImage2D(34069+ie,pe+1,0,0,Oe.width,Oe.height,De,Be,Oe.data):e.texImage2D(34069+ie,pe+1,qe,Oe.width,Oe.height,0,De,Be,Oe.data)}}else{ft?e.texSubImage2D(34069+ie,0,0,0,De,Be,ce[ie]):e.texImage2D(34069+ie,0,qe,De,Be,ce[ie]);for(let pe=0;pe<Q.length;pe++){let Re=Q[pe];ft?e.texSubImage2D(34069+ie,pe+1,0,0,De,Be,Re.image[ie]):e.texImage2D(34069+ie,pe+1,qe,De,Be,Re.image[ie])}}}E(O,Le)&&_(34067),Ce.__version=ye.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function k(L,O,ee,fe,ye){let Ce=s.convert(ee.format,ee.encoding),ke=s.convert(ee.type),Pe=b(ee.internalFormat,Ce,ke,ee.encoding);n.get(O).__hasExternalTextures||(ye===32879||ye===35866?e.texImage3D(ye,0,Pe,O.width,O.height,O.depth,0,Ce,ke,null):e.texImage2D(ye,0,Pe,O.width,O.height,0,Ce,ke,null)),e.bindFramebuffer(36160,L),xe(O)?h.framebufferTexture2DMultisampleEXT(36160,fe,ye,n.get(ee).__webglTexture,0,Me(O)):(ye===3553||ye>=34069&&ye<=34074)&&r.framebufferTexture2D(36160,fe,ye,n.get(ee).__webglTexture,0),e.bindFramebuffer(36160,null)}function ue(L,O,ee){if(r.bindRenderbuffer(36161,L),O.depthBuffer&&!O.stencilBuffer){let fe=33189;if(ee||xe(O)){let ye=O.depthTexture;ye&&ye.isDepthTexture&&(ye.type===ns?fe=36012:ye.type===Hs&&(fe=33190));let Ce=Me(O);xe(O)?h.renderbufferStorageMultisampleEXT(36161,Ce,fe,O.width,O.height):r.renderbufferStorageMultisample(36161,Ce,fe,O.width,O.height)}else r.renderbufferStorage(36161,fe,O.width,O.height);r.framebufferRenderbuffer(36160,36096,36161,L)}else if(O.depthBuffer&&O.stencilBuffer){let fe=Me(O);ee&&xe(O)===!1?r.renderbufferStorageMultisample(36161,fe,35056,O.width,O.height):xe(O)?h.renderbufferStorageMultisampleEXT(36161,fe,35056,O.width,O.height):r.renderbufferStorage(36161,34041,O.width,O.height),r.framebufferRenderbuffer(36160,33306,36161,L)}else{let fe=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let ye=0;ye<fe.length;ye++){let Ce=fe[ye],ke=s.convert(Ce.format,Ce.encoding),Pe=s.convert(Ce.type),ce=b(Ce.internalFormat,ke,Pe,Ce.encoding),je=Me(O);ee&&xe(O)===!1?r.renderbufferStorageMultisample(36161,je,ce,O.width,O.height):xe(O)?h.renderbufferStorageMultisampleEXT(36161,je,ce,O.width,O.height):r.renderbufferStorage(36161,ce,O.width,O.height)}}r.bindRenderbuffer(36161,null)}function he(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),j(O.depthTexture,0);let fe=n.get(O.depthTexture).__webglTexture,ye=Me(O);if(O.depthTexture.format===Oa)xe(O)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,fe,0,ye):r.framebufferTexture2D(36160,36096,3553,fe,0);else if(O.depthTexture.format===Lo)xe(O)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,fe,0,ye):r.framebufferTexture2D(36160,33306,3553,fe,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");he(O.__webglFramebuffer,L)}else if(ee){O.__webglDepthbuffer=[];for(let fe=0;fe<6;fe++)e.bindFramebuffer(36160,O.__webglFramebuffer[fe]),O.__webglDepthbuffer[fe]=r.createRenderbuffer(),ue(O.__webglDepthbuffer[fe],L,!1)}else e.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=r.createRenderbuffer(),ue(O.__webglDepthbuffer,L,!1);e.bindFramebuffer(36160,null)}function me(L,O,ee){let fe=n.get(L);O!==void 0&&k(fe.__webglFramebuffer,L,L.texture,36064,3553),ee!==void 0&&ae(L)}function be(L){let O=L.texture,ee=n.get(L),fe=n.get(O);L.addEventListener("dispose",P),L.isWebGLMultipleRenderTargets!==!0&&(fe.__webglTexture===void 0&&(fe.__webglTexture=r.createTexture()),fe.__version=O.version,o.memory.textures++);let ye=L.isWebGLCubeRenderTarget===!0,Ce=L.isWebGLMultipleRenderTargets===!0,ke=S(L)||a;if(ye){ee.__webglFramebuffer=[];for(let Pe=0;Pe<6;Pe++)ee.__webglFramebuffer[Pe]=r.createFramebuffer()}else{if(ee.__webglFramebuffer=r.createFramebuffer(),Ce)if(i.drawBuffers){let Pe=L.texture;for(let ce=0,je=Pe.length;ce<je;ce++){let Le=n.get(Pe[ce]);Le.__webglTexture===void 0&&(Le.__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&&xe(L)===!1){let Pe=Ce?O:[O];ee.__webglMultisampledFramebuffer=r.createFramebuffer(),ee.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ee.__webglMultisampledFramebuffer);for(let ce=0;ce<Pe.length;ce++){let je=Pe[ce];ee.__webglColorRenderbuffer[ce]=r.createRenderbuffer(),r.bindRenderbuffer(36161,ee.__webglColorRenderbuffer[ce]);let Le=s.convert(je.format,je.encoding),De=s.convert(je.type),Be=b(je.internalFormat,Le,De,je.encoding,L.isXRRenderTarget===!0),qe=Me(L);r.renderbufferStorageMultisample(36161,qe,Be,L.width,L.height),r.framebufferRenderbuffer(36160,36064+ce,36161,ee.__webglColorRenderbuffer[ce])}r.bindRenderbuffer(36161,null),L.depthBuffer&&(ee.__webglDepthRenderbuffer=r.createRenderbuffer(),ue(ee.__webglDepthRenderbuffer,L,!0)),e.bindFramebuffer(36160,null)}}if(ye){e.bindTexture(34067,fe.__webglTexture),V(34067,O,ke);for(let Pe=0;Pe<6;Pe++)k(ee.__webglFramebuffer[Pe],L,O,36064,34069+Pe);E(O,ke)&&_(34067),e.unbindTexture()}else if(Ce){let Pe=L.texture;for(let ce=0,je=Pe.length;ce<je;ce++){let Le=Pe[ce],De=n.get(Le);e.bindTexture(3553,De.__webglTexture),V(3553,Le,ke),k(ee.__webglFramebuffer,L,Le,36064+ce,3553),E(Le,ke)&&_(3553)}e.unbindTexture()}else{let Pe=3553;(L.isWebGL3DRenderTarget||L.isWebGLArrayRenderTarget)&&(a?Pe=L.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Pe,fe.__webglTexture),V(Pe,O,ke),k(ee.__webglFramebuffer,L,O,36064,Pe),E(O,ke)&&_(Pe),e.unbindTexture()}L.depthBuffer&&ae(L)}function ge(L){let O=S(L)||a,ee=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let fe=0,ye=ee.length;fe<ye;fe++){let Ce=ee[fe];if(E(Ce,O)){let ke=L.isWebGLCubeRenderTarget?34067:3553,Pe=n.get(Ce).__webglTexture;e.bindTexture(ke,Pe),_(ke),e.unbindTexture()}}}function Ae(L){if(a&&L.samples>0&&xe(L)===!1){let O=L.isWebGLMultipleRenderTargets?L.texture:[L.texture],ee=L.width,fe=L.height,ye=16384,Ce=[],ke=L.stencilBuffer?33306:36096,Pe=n.get(L),ce=L.isWebGLMultipleRenderTargets===!0;if(ce)for(let je=0;je<O.length;je++)e.bindFramebuffer(36160,Pe.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+je,36161,null),e.bindFramebuffer(36160,Pe.__webglFramebuffer),r.framebufferTexture2D(36009,36064+je,3553,null,0);e.bindFramebuffer(36008,Pe.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Pe.__webglFramebuffer);for(let je=0;je<O.length;je++){Ce.push(36064+je),L.depthBuffer&&Ce.push(ke);let Le=Pe.__ignoreDepthValues!==void 0?Pe.__ignoreDepthValues:!1;if(Le===!1&&(L.depthBuffer&&(ye|=256),L.stencilBuffer&&(ye|=1024)),ce&&r.framebufferRenderbuffer(36008,36064,36161,Pe.__webglColorRenderbuffer[je]),Le===!0&&(r.invalidateFramebuffer(36008,[ke]),r.invalidateFramebuffer(36009,[ke])),ce){let De=n.get(O[je]).__webglTexture;r.framebufferTexture2D(36009,36064,3553,De,0)}r.blitFramebuffer(0,0,ee,fe,0,0,ee,fe,ye,9728),f&&r.invalidateFramebuffer(36008,Ce)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),ce)for(let je=0;je<O.length;je++){e.bindFramebuffer(36160,Pe.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+je,36161,Pe.__webglColorRenderbuffer[je]);let Le=n.get(O[je]).__webglTexture;e.bindFramebuffer(36160,Pe.__webglFramebuffer),r.framebufferTexture2D(36009,36064+je,3553,Le,0)}e.bindFramebuffer(36009,Pe.__webglMultisampledFramebuffer)}}function Me(L){return Math.min(d,L.samples)}function xe(L){let O=n.get(L);return a&&L.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Ge(L){let O=o.render.frame;g.get(L)!==O&&(g.set(L,O),L.update())}function ht(L,O){let ee=L.encoding,fe=L.format,ye=L.type;return L.isCompressedTexture===!0||L.isVideoTexture===!0||L.format===Yv||ee!==Zr&&(ee===Ye?a===!1?t.has("EXT_sRGB")===!0&&fe===ui?(L.format=Yv,L.minFilter=it,L.generateMipmaps=!1):O=bp.sRGBToLinear(O):(fe!==ui||ye!==jt)&&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=Y,this.setTexture2D=j,this.setTexture2DArray=X,this.setTexture3D=N,this.setTextureCube=U,this.rebindTextures=me,this.setupRenderTarget=be,this.updateRenderTargetMipmap=ge,this.updateMultisampleRenderTarget=Ae,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=k,this.useMultisampledRTT=xe}function NN(r,t,e){let n=e.isWebGL2;function i(s,o=null){let a;if(s===jt)return 5121;if(s===T2)return 32819;if(s===M2)return 32820;if(s===A2)return 5120;if(s===E2)return 5122;if(s===nA)return 5123;if(s===_2)return 5124;if(s===Hs)return 5125;if(s===ns)return 5126;if(s===Bd)return n?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===C2)return 6406;if(s===ui)return 6408;if(s===P2)return 6409;if(s===D2)return 6410;if(s===Oa)return 6402;if(s===Lo)return 34041;if(s===Yv)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===I2)return 6403;if(s===O2)return 36244;if(s===L2)return 33319;if(s===R2)return 33320;if(s===N2)return 36249;if(s===av||s===lv||s===cv||s===uv)if(o===Ye)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===av)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===lv)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===cv)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===uv)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===av)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===lv)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===cv)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===uv)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Mw||s===Cw||s===Pw||s===Dw)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Mw)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Cw)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Pw)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Dw)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===B2)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Iw||s===Ow)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Iw)return o===Ye?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Ow)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Lw||s===Rw||s===Nw||s===Bw||s===Fw||s===Uw||s===Gw||s===kw||s===Vw||s===zw||s===Hw||s===Ww||s===jw||s===qw)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Lw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Rw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Nw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Bw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Fw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Uw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Gw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===kw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Vw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===zw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Hw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Ww)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===jw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===qw)return o===Ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===dv)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===dv)return o===Ye?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===F2||s===Xw||s===Yw||s===Qw)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===dv)return a.COMPRESSED_RED_RGTC1_EXT;if(s===Xw)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Yw)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Qw)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Do?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 s0=class extends un{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},rs=class extends ct{constructor(){super(),this.isGroup=!0,this.type="Group"}},BN={type:"move"},Ld=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new rs,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 rs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new rs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let 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(BN)))}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 rs;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},No=class extends Wt{constructor(t,e,n,i,s,o,a,l,u,c){if(c=c!==void 0?c:Oa,c!==Oa&&c!==Lo)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===Oa&&(n=Hs),n===void 0&&c===Lo&&(n=Do),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:Ut,this.minFilter=l!==void 0?l:Ut,this.flipY=!1,this.generateMipmaps=!1}},o0=class extends kt{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=[],S=new Set,w=new Map,E=new un;E.layers.enable(1),E.viewport=new $e;let _=new un;_.layers.enable(2),_.viewport=new $e;let b=[E,_],T=new s0;T.layers.enable(1),T.layers.enable(2);let M=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(N){let U=v[N];return U===void 0&&(U=new Ld,v[N]=U),U.getTargetRaySpace()},this.getControllerGrip=function(N){let U=v[N];return U===void 0&&(U=new Ld,v[N]=U),U.getGripSpace()},this.getHand=function(N){let U=v[N];return U===void 0&&(U=new Ld,v[N]=U),U.getHandSpace()};function P(N){let U=x.indexOf(N.inputSource);if(U===-1)return;let z=v[U];z!==void 0&&z.dispatchEvent({type:N.type,data:N.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",I);for(let N=0;N<v.length;N++){let U=x[N];U!==null&&(x[N]=null,v[N].disconnect(U))}M=null,D=null,t.setRenderTarget(m),f=null,h=null,d=null,i=null,y=null,X.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(N){s=N,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(N){a=N,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(N){u=N},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(N){if(i=N,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",I),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 Et(f.framebufferWidth,f.framebufferHeight,{format:ui,type:jt,encoding:t.outputEncoding,stencilBuffer:p.stencil})}else{let U=null,z=null,H=null;p.depth&&(H=p.stencil?35056:33190,U=p.stencil?Lo:Oa,z=p.stencil?Do:Hs);let V={colorFormat:32856,depthFormat:H,scaleFactor:s};d=new XRWebGLBinding(i,e),h=d.createProjectionLayer(V),i.updateRenderState({layers:[h]}),y=new Et(h.textureWidth,h.textureHeight,{format:ui,type:jt,depthTexture:new No(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),X.setContext(i),X.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function I(N){for(let U=0;U<N.removed.length;U++){let z=N.removed[U],H=x.indexOf(z);H>=0&&(x[H]=null,v[H].disconnect(z))}for(let U=0;U<N.added.length;U++){let z=N.added[U],H=x.indexOf(z);if(H===-1){for(let re=0;re<v.length;re++)if(re>=x.length){x.push(z),H=re;break}else if(x[re]===null){x[re]=z,H=re;break}if(H===-1)break}let V=v[H];V&&V.connect(z)}}let R=new A,G=new A;function Y(N,U,z){R.setFromMatrixPosition(U.matrixWorld),G.setFromMatrixPosition(z.matrixWorld);let H=R.distanceTo(G),V=U.projectionMatrix.elements,re=z.projectionMatrix.elements,K=V[14]/(V[10]-1),Z=V[14]/(V[10]+1),k=(V[9]+1)/V[5],ue=(V[9]-1)/V[5],he=(V[8]-1)/V[0],ae=(re[8]+1)/re[0],me=K*he,be=K*ae,ge=H/(-he+ae),Ae=ge*-he;U.matrixWorld.decompose(N.position,N.quaternion,N.scale),N.translateX(Ae),N.translateZ(ge),N.matrixWorld.compose(N.position,N.quaternion,N.scale),N.matrixWorldInverse.copy(N.matrixWorld).invert();let Me=K+ge,xe=Z+ge,Ge=me-Ae,ht=be+(H-Ae),L=k*Z/xe*Me,O=ue*Z/xe*Me;N.projectionMatrix.makePerspective(Ge,ht,L,O,Me,xe)}function W(N,U){U===null?N.matrixWorld.copy(N.matrix):N.matrixWorld.multiplyMatrices(U.matrixWorld,N.matrix),N.matrixWorldInverse.copy(N.matrixWorld).invert()}this.updateCamera=function(N){if(i===null)return;T.near=_.near=E.near=N.near,T.far=_.far=E.far=N.far,(M!==T.near||D!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),M=T.near,D=T.far);let U=N.parent,z=T.cameras;W(T,U);for(let V=0;V<z.length;V++)W(z[V],U);T.matrixWorld.decompose(T.position,T.quaternion,T.scale),N.matrix.copy(T.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale);let H=N.children;for(let V=0,re=H.length;V<re;V++)H[V].updateMatrixWorld(!0);z.length===2?Y(T,E,_):T.projectionMatrix.copy(E.projectionMatrix)},this.getCamera=function(){return T},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(N){l=N,h!==null&&(h.fixedFoveation=N),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=N)},this.getPlanes=function(){return S};let q=null;function j(N,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 H=!1;z.length!==T.cameras.length&&(T.cameras.length=0,H=!0);for(let V=0;V<z.length;V++){let re=z[V],K=null;if(f!==null)K=f.getViewport(re);else{let k=d.getViewSubImage(h,re);K=k.viewport,V===0&&(t.setRenderTargetTextures(y,k.colorTexture,h.ignoreDepthValues?void 0:k.depthStencilTexture),t.setRenderTarget(y))}let Z=b[V];Z===void 0&&(Z=new un,Z.layers.enable(V),Z.viewport=new $e,b[V]=Z),Z.matrix.fromArray(re.transform.matrix),Z.projectionMatrix.fromArray(re.projectionMatrix),Z.viewport.set(K.x,K.y,K.width,K.height),V===0&&T.matrix.copy(Z.matrix),H===!0&&T.cameras.push(Z)}}for(let z=0;z<v.length;z++){let H=x[z],V=v[z];H!==null&&V!==void 0&&V.update(H,U,u||o)}if(q&&q(N,U),U.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:U.detectedPlanes});let z=null;for(let H of S)U.detectedPlanes.has(H)||(z===null&&(z=[]),z.push(H));if(z!==null)for(let H of z)S.delete(H),w.delete(H),n.dispatchEvent({type:"planeremoved",data:H});for(let H of U.detectedPlanes)if(!S.has(H))S.add(H),w.set(H,U.lastChangedTime),n.dispatchEvent({type:"planeadded",data:H});else{let V=w.get(H);H.lastChangedTime>V&&(w.set(H,H.lastChangedTime),n.dispatchEvent({type:"planechanged",data:H}))}}g=null}let X=new oA;X.setAnimationLoop(j),this.setAnimationLoop=function(N){q=N},this.dispose=function(){}}};function FN(r,t){function e(p,m){m.color.getRGB(p.fogColor.value,sA(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===_n&&(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===_n&&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 S=r.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=m.lightMapIntensity*S}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===_n&&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 UN(r,t,e,n){let i={},s={},o=[],a=e.isWebGL2?r.getParameter(35375):0;function l(v,x){let S=x.program;n.uniformBlockBinding(v,S)}function u(v,x){let S=i[v.id];S===void 0&&(g(v),S=c(v),i[v.id]=S,v.addEventListener("dispose",m));let w=x.program;n.updateUBOMapping(v,w);let E=t.render.frame;s[v.id]!==E&&(h(v),s[v.id]=E)}function c(v){let x=d();v.__bindingPointIndex=x;let S=r.createBuffer(),w=v.__size,E=v.usage;return r.bindBuffer(35345,S),r.bufferData(35345,w,E),r.bindBuffer(35345,null),r.bindBufferBase(35345,x,S),S}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],S=v.uniforms,w=v.__cache;r.bindBuffer(35345,x);for(let E=0,_=S.length;E<_;E++){let b=S[E];if(f(b,E,w)===!0){let T=b.__offset,M=Array.isArray(b.value)?b.value:[b.value],D=0;for(let P=0;P<M.length;P++){let C=M[P],I=p(C);typeof C=="number"?(b.__data[0]=C,r.bufferSubData(35345,T+D,b.__data)):C.isMatrix3?(b.__data[0]=C.elements[0],b.__data[1]=C.elements[1],b.__data[2]=C.elements[2],b.__data[3]=C.elements[0],b.__data[4]=C.elements[3],b.__data[5]=C.elements[4],b.__data[6]=C.elements[5],b.__data[7]=C.elements[0],b.__data[8]=C.elements[6],b.__data[9]=C.elements[7],b.__data[10]=C.elements[8],b.__data[11]=C.elements[0]):(C.toArray(b.__data,D),D+=I.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(35345,T,b.__data)}}r.bindBuffer(35345,null)}function f(v,x,S){let w=v.value;if(S[x]===void 0){if(typeof w=="number")S[x]=w;else{let E=Array.isArray(w)?w:[w],_=[];for(let b=0;b<E.length;b++)_.push(E[b].clone());S[x]=_}return!0}else if(typeof w=="number"){if(S[x]!==w)return S[x]=w,!0}else{let E=Array.isArray(S[x])?S[x]:[S[x]],_=Array.isArray(w)?w:[w];for(let b=0;b<E.length;b++){let T=E[b];if(T.equals(_[b])===!1)return T.copy(_[b]),!0}}return!1}function g(v){let x=v.uniforms,S=0,w=16,E=0;for(let _=0,b=x.length;_<b;_++){let T=x[_],M={boundary:0,storage:0},D=Array.isArray(T.value)?T.value:[T.value];for(let P=0,C=D.length;P<C;P++){let I=D[P],R=p(I);M.boundary+=R.boundary,M.storage+=R.storage}if(T.__data=new Float32Array(M.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=S,_>0){E=S%w;let P=w-E;E!==0&&P-M.boundary<0&&(S+=w-E,T.__offset=S)}S+=M.storage}return E=S%w,E>0&&(S+=w-E),v.__size=S,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 S=o.indexOf(x.__bindingPointIndex);o.splice(S,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 GN(){let r=xp("canvas");return r.style.display="block",r}function I0(r={}){this.isWebGLRenderer=!0;let t=r.canvas!==void 0?r.canvas:GN(),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=Zr,this.physicallyCorrectLights=!1,this.toneMapping=js,this.toneMappingExposure=1;let p=this,m=!1,y=0,v=0,x=null,S=-1,w=null,E=new $e,_=new $e,b=null,T=t.width,M=t.height,D=1,P=null,C=null,I=new $e(0,0,T,M),R=new $e(0,0,T,M),G=!1,Y=new kd,W=!1,q=!1,j=null,X=new de,N=new F,U=new A,z={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function H(){return x===null?D:1}let V=e;function re(B,te){for(let se=0;se<B.length;se++){let $=B[se],le=t.getContext($,te);if(le!==null)return le}return null}try{let B={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${Qs}`),t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",qe,!1),t.addEventListener("webglcontextcreationerror",ft,!1),V===null){let te=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&te.shift(),V=re(te,B),V===null)throw re(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}V.getShaderPrecisionFormat===void 0&&(V.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(B){throw console.error("THREE.WebGLRenderer: "+B.message),B}let K,Z,k,ue,he,ae,me,be,ge,Ae,Me,xe,Ge,ht,L,O,ee,fe,ye,Ce,ke,Pe,ce,je;function Le(){K=new o3(V),Z=new e3(V,K,r),K.init(Z),Pe=new NN(V,K,Z),k=new LN(V,K,Z),ue=new c3,he=new SN,ae=new RN(V,K,k,he,Z,Pe,ue),me=new n3(p),be=new s3(p),ge=new vO(V,Z),ce=new JR(V,K,ge,Z),Ae=new a3(V,ge,ue,ce),Me=new f3(V,Ae,ge,ue),ye=new h3(V,Z,ae),O=new t3(he),xe=new bN(p,me,be,K,Z,ce,O),Ge=new FN(p,he),ht=new AN,L=new PN(K,Z),fe=new ZR(p,me,be,k,Me,c,o),ee=new ON(p,Me,Z),je=new UN(V,ue,Z,k),Ce=new $R(V,K,ue,Z),ke=new l3(V,K,ue,Z),ue.programs=xe.programs,p.capabilities=Z,p.extensions=K,p.properties=he,p.renderLists=ht,p.shadowMap=ee,p.state=k,p.info=ue}Le();let De=new o0(p,V);this.xr=De,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){let B=K.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){let B=K.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return D},this.setPixelRatio=function(B){B!==void 0&&(D=B,this.setSize(T,M,!1))},this.getSize=function(B){return B.set(T,M)},this.setSize=function(B,te,se){if(De.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=B,M=te,t.width=Math.floor(B*D),t.height=Math.floor(te*D),se!==!1&&(t.style.width=B+"px",t.style.height=te+"px"),this.setViewport(0,0,B,te)},this.getDrawingBufferSize=function(B){return B.set(T*D,M*D).floor()},this.setDrawingBufferSize=function(B,te,se){T=B,M=te,D=se,t.width=Math.floor(B*se),t.height=Math.floor(te*se),this.setViewport(0,0,B,te)},this.getCurrentViewport=function(B){return B.copy(E)},this.getViewport=function(B){return B.copy(I)},this.setViewport=function(B,te,se,$){B.isVector4?I.set(B.x,B.y,B.z,B.w):I.set(B,te,se,$),k.viewport(E.copy(I).multiplyScalar(D).floor())},this.getScissor=function(B){return B.copy(R)},this.setScissor=function(B,te,se,$){B.isVector4?R.set(B.x,B.y,B.z,B.w):R.set(B,te,se,$),k.scissor(_.copy(R).multiplyScalar(D).floor())},this.getScissorTest=function(){return G},this.setScissorTest=function(B){k.setScissorTest(G=B)},this.setOpaqueSort=function(B){P=B},this.setTransparentSort=function(B){C=B},this.getClearColor=function(B){return B.copy(fe.getClearColor())},this.setClearColor=function(){fe.setClearColor.apply(fe,arguments)},this.getClearAlpha=function(){return fe.getClearAlpha()},this.setClearAlpha=function(){fe.setClearAlpha.apply(fe,arguments)},this.clear=function(B=!0,te=!0,se=!0){let $=0;B&&($|=16384),te&&($|=256),se&&($|=1024),V.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",Be,!1),t.removeEventListener("webglcontextrestored",qe,!1),t.removeEventListener("webglcontextcreationerror",ft,!1),ht.dispose(),L.dispose(),he.dispose(),me.dispose(),be.dispose(),Me.dispose(),ce.dispose(),je.dispose(),xe.dispose(),De.dispose(),De.removeEventListener("sessionstart",Re),De.removeEventListener("sessionend",Oe),j&&(j.dispose(),j=null),pt.stop()};function Be(B){B.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function qe(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let B=ue.autoReset,te=ee.enabled,se=ee.autoUpdate,$=ee.needsUpdate,le=ee.type;Le(),ue.autoReset=B,ee.enabled=te,ee.autoUpdate=se,ee.needsUpdate=$,ee.type=le}function ft(B){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}function Ft(B){let te=B.target;te.removeEventListener("dispose",Ft),bn(te)}function bn(B){Q(B),he.remove(B)}function Q(B){let te=he.get(B).programs;te!==void 0&&(te.forEach(function(se){xe.releaseProgram(se)}),B.isShaderMaterial&&xe.releaseShaderCache(B))}this.renderBufferDirect=function(B,te,se,$,le,Je){te===null&&(te=z);let rt=le.isMesh&&le.matrixWorld.determinant()<0,ot=UI(B,te,se,$,le);k.setMaterial($,rt);let lt=se.index,At=1;$.wireframe===!0&&(lt=Ae.getWireframeAttribute(se),At=2);let mt=se.drawRange,gt=se.attributes.position,wn=mt.start*At,qr=(mt.start+mt.count)*At;Je!==null&&(wn=Math.max(wn,Je.start*At),qr=Math.min(qr,(Je.start+Je.count)*At)),lt!==null?(wn=Math.max(wn,0),qr=Math.min(qr,lt.count)):gt!=null&&(wn=Math.max(wn,0),qr=Math.min(qr,gt.count));let Ns=qr-wn;if(Ns<0||Ns===1/0)return;ce.setup(le,$,ot,se,lt);let Ea,An=Ce;if(lt!==null&&(Ea=ge.get(lt),An=ke,An.setIndex(Ea)),le.isMesh)$.wireframe===!0?(k.setLineWidth($.wireframeLinewidth*H()),An.setMode(1)):An.setMode(4);else if(le.isLine){let yt=$.linewidth;yt===void 0&&(yt=1),k.setLineWidth(yt*H()),le.isLineSegments?An.setMode(1):le.isLineLoop?An.setMode(2):An.setMode(3)}else le.isPoints?An.setMode(0):le.isSprite&&An.setMode(4);if(le.isInstancedMesh)An.renderInstances(wn,Ns,le.count);else if(se.isInstancedBufferGeometry){let yt=se._maxInstanceCount!==void 0?se._maxInstanceCount:1/0,nv=Math.min(se.instanceCount,yt);An.renderInstances(wn,Ns,nv)}else An.render(wn,Ns)},this.compile=function(B,te){function se($,le,Je){$.transparent===!0&&$.side===br&&$.forceSinglePass===!1?($.side=_n,$.needsUpdate=!0,li($,le,Je),$.side=Kr,$.needsUpdate=!0,li($,le,Je),$.side=br):li($,le,Je)}h=L.get(B),h.init(),g.push(h),B.traverseVisible(function($){$.isLight&&$.layers.test(te.layers)&&(h.pushLight($),$.castShadow&&h.pushShadow($))}),h.setupLights(p.physicallyCorrectLights),B.traverse(function($){let le=$.material;if(le)if(Array.isArray(le))for(let Je=0;Je<le.length;Je++){let rt=le[Je];se(rt,B,$)}else se(le,B,$)}),g.pop(),h=null};let ie=null;function pe(B){ie&&ie(B)}function Re(){pt.stop()}function Oe(){pt.start()}let pt=new oA;pt.setAnimationLoop(pe),typeof self<"u"&&pt.setContext(self),this.setAnimationLoop=function(B){ie=B,De.setAnimationLoop(B),B===null?pt.stop():pt.start()},De.addEventListener("sessionstart",Re),De.addEventListener("sessionend",Oe),this.render=function(B,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;B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),De.enabled===!0&&De.isPresenting===!0&&(De.cameraAutoUpdate===!0&&De.updateCamera(te),te=De.getCamera()),B.isScene===!0&&B.onBeforeRender(p,B,te,x),h=L.get(B,g.length),h.init(),g.push(h),X.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),Y.setFromProjectionMatrix(X),q=this.localClippingEnabled,W=O.init(this.clippingPlanes,q),d=ht.get(B,f.length),d.init(),f.push(d),Sn(B,te,0,p.sortObjects),d.finish(),p.sortObjects===!0&&d.sort(P,C),W===!0&&O.beginShadows();let se=h.state.shadowsArray;if(ee.render(se,B,te),W===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),fe.render(d,B),h.setupLights(p.physicallyCorrectLights),te.isArrayCamera){let $=te.cameras;for(let le=0,Je=$.length;le<Je;le++){let rt=$[le];ln(d,B,rt,rt.viewport)}}else ln(d,B,te);x!==null&&(ae.updateMultisampleRenderTarget(x),ae.updateRenderTargetMipmap(x)),B.isScene===!0&&B.onAfterRender(p,B,te),ce.resetDefaultState(),S=-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 Sn(B,te,se,$){if(B.visible===!1)return;if(B.layers.test(te.layers)){if(B.isGroup)se=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(te);else if(B.isLight)h.pushLight(B),B.castShadow&&h.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||Y.intersectsSprite(B)){$&&U.setFromMatrixPosition(B.matrixWorld).applyMatrix4(X);let rt=Me.update(B),ot=B.material;ot.visible&&d.push(B,rt,ot,se,U.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(B.isSkinnedMesh&&B.skeleton.frame!==ue.render.frame&&(B.skeleton.update(),B.skeleton.frame=ue.render.frame),!B.frustumCulled||Y.intersectsObject(B))){$&&U.setFromMatrixPosition(B.matrixWorld).applyMatrix4(X);let rt=Me.update(B),ot=B.material;if(Array.isArray(ot)){let lt=rt.groups;for(let At=0,mt=lt.length;At<mt;At++){let gt=lt[At],wn=ot[gt.materialIndex];wn&&wn.visible&&d.push(B,rt,wn,se,U.z,gt)}}else ot.visible&&d.push(B,rt,ot,se,U.z,null)}}let Je=B.children;for(let rt=0,ot=Je.length;rt<ot;rt++)Sn(Je[rt],te,se,$)}function ln(B,te,se,$){let le=B.opaque,Je=B.transmissive,rt=B.transparent;h.setupLightsView(se),W===!0&&O.setGlobalState(p.clippingPlanes,se),Je.length>0&&Aa(le,te,se),$&&k.viewport(E.copy($)),le.length>0&&Xt(le,te,se),Je.length>0&&Xt(Je,te,se),rt.length>0&&Xt(rt,te,se),k.buffers.depth.setTest(!0),k.buffers.depth.setMask(!0),k.buffers.color.setMask(!0),k.setPolygonOffset(!1)}function Aa(B,te,se){let $=Z.isWebGL2;j===null&&(j=new Et(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")?Bd:jt,minFilter:Ra,samples:$&&s===!0?4:0})),p.getDrawingBufferSize(N),$?j.setSize(N.x,N.y):j.setSize(vp(N.x),vp(N.y));let le=p.getRenderTarget();p.setRenderTarget(j),p.clear();let Je=p.toneMapping;p.toneMapping=js,Xt(B,te,se),p.toneMapping=Je,ae.updateMultisampleRenderTarget(j),ae.updateRenderTargetMipmap(j),p.setRenderTarget(le)}function Xt(B,te,se){let $=te.isScene===!0?te.overrideMaterial:null;for(let le=0,Je=B.length;le<Je;le++){let rt=B[le],ot=rt.object,lt=rt.geometry,At=$===null?rt.material:$,mt=rt.group;ot.layers.test(se.layers)&&Rs(ot,te,se,lt,At,mt)}}function Rs(B,te,se,$,le,Je){B.onBeforeRender(p,te,se,$,le,Je),B.modelViewMatrix.multiplyMatrices(se.matrixWorldInverse,B.matrixWorld),B.normalMatrix.getNormalMatrix(B.modelViewMatrix),le.onBeforeRender(p,te,se,$,B,Je),le.transparent===!0&&le.side===br&&le.forceSinglePass===!1?(le.side=_n,le.needsUpdate=!0,p.renderBufferDirect(se,te,$,le,B,Je),le.side=Kr,le.needsUpdate=!0,p.renderBufferDirect(se,te,$,le,B,Je),le.side=br):p.renderBufferDirect(se,te,$,le,B,Je),B.onAfterRender(p,te,se,$,le,Je)}function li(B,te,se){te.isScene!==!0&&(te=z);let $=he.get(B),le=h.state.lights,Je=h.state.shadowsArray,rt=le.state.version,ot=xe.getParameters(B,le.state,Je,te,se),lt=xe.getProgramCacheKey(ot),At=$.programs;$.environment=B.isMeshStandardMaterial?te.environment:null,$.fog=te.fog,$.envMap=(B.isMeshStandardMaterial?be:me).get(B.envMap||$.environment),At===void 0&&(B.addEventListener("dispose",Ft),At=new Map,$.programs=At);let mt=At.get(lt);if(mt!==void 0){if($.currentProgram===mt&&$.lightsStateVersion===rt)return mw(B,ot),mt}else ot.uniforms=xe.getUniforms(B),B.onBuild(se,ot,p),B.onBeforeCompile(ot,p),mt=xe.acquireProgram(ot,lt),At.set(lt,mt),$.uniforms=ot.uniforms;let gt=$.uniforms;(!B.isShaderMaterial&&!B.isRawShaderMaterial||B.clipping===!0)&&(gt.clippingPlanes=O.uniform),mw(B,ot),$.needsLights=kI(B),$.lightsStateVersion=rt,$.needsLights&&(gt.ambientLightColor.value=le.state.ambient,gt.lightProbe.value=le.state.probe,gt.directionalLights.value=le.state.directional,gt.directionalLightShadows.value=le.state.directionalShadow,gt.spotLights.value=le.state.spot,gt.spotLightShadows.value=le.state.spotShadow,gt.rectAreaLights.value=le.state.rectArea,gt.ltc_1.value=le.state.rectAreaLTC1,gt.ltc_2.value=le.state.rectAreaLTC2,gt.pointLights.value=le.state.point,gt.pointLightShadows.value=le.state.pointShadow,gt.hemisphereLights.value=le.state.hemi,gt.directionalShadowMap.value=le.state.directionalShadowMap,gt.directionalShadowMatrix.value=le.state.directionalShadowMatrix,gt.spotShadowMap.value=le.state.spotShadowMap,gt.spotLightMatrix.value=le.state.spotLightMatrix,gt.spotLightMap.value=le.state.spotLightMap,gt.pointShadowMap.value=le.state.pointShadowMap,gt.pointShadowMatrix.value=le.state.pointShadowMatrix);let wn=mt.getUniforms(),qr=jl.seqWithValue(wn.seq,gt);return $.currentProgram=mt,$.uniformsList=qr,mt}function mw(B,te){let se=he.get(B);se.outputEncoding=te.outputEncoding,se.instancing=te.instancing,se.skinning=te.skinning,se.morphTargets=te.morphTargets,se.morphNormals=te.morphNormals,se.morphColors=te.morphColors,se.morphTargetsCount=te.morphTargetsCount,se.numClippingPlanes=te.numClippingPlanes,se.numIntersection=te.numClipIntersection,se.vertexAlphas=te.vertexAlphas,se.vertexTangents=te.vertexTangents,se.toneMapping=te.toneMapping}function UI(B,te,se,$,le){te.isScene!==!0&&(te=z),ae.resetTextureUnits();let Je=te.fog,rt=$.isMeshStandardMaterial?te.environment:null,ot=x===null?p.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Zr,lt=($.isMeshStandardMaterial?be:me).get($.envMap||rt),At=$.vertexColors===!0&&!!se.attributes.color&&se.attributes.color.itemSize===4,mt=!!$.normalMap&&!!se.attributes.tangent,gt=!!se.morphAttributes.position,wn=!!se.morphAttributes.normal,qr=!!se.morphAttributes.color,Ns=$.toneMapped?p.toneMapping:js,Ea=se.morphAttributes.position||se.morphAttributes.normal||se.morphAttributes.color,An=Ea!==void 0?Ea.length:0,yt=he.get($),nv=h.state.lights;if(W===!0&&(q===!0||B!==w)){let Xr=B===w&&$.id===S;O.setState($,B,Xr)}let Wn=!1;$.version===yt.__version?(yt.needsLights&&yt.lightsStateVersion!==nv.state.version||yt.outputEncoding!==ot||le.isInstancedMesh&&yt.instancing===!1||!le.isInstancedMesh&&yt.instancing===!0||le.isSkinnedMesh&&yt.skinning===!1||!le.isSkinnedMesh&&yt.skinning===!0||yt.envMap!==lt||$.fog===!0&&yt.fog!==Je||yt.numClippingPlanes!==void 0&&(yt.numClippingPlanes!==O.numPlanes||yt.numIntersection!==O.numIntersection)||yt.vertexAlphas!==At||yt.vertexTangents!==mt||yt.morphTargets!==gt||yt.morphNormals!==wn||yt.morphColors!==qr||yt.toneMapping!==Ns||Z.isWebGL2===!0&&yt.morphTargetsCount!==An)&&(Wn=!0):(Wn=!0,yt.__version=$.version);let _a=yt.currentProgram;Wn===!0&&(_a=li($,te,le));let gw=!1,bd=!1,rv=!1,mr=_a.getUniforms(),Ta=yt.uniforms;if(k.useProgram(_a.program)&&(gw=!0,bd=!0,rv=!0),$.id!==S&&(S=$.id,bd=!0),gw||w!==B){if(mr.setValue(V,"projectionMatrix",B.projectionMatrix),Z.logarithmicDepthBuffer&&mr.setValue(V,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),w!==B&&(w=B,bd=!0,rv=!0),$.isShaderMaterial||$.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshStandardMaterial||$.envMap){let Xr=mr.map.cameraPosition;Xr!==void 0&&Xr.setValue(V,U.setFromMatrixPosition(B.matrixWorld))}($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial)&&mr.setValue(V,"isOrthographic",B.isOrthographicCamera===!0),($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial||$.isShadowMaterial||le.isSkinnedMesh)&&mr.setValue(V,"viewMatrix",B.matrixWorldInverse)}if(le.isSkinnedMesh){mr.setOptional(V,le,"bindMatrix"),mr.setOptional(V,le,"bindMatrixInverse");let Xr=le.skeleton;Xr&&(Z.floatVertexTextures?(Xr.boneTexture===null&&Xr.computeBoneTexture(),mr.setValue(V,"boneTexture",Xr.boneTexture,ae),mr.setValue(V,"boneTextureSize",Xr.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 iv=se.morphAttributes;if((iv.position!==void 0||iv.normal!==void 0||iv.color!==void 0&&Z.isWebGL2===!0)&&ye.update(le,se,$,_a),(bd||yt.receiveShadow!==le.receiveShadow)&&(yt.receiveShadow=le.receiveShadow,mr.setValue(V,"receiveShadow",le.receiveShadow)),$.isMeshGouraudMaterial&&$.envMap!==null&&(Ta.envMap.value=lt,Ta.flipEnvMap.value=lt.isCubeTexture&&lt.isRenderTargetTexture===!1?-1:1),bd&&(mr.setValue(V,"toneMappingExposure",p.toneMappingExposure),yt.needsLights&&GI(Ta,rv),Je&&$.fog===!0&&Ge.refreshFogUniforms(Ta,Je),Ge.refreshMaterialUniforms(Ta,$,D,M,j),jl.upload(V,yt.uniformsList,Ta,ae)),$.isShaderMaterial&&$.uniformsNeedUpdate===!0&&(jl.upload(V,yt.uniformsList,Ta,ae),$.uniformsNeedUpdate=!1),$.isSpriteMaterial&&mr.setValue(V,"center",le.center),mr.setValue(V,"modelViewMatrix",le.modelViewMatrix),mr.setValue(V,"normalMatrix",le.normalMatrix),mr.setValue(V,"modelMatrix",le.matrixWorld),$.isShaderMaterial||$.isRawShaderMaterial){let Xr=$.uniformsGroups;for(let sv=0,VI=Xr.length;sv<VI;sv++)if(Z.isWebGL2){let yw=Xr[sv];je.update(yw,_a),je.bind(yw,_a)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return _a}function GI(B,te){B.ambientLightColor.needsUpdate=te,B.lightProbe.needsUpdate=te,B.directionalLights.needsUpdate=te,B.directionalLightShadows.needsUpdate=te,B.pointLights.needsUpdate=te,B.pointLightShadows.needsUpdate=te,B.spotLights.needsUpdate=te,B.spotLightShadows.needsUpdate=te,B.rectAreaLights.needsUpdate=te,B.hemisphereLights.needsUpdate=te}function kI(B){return B.isMeshLambertMaterial||B.isMeshToonMaterial||B.isMeshPhongMaterial||B.isMeshStandardMaterial||B.isShadowMaterial||B.isShaderMaterial&&B.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(B,te,se){he.get(B.texture).__webglTexture=te,he.get(B.depthTexture).__webglTexture=se;let $=he.get(B);$.__hasExternalTextures=!0,$.__hasExternalTextures&&($.__autoAllocateDepthBuffer=se===void 0,$.__autoAllocateDepthBuffer||K.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(B,te){let se=he.get(B);se.__webglFramebuffer=te,se.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(B,te=0,se=0){x=B,y=te,v=se;let $=!0,le=null,Je=!1,rt=!1;if(B){let lt=he.get(B);lt.__useDefaultFramebuffer!==void 0?(k.bindFramebuffer(36160,null),$=!1):lt.__webglFramebuffer===void 0?ae.setupRenderTarget(B):lt.__hasExternalTextures&&ae.rebindTextures(B,he.get(B.texture).__webglTexture,he.get(B.depthTexture).__webglTexture);let At=B.texture;(At.isData3DTexture||At.isDataArrayTexture||At.isCompressedArrayTexture)&&(rt=!0);let mt=he.get(B).__webglFramebuffer;B.isWebGLCubeRenderTarget?(le=mt[te],Je=!0):Z.isWebGL2&&B.samples>0&&ae.useMultisampledRTT(B)===!1?le=he.get(B).__webglMultisampledFramebuffer:le=mt,E.copy(B.viewport),_.copy(B.scissor),b=B.scissorTest}else E.copy(I).multiplyScalar(D).floor(),_.copy(R).multiplyScalar(D).floor(),b=G;if(k.bindFramebuffer(36160,le)&&Z.drawBuffers&&$&&k.drawBuffers(B,le),k.viewport(E),k.scissor(_),k.setScissorTest(b),Je){let lt=he.get(B.texture);V.framebufferTexture2D(36160,36064,34069+te,lt.__webglTexture,se)}else if(rt){let lt=he.get(B.texture),At=te||0;V.framebufferTextureLayer(36160,36064,lt.__webglTexture,se||0,At)}S=-1},this.readRenderTargetPixels=function(B,te,se,$,le,Je,rt){if(!(B&&B.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ot=he.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&rt!==void 0&&(ot=ot[rt]),ot){k.bindFramebuffer(36160,ot);try{let lt=B.texture,At=lt.format,mt=lt.type;if(At!==ui&&Pe.convert(At)!==V.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let gt=mt===Bd&&(K.has("EXT_color_buffer_half_float")||Z.isWebGL2&&K.has("EXT_color_buffer_float"));if(mt!==jt&&Pe.convert(mt)!==V.getParameter(35738)&&!(mt===ns&&(Z.isWebGL2||K.has("OES_texture_float")||K.has("WEBGL_color_buffer_float")))&&!gt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=B.width-$&&se>=0&&se<=B.height-le&&V.readPixels(te,se,$,le,Pe.convert(At),Pe.convert(mt),Je)}finally{let lt=x!==null?he.get(x).__webglFramebuffer:null;k.bindFramebuffer(36160,lt)}}},this.copyFramebufferToTexture=function(B,te,se=0){let $=Math.pow(2,-se),le=Math.floor(te.image.width*$),Je=Math.floor(te.image.height*$);ae.setTexture2D(te,0),V.copyTexSubImage2D(3553,se,0,0,B.x,B.y,le,Je),k.unbindTexture()},this.copyTextureToTexture=function(B,te,se,$=0){let le=te.image.width,Je=te.image.height,rt=Pe.convert(se.format),ot=Pe.convert(se.type);ae.setTexture2D(se,0),V.pixelStorei(37440,se.flipY),V.pixelStorei(37441,se.premultiplyAlpha),V.pixelStorei(3317,se.unpackAlignment),te.isDataTexture?V.texSubImage2D(3553,$,B.x,B.y,le,Je,rt,ot,te.image.data):te.isCompressedTexture?V.compressedTexSubImage2D(3553,$,B.x,B.y,te.mipmaps[0].width,te.mipmaps[0].height,rt,te.mipmaps[0].data):V.texSubImage2D(3553,$,B.x,B.y,rt,ot,te.image),$===0&&se.generateMipmaps&&V.generateMipmap(3553),k.unbindTexture()},this.copyTextureToTexture3D=function(B,te,se,$,le=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Je=B.max.x-B.min.x+1,rt=B.max.y-B.min.y+1,ot=B.max.z-B.min.z+1,lt=Pe.convert($.format),At=Pe.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}V.pixelStorei(37440,$.flipY),V.pixelStorei(37441,$.premultiplyAlpha),V.pixelStorei(3317,$.unpackAlignment);let gt=V.getParameter(3314),wn=V.getParameter(32878),qr=V.getParameter(3316),Ns=V.getParameter(3315),Ea=V.getParameter(32877),An=se.isCompressedTexture?se.mipmaps[0]:se.image;V.pixelStorei(3314,An.width),V.pixelStorei(32878,An.height),V.pixelStorei(3316,B.min.x),V.pixelStorei(3315,B.min.y),V.pixelStorei(32877,B.min.z),se.isDataTexture||se.isData3DTexture?V.texSubImage3D(mt,le,te.x,te.y,te.z,Je,rt,ot,lt,At,An.data):se.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),V.compressedTexSubImage3D(mt,le,te.x,te.y,te.z,Je,rt,ot,lt,An.data)):V.texSubImage3D(mt,le,te.x,te.y,te.z,Je,rt,ot,lt,At,An),V.pixelStorei(3314,gt),V.pixelStorei(32878,wn),V.pixelStorei(3316,qr),V.pixelStorei(3315,Ns),V.pixelStorei(32877,Ea),le===0&&$.generateMipmaps&&V.generateMipmap(mt),k.unbindTexture()},this.initTexture=function(B){B.isCubeTexture?ae.setTextureCube(B,0):B.isData3DTexture?ae.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?ae.setTexture2DArray(B,0):ae.setTexture2D(B,0),k.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,k.reset(),ce.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var a0=class extends I0{};a0.prototype.isWebGL1Renderer=!0;var Ql=class{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ne(t),this.near=e,this.far=n}clone(){return new Ql(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Sr=class extends ct{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}},Tp=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Xv,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=is()}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=is()),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=is()),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}}},yr=new A,Fa=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++)yr.fromBufferAttribute(this,e),yr.applyMatrix4(t),this.setXYZ(e,yr.x,yr.y,yr.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)yr.fromBufferAttribute(this,e),yr.applyNormalMatrix(t),this.setXYZ(e,yr.x,yr.y,yr.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)yr.fromBufferAttribute(this,e),yr.transformDirection(t),this.setXYZ(e,yr.x,yr.y,yr.z);return this}setX(t,e){return this.normalized&&(e=Nt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Nt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Nt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Nt(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=Ws(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ws(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ws(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ws(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Nt(e,this.array),n=Nt(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=Nt(e,this.array),n=Nt(n,this.array),i=Nt(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=Nt(e,this.array),n=Nt(n,this.array),i=Nt(i,this.array),s=Nt(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 Fe(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 Fa(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 Mp=class extends Fe{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 di=class extends Na{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ne(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}},O1=new A,L1=new A,R1=new de,Fv=new Ci,ap=new Tn,Ua=class extends ct{constructor(t=new _e,e=new di){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++)O1.fromBufferAttribute(e,i-1),L1.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=O1.distanceTo(L1);t.setAttribute("lineDistance",new Se(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(),ap.copy(n.boundingSphere),ap.applyMatrix4(i),ap.radius+=s,t.ray.intersectsSphere(ap)===!1)return;R1.copy(i).invert(),Fv.copy(t.ray).applyMatrix4(R1);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new A,c=new A,d=new A,h=new A,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,S=v-1;x<S;x+=f){let w=g.getX(x),E=g.getX(x+1);if(u.fromBufferAttribute(m,w),c.fromBufferAttribute(m,E),Fv.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(h);b<t.near||b>t.far||e.push({distance:b,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,S=v-1;x<S;x+=f){if(u.fromBufferAttribute(m,x),c.fromBufferAttribute(m,x+1),Fv.distanceSqToSegment(u,c,h,d)>l)continue;h.applyMatrix4(this.matrixWorld);let E=t.ray.origin.distanceTo(h);E<t.near||E>t.far||e.push({distance:E,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}}}}},N1=new A,B1=new A,Bo=class extends Ua{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)N1.fromBufferAttribute(e,i),B1.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+N1.distanceTo(B1);t.setAttribute("lineDistance",new Se(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Cp=class extends Wt{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:it,this.magFilter=s!==void 0?s:it,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 hi=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 A);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new A,i=[],s=[],o=[],a=new A,l=new de;for(let f=0;f<=t;f++){let g=f/t;i[f]=this.getTangentAt(g,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(i[0].x),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(On(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(On(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}},Ga=class extends hi{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}},l0=class extends Ga{constructor(t,e,n,i,s,o){super(t,e,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function O0(){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 lp=new A,Uv=new O0,Gv=new O0,kv=new O0,c0=class extends hi{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 A){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]:(lp.subVectors(i[0],i[1]).add(i[0]),u=lp);let d=i[a%s],h=i[(a+1)%s];if(this.closed||a+2<s?c=i[(a+2)%s]:(lp.subVectors(i[s-1],i[s-2]).add(i[s-1]),c=lp),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),Uv.initNonuniformCatmullRom(u.x,d.x,h.x,c.x,g,p,m),Gv.initNonuniformCatmullRom(u.y,d.y,h.y,c.y,g,p,m),kv.initNonuniformCatmullRom(u.z,d.z,h.z,c.z,g,p,m)}else this.curveType==="catmullrom"&&(Uv.initCatmullRom(u.x,d.x,h.x,c.x,this.tension),Gv.initCatmullRom(u.y,d.y,h.y,c.y,this.tension),kv.initCatmullRom(u.z,d.z,h.z,c.z,this.tension));return n.set(Uv.calc(l),Gv.calc(l),kv.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 A().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function F1(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 kN(r,t){let e=1-r;return e*e*t}function VN(r,t){return 2*(1-r)*r*t}function zN(r,t){return r*r*t}function Rd(r,t,e,n){return kN(r,t)+VN(r,e)+zN(r,n)}function HN(r,t){let e=1-r;return e*e*e*t}function WN(r,t){let e=1-r;return 3*e*e*r*t}function jN(r,t){return 3*(1-r)*r*r*t}function qN(r,t){return r*r*r*t}function Nd(r,t,e,n,i){return HN(r,t)+WN(r,e)+jN(r,n)+qN(r,i)}var cr=class extends hi{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(Nd(t,i.x,s.x,o.x,a.x),Nd(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}},ka=class extends hi{constructor(t=new A,e=new A,n=new A,i=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new A){let n=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Nd(t,i.x,s.x,o.x,a.x),Nd(t,i.y,s.y,o.y,a.y),Nd(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}},ur=class extends hi{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}},zd=class extends hi{constructor(t=new A,e=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new A){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Jr=class extends hi{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(Rd(t,i.x,s.x,o.x),Rd(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}},u0=class extends hi{constructor(t=new A,e=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new A){let n=e,i=this.v0,s=this.v1,o=this.v2;return n.set(Rd(t,i.x,s.x,o.x),Rd(t,i.y,s.y,o.y),Rd(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}},Kl=class extends hi{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(F1(a,l.x,u.x,c.x,d.x),F1(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}},XN=Object.freeze({__proto__:null,ArcCurve:l0,CatmullRomCurve3:c0,CubicBezierCurve:cr,CubicBezierCurve3:ka,EllipseCurve:Ga,LineCurve:ur,LineCurve3:zd,QuadraticBezierCurve:Jr,QuadraticBezierCurve3:u0,SplineCurve:Kl}),Hd=class extends hi{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 ur(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 XN[i.type]().fromJSON(i))}return this}},Va=class extends Hd{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 ur(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 Jr(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 cr(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 Kl(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 Ga(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}},Zl=class extends _e{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=On(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,d=new A,h=new F,f=new A,g=new A,p=new A,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,S=Math.sin(x),w=Math.cos(x);for(let E=0;E<=t.length-1;E++){d.x=t[E].x*S,d.y=t[E].y,d.z=t[E].x*w,o.push(d.x,d.y,d.z),h.x=v/e,h.y=E/(t.length-1),a.push(h.x,h.y);let _=l[3*E+0]*S,b=l[3*E+1],T=l[3*E+0]*w;u.push(_,b,T)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let S=x+v*t.length,w=S,E=S+t.length,_=S+t.length+1,b=S+1;s.push(w,E,b),s.push(_,b,E)}this.setIndex(s),this.setAttribute("position",new Se(o,3)),this.setAttribute("uv",new Se(a,2)),this.setAttribute("normal",new Se(u,3))}static fromJSON(t){return new Zl(t.points,t.segments,t.phiStart,t.phiLength)}};var za=class extends _e{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 Se(d,3)),this.setAttribute("normal",new Se(h,3)),this.setAttribute("uv",new Se(f,2));function v(){let S=new A,w=new A,E=0,_=(e-t)/n;for(let b=0;b<=s;b++){let T=[],M=b/s,D=M*(e-t)+t;for(let P=0;P<=i;P++){let C=P/i,I=C*l+a,R=Math.sin(I),G=Math.cos(I);w.x=D*R,w.y=-M*n+m,w.z=D*G,d.push(w.x,w.y,w.z),S.set(R,_,G).normalize(),h.push(S.x,S.y,S.z),f.push(C,1-M),T.push(g++)}p.push(T)}for(let b=0;b<i;b++)for(let T=0;T<s;T++){let M=p[T][b],D=p[T+1][b],P=p[T+1][b+1],C=p[T][b+1];c.push(M,D,C),c.push(D,P,C),E+=6}u.addGroup(y,E,0),y+=E}function x(S){let w=g,E=new F,_=new A,b=0,T=S===!0?t:e,M=S===!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 D=g;for(let P=0;P<=i;P++){let I=P/i*l+a,R=Math.cos(I),G=Math.sin(I);_.x=T*G,_.y=m*M,_.z=T*R,d.push(_.x,_.y,_.z),h.push(0,M,0),E.x=R*.5+.5,E.y=G*.5*M+.5,f.push(E.x,E.y),g++}for(let P=0;P<i;P++){let C=w+P,I=D+P;S===!0?c.push(I,I+1,C):c.push(I+1,I,C),b+=3}u.addGroup(y,b,S===!0?1:2),y+=b}}static fromJSON(t){return new za(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Jl=class extends za{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 Jl(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},$l=class extends _e{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 Se(s,3)),this.setAttribute("normal",new Se(s.slice(),3)),this.setAttribute("uv",new Se(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new A,S=new A,w=new A;for(let E=0;E<e.length;E+=3)f(e[E+0],x),f(e[E+1],S),f(e[E+2],w),l(x,S,w,v)}function l(v,x,S,w){let E=w+1,_=[];for(let b=0;b<=E;b++){_[b]=[];let T=v.clone().lerp(S,b/E),M=x.clone().lerp(S,b/E),D=E-b;for(let P=0;P<=D;P++)P===0&&b===E?_[b][P]=T:_[b][P]=T.clone().lerp(M,P/D)}for(let b=0;b<E;b++)for(let T=0;T<2*(E-b)-1;T++){let M=Math.floor(T/2);T%2===0?(h(_[b][M+1]),h(_[b+1][M]),h(_[b][M])):(h(_[b][M+1]),h(_[b+1][M+1]),h(_[b+1][M]))}}function u(v){let x=new A;for(let S=0;S<s.length;S+=3)x.x=s[S+0],x.y=s[S+1],x.z=s[S+2],x.normalize().multiplyScalar(v),s[S+0]=x.x,s[S+1]=x.y,s[S+2]=x.z}function c(){let v=new A;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let S=m(v)/2/Math.PI+.5,w=y(v)/Math.PI+.5;o.push(S,1-w)}g(),d()}function d(){for(let v=0;v<o.length;v+=6){let x=o[v+0],S=o[v+2],w=o[v+4],E=Math.max(x,S,w),_=Math.min(x,S,w);E>.9&&_<.1&&(x<.2&&(o[v+0]+=1),S<.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 S=v*3;x.x=t[S+0],x.y=t[S+1],x.z=t[S+2]}function g(){let v=new A,x=new A,S=new A,w=new A,E=new F,_=new F,b=new F;for(let T=0,M=0;T<s.length;T+=9,M+=6){v.set(s[T+0],s[T+1],s[T+2]),x.set(s[T+3],s[T+4],s[T+5]),S.set(s[T+6],s[T+7],s[T+8]),E.set(o[M+0],o[M+1]),_.set(o[M+2],o[M+3]),b.set(o[M+4],o[M+5]),w.copy(v).add(x).add(S).divideScalar(3);let D=m(w);p(E,M+0,v,D),p(_,M+2,x,D),p(b,M+4,S,D)}}function p(v,x,S,w){w<0&&v.x===1&&(o[x]=v.x-1),S.x===0&&S.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 $l(t.vertices,t.indices,t.radius,t.details)}},ec=class extends $l{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 ec(t.radius,t.detail)}};var Ys=class extends Va{constructor(t){super(t),this.uuid=is(),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 Va().fromJSON(i))}return this}},YN={triangulate:function(r,t,e=2){let n=t&&t.length,i=n?t[0]*e:r.length,s=dA(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 Wd(s,o,e,a,l,f,0),o}};function dA(r,t,e,n,i){let s,o;if(i===uB(r,t,e,n)>0)for(s=t;s<e;s+=n)o=U1(s,r[s],r[s+1],o);else for(s=e-n;s>=t;s-=n)o=U1(s,r[s],r[s+1],o);return o&&Vp(o,o.next)&&(qd(o),o=o.next),o}function Ha(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(Vp(e,e.next)||en(e.prev,e,e.next)===0)){if(qd(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Wd(r,t,e,n,i,s,o){if(!r)return;!o&&s&&iB(r,n,i,s);let a=r,l,u;for(;r.prev!==r.next;){if(l=r.prev,u=r.next,s?KN(r,n,i,s):QN(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(u.i/e|0),qd(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=ZN(Ha(r),t,e),Wd(r,t,e,n,i,s,2)):o===2&&JN(r,t,e,n,i,s):Wd(Ha(r),t,e,n,i,s,1);break}}}function QN(r){let t=r.prev,e=r,n=r.next;if(en(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&&Hl(i,a,s,l,o,u,g.x,g.y)&&en(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function KN(r,t,e,n){let i=r.prev,s=r,o=r.next;if(en(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=d0(f,g,t,e,n),v=d0(p,m,t,e,n),x=r.prevZ,S=r.nextZ;for(;x&&x.z>=y&&S&&S.z<=v;){if(x.x>=f&&x.x<=p&&x.y>=g&&x.y<=m&&x!==i&&x!==o&&Hl(a,c,l,d,u,h,x.x,x.y)&&en(x.prev,x,x.next)>=0||(x=x.prevZ,S.x>=f&&S.x<=p&&S.y>=g&&S.y<=m&&S!==i&&S!==o&&Hl(a,c,l,d,u,h,S.x,S.y)&&en(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=p&&x.y>=g&&x.y<=m&&x!==i&&x!==o&&Hl(a,c,l,d,u,h,x.x,x.y)&&en(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;S&&S.z<=v;){if(S.x>=f&&S.x<=p&&S.y>=g&&S.y<=m&&S!==i&&S!==o&&Hl(a,c,l,d,u,h,S.x,S.y)&&en(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function ZN(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!Vp(i,s)&&hA(i,n,n.next,s)&&jd(i,s)&&jd(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),qd(n),qd(n.next),n=r=s),n=n.next}while(n!==r);return Ha(n)}function JN(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&aB(o,a)){let l=fA(o,a);o=Ha(o,o.next),l=Ha(l,l.next),Wd(o,t,e,n,i,s,0),Wd(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=dA(r,a,l,n,!1),u===u.next&&(u.steiner=!0),i.push(oB(u));for(i.sort(eB),s=0;s<i.length;s++)e=tB(i[s],e);return e}function eB(r,t){return r.x-t.x}function tB(r,t){let e=nB(r,t);if(!e)return t;let n=fA(e,r);return Ha(n,n.next),Ha(e,e.next)}function nB(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&&Hl(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),jd(e,r)&&(d<c||d===c&&(e.x>i.x||e.x===i.x&&rB(i,e)))&&(i=e,c=d)),e=e.next;while(e!==a);return i}function rB(r,t){return en(r.prev,r,t.prev)<0&&en(t.next,r,r.next)<0}function iB(r,t,e,n){let i=r;do i.z===0&&(i.z=d0(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,sB(i)}function sB(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 d0(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 oB(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 Hl(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 aB(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!lB(r,t)&&(jd(r,t)&&jd(t,r)&&cB(r,t)&&(en(r.prev,r,t.prev)||en(r,t.prev,t))||Vp(r,t)&&en(r.prev,r,r.next)>0&&en(t.prev,t,t.next)>0)}function en(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Vp(r,t){return r.x===t.x&&r.y===t.y}function hA(r,t,e,n){let i=up(en(r,t,e)),s=up(en(r,t,n)),o=up(en(e,n,r)),a=up(en(e,n,t));return!!(i!==s&&o!==a||i===0&&cp(r,e,t)||s===0&&cp(r,n,t)||o===0&&cp(e,r,n)||a===0&&cp(e,t,n))}function cp(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 up(r){return r>0?1:r<0?-1:0}function lB(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&&hA(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function jd(r,t){return en(r.prev,r,r.next)<0?en(r,t,r.next)>=0&&en(r,r.prev,t)>=0:en(r,t,r.prev)<0||en(r,r.next,t)<0}function cB(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 fA(r,t){let e=new h0(r.i,r.x,r.y),n=new h0(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 U1(r,t,e,n){let i=new h0(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 qd(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 h0(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 uB(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 tc=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 tc.area(t)<0}static triangulateShape(t,e){let n=[],i=[],s=[];G1(t),k1(n,t);let o=t.length;e.forEach(G1);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,k1(n,e[l]);let a=YN.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function G1(r){let t=r.length;t>2&&r[t-1].equals(r[0])&&r.pop()}function k1(r,t){for(let e=0;e<t.length;e++)r.push(t[e].x),r.push(t[e].y)}var nc=class extends $l{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 nc(t.radius,t.detail)}};var Wa=class extends _e{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 A,h=new A,f=[],g=[],p=[],m=[];for(let y=0;y<=n;y++){let v=[],x=y/n,S=0;y==0&&o==0?S=.5/e:y==n&&l==Math.PI&&(S=-.5/e);for(let w=0;w<=e;w++){let E=w/e;d.x=-t*Math.cos(i+E*s)*Math.sin(o+x*a),d.y=t*Math.cos(o+x*a),d.z=t*Math.sin(i+E*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(E+S,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],S=c[y][v],w=c[y+1][v],E=c[y+1][v+1];(y!==0||o>0)&&f.push(x,S,E),(y!==n-1||l<Math.PI)&&f.push(S,w,E)}this.setIndex(f),this.setAttribute("position",new Se(g,3)),this.setAttribute("normal",new Se(p,3)),this.setAttribute("uv",new Se(m,2))}static fromJSON(t){return new Wa(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var rc=class extends _e{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 A,h=new A,f=new A,g=new A,p=new A,m=new A,y=new A;for(let x=0;x<=n;++x){let S=x/n*s*Math.PI*2;v(S,s,o,t,f),v(S+.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 E=w/i*Math.PI*2,_=-e*Math.cos(E),b=e*Math.sin(E);d.x=f.x+(_*y.x+b*p.x),d.y=f.y+(_*y.y+b*p.y),d.z=f.z+(_*y.z+b*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 S=1;S<=i;S++){let w=(i+1)*(x-1)+(S-1),E=(i+1)*x+(S-1),_=(i+1)*x+S,b=(i+1)*(x-1)+S;a.push(w,E,b),a.push(E,_,b)}this.setIndex(a),this.setAttribute("position",new Se(l,3)),this.setAttribute("normal",new Se(u,3)),this.setAttribute("uv",new Se(c,2));function v(x,S,w,E,_){let b=Math.cos(x),T=Math.sin(x),M=w/S*x,D=Math.cos(M);_.x=E*(2+D)*.5*b,_.y=E*(2+D)*T*.5,_.z=E*Math.sin(M)*.5}}static fromJSON(t){return new rc(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function Po(r,t,e){return pA(r)?new r.constructor(r.subarray(t,e!==void 0?e:r.length)):r.slice(t,e)}function dp(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 pA(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var ic=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_(){}},f0=class extends ic{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:Kw,endingEnd:Kw}}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 Zw:s=t,a=2*e-n;break;case Jw: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 Zw:o=t,l=2*n-e;break;case Jw: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,S=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]+S*o[d+w];return s}},p0=class extends ic{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}},m0=class extends ic{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}},Di=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=dp(e,this.TimeBufferType),this.values=dp(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:dp(t.times,Array),values:dp(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new m0(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new p0(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new f0(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case gp:e=this.InterpolantFactoryMethodDiscrete;break;case yp:e=this.InterpolantFactoryMethodLinear;break;case hv: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 gp;case this.InterpolantFactoryMethodLinear:return yp;case this.InterpolantFactoryMethodSmooth:return hv}}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=Po(n,s,o),this.values=Po(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&&pA(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=Po(this.times),e=Po(this.values),n=this.getValueSize(),i=this.getInterpolation()===hv,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=Po(t,0,o),this.values=Po(e,0,o*n)):(this.times=t,this.values=e),this}clone(){let t=Po(this.times,0),e=Po(this.values,0),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};Di.prototype.TimeBufferType=Float32Array;Di.prototype.ValueBufferType=Float32Array;Di.prototype.DefaultInterpolation=yp;var ja=class extends Di{};ja.prototype.ValueTypeName="bool";ja.prototype.ValueBufferType=Array;ja.prototype.DefaultInterpolation=gp;ja.prototype.InterpolantFactoryMethodLinear=void 0;ja.prototype.InterpolantFactoryMethodSmooth=void 0;var g0=class extends Di{};g0.prototype.ValueTypeName="color";var y0=class extends Di{};y0.prototype.ValueTypeName="number";var v0=class extends ic{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)Qe.slerpFlat(s,0,o,u-a,o,u,l);return s}},Xd=class extends Di{InterpolantFactoryMethodLinear(t){return new v0(this.times,this.values,this.getValueSize(),t)}};Xd.prototype.ValueTypeName="quaternion";Xd.prototype.DefaultInterpolation=yp;Xd.prototype.InterpolantFactoryMethodSmooth=void 0;var qa=class extends Di{};qa.prototype.ValueTypeName="string";qa.prototype.ValueBufferType=Array;qa.prototype.DefaultInterpolation=gp;qa.prototype.InterpolantFactoryMethodLinear=void 0;qa.prototype.InterpolantFactoryMethodSmooth=void 0;var x0=class extends Di{};x0.prototype.ValueTypeName="vector";var V1={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={}}},Yd=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}}},dB=new Yd,sc=class{constructor(t){this.manager=t!==void 0?t:dB,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}},zs={},b0=class extends Error{constructor(t,e){super(t),this.response=e}},oc=class extends sc{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=V1.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(zs[t]!==void 0){zs[t].push({onLoad:e,onProgress:n,onError:i});return}zs[t]=[],zs[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=zs[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:S})=>{if(x)y.close();else{p+=S.byteLength;let w=new ProgressEvent("progress",{lengthComputable:g,loaded:p,total:f});for(let E=0,_=c.length;E<_;E++){let b=c[E];b.onProgress&&b.onProgress(w)}y.enqueue(S),v()}})}}});return new Response(m)}else throw new b0(`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=>{V1.add(t,u);let c=zs[t];delete zs[t];for(let d=0,h=c.length;d<h;d++){let f=c[d];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=zs[t];if(c===void 0)throw this.manager.itemError(t),u;delete zs[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 Fo=class extends ct{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Ne(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}},Pp=class extends Fo{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ct.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ne(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},Vv=new de,z1=new A,H1=new A,Qd=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 kd,this._frameExtents=new F(1,1),this._viewportCount=1,this._viewports=[new $e(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;z1.setFromMatrixPosition(t.matrixWorld),e.position.copy(z1),H1.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(H1),e.updateMatrixWorld(),Vv.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Vv),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Vv)}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}},S0=class extends Qd{constructor(){super(new un(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,n=Ud*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}},Dp=class extends Fo{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(ct.DEFAULT_UP),this.updateMatrix(),this.target=new ct,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new S0}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,Cd=new A,zv=new A,w0=class extends Qd{constructor(){super(new un(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new F(4,2),this._viewportCount=6,this._viewports=[new $e(2,1,1,1),new $e(0,1,1,1),new $e(3,1,1,1),new $e(1,1,1,1),new $e(3,0,1,1),new $e(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,i=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Cd.setFromMatrixPosition(t.matrixWorld),n.position.copy(Cd),zv.copy(n.position),zv.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(zv),n.updateMatrixWorld(),i.makeTranslation(-Cd.x,-Cd.y,-Cd.z),W1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(W1)}},Ip=class extends Fo{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 w0}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}},A0=class extends Qd{constructor(){super(new Ba(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Op=class extends Fo{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ct.DEFAULT_UP),this.updateMatrix(),this.target=new ct,this.shadow=new A0}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var E0=class extends _e{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}},ac=class extends sc{constructor(t){super(t)}load(t,e,n,i){let s=this,o=new oc(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=zf(m.type,y),x=new Tp(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 E0:new _e,a=t.data.index;if(a!==void 0){let f=zf(a.type,a.array);o.setIndex(new Fe(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 Fa(m,g.itemSize,g.offset,g.normalized)}else{let m=zf(g.type,g.array),y=g.isInstancedBufferAttribute?Mp:Fe;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 S=i(t.data,v.data);x=new Fa(S,v.itemSize,v.offset,v.normalized)}else{let S=zf(v.type,v.array);x=new Fe(S,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 A;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new Tn(f,h.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var Lp=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=j1(),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=j1();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function j1(){return(typeof performance>"u"?Date:performance).now()}var L0="\\[\\]\\.:\\/",hB=new RegExp("["+L0+"]","g"),R0="[^"+L0+"]",fB="[^"+L0.replace("\\.","")+"]",pB=/((?:WC+[\/:])*)/.source.replace("WC",R0),mB=/(WCOD+)?/.source.replace("WCOD",fB),gB=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",R0),yB=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",R0),vB=new RegExp("^"+pB+mB+gB+yB+"$"),xB=["material","materials","bones","map"],_0=class{constructor(t,e,n){let i=n||Pt.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()}},Pt=class{constructor(t,e,n){this.path=e,this.parsedPath=n||Pt.parseTrackName(e),this.node=Pt.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 Pt.Composite(t,e,n):new Pt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(hB,"")}static parseTrackName(t){let e=vB.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);xB.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=Pt.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}};Pt.Composite=_0;Pt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Pt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Pt.prototype.GetterByBindingType=[Pt.prototype._getValue_direct,Pt.prototype._getValue_array,Pt.prototype._getValue_arrayElement,Pt.prototype._getValue_toArray];Pt.prototype.SetterByBindingTypeAndVersioning=[[Pt.prototype._setValue_direct,Pt.prototype._setValue_direct_setNeedsUpdate,Pt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Pt.prototype._setValue_array,Pt.prototype._setValue_array_setNeedsUpdate,Pt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Pt.prototype._setValue_arrayElement,Pt.prototype._setValue_arrayElement_setNeedsUpdate,Pt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Pt.prototype._setValue_fromArray,Pt.prototype._setValue_fromArray_setNeedsUpdate,Pt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var p8=new Float32Array(1);var we=class{constructor(t){this.value=t}clone(){return new we(this.value.clone===void 0?this.value:this.value.clone())}};var lc=class{constructor(t,e,n=0,i=1/0){this.ray=new Ci(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new Gd,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 T0(t,this,n,e),n.sort(q1),n}intersectObjects(t,e=!0,n=[]){for(let i=0,s=t.length;i<s;i++)T0(t[i],this,n,e);return n.sort(q1),n}};function q1(r,t){return r.distance-t.distance}function T0(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++)T0(i[s],t,e,!0)}}var Kd=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(On(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var X1=new F,Rp=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=X1.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 X1.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)}},Y1=new A,hp=new A,Nn=class{constructor(t=new A,e=new A){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Y1.subVectors(t,this.start),hp.subVectors(this.end,this.start);let n=hp.dot(hp),s=hp.dot(Y1)/n;return e&&(s=On(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)}},Q1=new A,Np=class extends ct{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new _e,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 Se(i,3));let s=new di({fog:!1,toneMapped:!1});this.cone=new Bo(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),Q1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Q1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Bp=class extends qn{constructor(t,e,n){let i=new Wa(e,4,2),s=new qs({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 K1=new A,fp=new A,Z1=new A,Fp=class extends ct{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 _e;i.setAttribute("position",new Se([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new di({fog:!1,toneMapped:!1});this.lightPlane=new Ua(i,s),this.add(this.lightPlane),i=new _e,i.setAttribute("position",new Se([0,0,0,0,0,1],3)),this.targetLine=new Ua(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),K1.setFromMatrixPosition(this.light.matrixWorld),fp.setFromMatrixPosition(this.light.target.matrixWorld),Z1.subVectors(fp,K1),this.lightPlane.lookAt(fp),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(fp),this.targetLine.scale.z=Z1.length()}},pp=new A,nn=new Pi,Uo=class extends Bo{constructor(t){let e=new _e,n=new di({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 Se(i,3)),e.setAttribute("color",new Se(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 Ne(16755200),c=new Ne(16711680),d=new Ne(43775),h=new Ne(16777215),f=new Ne(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;nn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),cn("c",e,t,nn,0,0,-1),cn("t",e,t,nn,0,0,1),cn("n1",e,t,nn,-n,-i,-1),cn("n2",e,t,nn,n,-i,-1),cn("n3",e,t,nn,-n,i,-1),cn("n4",e,t,nn,n,i,-1),cn("f1",e,t,nn,-n,-i,1),cn("f2",e,t,nn,n,-i,1),cn("f3",e,t,nn,-n,i,1),cn("f4",e,t,nn,n,i,1),cn("u1",e,t,nn,n*.7,i*1.1,-1),cn("u2",e,t,nn,-n*.7,i*1.1,-1),cn("u3",e,t,nn,0,i*2,-1),cn("cf1",e,t,nn,-n,0,1),cn("cf2",e,t,nn,n,0,1),cn("cf3",e,t,nn,0,-i,1),cn("cf4",e,t,nn,0,i,1),cn("cn1",e,t,nn,-n,0,-1),cn("cn2",e,t,nn,n,0,-1),cn("cn3",e,t,nn,0,-i,-1),cn("cn4",e,t,nn,0,i,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function cn(r,t,e,n,i,s,o){pp.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],pp.x,pp.y,pp.z)}}var Go=class extends Bo{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 _e;s.setIndex(new Fe(n,1)),s.setAttribute("position",new Se(i,3)),super(s,new di({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 Up=class extends Bo{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 _e;i.setAttribute("position",new Se(e,3)),i.setAttribute("color",new Se(n,3));let s=new di({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,n){let i=new Ne,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:Qs}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Qs);var dc=".",Zd=Symbol("target"),N0=Symbol("unsubscribe");function Jd(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function mA(r){return(typeof r=="object"?r===null:typeof r!="function")||r instanceof RegExp}var ei=Array.isArray;function Xa(r){return typeof r=="symbol"}var bB={after:(r,t)=>ei(r)?r.slice(t.length):t===""?r:r.slice(t.length+1),concat:(r,t)=>ei(r)?(r=[...r],t&&r.push(t),r):t&&t.toString!==void 0?(r!==""&&(r+=dc),Xa(t)?r+t.toString():r+t):r,initial:r=>{if(ei(r))return r.slice(0,-1);if(r==="")return r;let t=r.lastIndexOf(dc);return t===-1?"":r.slice(0,t)},last:r=>{if(ei(r))return r[r.length-1]||"";if(r==="")return r;let t=r.lastIndexOf(dc);return t===-1?r:r.slice(t+1)},walk:(r,t)=>{if(ei(r))for(let e of r)t(e);else if(r!==""){let e=0,n=r.indexOf(dc);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(dc,e)}},get(r,t){return this.walk(t,e=>{r&&(r=r[e])}),r}},wr=bB;function B0(r){return typeof r=="object"&&typeof r.next=="function"}function F0(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[Zd].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 zp(r,t,e){return r.isUnsubscribed||t.ignoreSymbols&&Xa(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var $d=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,wr.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 hc(r){return toString.call(r)==="[object Object]"}function fc(){return!0}function ko(r,t){return r.length!==t.length||r.some((e,n)=>t[n]!==e)}var Hp=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var SB=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),U0={push:fc,pop:fc,shift:fc,unshift:fc,copyWithin:ko,reverse:ko,sort:ko,splice:ko,flat:ko,fill:ko},gA=new Set([...Hp,...SB,...Object.keys(U0)]);function pc(r,t){if(r.size!==t.size)return!0;for(let e of r)if(!t.has(e))return!0;return!1}var G0=["keys","values","entries"],k0=new Set(["has","toString"]),V0={add:pc,clear:pc,delete:pc,forEach:pc},yA=new Set([...k0,...Object.keys(V0),...G0]);function mc(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 wB=new Set([...k0,"get"]),z0={set:mc,clear:mc,delete:mc,forEach:mc},vA=new Set([...wB,...Object.keys(z0),...G0]);var Qn=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 Hp.has(t)}_shallowClone(t){let e=t;if(hc(t))e={...t};else if(ei(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?(ei(i)?this._onIsChanged=U0[e]:i instanceof Set?this._onIsChanged=V0[e]:i instanceof Map&&(this._onIsChanged=z0[e]),i):n}update(t,e,n){let i=wr.after(t,this._path);if(e!=="length"){let s=this.clone;wr.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],wr.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var gc=class extends Qn{static isHandledMethod(t){return gA.has(t)}};var eh=class extends Qn{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var yc=class extends Qn{static isHandledMethod(t){return yA.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 vc=class extends Qn{static isHandledMethod(t){return vA.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 th=class extends Qn{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 nh=class extends Qn{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 Oi=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return hc(t)||ei(t)||Jd(t)}static isHandledMethod(t,e){return hc(t)?Qn.isHandledMethod(e):ei(t)?gc.isHandledMethod(e):t instanceof Set?yc.isHandledMethod(e):t instanceof Map?vc.isHandledMethod(e):Jd(t)}get isCloning(){return this._stack.length>0}start(t,e,n){let i=Qn;ei(t)?i=gc:t instanceof Date?i=eh:t instanceof Set?i=yc:t instanceof Map?i=vc:t instanceof WeakSet?i=th:t instanceof WeakMap&&(i=nh),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=Oi.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 AB={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},H0=(r,t,e={})=>{e={...AB,...e};let n=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=e,l=new $d(i),u=typeof e.onValidate=="function",c=new Oi(u),d=(v,x,S,w,E)=>!u||c.isCloning||e.onValidate(wr.concat(l.getPath(v),x),S,w,E)===!0,h=(v,x,S,w)=>{!zp(l,e,x)&&!(o&&l.isDetached(v,r))&&f(l.getPath(v),x,S,w)},f=(v,x,S,w,E)=>{c.isCloning?c.update(v,x,w):t(wr.concat(v,x),S,w,E)},g=v=>v&&(v[n]||v),p=(v,x,S,w)=>mA(v)||S==="constructor"||s&&!Oi.isHandledMethod(x,S)||zp(l,e,S)||l.isGetInvariant(x,S)||o&&l.isDetached(x,r)?v:(w===void 0&&(w=l.getPath(x)),l.getProxy(v,wr.concat(w,S),m,n)),m={get(v,x,S){if(Xa(x)){if(x===n||x===Zd)return v;if(x===N0&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let w=Jd(v)?Reflect.get(v,x):Reflect.get(v,x,S);return p(w,v,x)},set(v,x,S,w){S=g(S);let E=v[n]||v,_=E[x];if(i(_,S)&&x in v)return!0;let b=d(v,x,S,_);return b&&l.setProperty(E,x,S,w,_)?(h(v,x,v[x],_),!0):!b},defineProperty(v,x,S){if(!l.isSameDescriptor(S,v,x)){let w=v[x];d(v,x,S.value,w)&&l.defineProperty(v,x,S,w)&&h(v,x,S.value,w)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let S=Reflect.get(v,x),w=d(v,x,void 0,S);return w&&l.deleteProperty(v,x,S)?(h(v,x,void 0,S),!0):!w},apply(v,x,S){let w=x[n]||x;if(l.isUnsubscribed)return Reflect.apply(v,w,S);if((a===!1||a!==!0&&!a.includes(v.name))&&Oi.isHandledType(w)){let E=wr.initial(l.getPath(v)),_=Oi.isHandledMethod(w,v.name);c.start(w,E,S);let b=Reflect.apply(v,c.preferredThisArg(v,x,w),_?S.map(D=>g(D)):S),T=c.isChanged(w,i),M=c.stop();if(Oi.isHandledType(b)&&_&&(x instanceof Map&&v.name==="get"&&(E=wr.concat(E,S[0])),b=l.getProxy(b,E,m)),T){let D={name:v.name,args:S,result:b},P=c.isCloning?wr.initial(E):E,C=c.isCloning?wr.last(E):"";d(wr.get(r,P),C,w,M,D)?f(P,C,w,M,D):c.undo(w)}return(x instanceof Map||x instanceof Set)&&B0(b)?F0(b,v,x,E,p):b}return Reflect.apply(v,x,S)}},y=l.getProxy(r,e.pathAsArray?[]:"",m);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};H0.target=r=>r&&r[Zd]||r;H0.unsubscribe=r=>r[N0]||r;var W0=H0;var EB=typeof global=="object"&&global&&global.Object===Object&&global,Wp=EB;var _B=typeof self=="object"&&self&&self.Object===Object&&self,TB=Wp||_B||Function("return this")(),sn=TB;var MB=sn.Symbol,Kn=MB;var xA=Object.prototype,CB=xA.hasOwnProperty,PB=xA.toString,rh=Kn?Kn.toStringTag:void 0;function DB(r){var t=CB.call(r,rh),e=r[rh];try{r[rh]=void 0;var n=!0}catch{}var i=PB.call(r);return n&&(t?r[rh]=e:delete r[rh]),i}var bA=DB;var IB=Object.prototype,OB=IB.toString;function LB(r){return OB.call(r)}var SA=LB;var RB="[object Null]",NB="[object Undefined]",wA=Kn?Kn.toStringTag:void 0;function BB(r){return r==null?r===void 0?NB:RB:wA&&wA in Object(r)?bA(r):SA(r)}var ti=BB;function FB(r){return r!=null&&typeof r=="object"}var ir=FB;var UB="[object Symbol]";function GB(r){return typeof r=="symbol"||ir(r)&&ti(r)==UB}var Vo=GB;function kB(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 jp=kB;var VB=Array.isArray,Bn=VB;var zB=1/0,AA=Kn?Kn.prototype:void 0,EA=AA?AA.toString:void 0;function _A(r){if(typeof r=="string")return r;if(Bn(r))return jp(r,_A)+"";if(Vo(r))return EA?EA.call(r):"";var t=r+"";return t=="0"&&1/r==-zB?"-0":t}var TA=_A;var HB=/\s/;function WB(r){for(var t=r.length;t--&&HB.test(r.charAt(t)););return t}var MA=WB;var jB=/^\s+/;function qB(r){return r&&r.slice(0,MA(r)+1).replace(jB,"")}var CA=qB;function XB(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}var Mn=XB;var PA=0/0,YB=/^[-+]0x[0-9a-f]+$/i,QB=/^0b[01]+$/i,KB=/^0o[0-7]+$/i,ZB=parseInt;function JB(r){if(typeof r=="number")return r;if(Vo(r))return PA;if(Mn(r)){var t=typeof r.valueOf=="function"?r.valueOf():r;r=Mn(t)?t+"":t}if(typeof r!="string")return r===0?r:+r;r=CA(r);var e=QB.test(r);return e||KB.test(r)?ZB(r.slice(2),e?2:8):YB.test(r)?PA:+r}var j0=JB;function $B(r){return r}var DA=$B;var eF="[object AsyncFunction]",tF="[object Function]",nF="[object GeneratorFunction]",rF="[object Proxy]";function iF(r){if(!Mn(r))return!1;var t=ti(r);return t==tF||t==nF||t==eF||t==rF}var qp=iF;var sF=sn["__core-js_shared__"],Xp=sF;var IA=function(){var r=/[^.]+$/.exec(Xp&&Xp.keys&&Xp.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function oF(r){return!!IA&&IA in r}var OA=oF;var aF=Function.prototype,lF=aF.toString;function cF(r){if(r!=null){try{return lF.call(r)}catch{}try{return r+""}catch{}}return""}var Ks=cF;var uF=/[\\^$.*+?()[\]{}|]/g,dF=/^\[object .+?Constructor\]$/,hF=Function.prototype,fF=Object.prototype,pF=hF.toString,mF=fF.hasOwnProperty,gF=RegExp("^"+pF.call(mF).replace(uF,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function yF(r){if(!Mn(r)||OA(r))return!1;var t=qp(r)?gF:dF;return t.test(Ks(r))}var LA=yF;function vF(r,t){return r?.[t]}var RA=vF;function xF(r,t){var e=RA(r,t);return LA(e)?e:void 0}var Or=xF;var bF=Or(sn,"WeakMap"),Yp=bF;var NA=Object.create,SF=function(){function r(){}return function(t){if(!Mn(t))return{};if(NA)return NA(t);r.prototype=t;var e=new r;return r.prototype=void 0,e}}(),BA=SF;function wF(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 FA=wF;function AF(r,t){var e=-1,n=r.length;for(t||(t=Array(n));++e<n;)t[e]=r[e];return t}var UA=AF;var EF=800,_F=16,TF=Date.now;function MF(r){var t=0,e=0;return function(){var n=TF(),i=_F-(n-e);if(e=n,i>0){if(++t>=EF)return arguments[0]}else t=0;return r.apply(void 0,arguments)}}var GA=MF;function CF(r){return function(){return r}}var kA=CF;var PF=function(){try{var r=Or(Object,"defineProperty");return r({},"",{}),r}catch{}}(),xc=PF;var DF=xc?function(r,t){return xc(r,"toString",{configurable:!0,enumerable:!1,value:kA(t),writable:!0})}:DA,VA=DF;var IF=GA(VA),zA=IF;function OF(r,t){for(var e=-1,n=r==null?0:r.length;++e<n&&t(r[e],e,r)!==!1;);return r}var HA=OF;var LF=9007199254740991,RF=/^(?:0|[1-9]\d*)$/;function NF(r,t){var e=typeof r;return t=t??LF,!!t&&(e=="number"||e!="symbol"&&RF.test(r))&&r>-1&&r%1==0&&r<t}var bc=NF;function BF(r,t,e){t=="__proto__"&&xc?xc(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[t]=e}var Qp=BF;function FF(r,t){return r===t||r!==r&&t!==t}var Sc=FF;var UF=Object.prototype,GF=UF.hasOwnProperty;function kF(r,t,e){var n=r[t];(!(GF.call(r,t)&&Sc(n,e))||e===void 0&&!(t in r))&&Qp(r,t,e)}var wc=kF;function VF(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?Qp(e,a,l):wc(e,a,l)}return e}var ss=VF;var WA=Math.max;function zF(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),FA(r,this,a)}}var jA=zF;var HF=9007199254740991;function WF(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=HF}var Ac=WF;function jF(r){return r!=null&&Ac(r.length)&&!qp(r)}var Kp=jF;var qF=Object.prototype;function XF(r){var t=r&&r.constructor,e=typeof t=="function"&&t.prototype||qF;return r===e}var Ec=XF;function YF(r,t){for(var e=-1,n=Array(r);++e<r;)n[e]=t(e);return n}var qA=YF;var QF="[object Arguments]";function KF(r){return ir(r)&&ti(r)==QF}var q0=KF;var XA=Object.prototype,ZF=XA.hasOwnProperty,JF=XA.propertyIsEnumerable,$F=q0(function(){return arguments}())?q0:function(r){return ir(r)&&ZF.call(r,"callee")&&!JF.call(r,"callee")},_c=$F;function eU(){return!1}var YA=eU;var ZA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,QA=ZA&&typeof module=="object"&&module&&!module.nodeType&&module,tU=QA&&QA.exports===ZA,KA=tU?sn.Buffer:void 0,nU=KA?KA.isBuffer:void 0,rU=nU||YA,Ya=rU;var iU="[object Arguments]",sU="[object Array]",oU="[object Boolean]",aU="[object Date]",lU="[object Error]",cU="[object Function]",uU="[object Map]",dU="[object Number]",hU="[object Object]",fU="[object RegExp]",pU="[object Set]",mU="[object String]",gU="[object WeakMap]",yU="[object ArrayBuffer]",vU="[object DataView]",xU="[object Float32Array]",bU="[object Float64Array]",SU="[object Int8Array]",wU="[object Int16Array]",AU="[object Int32Array]",EU="[object Uint8Array]",_U="[object Uint8ClampedArray]",TU="[object Uint16Array]",MU="[object Uint32Array]",qt={};qt[xU]=qt[bU]=qt[SU]=qt[wU]=qt[AU]=qt[EU]=qt[_U]=qt[TU]=qt[MU]=!0;qt[iU]=qt[sU]=qt[yU]=qt[oU]=qt[vU]=qt[aU]=qt[lU]=qt[cU]=qt[uU]=qt[dU]=qt[hU]=qt[fU]=qt[pU]=qt[mU]=qt[gU]=!1;function CU(r){return ir(r)&&Ac(r.length)&&!!qt[ti(r)]}var JA=CU;function PU(r){return function(t){return r(t)}}var Tc=PU;var $A=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ih=$A&&typeof module=="object"&&module&&!module.nodeType&&module,DU=ih&&ih.exports===$A,X0=DU&&Wp.process,IU=function(){try{var r=ih&&ih.require&&ih.require("util").types;return r||X0&&X0.binding&&X0.binding("util")}catch{}}(),Zs=IU;var eE=Zs&&Zs.isTypedArray,OU=eE?Tc(eE):JA,Zp=OU;var LU=Object.prototype,RU=LU.hasOwnProperty;function NU(r,t){var e=Bn(r),n=!e&&_c(r),i=!e&&!n&&Ya(r),s=!e&&!n&&!i&&Zp(r),o=e||n||i||s,a=o?qA(r.length,String):[],l=a.length;for(var u in r)(t||RU.call(r,u))&&!(o&&(u=="length"||i&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||bc(u,l)))&&a.push(u);return a}var Jp=NU;function BU(r,t){return function(e){return r(t(e))}}var $p=BU;var FU=$p(Object.keys,Object),tE=FU;var UU=Object.prototype,GU=UU.hasOwnProperty;function kU(r){if(!Ec(r))return tE(r);var t=[];for(var e in Object(r))GU.call(r,e)&&e!="constructor"&&t.push(e);return t}var nE=kU;function VU(r){return Kp(r)?Jp(r):nE(r)}var Mc=VU;function zU(r){var t=[];if(r!=null)for(var e in Object(r))t.push(e);return t}var rE=zU;var HU=Object.prototype,WU=HU.hasOwnProperty;function jU(r){if(!Mn(r))return rE(r);var t=Ec(r),e=[];for(var n in r)n=="constructor"&&(t||!WU.call(r,n))||e.push(n);return e}var iE=jU;function qU(r){return Kp(r)?Jp(r,!0):iE(r)}var Cc=qU;var XU=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,YU=/^\w*$/;function QU(r,t){if(Bn(r))return!1;var e=typeof r;return e=="number"||e=="symbol"||e=="boolean"||r==null||Vo(r)?!0:YU.test(r)||!XU.test(r)||t!=null&&r in Object(t)}var sE=QU;var KU=Or(Object,"create"),Js=KU;function ZU(){this.__data__=Js?Js(null):{},this.size=0}var oE=ZU;function JU(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}var aE=JU;var $U="__lodash_hash_undefined__",eG=Object.prototype,tG=eG.hasOwnProperty;function nG(r){var t=this.__data__;if(Js){var e=t[r];return e===$U?void 0:e}return tG.call(t,r)?t[r]:void 0}var lE=nG;var rG=Object.prototype,iG=rG.hasOwnProperty;function sG(r){var t=this.__data__;return Js?t[r]!==void 0:iG.call(t,r)}var cE=sG;var oG="__lodash_hash_undefined__";function aG(r,t){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=Js&&t===void 0?oG:t,this}var uE=aG;function Pc(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])}}Pc.prototype.clear=oE;Pc.prototype.delete=aE;Pc.prototype.get=lE;Pc.prototype.has=cE;Pc.prototype.set=uE;var Y0=Pc;function lG(){this.__data__=[],this.size=0}var dE=lG;function cG(r,t){for(var e=r.length;e--;)if(Sc(r[e][0],t))return e;return-1}var zo=cG;var uG=Array.prototype,dG=uG.splice;function hG(r){var t=this.__data__,e=zo(t,r);if(e<0)return!1;var n=t.length-1;return e==n?t.pop():dG.call(t,e,1),--this.size,!0}var hE=hG;function fG(r){var t=this.__data__,e=zo(t,r);return e<0?void 0:t[e][1]}var fE=fG;function pG(r){return zo(this.__data__,r)>-1}var pE=pG;function mG(r,t){var e=this.__data__,n=zo(e,r);return n<0?(++this.size,e.push([r,t])):e[n][1]=t,this}var mE=mG;function Dc(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])}}Dc.prototype.clear=dE;Dc.prototype.delete=hE;Dc.prototype.get=fE;Dc.prototype.has=pE;Dc.prototype.set=mE;var Ho=Dc;var gG=Or(sn,"Map"),Wo=gG;function yG(){this.size=0,this.__data__={hash:new Y0,map:new(Wo||Ho),string:new Y0}}var gE=yG;function vG(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}var yE=vG;function xG(r,t){var e=r.__data__;return yE(t)?e[typeof t=="string"?"string":"hash"]:e.map}var jo=xG;function bG(r){var t=jo(this,r).delete(r);return this.size-=t?1:0,t}var vE=bG;function SG(r){return jo(this,r).get(r)}var xE=SG;function wG(r){return jo(this,r).has(r)}var bE=wG;function AG(r,t){var e=jo(this,r),n=e.size;return e.set(r,t),this.size+=e.size==n?0:1,this}var SE=AG;function Ic(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])}}Ic.prototype.clear=gE;Ic.prototype.delete=vE;Ic.prototype.get=xE;Ic.prototype.has=bE;Ic.prototype.set=SE;var Qa=Ic;var EG="Expected a function";function Q0(r,t){if(typeof r!="function"||t!=null&&typeof t!="function")throw new TypeError(EG);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(Q0.Cache||Qa),e}Q0.Cache=Qa;var wE=Q0;var _G=500;function TG(r){var t=wE(r,function(n){return e.size===_G&&e.clear(),n}),e=t.cache;return t}var AE=TG;var MG=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,CG=/\\(\\)?/g,PG=AE(function(r){var t=[];return r.charCodeAt(0)===46&&t.push(""),r.replace(MG,function(e,n,i,s){t.push(i?s.replace(CG,"$1"):n||e)}),t}),EE=PG;function DG(r){return r==null?"":TA(r)}var _E=DG;function IG(r,t){return Bn(r)?r:sE(r,t)?[r]:EE(_E(r))}var fi=IG;var OG=1/0;function LG(r){if(typeof r=="string"||Vo(r))return r;var t=r+"";return t=="0"&&1/r==-OG?"-0":t}var qo=LG;function RG(r,t){t=fi(t,r);for(var e=0,n=t.length;r!=null&&e<n;)r=r[qo(t[e++])];return e&&e==n?r:void 0}var em=RG;function NG(r,t){for(var e=-1,n=t.length,i=r.length;++e<n;)r[i+e]=t[e];return r}var Oc=NG;var TE=Kn?Kn.isConcatSpreadable:void 0;function BG(r){return Bn(r)||_c(r)||!!(TE&&r&&r[TE])}var ME=BG;function CE(r,t,e,n,i){var s=-1,o=r.length;for(e||(e=ME),i||(i=[]);++s<o;){var a=r[s];t>0&&e(a)?t>1?CE(a,t-1,e,n,i):Oc(i,a):n||(i[i.length]=a)}return i}var PE=CE;function FG(r){var t=r==null?0:r.length;return t?PE(r,1):[]}var DE=FG;function UG(r){return zA(jA(r,void 0,DE),r+"")}var tm=UG;var GG=$p(Object.getPrototypeOf,Object),Lc=GG;var kG="[object Object]",VG=Function.prototype,zG=Object.prototype,IE=VG.toString,HG=zG.hasOwnProperty,WG=IE.call(Object);function jG(r){if(!ir(r)||ti(r)!=kG)return!1;var t=Lc(r);if(t===null)return!0;var e=HG.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&IE.call(e)==WG}var OE=jG;function qG(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 LE=qG;function XG(){this.__data__=new Ho,this.size=0}var RE=XG;function YG(r){var t=this.__data__,e=t.delete(r);return this.size=t.size,e}var NE=YG;function QG(r){return this.__data__.get(r)}var BE=QG;function KG(r){return this.__data__.has(r)}var FE=KG;var ZG=200;function JG(r,t){var e=this.__data__;if(e instanceof Ho){var n=e.__data__;if(!Wo||n.length<ZG-1)return n.push([r,t]),this.size=++e.size,this;e=this.__data__=new Qa(n)}return e.set(r,t),this.size=e.size,this}var UE=JG;function Rc(r){var t=this.__data__=new Ho(r);this.size=t.size}Rc.prototype.clear=RE;Rc.prototype.delete=NE;Rc.prototype.get=BE;Rc.prototype.has=FE;Rc.prototype.set=UE;var Nc=Rc;function $G(r,t){return r&&ss(t,Mc(t),r)}var GE=$G;function ek(r,t){return r&&ss(t,Cc(t),r)}var kE=ek;var WE=typeof exports=="object"&&exports&&!exports.nodeType&&exports,VE=WE&&typeof module=="object"&&module&&!module.nodeType&&module,tk=VE&&VE.exports===WE,zE=tk?sn.Buffer:void 0,HE=zE?zE.allocUnsafe:void 0;function nk(r,t){if(t)return r.slice();var e=r.length,n=HE?HE(e):new r.constructor(e);return r.copy(n),n}var jE=nk;function rk(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 qE=rk;function ik(){return[]}var nm=ik;var sk=Object.prototype,ok=sk.propertyIsEnumerable,XE=Object.getOwnPropertySymbols,ak=XE?function(r){return r==null?[]:(r=Object(r),qE(XE(r),function(t){return ok.call(r,t)}))}:nm,Bc=ak;function lk(r,t){return ss(r,Bc(r),t)}var YE=lk;var ck=Object.getOwnPropertySymbols,uk=ck?function(r){for(var t=[];r;)Oc(t,Bc(r)),r=Lc(r);return t}:nm,rm=uk;function dk(r,t){return ss(r,rm(r),t)}var QE=dk;function hk(r,t,e){var n=t(r);return Bn(r)?n:Oc(n,e(r))}var im=hk;function fk(r){return im(r,Mc,Bc)}var sh=fk;function pk(r){return im(r,Cc,rm)}var sm=pk;var mk=Or(sn,"DataView"),om=mk;var gk=Or(sn,"Promise"),am=gk;var yk=Or(sn,"Set"),lm=yk;var KE="[object Map]",vk="[object Object]",ZE="[object Promise]",JE="[object Set]",$E="[object WeakMap]",e_="[object DataView]",xk=Ks(om),bk=Ks(Wo),Sk=Ks(am),wk=Ks(lm),Ak=Ks(Yp),Ka=ti;(om&&Ka(new om(new ArrayBuffer(1)))!=e_||Wo&&Ka(new Wo)!=KE||am&&Ka(am.resolve())!=ZE||lm&&Ka(new lm)!=JE||Yp&&Ka(new Yp)!=$E)&&(Ka=function(r){var t=ti(r),e=t==vk?r.constructor:void 0,n=e?Ks(e):"";if(n)switch(n){case xk:return e_;case bk:return KE;case Sk:return ZE;case wk:return JE;case Ak:return $E}return t});var $s=Ka;var Ek=Object.prototype,_k=Ek.hasOwnProperty;function Tk(r){var t=r.length,e=new r.constructor(t);return t&&typeof r[0]=="string"&&_k.call(r,"index")&&(e.index=r.index,e.input=r.input),e}var t_=Tk;var Mk=sn.Uint8Array,Fc=Mk;function Ck(r){var t=new r.constructor(r.byteLength);return new Fc(t).set(new Fc(r)),t}var Uc=Ck;function Pk(r,t){var e=t?Uc(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.byteLength)}var n_=Pk;var Dk=/\w*$/;function Ik(r){var t=new r.constructor(r.source,Dk.exec(r));return t.lastIndex=r.lastIndex,t}var r_=Ik;var i_=Kn?Kn.prototype:void 0,s_=i_?i_.valueOf:void 0;function Ok(r){return s_?Object(s_.call(r)):{}}var o_=Ok;function Lk(r,t){var e=t?Uc(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.length)}var a_=Lk;var Rk="[object Boolean]",Nk="[object Date]",Bk="[object Map]",Fk="[object Number]",Uk="[object RegExp]",Gk="[object Set]",kk="[object String]",Vk="[object Symbol]",zk="[object ArrayBuffer]",Hk="[object DataView]",Wk="[object Float32Array]",jk="[object Float64Array]",qk="[object Int8Array]",Xk="[object Int16Array]",Yk="[object Int32Array]",Qk="[object Uint8Array]",Kk="[object Uint8ClampedArray]",Zk="[object Uint16Array]",Jk="[object Uint32Array]";function $k(r,t,e){var n=r.constructor;switch(t){case zk:return Uc(r);case Rk:case Nk:return new n(+r);case Hk:return n_(r,e);case Wk:case jk:case qk:case Xk:case Yk:case Qk:case Kk:case Zk:case Jk:return a_(r,e);case Bk:return new n;case Fk:case kk:return new n(r);case Uk:return r_(r);case Gk:return new n;case Vk:return o_(r)}}var l_=$k;function eV(r){return typeof r.constructor=="function"&&!Ec(r)?BA(Lc(r)):{}}var c_=eV;var tV="[object Map]";function nV(r){return ir(r)&&$s(r)==tV}var u_=nV;var d_=Zs&&Zs.isMap,rV=d_?Tc(d_):u_,h_=rV;var iV="[object Set]";function sV(r){return ir(r)&&$s(r)==iV}var f_=sV;var p_=Zs&&Zs.isSet,oV=p_?Tc(p_):f_,m_=oV;var aV=1,lV=2,cV=4,g_="[object Arguments]",uV="[object Array]",dV="[object Boolean]",hV="[object Date]",fV="[object Error]",y_="[object Function]",pV="[object GeneratorFunction]",mV="[object Map]",gV="[object Number]",v_="[object Object]",yV="[object RegExp]",vV="[object Set]",xV="[object String]",bV="[object Symbol]",SV="[object WeakMap]",wV="[object ArrayBuffer]",AV="[object DataView]",EV="[object Float32Array]",_V="[object Float64Array]",TV="[object Int8Array]",MV="[object Int16Array]",CV="[object Int32Array]",PV="[object Uint8Array]",DV="[object Uint8ClampedArray]",IV="[object Uint16Array]",OV="[object Uint32Array]",zt={};zt[g_]=zt[uV]=zt[wV]=zt[AV]=zt[dV]=zt[hV]=zt[EV]=zt[_V]=zt[TV]=zt[MV]=zt[CV]=zt[mV]=zt[gV]=zt[v_]=zt[yV]=zt[vV]=zt[xV]=zt[bV]=zt[PV]=zt[DV]=zt[IV]=zt[OV]=!0;zt[fV]=zt[y_]=zt[SV]=!1;function cm(r,t,e,n,i,s){var o,a=t&aV,l=t&lV,u=t&cV;if(e&&(o=i?e(r,n,i,s):e(r)),o!==void 0)return o;if(!Mn(r))return r;var c=Bn(r);if(c){if(o=t_(r),!a)return UA(r,o)}else{var d=$s(r),h=d==y_||d==pV;if(Ya(r))return jE(r,a);if(d==v_||d==g_||h&&!i){if(o=l||h?{}:c_(r),!a)return l?QE(r,kE(o,r)):YE(r,GE(o,r))}else{if(!zt[d])return i?r:{};o=l_(r,d,a)}}s||(s=new Nc);var f=s.get(r);if(f)return f;s.set(r,o),m_(r)?r.forEach(function(m){o.add(cm(m,t,e,m,r,s))}):h_(r)&&r.forEach(function(m,y){o.set(y,cm(m,t,e,y,r,s))});var g=u?l?sm:sh:l?Cc:Mc,p=c?void 0:g(r);return HA(p||r,function(m,y){p&&(y=m,m=r[y]),wc(o,y,cm(m,t,e,y,r,s))}),o}var um=cm;var LV=1,RV=4;function NV(r){return um(r,LV|RV)}var eo=NV;var BV="__lodash_hash_undefined__";function FV(r){return this.__data__.set(r,BV),this}var x_=FV;function UV(r){return this.__data__.has(r)}var b_=UV;function dm(r){var t=-1,e=r==null?0:r.length;for(this.__data__=new Qa;++t<e;)this.add(r[t])}dm.prototype.add=dm.prototype.push=x_;dm.prototype.has=b_;var S_=dm;function GV(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 w_=GV;function kV(r,t){return r.has(t)}var A_=kV;var VV=1,zV=2;function HV(r,t,e,n,i,s){var o=e&VV,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&zV?new S_: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(!w_(t,function(y,v){if(!A_(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 hm=HV;function WV(r){var t=-1,e=Array(r.size);return r.forEach(function(n,i){e[++t]=[i,n]}),e}var E_=WV;function jV(r){var t=-1,e=Array(r.size);return r.forEach(function(n){e[++t]=n}),e}var __=jV;var qV=1,XV=2,YV="[object Boolean]",QV="[object Date]",KV="[object Error]",ZV="[object Map]",JV="[object Number]",$V="[object RegExp]",ez="[object Set]",tz="[object String]",nz="[object Symbol]",rz="[object ArrayBuffer]",iz="[object DataView]",T_=Kn?Kn.prototype:void 0,K0=T_?T_.valueOf:void 0;function sz(r,t,e,n,i,s,o){switch(e){case iz:if(r.byteLength!=t.byteLength||r.byteOffset!=t.byteOffset)return!1;r=r.buffer,t=t.buffer;case rz:return!(r.byteLength!=t.byteLength||!s(new Fc(r),new Fc(t)));case YV:case QV:case JV:return Sc(+r,+t);case KV:return r.name==t.name&&r.message==t.message;case $V:case tz:return r==t+"";case ZV:var a=E_;case ez:var l=n&qV;if(a||(a=__),r.size!=t.size&&!l)return!1;var u=o.get(r);if(u)return u==t;n|=XV,o.set(r,t);var c=hm(a(r),a(t),n,i,s,o);return o.delete(r),c;case nz:if(K0)return K0.call(r)==K0.call(t)}return!1}var M_=sz;var oz=1,az=Object.prototype,lz=az.hasOwnProperty;function cz(r,t,e,n,i,s){var o=e&oz,a=sh(r),l=a.length,u=sh(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 S=r.constructor,w=t.constructor;S!=w&&"constructor"in r&&"constructor"in t&&!(typeof S=="function"&&S instanceof S&&typeof w=="function"&&w instanceof w)&&(p=!1)}return s.delete(r),s.delete(t),p}var C_=cz;var uz=1,P_="[object Arguments]",D_="[object Array]",fm="[object Object]",dz=Object.prototype,I_=dz.hasOwnProperty;function hz(r,t,e,n,i,s){var o=Bn(r),a=Bn(t),l=o?D_:$s(r),u=a?D_:$s(t);l=l==P_?fm:l,u=u==P_?fm:u;var c=l==fm,d=u==fm,h=l==u;if(h&&Ya(r)){if(!Ya(t))return!1;o=!0,c=!1}if(h&&!c)return s||(s=new Nc),o||Zp(r)?hm(r,t,e,n,i,s):M_(r,t,l,e,n,i,s);if(!(e&uz)){var f=c&&I_.call(r,"__wrapped__"),g=d&&I_.call(t,"__wrapped__");if(f||g){var p=f?r.value():r,m=g?t.value():t;return s||(s=new Nc),i(p,m,e,n,s)}}return h?(s||(s=new Nc),C_(r,t,e,n,i,s)):!1}var O_=hz;function L_(r,t,e,n,i){return r===t?!0:r==null||t==null||!ir(r)&&!ir(t)?r!==r&&t!==t:O_(r,t,e,n,L_,i)}var R_=L_;function fz(r,t){return r!=null&&t in Object(r)}var N_=fz;function pz(r,t,e){t=fi(t,r);for(var n=-1,i=t.length,s=!1;++n<i;){var o=qo(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&&Ac(i)&&bc(o,i)&&(Bn(r)||_c(r)))}var B_=pz;function mz(r,t){return r!=null&&B_(r,t,N_)}var F_=mz;var gz=function(){return sn.Date.now()},pm=gz;var yz="Expected a function",vz=Math.max,xz=Math.min;function bz(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(yz);t=j0(t)||0,Mn(e)&&(c=!!e.leading,d="maxWait"in e,s=d?vz(j0(e.maxWait)||0,t):s,h="trailing"in e?!!e.trailing:h);function f(E){var _=n,b=i;return n=i=void 0,u=E,o=r.apply(b,_),o}function g(E){return u=E,a=setTimeout(y,t),c?f(E):o}function p(E){var _=E-l,b=E-u,T=t-_;return d?xz(T,s-b):T}function m(E){var _=E-l,b=E-u;return l===void 0||_>=t||_<0||d&&b>=s}function y(){var E=pm();if(m(E))return v(E);a=setTimeout(y,p(E))}function v(E){return a=void 0,h&&n?f(E):(n=i=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,n=l=i=a=void 0}function S(){return a===void 0?o:v(pm())}function w(){var E=pm(),_=m(E);if(n=arguments,i=this,l=E,_){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=S,w}var Za=bz;function Sz(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}var U_=Sz;function wz(r,t){return t.length<2?r:em(r,LE(t,0,-1))}var G_=wz;function Az(r,t){return R_(r,t)}var Ja=Az;function Ez(r,t){return t=fi(t,r),r=G_(r,t),r==null||delete r[qo(U_(t))]}var k_=Ez;function _z(r){return OE(r)?void 0:r}var V_=_z;var Tz=1,Mz=2,Cz=4,Pz=tm(function(r,t){var e={};if(r==null)return e;var n=!1;t=jp(t,function(s){return s=fi(s,r),n||(n=s.length>1),s}),ss(r,sm(r),e),n&&(e=um(e,Tz|Mz|Cz,V_));for(var i=t.length;i--;)k_(e,t[i]);return e}),Gc=Pz;function Dz(r,t,e,n){if(!Mn(r))return r;t=fi(t,r);for(var i=-1,s=t.length,o=s-1,a=r;a!=null&&++i<s;){var l=qo(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=Mn(c)?c:bc(t[i+1])?[]:{})}wc(a,l,u),a=a[l]}return r}var z_=Dz;function Iz(r,t,e){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=em(r,o);e(a,o)&&z_(s,fi(o,r),a)}return s}var H_=Iz;function Oz(r,t){return H_(r,t,function(e,n){return F_(r,n)})}var W_=Oz;var Lz=tm(function(r,t){return r==null?{}:W_(r,t)}),Xo=Lz;var Rz="Expected a function";function Nz(r,t,e){var n=!0,i=!0;if(typeof r!="function")throw new TypeError(Rz);return Mn(e)&&(n="leading"in e?!!e.leading:n,i="trailing"in e?!!e.trailing:i),Za(r,t,{leading:n,maxWait:t,trailing:i})}var Z0=Nz;var q_,X_=new Promise(r=>{q_=r}),j_=!1;async function Y_(){if(j_)return;let r=await import("./physics.js");await r.init(),q_(r),j_=!0}var Lt=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,Lt.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,Lt.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,Lt.prototype),delete s[n],{data:s,actual:t,reverse:{type:1,id:n,data:i}}}}return null}};function oh(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"&&oh(n)}return Object.freeze(r)}function Q_(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 kc=class extends Error{};function mm(r){let t={...r};return Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}function os(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 Vc(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 K_(){return typeof process<"u"}function Z_(r,t){for(let e of r)t(e.id,e.data)!==!0&&Z_(e.children,t)}function J_(r,t){if(t(r.id,r.data)!==!0)for(let e of r.children)J_(e,t)}var Qt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Qt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)oh(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&&J_(i,n)}}traverse(e){Z_(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 kc("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)=>Q_(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 os(0,i,i);{let o=s[0].fi;return os(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 os(l,l+i,i)}else return os(o.fi,a.fi,i)}}};var zc;(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})(zc||(zc={}));var ze=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ze.prototype)}deepFreeze(){let e=0;for(;e<this.length;)oh(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,ze.prototype);let n=e;return K_()||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 os(0,n,n);{let s=i[0].fi;return os(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 os(a,a+n,n)}else return os(s.fi,o.fi,n)}}};function Hc(r){return r&&typeof r=="object"&&r instanceof Kt}var Kt=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&&!Hc(n))return null;i+=1}n=n?mm(n):new Kt;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=mm(l),delete n[t.path[i-1]])}else{let l=e[i-1];if(l){let u=mm(l);u[t.path[i-1]]=n,n=u}else{let u=new Kt;u[t.path[i-1]]=n,n=u}}i-=1}let o=Object.setPrototypeOf(n,Kt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},to;(n=>{function r(i,s){return ah(i,s)??i}n.apply=r;function t(i,s){return $0(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=Ar.zoomOnce(l,a[o]),l===void 0)return s;if(!Hc(l))return;o+=1}if(l===void 0)return s;if(!!Hc(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=J0([s],l);return u?(console.log(u),u):s}else return s}n.filterOp=e})(to||(to={}));function J0(r,t){if(t===void 0)return;let e=!1,n=r.map(i=>{let s=i.id,o=ah(i.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=i.data),i.children){let a=J0(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 Bz(r,t){if(t===void 0)return;let e=!1,n=r.map(i=>{let s=i.id,o=ah(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 ah(r,t){if(!Hc(t))return t;if(r instanceof Qt){let e=J0(r,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}else{if(r instanceof ze)return Bz(r,t);if(Array.isArray(r)){let e=!1,n=r.map((i,s)=>{let o=ah(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 Kt)return $0(r,t);if(r&&typeof r=="object"){let e={},n=!1;for(let[i,s]of Object.entries(r)){let o=ah(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 $0(r,t){if(r===void 0)return t;if(t===void 0)return r;if(!Hc(t))return t;if(!Hc(r))return to.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 Kt;for(let i of e){let s=$0(r===void 0?void 0:r[i],t===void 0?void 0:t[i]);n[i]=s}return n}function $_(r,t){let e={cur:[],result:[],len:0};return r=lh(r,t,e)??r,[r,e.result]}function gm(r,t){return r===null?null:(r.cur[r.len]=t,r.len+=1,r)}function ym(r){r&&(r.len-=1)}function Fz(r){if(r===null)return null;r.result.push(r.cur.slice(0,r.len))}function eT(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=lh(s.data,t,gm(e,o));ym(e),n=n||l!==void 0,l===void 0&&(l=s.data);let u=eT(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 Uz(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=lh(s.data,t,gm(e,o));return ym(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 lh(r,t,e){if(r instanceof Qt){let n=eT(r,t,e);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}else{if(r instanceof ze)return Uz(r,t,e);if(Array.isArray(r)){let n=!1,i=r.map((s,o)=>{let a=lh(s,t,gm(e,o));return ym(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"&&!Vc(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=lh(o,t,gm(e,s));ym(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");Fz(e)}return n}else return}}var vm;(t=>{function r(e,n){let i=Ar.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})(vm||(vm={}));var sr;(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 Kt&&u.type===0&&(h=l.runOp({...u,path:c.slice(d.length)}),h===null&&(h=void 0)),h===void 0&&d.length===c.length&&(l instanceof Qt||l instanceof ze||l instanceof Lt?h=l.runOp(u):h=zc.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 ze){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Lt){if(typeof y=="number")throw new Error("illegal arg");p=v.modifyById(y,p)}else if(v instanceof Kt){let x={...v,[y]:p};p=Object.setPrototypeOf(x,Kt.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 ze){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})(sr||(sr={}));var ex;(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=>sr.subsumed(h,f))),...c]}l.compress=i;function s(u,c){return u.every(d=>c.every(h=>sr.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=Ar.zoom(d,[...g.path,g.id]),m=sr.apply(d,{...g,type:2});if(m!==null){d=m.data;let[y,v]=$_(d,{[g.id]:p});d=y;for(let x of v){let S=x[x.length-1];x.splice(x.length-1,1),h.push({type:0,path:x,props:{[S]:p}}),f.push({type:0,path:x,props:{[S]:g.id}})}f.push(m.reverse),h.push(m.actual)}}else{let p=sr.apply(d,g);p!==null&&(h.push(p.actual),d=p.data,f.push(p.reverse))}}catch(p){if(p instanceof kc)return null;throw p}return{data:d,actual:h,reverse:f.reverse()}}l.apply=a})(ex||(ex={}));var tT=Symbol(),Gz=Symbol(),bm=Symbol(),$a=class{reportOp(t,e,n=[]){let i=this;if(e===null)return;i._current=e.data;let s=n;for(;!(i instanceof xm);){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[bm];n&&n(),delete this._children[t]}}}},nx=class extends $a{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,zc.runOp(this._current,t),t.path)}},rx=class extends $a{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,Lt.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},nT={get(r,t){if(t===bm)return()=>{r._parent=null};if(t===tT)return r._current;if(t===Gz)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=Sm(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]}}},kz={...nT,set(r,t,e){let n={type:0,props:{[t]:Zn(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}},Vz={...nT,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}},Wc=class extends $a{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[bm]=()=>{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=Sm(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)}},jc=class extends $a{constructor(t,e,n){super(),this._children={},this._parent=t,this._path=e,this._current=n,this[bm]=()=>{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=Sm(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 tx(r,t,e){if(r.length>0){let n=r[r.length-1];if(n.type===0&&t.type===0&&Ar.equal(n.path,e)){Object.assign(n.props,t.props);return}}r.push({...t,path:e})}var xm=class extends $a{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){tx(this.ts,e,t),tx(this.actual,n,t),tx(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Sm(r,t,e){return e instanceof Qt?new Wc(r,t,e):e instanceof ze?new jc(r,t,e):e instanceof Lt?new Proxy(new rx(r,t,e),Vz):e!==null&&typeof e=="object"?Vc(e)?e:new Proxy(new nx(r,t,e),kz):e}function ix(r){let t=new xm(r);return[Sm(t,"",r),t]}function qc(r,t){let[e,n]=ix(r);return t(e),n.result()}function Zn(r){return r instanceof Wc||r instanceof jc?r._current:r!==null&&typeof r=="object"?r[tT]:r}var Ar;(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 Wc)&&typeof o=="string")return s.data(o);if((s instanceof ze||s instanceof jc)&&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})(Ar||(Ar={}));function rT(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 Li(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 wm=class{},ch=class extends wm{constructor(e){super();this.id=e}},uh=class extends wm{constructor(e){super();this.data=e}};var ox;try{ox=new TextDecoder}catch{}var Ie,Qo,J=0;var dT=[],ax=dT,lx=0,Lr={},_t,Yo,pi=0,as=0,ni,no,Er=[],Dt,iT={useRecords:!1,mapsAsObjects:!0},dh=class{},ux=new dh;ux.name="MessagePack 0xC1";var Xc=!1,ls=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(Ie)return gT(()=>(Em(),this?this.unpack(t,e):ls.prototype.unpack.call(iT,t,e)));Qo=e>-1?e:t.length,J=0,lx=0,as=0,Yo=null,ax=dT,ni=null,Ie=t;try{Dt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw Ie=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 ls){if(Lr=this,this.structures)return _t=this.structures,Am();(!_t||_t.length>0)&&(_t=[])}else Lr=iT,(!_t||_t.length>0)&&(_t=[]);return Am()}unpackMultiple(t,e){let n,i=0;try{Xc=!0;let s=t.length,o=this?this.unpack(t,s):Mm.unpack(t,s);if(e){for(e(o);J<s;)if(i=J,e(Am())===!1)return}else{for(n=[o];J<s;)i=J,n.push(Am());return n}}catch(s){throw s.lastPosition=i,s.values=n,s}finally{Xc=!1,Em()}}_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 Am(){try{if(!Lr.trusted&&!Xc){let t=_t.sharedLength||0;t<_t.length&&(_t.length=t)}let r=on();if(J==Qo)_t.restoreStructures&&sT(),_t=null,Ie=null,no&&(no=null);else if(J>Qo){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Xc)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw _t.restoreStructures&&sT(),Em(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function sT(){for(let r in _t.restoreStructures)_t[r]=_t.restoreStructures[r];_t.restoreStructures=null}function on(){let r=Ie[J++];if(r<160)if(r<128){if(r<64)return r;{let t=_t[r&63]||Lr.getStructures&&hT()[r&63];return t?(t.read||(t.read=dx(t,r&63)),t.read()):r}}else if(r<144)if(r-=128,Lr.mapsAsObjects){let t={};for(let e=0;e<r;e++)t[pT()]=on();return t}else{let t=new Map;for(let e=0;e<r;e++)t.set(on(),on());return t}else{r-=144;let t=new Array(r);for(let e=0;e<r;e++)t[e]=on();return t}else if(r<192){let t=r-160;if(as>=J)return Yo.slice(J-pi,(J+=t)-pi);if(as==0&&Qo<140){let e=t<16?hx(t):fT(t);if(e!=null)return e}return cx(t)}else{let t;switch(r){case 192:return null;case 193:return ni?(t=on(),t>0?ni[1].slice(ni.position1,ni.position1+=t):ni[0].slice(ni.position0,ni.position0-=t)):ux;case 194:return!1;case 195:return!0;case 196:return sx(Ie[J++]);case 197:return t=Dt.getUint16(J),J+=2,sx(t);case 198:return t=Dt.getUint32(J),J+=4,sx(t);case 199:return el(Ie[J++]);case 200:return t=Dt.getUint16(J),J+=2,el(t);case 201:return t=Dt.getUint32(J),J+=4,el(t);case 202:if(t=Dt.getFloat32(J),Lr.useFloat32>2){let e=Tm[(Ie[J]&127)<<1|Ie[J+1]>>7];return J+=4,(e*t+(t>0?.5:-.5)>>0)/e}return J+=4,t;case 203:return t=Dt.getFloat64(J),J+=8,t;case 204:return Ie[J++];case 205:return t=Dt.getUint16(J),J+=2,t;case 206:return t=Dt.getUint32(J),J+=4,t;case 207:return Lr.int64AsNumber?(t=Dt.getUint32(J)*4294967296,t+=Dt.getUint32(J+4)):t=Dt.getBigUint64(J),J+=8,t;case 208:return Dt.getInt8(J++);case 209:return t=Dt.getInt16(J),J+=2,t;case 210:return t=Dt.getInt32(J),J+=4,t;case 211:return Lr.int64AsNumber?(t=Dt.getInt32(J)*4294967296,t+=Dt.getUint32(J+4)):t=Dt.getBigInt64(J),J+=8,t;case 212:if(t=Ie[J++],t==114)return uT(Ie[J++]&63);{let e=Er[t];if(e)return e.read?(J++,e.read(on())):e.noBuffer?(J++,e()):e(Ie.subarray(J,++J));throw new Error("Unknown extension "+t)}case 213:return t=Ie[J],t==114?(J++,uT(Ie[J++]&63,Ie[J++])):el(2);case 214:return el(4);case 215:return el(8);case 216:return el(16);case 217:return t=Ie[J++],as>=J?Yo.slice(J-pi,(J+=t)-pi):Hz(t);case 218:return t=Dt.getUint16(J),J+=2,as>=J?Yo.slice(J-pi,(J+=t)-pi):Wz(t);case 219:return t=Dt.getUint32(J),J+=4,as>=J?Yo.slice(J-pi,(J+=t)-pi):jz(t);case 220:return t=Dt.getUint16(J),J+=2,aT(t);case 221:return t=Dt.getUint32(J),J+=4,aT(t);case 222:return t=Dt.getUint16(J),J+=2,lT(t);case 223:return t=Dt.getUint32(J),J+=4,lT(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 zz=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function dx(r,t){function e(){if(e.count++>2){let i=r.read=new Function("r","return function(){return {"+r.map(s=>zz.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(on);return r.highByte===0&&(r.read=oT(t,r.read)),i()}let n={};for(let i=0,s=r.length;i<s;i++){let o=r[i];n[o]=on()}return n}return e.count=0,r.highByte===0?oT(t,e):e}var oT=(r,t)=>function(){let e=Ie[J++];if(e===0)return t();let n=r<32?-(r+(e<<5)):r+(e<<5),i=_t[n]||hT()[n];if(!i)throw new Error("Record id is not defined for "+n);return i.read||(i.read=dx(i,r)),i.read()};function hT(){let r=gT(()=>(Ie=null,Lr.getStructures()));return _t=Lr._mergeStructures(r,_t)}var cx=_m,Hz=_m,Wz=_m,jz=_m;function _m(r){let t;if(r<16&&(t=hx(r)))return t;if(r>64&&ox)return ox.decode(Ie.subarray(J,J+=r));let e=J+r,n=[];for(t="";J<e;){let i=Ie[J++];if((i&128)===0)n.push(i);else if((i&224)===192){let s=Ie[J++]&63;n.push((i&31)<<6|s)}else if((i&240)===224){let s=Ie[J++]&63,o=Ie[J++]&63;n.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Ie[J++]&63,o=Ie[J++]&63,a=Ie[J++]&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 aT(r){let t=new Array(r);for(let e=0;e<r;e++)t[e]=on();return t}function lT(r){if(Lr.mapsAsObjects){let t={};for(let e=0;e<r;e++)t[pT()]=on();return t}else{let t=new Map;for(let e=0;e<r;e++)t.set(on(),on());return t}}var Jn=String.fromCharCode;function fT(r){let t=J,e=new Array(r);for(let n=0;n<r;n++){let i=Ie[J++];if((i&128)>0){J=t;return}e[n]=i}return Jn.apply(String,e)}function hx(r){if(r<4)if(r<2){if(r===0)return"";{let t=Ie[J++];if((t&128)>1){J-=1;return}return Jn(t)}}else{let t=Ie[J++],e=Ie[J++];if((t&128)>0||(e&128)>0){J-=2;return}if(r<3)return Jn(t,e);let n=Ie[J++];if((n&128)>0){J-=3;return}return Jn(t,e,n)}else{let t=Ie[J++],e=Ie[J++],n=Ie[J++],i=Ie[J++];if((t&128)>0||(e&128)>0||(n&128)>0||(i&128)>0){J-=4;return}if(r<6){if(r===4)return Jn(t,e,n,i);{let s=Ie[J++];if((s&128)>0){J-=5;return}return Jn(t,e,n,i,s)}}else if(r<8){let s=Ie[J++],o=Ie[J++];if((s&128)>0||(o&128)>0){J-=6;return}if(r<7)return Jn(t,e,n,i,s,o);let a=Ie[J++];if((a&128)>0){J-=7;return}return Jn(t,e,n,i,s,o,a)}else{let s=Ie[J++],o=Ie[J++],a=Ie[J++],l=Ie[J++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){J-=8;return}if(r<10){if(r===8)return Jn(t,e,n,i,s,o,a,l);{let u=Ie[J++];if((u&128)>0){J-=9;return}return Jn(t,e,n,i,s,o,a,l,u)}}else if(r<12){let u=Ie[J++],c=Ie[J++];if((u&128)>0||(c&128)>0){J-=10;return}if(r<11)return Jn(t,e,n,i,s,o,a,l,u,c);let d=Ie[J++];if((d&128)>0){J-=11;return}return Jn(t,e,n,i,s,o,a,l,u,c,d)}else{let u=Ie[J++],c=Ie[J++],d=Ie[J++],h=Ie[J++];if((u&128)>0||(c&128)>0||(d&128)>0||(h&128)>0){J-=12;return}if(r<14){if(r===12)return Jn(t,e,n,i,s,o,a,l,u,c,d,h);{let f=Ie[J++];if((f&128)>0){J-=13;return}return Jn(t,e,n,i,s,o,a,l,u,c,d,h,f)}}else{let f=Ie[J++],g=Ie[J++];if((f&128)>0||(g&128)>0){J-=14;return}if(r<15)return Jn(t,e,n,i,s,o,a,l,u,c,d,h,f,g);let p=Ie[J++];if((p&128)>0){J-=15;return}return Jn(t,e,n,i,s,o,a,l,u,c,d,h,f,g,p)}}}}}function sx(r){return Lr.copyBuffers?Uint8Array.prototype.slice.call(Ie,J,J+=r):Ie.subarray(J,J+=r)}function el(r){let t=Ie[J++];if(Er[t])return Er[t](Ie.subarray(J,J+=r));throw new Error("Unknown extension type "+t)}var cT=new Array(4096);function pT(){let r=Ie[J++];if(r>=160&&r<192){if(r=r-160,as>=J)return Yo.slice(J-pi,(J+=r)-pi);if(!(as==0&&Qo<180))return cx(r)}else return J--,on();let t=(r<<5^(r>1?Dt.getUint16(J):r>0?Ie[J]:0))&4095,e=cT[t],n=J,i=J+r-3,s,o=0;if(e&&e.bytes==r){for(;n<i;){if(s=Dt.getUint32(n),s!=e[o++]){n=1879048192;break}n+=4}for(i+=3;n<i;)if(s=Ie[n++],s!=e[o++]){n=1879048192;break}if(n===i)return J=n,e.string;i-=3,n=J}for(e=[],cT[t]=e,e.bytes=r;n<i;)s=Dt.getUint32(n),e.push(s),n+=4;for(i+=3;n<i;)s=Ie[n++],e.push(s);let a=r<16?hx(r):fT(r);return a!=null?e.string=a:e.string=cx(r)}var uT=(r,t)=>{var e=on();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=dx(e,n),e.read()},mT=typeof self=="object"?self:global;Er[0]=()=>{};Er[0].noBuffer=!0;Er[101]=()=>{let r=on();return(mT[r[0]]||Error)(r[1])};Er[105]=r=>{let t=Dt.getUint32(J-4);no||(no=new Map);let e=Ie[J],n;e>=144&&e<160||e==220||e==221?n=[]:n={};let i={target:n};no.set(t,i);let s=on();return i.used?Object.assign(n,s):(i.target=s,s)};Er[112]=r=>{let t=Dt.getUint32(J-4),e=no.get(t);return e.used=!0,e.target};Er[115]=()=>new Set(on());var fx=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");Er[116]=r=>{let t=r[0],e=fx[t];if(!e)throw new Error("Could not find typed array for code "+t);return new mT[e](Uint8Array.prototype.slice.call(r,1).buffer)};Er[120]=()=>{let r=on();return new RegExp(r[0],r[1])};Er[98]=r=>{let t=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],e=J;J+=t-4,ni=[on(),on()],ni.position0=0,ni.position1=0;let n=J;J=e;try{return on()}finally{J=n}};Er[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 gT(r){let t=Qo,e=J,n=lx,i=pi,s=as,o=Yo,a=ax,l=no,u=ni,c=new Uint8Array(Ie.slice(0,Qo)),d=_t,h=_t.slice(0,_t.length),f=Lr,g=Xc,p=r();return Qo=t,J=e,lx=n,pi=i,as=s,Yo=o,ax=a,no=l,ni=u,Ie=c,Xc=g,_t=d,_t.splice(0,_t.length,...h),Lr=f,Dt=new DataView(Ie.buffer,Ie.byteOffset,Ie.byteLength),p}function Em(){Ie=null,no=null,_t=null}function yT(r){r.unpack?Er[r.type]=r.unpack:Er[r.type]=r}var Tm=new Array(147);for(let r=0;r<256;r++)Tm[r]=+("1e"+Math.floor(45.15-r*.30103));var Mm=new ls({useRecords:!1}),qz=Mm.unpack,Xz=Mm.unpackMultiple,Yz=Mm.unpack,Cm={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Qz=new Float32Array(1),mee=new Uint8Array(Qz.buffer,0,4);var Pm;try{Pm=new TextEncoder}catch{}var Dm,mx,Im=typeof Buffer<"u",px=Im?Buffer.allocUnsafeSlow:Uint8Array,ST=Im?Buffer:Uint8Array,vT=Im?4294967296:2144337920,oe,hn,ne=0,cs,us=null,Kz=/[\u0080-\uFFFF]/,hh=Symbol("record-id"),tl=class extends ls{constructor(t){super(t),this.offset=0;let e,n,i,s,o,a,l=0,u=ST.prototype.utf8Write?function(b,T,M){return oe.utf8Write(b,T,M)}:Pm&&Pm.encodeInto?function(b,T){return Pm.encodeInto(b,oe.subarray(T)).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,S=0;this.pack=this.encode=function(b,T){if(oe||(oe=new px(8192),hn=new DataView(oe.buffer,0,8192),ne=0),cs=oe.length-10,cs-ne<2048?(oe=new px(oe.length),hn=new DataView(oe.buffer,0,oe.length),cs=oe.length-10,ne=0):ne=ne+7&2147483640,n=ne,a=c.structuredClone?new Map:null,c.bundleStrings?(us=["",""],oe[ne++]=214,oe[ne++]=98,us.position=ne-n,ne+=4):us=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 D=0;D<M;D++){let P=i[D];if(!P)continue;let C,I=i.transitions;for(let R=0,G=P.length;R<G;R++){let Y=P[R];C=I[Y],C||(C=I[Y]=Object.create(null)),I=C}I[hh]=D+64}l=M}d||(i.nextId=M+64)}s&&(s=!1),o=i||[];try{if(w(b),us){hn.setUint32(us.position+n,ne-us.position-n);let M=us;us=null,w(M[0]),w(M[1])}if(c.offset=ne,a&&a.idsToInsert){ne+=a.idsToInsert.length*6,ne>cs&&_(ne),c.offset=ne;let M=Jz(oe.subarray(n,ne),a.idsToInsert);return a=null,M}return T&AT?(oe.start=n,oe.end=ne,oe):oe.subarray(n,ne)}finally{if(i){if(S<10&&S++,x>1e4)i.transitions=null,S=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let M=0,D=v.length;M<D;M++)v[M][hh]=0;v=[]}if(s&&c.saveStructures){let M=i.sharedLength||f;i.length>M&&(i=i.slice(0,M));let D=oe.subarray(n,ne);return c.saveStructures(i,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(b)):(l=M,D)}}T&s4&&(ne=n)}};let w=b=>{ne>cs&&(oe=_(ne));var T=typeof b,M;if(T==="string"){let D=b.length;if(us&&D>=8&&D<4096){let I=Kz.test(b);us[I?0:1]+=b,oe[ne++]=193,w(I?-D:D);return}let P;D<32?P=1:D<256?P=2:D<65536?P=3:P=5;let C=D*3;if(ne+C>cs&&(oe=_(ne+C)),D<64||!u){let I,R,G,Y=ne+P;for(I=0;I<D;I++)R=b.charCodeAt(I),R<128?oe[Y++]=R:R<2048?(oe[Y++]=R>>6|192,oe[Y++]=R&63|128):(R&64512)===55296&&((G=b.charCodeAt(I+1))&64512)===56320?(R=65536+((R&1023)<<10)+(G&1023),I++,oe[Y++]=R>>18|240,oe[Y++]=R>>12&63|128,oe[Y++]=R>>6&63|128,oe[Y++]=R&63|128):(oe[Y++]=R>>12|224,oe[Y++]=R>>6&63|128,oe[Y++]=R&63|128);M=Y-ne-P}else M=u(b,ne+P,C);M<32?oe[ne++]=160|M:M<256?(P<2&&oe.copyWithin(ne+2,ne+1,ne+1+M),oe[ne++]=217,oe[ne++]=M):M<65536?(P<3&&oe.copyWithin(ne+3,ne+2,ne+2+M),oe[ne++]=218,oe[ne++]=M>>8,oe[ne++]=M&255):(P<5&&oe.copyWithin(ne+5,ne+3,ne+3+M),oe[ne++]=219,hn.setUint32(ne,M),ne+=4),ne+=M}else if(T==="number")if(b>>>0===b)b<64?oe[ne++]=b:b<256?(oe[ne++]=204,oe[ne++]=b):b<65536?(oe[ne++]=205,oe[ne++]=b>>8,oe[ne++]=b&255):(oe[ne++]=206,hn.setUint32(ne,b),ne+=4);else if(b>>0===b)b>=-32?oe[ne++]=256+b:b>=-128?(oe[ne++]=208,oe[ne++]=b+256):b>=-32768?(oe[ne++]=209,hn.setInt16(ne,b),ne+=2):(oe[ne++]=210,hn.setInt32(ne,b),ne+=4);else{let D;if((D=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){oe[ne++]=202,hn.setFloat32(ne,b);let P;if(D<4||(P=b*Tm[(oe[ne]&127)<<1|oe[ne+1]>>7])>>0===P){ne+=4;return}else ne--}oe[ne++]=203,hn.setFloat64(ne,b),ne+=8}else if(T==="object")if(!b)oe[ne++]=192;else{if(a){let P=a.get(b);if(P){if(!P.id){let C=a.idsToInsert||(a.idsToInsert=[]);P.id=C.push(P)}oe[ne++]=214,oe[ne++]=112,hn.setUint32(ne,P.id),ne+=4;return}else a.set(b,{offset:ne-n})}let D=b.constructor;if(D===Object)E(b,!0);else if(D===Array){M=b.length,M<16?oe[ne++]=144|M:M<65536?(oe[ne++]=220,oe[ne++]=M>>8,oe[ne++]=M&255):(oe[ne++]=221,hn.setUint32(ne,M),ne+=4);for(let P=0;P<M;P++)w(b[P])}else if(D===Map){M=b.size,M<16?oe[ne++]=128|M:M<65536?(oe[ne++]=222,oe[ne++]=M>>8,oe[ne++]=M&255):(oe[ne++]=223,hn.setUint32(ne,M),ne+=4);for(let[P,C]of b)w(P),w(C)}else{for(let P=0,C=Dm.length;P<C;P++){let I=mx[P];if(b instanceof I){let R=Dm[P];if(R.write){R.type&&(oe[ne++]=212,oe[ne++]=R.type,oe[ne++]=0),w(R.write.call(this,b));return}let G=oe,Y=hn,W=ne;oe=null;let q;try{q=R.pack.call(this,b,j=>(oe=G,G=null,ne+=j,ne>cs&&_(ne),{target:oe,targetView:hn,position:ne-j}),w)}finally{G&&(oe=G,hn=Y,ne=W,cs=oe.length-10)}q&&(q.length+ne>cs&&_(q.length+ne),ne=Zz(q,oe,ne,R.type));return}}E(b,!b.hasOwnProperty)}}else if(T==="boolean")oe[ne++]=b?195:194;else if(T==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))oe[ne++]=211,hn.setBigInt64(ne,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)oe[ne++]=207,hn.setBigUint64(ne,b);else if(this.largeBigIntToFloat)oe[ne++]=203,hn.setFloat64(ne,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ne+=8}else if(T==="undefined")this.encodeUndefinedAsNil?oe[ne++]=192:(oe[ne++]=212,oe[ne++]=0,oe[ne++]=0);else if(T==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},E=this.useRecords===!1?this.variableMapSize?b=>{let T=Object.keys(b),M=T.length;M<16?oe[ne++]=128|M:M<65536?(oe[ne++]=222,oe[ne++]=M>>8,oe[ne++]=M&255):(oe[ne++]=223,hn.setUint32(ne,M),ne+=4);let D;for(let P=0;P<M;P++)w(D=T[P]),w(b[D])}:(b,T)=>{oe[ne++]=222;let M=ne-n;ne+=2;let D=0;for(let P in b)(T||b.hasOwnProperty(P))&&(w(P),w(b[P]),D++);oe[M+++n]=D>>8,oe[M+n]=D&255}:b=>{let T=Object.keys(b),M,D=o.transitions||(o.transitions=Object.create(null)),P=0;for(let I=0,R=T.length;I<R;I++){let G=T[I];M=D[G],M||(M=D[G]=Object.create(null),P++),D=M}let C=D[hh];if(C)C>=96&&p?(oe[ne++]=((C-=96)&31)+96,oe[ne++]=C>>5):oe[ne++]=C;else{C=o.nextId,C||(C=64),C<m&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(C=o.nextOwnId,C<y||(C=m),o.nextOwnId=C+1):(C>=y&&(C=m),o.nextId=C+1);let I=T.highByte=C>=96&&p?C-96>>5:-1;D[hh]=C,o[C-64]=T,C<m?(T.isShared=!0,o.sharedLength=C-63,s=!0,I>=0?(oe[ne++]=(C&31)+96,oe[ne++]=I):oe[ne++]=C):(I>=0?(oe[ne++]=213,oe[ne++]=114,oe[ne++]=(C&31)+96,oe[ne++]=I):(oe[ne++]=212,oe[ne++]=114,oe[ne++]=C),P&&(x+=S*P),v.length>=g&&(v.shift()[hh]=0),v.push(D),w(T))}for(let I=0,R=T.length;I<R;I++)w(b[T[I]])},_=b=>{let T;if(b>16777216){if(b-n>vT)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(vT,Math.round(Math.max((b-n)*(b>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(b-n<<2,oe.length-1)>>12)+1<<12;let M=new px(T);return hn=new DataView(M.buffer,0,T),oe.copy?oe.copy(M,0,n,b):M.set(oe.slice(n,b)),ne-=n,n=0,cs=M.length-10,oe=M}}useBuffer(t){oe=t,hn=new DataView(oe.buffer,oe.byteOffset,oe.byteLength),ne=0}};mx=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,dh];Dm=[{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?xT(r,16,t):bT(Im?Buffer.from(r):new Uint8Array(r),t)}},{pack(r,t){let e=r.constructor;e!==ST&&this.structuredClone?xT(r,fx.indexOf(e.name),t):bT(r,t)}},{pack(r,t){let{target:e,position:n}=t(1);e[n]=193}}];function xT(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 bT(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 Zz(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 Jz(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 Ko(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)");mx.unshift(r.Class),Dm.unshift(r)}yT(r)}var wT=new tl({useRecords:!1}),$z=wT.pack,e4=wT.pack;var{NEVER:t4,ALWAYS:n4,DECIMAL_ROUND:r4,DECIMAL_FIT:i4}=Cm,AT=512,s4=1024;var ET=new tl({structuredClone:!0});Ko({Class:Lt.prototype.constructor,type:1,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Lt.prototype),r}});Ko({Class:ze.prototype.constructor,type:2,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,ze.prototype),r}});Ko({Class:Qt.prototype.constructor,type:3,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Qt.prototype),r}});Ko({Class:ch.prototype.constructor,type:4,write(r){return r.id},read(r){return new ch(r)}});Ko({Class:uh.prototype.constructor,type:5,write(r){return r.data},read(r){return new uh(r)}});Ko({Class:Kt.prototype.constructor,type:6,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Kt.prototype),r}});function o4(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 gx(r){if(Vc(r))return r;if(Array.isArray(r))return r.map(gx);if(typeof r=="object"&&r!==null){let t={};for(let e of Object.keys(r).sort())t[e]=gx(r[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}else return r}var Om;(n=>{function r(i){return ET.pack(i)}n.serialize=r;function t(i){return ET.unpack(i)}n.deserialize=t;function e(i){return o4(r(gx(i))).toString()}n.checksum=e})(Om||(Om={}));var ro={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Audio","Create"],["MouseHover"]:["Transition","Create","Destroy","SwitchCamera"],["Scroll"]:["Transition","Create"],["Start"]:["Transition","Audio","Video","Create","Destroy","SwitchCamera"],["Conditional"]:["Transition","Audio","Video","Create","Destroy","SwitchCamera","Reset"],["MouseDown"]:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],["MouseUp"]:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],["MousePress"]:["Transition","SwitchCamera","Audio","Video","Link","Create","Reset"],["KeyDown"]:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],["KeyUp"]:["Transition","SwitchCamera","Audio","Video","Link","Create","Destroy","Reset"],["KeyPress"]:["Transition","SwitchCamera","Audio","Video","Link","Create","Reset"],["GameControl"]:["Transition","Audio","Video","Create"],["Collision"]:["Transition","Audio","Video","Create","Destroy","Reset"]},_T;(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,mode:"Object",disabled:!1,toggle:!1,actions:new ze}:{type:n,disabled:!1,key:void 0,toggle:!1,actions:new ze}}e.defaultData=t})(_T||(_T={}));var Lm;(e=>{function r(n){return{type:"Property",value:[n??null,"position","x"]}}e.propertyDefaultData=r,e.valueDefaultData={type:"Literal",value:0}})(Lm||(Lm={}));var yx;(n=>{function r(i){return{type:"Comparison",operator:"==",lOperand:Lm.propertyDefaultData(i),rOperand:{...Lm.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})(yx||(yx={}));var TT;(e=>{function r(n){return n.type==="Conditional"}e.is=r;function t(n){return{type:"Conditional",disabled:!1,inActions:new ze,outActions:new ze,condition:yx.distanceDefaultData(n)}}e.defaultData=t})(TT||(TT={}));var MT;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new ze,drop:new ze}})(MT||(MT={}));var Rm;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new ze})(Rm||(Rm={}));var Nm;(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})(Nm||(Nm={}));var CT;(e=>{function r(n){return n.type==="MouseHover"}e.is=r;function t(){return{type:"MouseHover",disabled:!1,actions:new ze}}e.defaultData=t})(CT||(CT={}));var PT;(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 ze}}e.defaultData=t})(PT||(PT={}));var DT;(e=>{function r(n){return n.type==="Start"}e.is=r;function t(){return{type:"Start",disabled:!1,actions:new ze}}e.defaultData=t})(DT||(DT={}));var IT;(e=>{function r(n){return n.type==="Collision"}e.is=r;function t(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new ze}}e.defaultData=t})(IT||(IT={}));var nl;(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})(nl||(nl={}));var ds;(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})(ds||(ds={}));var fh;(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})(fh||(fh={}));var Zo;(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})(Zo||(Zo={}));var dr;(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})(dr||(dr={}));var Rr;(a=>{a.white={...dr.white,a:1},a.transparent={...dr.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{...dr.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 dr.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})(Rr||(Rr={}));var Bm;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Bm||(Bm={}));var OT;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(OT||(OT={}));var LT;(t=>t.defaultData={control1:[.5,.05],control2:[.1,.3]})(LT||(LT={}));var Ri;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(n){return e.all.includes(n)}e.is=t})(Ri||(Ri={}));var rl;(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})(rl||(rl={}));var hs;(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(vx.forEach(o=>{Object.assign(s,{[o]:i[o]??n[o]})}),s.radial={...n.radial},i.radial){let o=n.radial,a=i.radial;xx.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;bx.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;Sx.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;wx.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;Ax.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(hs||(hs={}));var Fm;(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})(Fm||(Fm={}));var vx=["count"],xx=["radius","start","end","position","scale","rotation"],bx=["position","scale","rotation"],Sx=["count","size"],wx=["count","position","scale","rotation"],Ax=["strength","scale","rotation","position","movement","seed","freqScale"];var il;(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}}})(il||(il={}));var Um;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(n){return e.all.includes(n)}e.is=t})(Um||(Um={}));var Gm;(e=>{function r(n){return t(n)}e.defaultData=r;function t(n){if(n==="PointLight")return{type:n,color:Rr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(n==="SpotLight")return{type:n,color:Rr.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:Rr.white,intensity:1,shadows:!0,size:2e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Gm||(Gm={}));var Ex;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(n,i){return n.castShadow===i.castShadow&&n.receiveShadow===i.receiveShadow}e.equals=t})(Ex||(Ex={}));var _x;(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})(_x||(_x={}));var km;(t=>t.defaultData={..._x.defaultData,...Ex.defaultData})(km||(km={}));var Yc;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Yc||(Yc={}));var RT;(t=>{function r(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="light"}t.is=r})(RT||(RT={}));var NT;(t=>{function r(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=r})(NT||(NT={}));var Vm=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],BT=["wrapping","image","video"],_r;(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:Yc.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:dr.fromHex(5526619)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...dr.fromHex(6710886),a:1},colorB:{...dr.fromHex(6710886),a:1},colorC:{...dr.fromHex(16777215),a:1},colorD:{...dr.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:Rr.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:Rr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:Rr.fromHexAndA(0,1),contourColor:Rr.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}}}})(_r||(_r={}));var $n;(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 ze}}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 ze;return h.push({fi:0,data:_r.defaultData("light",u),id:c}),h.push({fi:1,data:_r.defaultData("color"),id:d}),{layers:h}}l.defaultTwoLayerData=s;function o(u,c="phong",d="layer1",h="layer2"){let f=_r.defaultData("texture");Object.assign(f.texture,{image:u});let g=new ze;return g.push({fi:0,data:f,id:d}),g.push({fi:1,data:_r.defaultData("light",c),id:h}),{layers:g}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",d="layer1",h="layer2"){let f=_r.defaultData("video");Object.assign(f.texture,{video:u});let g=new ze;return g.push({fi:0,data:f,id:d}),g.push({fi:1,data:_r.defaultData("light",c),id:h}),{layers:g}}l.defaultTwoLayerVideoTextureData=a})($n||($n={}));var Qc;(t=>{function r(){return{points:new ze,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=r})(Qc||(Qc={}));var Kc;(t=>{function r(){return{points:new ze,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=r})(Kc||(Kc={}));var Tx={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0};var zm;(t=>{function r(e,n){let i={...e};return Mx.forEach(s=>{Object.assign(i,{[s]:n[s]??e[s]})}),i}t.merge=r})(zm||(zm={}));var Hm={shape:Tx,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},Mx=["depth","offset","angle","twist","startScale","endScale"];var ph;(e=>{function r(n){return n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"}e.is2DParametricMesh=r;function t(n){return n==="PolygonGeometry"||n==="PolygonGeometry"||n==="RectangleGeometry"||n==="StarGeometry"||n==="TriangleGeometry"||n==="EllipseGeometry"||n==="PathGeometry"||n==="VectorGeometry"||n==="ConeGeometry"||n==="CubeGeometry"||n==="CylinderGeometry"||n==="DodecahedronGeometry"||n==="HelixGeometry"||n==="IcosahedronGeometry"||n==="LatheGeometry"||n==="PyramidGeometry"||n==="SphereGeometry"||n==="PlaneGeometry"||n==="BackdropGeometry"||n==="TorusGeometry"||n==="TorusKnotGeometry"||n==="BooleanGeometry"||n==="TextGeometry"}e.isParametricMesh=t})(ph||(ph={}));var Wm;(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,zm.merge(i.extrusion,n.extrusion))),i}t.merge=r})(Wm||(Wm={}));var Jo;(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:Kc.defaultData(),extrusion:Hm};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Qc.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})(Jo||(Jo={}));var Cx=["width","height","depth"];function FT(r){for(let t of Object.keys(r))r[t]===void 0&&delete r[t];return r}function Bi(r,t){return Object.setPrototypeOf(r,t),r}var a4=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),l4=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),c4=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||sl&&"ontouchend"in document,u4=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,d4=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,h4=()=>{if(typeof window>"u")return!1;let r=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(r)&&/Apple Computer/.test(t)},f4=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},xte=a4(),sl=l4(),jm=c4(),UT=u4(),Fn=d4(),Px=h4(),Dx=Number(f4());function qm(r){return Array.isArray(r)?r:[r]}function GT(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 mh(r){return sl?r.metaKey:r.ctrlKey}var Ue=[],Ym={},gh={},Xm={};function kT(r){Ue.includes(r)||Ue.push(r)}function Zc(r){delete Ym[r.pointerId];for(let t=0;t<Ue.length;t++)if(Ue[t].pointerId===r.pointerId){Ue.splice(t,1);break}}function VT(){Ue.splice(0,Ue.length)}function Qm(r){if(r.pointerType!=="touch")return;let t=Ym[r.pointerId];t===void 0&&(t={x:0,y:0},Ym[r.pointerId]=t),t.x=r.pageX,t.y=r.pageY}function Km(r){let t=r.pointerId===Ue[0].pointerId?Ue[1]:Ue[0];return Ym[t.pointerId]}function zT(r){gh[r.key]=!0,Xm[r.key]=Xm[r.key]===void 0?1:Xm[r.key]+1}function HT(r){if(sl&&gh.Meta)for(let t in gh)gh[t]=!1;else gh[r.key]=!1;Xm={}}function WT(r){r.addEventListener("pointerdown",kT,!0),r.addEventListener("pointerdown",Qm,!0),r.addEventListener("pointermove",Qm,!0),r.addEventListener("pointerup",Zc,!0),r.addEventListener("pointercancel",Zc,!0),r.addEventListener("pointerleave",Zc,!0),window.addEventListener("keydown",zT,!0),window.addEventListener("keyup",HT,!0)}function jT(r){r.removeEventListener("pointerdown",kT,!0),r.removeEventListener("pointerdown",Qm,!0),r.removeEventListener("pointermove",Qm,!0),r.removeEventListener("pointerup",Zc,!0),r.removeEventListener("pointercancel",Zc,!0),r.removeEventListener("pointerleave",Zc,!0),window.removeEventListener("keydown",zT,!0),window.removeEventListener("keyup",HT,!0)}var qT;(e=>{function r(n){return n==="Component"||n==="Instance"}e.isComponentRelated=r;function t(n){return n==="Empty"||n==="Instance"}e.isEmptyOrComponent=t})(qT||(qT={}));var Jc;(i=>{i.identity={...Bm.identity,hiddenMatrix:Zo.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 FT({position:ds.isEqual(s.position,o.position)?void 0:o.position,rotation:ds.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:ds.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:Zo.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}i.diff=n})(Jc||(Jc={}));var XT;(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]})(XT||(XT={}));var ri;(t=>t.defaultData={states:new ze,events:new ze,visible:!0,raycastLock:!1,collision:"visibility",physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Jc.identity,cloner:null})(ri||(ri={}));var YT;(t=>t.defaultData={type:"Empty",...ri.defaultData})(YT||(YT={}));var QT;(t=>t.defaultData={type:"Component",...ri.defaultData})(QT||(QT={}));var ol;(t=>t.defaultData={type:"Mesh",...ri.defaultData,...km.defaultData})(ol||(ol={}));var $c;(t=>t.defaultData={...ri.defaultData,...Jc.identity,...rl.defaultData})($c||($c={}));var Zm;(t=>{function r(e){return{...ri.defaultData,...Gm.defaultData(e)}}t.defaultData=r})(Zm||(Zm={}));var eu;(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})(eu||(eu={}));var $o;(s=>{s.rootOverrideProps=["physics"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function n(o,a){return{...ri.defaultData,...a,component:o,overrides:new Kt,physics:void 0,type:"Instance"}}s.ofComponent=n;function i(o){let a=Jc.fromObject(o.data);return n(o.id,a)}s.fromComponentData=i})($o||($o={}));var Jm;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Zo.identity,name:"Play Camera",visible:!0,raycastLock:!1,collision:"visibility",physics:null,states:new ze,events:new ze,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...rl.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",...ri.defaultData,...ol.defaultData,geometry:Jo.defaultData("RectangleGeometry"),material:$n.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...ri.defaultData,...ol.defaultData,geometry:Jo.defaultData("BooleanGeometry"),material:$n.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...ri.defaultData,...ol.defaultData,geometry:Jo.defaultData("TextGeometry"),material:$n.defaultTwoLayerData("phong","layer1","layer2")}))(Jm||(Jm={}));var io;(i=>{function r(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Kt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Kt})))):Ri.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=qc(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let d=l.layers.data(u);d&&_r.patch(d,c)}}).data),a.materials&&o.materials&&(a.materials=qc(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&&_r.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(...Fm.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,Jc.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})}),Ri.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:Wm.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:hs.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:hs.merge(a.cloner,o.cloner)});else if(Um.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=dr.clone(l.color))}return a}i.patch=n})(io||(io={}));var vh;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:dr.white,near:.1,far:2e3})(vh||(vh={}));var tu;(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})(tu||(tu={}));var so;(t=>t.defaultData={orbitControls:tu.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((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})(so||(so={}));var Tr;(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})(Tr||(Tr={}));var $m;(o=>{o.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(a={withLight:!0,withSquare:!0}){let l=new Qt,u=Jm.defaultMeshObject;return a.withLight===!0&&l.push({fi:-1,data:{...Zm.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:Rr.fromHexAndA(2960946,1),postprocessing:il.defaultData,fog:vh.defaultData,objects:t(),environment:Tr.defaultData,publish:so.defaultData},o.emptyData=function(a){return{backgroundColor:Rr.fromHexAndA(2960946,1),postprocessing:il.defaultData,fog:vh.defaultData,objects:a?t(a):new Qt,environment:Tr.defaultData,publish:so.defaultData}};function i(a){return{...o.defaultData,objects:Bi(a,Qt.prototype)}}o.withObjs=i;function s(a,l){return i([{id:a,data:l,children:[],fi:0}])}o.withObj=s})($m||($m={}));var nu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(nu||(nu={}));var ru;(n=>{function r(){let i={};return i["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Bi(i,Lt.prototype)}n.defaultColors=r;function t(i){let s={};return i?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...nu.emptyImage,name:"AI generated image"}),Bi(s,Lt.prototype)}n.defaultImages=t;function e(){return{materials:new Lt,images:new Lt,videos:new Lt,colors:new Lt,audios:new Lt,fonts:new Lt,penumbraSize:[2,2,2]}}n.emptyData=e})(ru||(ru={}));function KT(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={...Xo(Zn(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={...Zn(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function eg(r,t){Object.values(r.shared.materials).forEach(e=>t(e))}function tg(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 m4(r){Object.assign(r.scene.publish,{orbitControls:{...tu.defaultData,...Zn(r.scene.publish.orbitControls)}})}function g4(r){Object.assign(r.scene.publish.settings,{video:{...so.defaultData.settings.video,...Zn(r.scene.publish.settings.video)}})}function y4(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((Vm.includes(i)||typeof s=="boolean")&&delete n[i],i==="texture")for(let[o,a]of Object.entries(s))(BT.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 v4(r){r.scene.publish.withBackground=!0}function x4(r){r.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function b4(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 S4(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 w4(r){r.scene.objects.traverse((t,e)=>{let n=r.scene.objects.unproxy().parent(t);if(n){let i=Zn(r.scene.objects.data(n));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Zn(e).booleanExclude!==!0)}})}function A4(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 E4(r){function t(n){Object.setPrototypeOf(n,Kt.prototype),n.texture&&Object.setPrototypeOf(n.texture,Kt.prototype)}function e(n){Object.setPrototypeOf(n,Kt.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=Zn(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=Zn(l).layers;e(u),l.layers=u}})})}function ZT(r){r.layers===void 0&&Object.assign(r,$n.defaultTwoLayerData("lambert"))}function Ix(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={...Zn(t),colors:e,steps:n};Object.assign(t,i)}})}function _4(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function JT(r){r.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(n=>{typeof n!="string"&&Ix(n)}):"material"in e&&typeof e.material!="string"&&Ix(e.material)}),Object.values(r.shared.materials).forEach(t=>Ix(t))}function T4(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 M4(r){r.shared.audios=Bi({},Lt.prototype)}function C4(r){r.shared.videos=Bi({},Lt.prototype)}function P4(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 D4(r){Object.entries(Zn(r.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.images[n]}),Object.entries(Zn(r.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.audios[n]})}function I4(r){r.scene.publish.settings.web.preload=!1}function $T(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 O4(r){r.shared.fonts=Bi({},Lt.prototype)}function L4(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 R4(r){let t=[];r.scene.objects.traverse((e,n)=>{let i=n;if(i.type==="TextFrame"){let s=$n.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=L4(i.font);r.shared.fonts[a]===void 0&&(r.shared.fonts[a]={name:a});let l={name:i.name,...ri.defaultData,...ol.defaultData,flatShading:!1,wireframe:!1,geometry:{...Jo.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:Zn(i.states),events:Zn(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},u=Zn(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 N4(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 ze,move:new ze,jump:new ze}});else{let s=new ze;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,Xo(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 ze({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 B4(r){r.scene.objects.traverse((t,e)=>{function n(i,s){let o=new ze,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let d;a.push(u),l.interaction==="play"?d={...Xo(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={...Xo(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 eM(r){let t=r.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=_r.defaultData("light","phong"),n=t;Object.assign(n,e),n.visible=!1}}function tM(r){eg(r,eM),tg(r,eM)}function F4(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function U4(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 G4(r){r.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=$n.defaultTwoLayerData("phong"))})}function k4(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 V4(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 z4(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 H4(r){let{video:t}=r.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function W4(r){r.scene.objects.traverse((t,e)=>{e.events.forEach(n=>{n.type==="GameControl"&&(n.resetYPosition=Math.abs(n.resetYPosition-e.position[1]))})})}function j4(r){let t=r.scene.environment.usePhysics;r.scene.objects.traverse((e,n)=>{t&&n.physics===null?n.collision=!1:n.collision="visibility"})}var nM=37;function rM(r){let t=r.schema??0;t!==nM&&(console.warn("updating from ",t,"to ",nM),t<1&&(tg(r,KT),eg(r,KT),r.schema=1),t<2&&(m4(r),r.schema=2),t<3&&(y4(r),r.schema=3),t<4&&(v4(r),r.schema=4),t<5&&(x4(r),r.schema=5),t<6&&(b4(r),r.schema=6),t<7&&(S4(r),r.schema=7),t<8&&(r.schema=8),t<9&&(JT(r),r.schema=9),t<10&&(_4(r),r.schema=10),t<11&&(T4(r),r.schema=11),t<12&&(JT(r),r.schema=12),t<13&&(M4(r),r.schema=13),t<14&&(P4(r),r.schema=14),t<15&&(D4(r),r.schema=15),t<16&&(I4(r),r.schema=16),t<17&&(tg(r,$T),eg(r,$T),r.schema=17),t<18&&(tg(r,ZT),eg(r,ZT),r.schema=18),t<19&&(g4(r),r.schema=19),t<20&&(O4(r),R4(r),r.schema=20),t<21&&(N4(r),B4(r),r.schema=21),t<22&&(tM(r),r.schema=22),t<23&&(F4(r),r.schema=23),t<24&&(U4(r),r.schema=24),(t<25||r.shared.videos===void 0)&&(C4(r),t<25&&(r.schema=25)),t<26&&(w4(r),r.schema=26),t<27&&(A4(r),r.schema=27),t<28&&(tM(r),r.schema=28),t<29&&(E4(r),r.schema=29),t<30&&(G4(r),r.schema=30),t<31&&(k4(r),r.schema=31),t<33&&(V4(r),r.schema=33),t<34&&(z4(r),r.schema=34),t<35&&(H4(r),r.schema=35),t<36&&(W4(r),r.schema=36),t<37&&(j4(r),r.schema=37))}function oo(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 _e,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=iM(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=iM(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 iM(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 Fe(s,e,n)}var ng;(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 ze,move:new ze,jump:new ze}}))(ng||(ng={}));var sM=Math.pow(2,-24);var al=class{constructor(){}};function mi(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 Ox(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 Lx(r,t){t.set(r)}function Rx(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 xh(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 su(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 Y4(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 Fe(i,1));for(let s=0;s<e;s++)i[s]=s}}function Q4(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 Bx(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 S=r[v+0],w=r[v+1],E=S-w,_=S+w;E<s&&(s=E),_>l&&(l=_),y&&S<d&&(d=S),y&&S>g&&(g=S);let b=r[v+2],T=r[v+3],M=b-T,D=b+T;M<o&&(o=M),D>u&&(u=D),y&&b<h&&(h=b),y&&b>p&&(p=b);let P=r[v+4],C=r[v+5],I=P-C,R=P+C;I<a&&(a=I),R>c&&(c=R),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 K4(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 Z4(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 ao=32,J4=(r,t)=>r.candidate-t.candidate,ea=new Array(ao).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),rg=new Float32Array(6);function $4(r,t,e,n,i,s){let o=-1,a=0;if(s===0)o=Ox(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=Ox(r),o!==-1&&(a=eH(e,n,i,o));else if(s===2){let l=su(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)/ao;if(i<ao/4){let y=[...ea];y.length=i;let v=0;for(let S=c;S<d;S+=6,v++){let w=y[v];w.candidate=e[S+2*h],w.count=0;let{bounds:E,leftCacheBounds:_,rightCacheBounds:b}=w;for(let T=0;T<3;T++)b[T]=1/0,b[T+3]=-1/0,_[T]=1/0,_[T+3]=-1/0,E[T]=1/0,E[T+3]=-1/0;xh(S,e,E)}y.sort(J4);let x=i;for(let S=0;S<x;S++){let w=y[S];for(;S+1<x&&y[S+1].candidate===w.candidate;)y.splice(S+1,1),x--}for(let S=c;S<d;S+=6){let w=e[S+2*h];for(let E=0;E<x;E++){let _=y[E];w>=_.candidate?xh(S,e,_.rightCacheBounds):(xh(S,e,_.leftCacheBounds),_.count++)}}for(let S=0;S<x;S++){let w=y[S],E=w.count,_=i-w.count,b=w.leftCacheBounds,T=w.rightCacheBounds,M=0;E!==0&&(M=su(b)/l);let D=0;_!==0&&(D=su(T)/l);let P=1+1.25*(M*E+D*_);P<u&&(o=h,u=P,a=w.candidate)}}else{for(let x=0;x<ao;x++){let S=ea[x];S.count=0,S.candidate=f+m+x*m;let w=S.bounds;for(let E=0;E<3;E++)w[E]=1/0,w[E+3]=-1/0}for(let x=c;x<d;x+=6){let E=~~((e[x+2*h]-f)/m);E>=ao&&(E=ao-1);let _=ea[E];_.count++,xh(x,e,_.bounds)}let y=ea[ao-1];Lx(y.bounds,y.rightCacheBounds);for(let x=ao-2;x>=0;x--){let S=ea[x],w=ea[x+1];Rx(S.bounds,w.rightCacheBounds,S.rightCacheBounds)}let v=0;for(let x=0;x<ao-1;x++){let S=ea[x],w=S.count,E=S.bounds,b=ea[x+1].rightCacheBounds;w!==0&&(v===0?Lx(E,rg):Rx(E,rg,rg)),v+=w;let T=0,M=0;v!==0&&(T=su(rg)/l);let D=i-v;D!==0&&(M=su(b)/l);let P=1+1.25*(T*v+M*D);P<u&&(o=h,u=P,a=S.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function eH(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 tH(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 S=m;y>S&&(S=y),v>S&&(S=v);let w=(S-x)/2,E=p*2;o[d+E+0]=x+w,o[d+E+1]=w+(Math.abs(x)+w)*sM,x<t[p]&&(t[p]=x),S>t[p+3]&&(t[p+3]=S)}}return o}function nH(r,t){function e(y){h&&h(y/f)}function n(y,v,x,S=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 E=$4(y.boundingData,S,o,v,x,d);if(E.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let _=Z4(a,o,v,x,E);if(_===v||_===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=E.axis;let b=new al,T=v,M=_-v;y.left=b,b.boundingData=new Float32Array(6),Bx(o,T,M,b.boundingData,s),n(b,T,M,s,w+1);let D=new al,P=_,C=x-M;y.right=D,D.boundingData=new Float32Array(6),Bx(o,P,C,D.boundingData,s),n(D,P,C,s,w+1)}return y}Y4(r,t);let i=new Float32Array(6),s=new Float32Array(6),o=tH(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=Q4(r);if(m.length===1){let y=m[0],v=new al;v.boundingData=i,K4(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 al;v.boundingData=new Float32Array(6),Bx(o,y.offset,y.count,v.boundingData,s),n(v,y.offset,y.count,s),p.push(v)}return p}function lM(r,t){let e=nH(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 Nr=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}};Nr.prototype.setFromBox=function(){let r=new A;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 mre=function(){let r=new Nr;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 rH=function(){let r=new A,t=new A,e=new A;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}}(),bh=function(){let r=new F,t=new A,e=new A;return function(i,s,o,a){rH(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}}}}(),cM=function(){let r=new A,t=new A,e=new dn,n=new Nn;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 iH=1e-15;function ou(r){return Math.abs(r)<iH}var Br=class extends rn{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new Nr),this.points=[this.a,this.b,this.c],this.sphere=new Tn,this.plane=new dn,this.needsUpdate=!0}intersectsSphere(t){return cM(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}};Br.prototype.closestPointToSegment=function(){let r=new A,t=new A,e=new Nn;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]),bh(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)}}();Br.prototype.intersectsTriangle=function(){let r=new Br,t=new Array(3),e=new Array(3),n=new Nr,i=new Nr,s=new A,o=new A,a=new A,l=new A,u=new Nn,c=new Nn,d=new Nn;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 E=y[w],_=v[w];if(n.setFromPoints(_,e),E.isSeparated(n))return!1}let x=f.satBounds,S=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let E=x[w],_=S[w];if(n.setFromPoints(_,t),E.isSeparated(n))return!1}for(let w=0;w<4;w++){let E=v[w];for(let _=0;_<4;_++){let b=S[_];if(s.crossVectors(E,b),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 I=y[C],R=y[(C+1)%3];u.start.copy(I),u.end.copy(R),u.delta(o);let G=v?c.start:c.end,Y=ou(m.distanceToPoint(I));if(ou(m.normal.dot(o))&&Y){c.copy(u),x=2;break}if((m.intersectLine(u,G)||Y)&&!ou(G.distanceTo(R))){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 S=f.points,w=!1,E=0;for(let C=0;C<3;C++){let I=S[C],R=S[(C+1)%3];u.start.copy(I),u.end.copy(R),u.delta(a);let G=w?d.start:d.end,Y=ou(p.distanceToPoint(I));if(ou(p.normal.dot(a))&&Y){d.copy(u),E=2;break}if((p.intersectLine(u,G)||Y)&&!ou(G.distanceTo(R))){if(E++,w)break;w=!0}}if(E===1&&this.containsPoint(d.start))return g&&(g.start.copy(d.start),g.end.copy(d.start)),!0;if(E!==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 _=c.start.dot(o),b=c.end.dot(o),T=d.start.dot(o),M=d.end.dot(o),D=b<T,P=_<M;return _!==M&&T!==b&&D===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)}}}();Br.prototype.distanceToPoint=function(){let r=new A;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();Br.prototype.distanceToTriangle=function(){let r=new A,t=new A,e=["a","b","c"],n=new Nn,i=new Nn;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]),bh(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 Fr=class extends bt{constructor(...t){super(...t),this.isOrientedBox=!0,this.matrix=new de,this.invMatrix=new de,this.points=new Array(8).fill().map(()=>new A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new Nr),this.alignedSatBounds=new Array(3).fill().map(()=>new Nr),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}};Fr.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}}();Fr.prototype.intersectsBox=function(){let r=new Nr;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}}();Fr.prototype.intersectsTriangle=function(){let r=new Br,t=new Array(3),e=new Nr,n=new Nr,i=new A;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);let a=this.satBounds,l=this.satAxes;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}}();Fr.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}}();Fr.prototype.distanceToPoint=function(){let r=new A;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}();Fr.prototype.distanceToBox=function(){let r=["x","y","z"],t=new Array(12).fill().map(()=>new Nn),e=new Array(12).fill().map(()=>new Nn),n=new A,i=new A;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),u&&u.copy(i)),0;let c=a*a,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,S=(m+2)%3,w=y<<x|v<<S,E=1<<m|y<<x|v<<S,_=f[w],b=f[E];t[p].set(_,b);let M=r[m],D=r[x],P=r[S],C=e[p],I=C.start,R=C.end;I[M]=d[M],I[D]=y?d[D]:h[D],I[P]=v?d[P]:h[D],R[M]=h[M],R[D]=y?d[D]:h[D],R[P]=v?d[P]:h[D],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];bh(y,x,n,i);let S=n.distanceToSquared(i);if(S<g&&(g=S,l&&l.copy(n),u&&u.copy(i),S<c))return Math.sqrt(S)}}return Math.sqrt(g)}}();var sg=new A,og=new A,ag=new A,uM=new F,dM=new F,hM=new F,fM=new A;function sH(r,t,e,n,i,s){let o;return s===_n?o=r.intersectTriangle(n,e,t,!0,i):o=r.intersectTriangle(t,e,n,s!==br,i),o===null?null:{distance:r.origin.distanceTo(i),point:i.clone()}}function oH(r,t,e,n,i,s,o){sg.fromBufferAttribute(t,n),og.fromBufferAttribute(t,i),ag.fromBufferAttribute(t,s);let a=sH(r,sg,og,ag,fM,o);if(a){e&&(uM.fromBufferAttribute(e,n),dM.fromBufferAttribute(e,i),hM.fromBufferAttribute(e,s),a.uv=rn.getUV(fM,sg,og,ag,uM,dM,hM,new F));let l={a:n,b:i,c:s,normal:new A,materialIndex:0};rn.getNormal(sg,og,ag,l.normal),a.face=l,a.faceIndex=n}return a}function Ux(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=oH(e,r.attributes.position,r.attributes.uv,o,a,l,t);return u?(u.faceIndex=n,i&&i.push(u),u):null}function pM(r,t,e,n,i,s){for(let o=n,a=n+i;o<a;o++)Ux(r,t,e,o,s)}function mM(r,t,e,n,i){let s=1/0,o=null;for(let a=n,l=n+i;a<l;a++){let u=Ux(r,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Gx(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 gi(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 kx(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(gi(o,u*3,a,l),o.needsUpdate=!0,n(o,u,i,s))return!0;return!1}var au=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 lo(r,t){return t[r+15]===65535}function ll(r,t){return t[r+6]}function lu(r,t){return t[r+14]}function cu(r){return r+8}function uu(r,t){return t[r+6]}function gM(r,t){return t[r+7]}var du=new bt,cg=new A,lH=["x","y","z"];function ug(r,t,e,n,i){let s=r*2,o=hu,a=ta,l=na;if(lo(s,a)){let c=ll(r,l),d=lu(s,a);pM(t,e,n,c,d,i)}else{let c=cu(r);hg(c,o,n,cg)&&ug(c,t,e,n,i);let d=uu(r,l);hg(d,o,n,cg)&&ug(d,t,e,n,i)}}function dg(r,t,e,n){let i=r*2,s=hu,o=ta,a=na;if(lo(i,o)){let u=ll(r,a),c=lu(i,o);return mM(t,e,n,u,c)}else{let u=gM(r,a),c=lH[u],h=n.direction[c]>=0,f,g;h?(f=cu(r),g=uu(r,a)):(f=uu(r,a),g=cu(r));let m=hg(f,s,n,cg)?dg(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=hg(g,s,n,cg)?dg(g,t,e,n):null;return m&&v?m.distance<=v.distance?m:v:m||v||null}}var yM=function(){let r,t,e=[],n=new au(()=>new bt);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 S=x*2,w=ta,E=na;for(;!lo(S,w);)x=cu(x),S=x*2;return ll(x,E)}function f(x){let S=x*2,w=ta,E=na;for(;!lo(S,w);)x=uu(x,E),S=x*2;return ll(x,E)+lu(S,w)}let g=s*2,p=hu,m=ta,y=na;if(lo(g,m)){let x=ll(s,y),S=lu(g,m);return mi(s,p,r),l(x,S,!1,d,c+s,r)}else{let x=cu(s),S=uu(s,y),w=x,E=S,_,b,T,M;if(u&&(T=r,M=t,mi(w,p,T),mi(E,p,M),_=u(T),b=u(M),b<_)){w=S,E=x;let Y=_;_=b,b=Y,T=M}T||(T=r,mi(w,p,T));let D=lo(w*2,m),P=a(T,D,_,d+1,c+w),C;if(P===2){let Y=h(w),q=f(w)-Y;C=l(Y,q,!0,d+1,c+w,T)}else C=P&&i(w,o,a,l,u,c,d+1);if(C)return!0;M=t,mi(E,p,M);let I=lo(E*2,m),R=a(M,I,b,d+1,c+E),G;if(R===2){let Y=h(E),q=f(E)-Y;G=l(Y,q,!0,d+1,c+E,M)}else G=R&&i(E,o,a,l,u,c,d+1);return!!G}}}(),vM=function(){let r=new Br,t=new Br,e=new de,n=new Fr,i=new Fr;return function s(o,a,l,u,c=null){let d=o*2,h=hu,f=ta,g=na;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),lo(d,f)){let m=a,y=m.index,v=m.attributes.position,x=l.index,S=l.attributes.position,w=ll(o,g),E=lu(d,f);if(e.copy(u).invert(),l.boundsTree)return mi(o,h,i),i.matrix.copy(e),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:b=>i.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(u),b.b.applyMatrix4(u),b.c.applyMatrix4(u),b.needsUpdate=!0;for(let T=w*3,M=(E+w)*3;T<M;T+=3)if(gi(t,T,y,v),t.needsUpdate=!0,b.intersectsTriangle(t))return!0;return!1}});for(let _=w*3,b=E+w*3;_<b;_+=3){gi(r,_,y,v),r.a.applyMatrix4(e),r.b.applyMatrix4(e),r.c.applyMatrix4(e),r.needsUpdate=!0;for(let T=0,M=x.count;T<M;T+=3)if(gi(t,T,x,S),t.needsUpdate=!0,r.intersectsTriangle(t))return!0}}else{let m=o+8,y=g[o+6];return mi(m,h,du),!!(c.intersectsBox(du)&&s(m,a,l,u,c)||(mi(y,h,du),c.intersectsBox(du)&&s(y,a,l,u,c)))}}}();function hg(r,t,e,n){return mi(r,t,du),e.intersectBox(du,n)}var Vx=[],lg,hu,ta,na;function fu(r){lg&&Vx.push(lg),lg=r,hu=new Float32Array(r),ta=new Uint16Array(r),na=new Uint32Array(r)}function Sh(){lg=null,hu=null,ta=null,na=null,Vx.length&&fu(Vx.pop())}var zx=Symbol("skip tree generation"),Hx=new bt,Wx=new bt,pu=new de,cl=new Fr,wh=new Fr,Ah=new A,fg=new A,cH=new A,uH=new A,dH=new A,xM=new bt,fs=new au(()=>new Br),an=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."),an.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."),an.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 an(e,{...n,[zx]:!0});if(o._roots=s,n.setIndex){let a=e.getIndex();if(a===null){let l=new Fe(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,[zx]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[zx]||(this._roots=lM(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new bt))),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 S=u[p+6],w=c[v+14],E=1/0,_=1/0,b=1/0,T=-1/0,M=-1/0,D=-1/0;for(let P=3*S,C=3*(S+w);P<C;P++){let I=n[P]*a+o,R=s[I+0],G=s[I+1],Y=s[I+2];R<E&&(E=R),R>T&&(T=R),G<_&&(_=G),G>M&&(M=G),Y<b&&(b=Y),Y>D&&(D=Y)}return d[p+0]!==E||d[p+1]!==_||d[p+2]!==b||d[p+3]!==T||d[p+4]!==M||d[p+5]!==D?(d[p+0]=E,d[p+1]=_,d[p+2]=b,d[p+3]=T,d[p+4]=M,d[p+5]=D,!0):!1}else{let S=p+8,w=u[p+6],E=S+m,_=w+m,b=y,T=!1,M=!1;t?b||(T=t.has(E),M=t.has(_),b=!T&&!M):(T=!0,M=!0);let D=b||T,P=b||M,C=!1;D&&(C=g(S,m,b));let I=!1;P&&(I=g(w,m,b));let R=C||I;if(R)for(let G=0;G<3;G++){let Y=S+G,W=w+G,q=d[Y],j=d[Y+3],X=d[W],N=d[W+3];d[p+G]=q<X?q:X,d[p+G+3]=j>N?j:N}return R}}}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=Kr){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(fu(n[c]),ug(0,i,h,t,s),Sh(),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=Kr){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;fu(n[c]);let f=dg(0,i,h,t);Sh(),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(fu(s),i=vM(0,n,t,e),Sh(),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=fs.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:kx(f,g,i,u,p,m,s)}else l||(u?l=(h,f,g,p)=>kx(h,f,i,u,g,p,s):l=(h,f,g)=>g);let c=!1,d=0;for(let h of this._roots){if(fu(h),c=yM(0,i,a,l,o,d),Sh(),c)break;d+=h.byteLength}return fs.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;pu.copy(e).invert();let c=fs.getPrimitive(),d=fs.getPrimitive();if(s){let f=function(g,p,m,y,v,x,S,w){for(let E=m,_=m+y;E<_;E++){gi(d,E*3,l,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let b=g,T=g+p;b<T;b++)if(gi(c,b*3,o,a),c.needsUpdate=!0,s(c,d,b,E,v,x,S,w))return!0}return!1};if(i){let g=i;i=function(p,m,y,v,x,S,w,E){return g(p,m,y,v,x,S,w,E)?!0:f(p,m,y,v,x,S,w,E)}}else i=f}t.getBoundingBox(Wx),Wx.applyMatrix4(e);let h=this.shapecast({intersectsBounds:f=>Wx.intersectsBox(f),intersectsRange:(f,g,p,m,y,v)=>(Hx.copy(v),Hx.applyMatrix4(pu),t.shapecast({intersectsBounds:x=>Hx.intersectsBox(x),intersectsRange:(x,S,w,E,_)=>i(f,g,x,S,m,y,E,_)}))});return fs.releasePrimitive(c),fs.releasePrimitive(d),h}intersectsBox(t,e){return cl.set(t.min,t.max,e),cl.needsUpdate=!0,this.shapecast({intersectsBounds:n=>cl.intersectsBox(n),intersectsTriangle:n=>cl.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(),cl.set(t.boundingBox.min,t.boundingBox.max,e),cl.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,d=t.index,h=fs.getPrimitive(),f=fs.getPrimitive(),g=fg,p=cH,m=null,y=null;i&&(m=uH,y=dH);let v=1/0,x=null,S=null;return pu.copy(e).invert(),wh.matrix.copy(pu),this.shapecast({boundsTraverseOrder:w=>cl.distanceToBox(w),intersectsBounds:(w,E,_)=>_<v&&_<o?(E&&(wh.min.copy(w.min),wh.max.copy(w.max),wh.needsUpdate=!0),!0):!1,intersectsRange:(w,E)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:_=>wh.distanceToBox(_),intersectsBounds:(_,b,T)=>T<v&&T<o,intersectsRange:(_,b)=>{for(let T=_*3,M=(_+b)*3;T<M;T+=3){gi(f,T,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let D=w*3,P=(w+E)*3;D<P;D+=3){gi(h,D,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=D/3,S=T/3),C<s)return!0}}}});{let _=d?d.count:c.count;for(let b=0,T=_;b<T;b+=3){gi(f,b,d,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let M=w*3,D=(w+E)*3;M<D;M+=3){gi(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,S=b/3),P<s)return!0}}}}}),fs.releasePrimitive(h),fs.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(pu),p.applyMatrix4(pu),i.distance=p.sub(i.point).length(),i.faceIndex=S),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=>(Ah.copy(t).clamp(c.min,c.max),Ah.distanceToSquared(t)),intersectsBounds:(c,d,h)=>h<a&&h<o,intersectsTriangle:(c,d)=>{c.closestPointToPoint(t,Ah);let h=t.distanceToSquared(Ah);return h<a&&(fg.copy(Ah),a=h,l=d),h<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(fg):e.point=fg.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{mi(0,new Float32Array(n),xM),t.union(xM)}),t}},bM=an.prototype.raycast;an.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 bM.call(this,n,t.material).forEach(o=>{o=Gx(o,t,e),o&&i.push(o)}),i}else return bM.apply(this,r)};var SM=an.prototype.raycastFirst;an.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 Gx(SM.call(this,n,t.material),t,e)}else return SM.apply(this,r)};var wM=an.prototype.closestPointToPoint;an.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,wM.apply(this,r),t&&t.copy(e.point),e.distance}else return wM.apply(this,r)};var AM=an.prototype.closestPointToGeometry;an.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,AM.apply(this,r),t&&t.copy(n.point),e&&e.copy(i.point).applyMatrix4(s),n.distance}else return AM.apply(this,r)};var EM=an.prototype.refit;an.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)),EM.call(this,n)}else EM.apply(this,r)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(r=>{let t=an.prototype[r];an.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 ju=Bs(TM());var hH=.5*(Math.sqrt(3)-1),Eh=(3-Math.sqrt(3))/6,fH=1/3,ps=1/6,cie=(Math.sqrt(5)-1)/4,uie=(5-Math.sqrt(5))/20,_h=r=>Math.floor(r)|0,MM=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]),qx=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 pg(r=Math.random){let t=PM(r),e=new Float64Array(t).map(i=>MM[i%12*2]),n=new Float64Array(t).map(i=>MM[i%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*hH,d=_h(s+c),h=_h(o+c),f=(d+h)*Eh,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 S=m-v+Eh,w=y-x+Eh,E=m-1+2*Eh,_=y-1+2*Eh,b=d&255,T=h&255,M=.5-m*m-y*y;if(M>=0){let C=b+t[T],I=e[C],R=n[C];M*=M,a=M*M*(I*m+R*y)}let D=.5-S*S-w*w;if(D>=0){let C=b+v+t[T+x],I=e[C],R=n[C];D*=D,l=D*D*(I*S+R*w)}let P=.5-E*E-_*_;if(P>=0){let C=b+1+t[T+1],I=e[C],R=n[C];P*=P,u=P*P*(I*E+R*_)}return 70*(a+l+u)}}function CM(r=Math.random){let t=PM(r),e=new Float64Array(t).map(s=>qx[s%12*3]),n=new Float64Array(t).map(s=>qx[s%12*3+1]),i=new Float64Array(t).map(s=>qx[s%12*3+2]);return function(o,a,l){let u,c,d,h,f=(o+a+l)*fH,g=_h(o+f),p=_h(a+f),m=_h(l+f),y=(g+p+m)*ps,v=g-y,x=p-y,S=m-y,w=o-v,E=a-x,_=l-S,b,T,M,D,P,C;w>=E?E>=_?(b=1,T=0,M=0,D=1,P=1,C=0):w>=_?(b=1,T=0,M=0,D=1,P=0,C=1):(b=0,T=0,M=1,D=1,P=0,C=1):E<_?(b=0,T=0,M=1,D=0,P=1,C=1):w<_?(b=0,T=1,M=0,D=0,P=1,C=1):(b=0,T=1,M=0,D=1,P=1,C=0);let I=w-b+ps,R=E-T+ps,G=_-M+ps,Y=w-D+2*ps,W=E-P+2*ps,q=_-C+2*ps,j=w-1+3*ps,X=E-1+3*ps,N=_-1+3*ps,U=g&255,z=p&255,H=m&255,V=.6-w*w-E*E-_*_;if(V<0)u=0;else{let k=U+t[z+t[H]];V*=V,u=V*V*(e[k]*w+n[k]*E+i[k]*_)}let re=.6-I*I-R*R-G*G;if(re<0)c=0;else{let k=U+b+t[z+T+t[H+M]];re*=re,c=re*re*(e[k]*I+n[k]*R+i[k]*G)}let K=.6-Y*Y-W*W-q*q;if(K<0)d=0;else{let k=U+D+t[z+P+t[H+C]];K*=K,d=K*K*(e[k]*Y+n[k]*W+i[k]*q)}let Z=.6-j*j-X*X-N*N;if(Z<0)h=0;else{let k=U+1+t[z+1+t[H+1]];Z*=Z,h=Z*Z*(e[k]*j+n[k]*X+i[k]*N)}return 32*(u+c+d+h)}}function PM(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 Fi=new rn,mg=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;Fi.a.fromBufferAttribute(t,i),Fi.b.fromBufferAttribute(t,i+1),Fi.c.fromBufferAttribute(t,i+2),s*=Fi.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),Fi.a.fromBufferAttribute(this.positionAttribute,t*3),Fi.b.fromBufferAttribute(this.positionAttribute,t*3+1),Fi.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Fi.a,i).addScaledVector(Fi.b,s).addScaledVector(Fi.c,1-(i+s)),Fi.getNormal(n),this}};var IM=Bs(Xx()),pH=new de,mH=new de,gH=new de,Th;(t=>{function r(e){return e&&e.__isSPEObject}t.is=r})(Th||(Th={}));var mu=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 ct&&(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)Th.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=pH.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=mH.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=gH.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}copy(n,i=!1){return super.copy(n,i),this.hasNonUniformScale=n.hasNonUniformScale,this}};var Yx=class extends mu(ct){},yH=r=>r.type==="Mesh",or=class extends Yx{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,n){}expand(){let e=0,n=this.object.entityChildren(e);for(;n;){let i=this.children[e];i?.object!==n&&(i&&this.remove(i),i=new or(n),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,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.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return yH(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 ul=new A,dl=new A,gu=new de,LM=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],vH=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],xH=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],OM=(r,t,e)=>{r.updateEntityBoxSize(ul,dl),gu.copy(t).multiply(r.matrixWorld),dl.x===0&&dl.y===0&&dl.z===0?e.push(new A(ul.x,ul.y,ul.z).applyMatrix4(gu)):LM.forEach(n=>{e.push(n.clone().multiply(dl).add(ul).applyMatrix4(gu))})},Mh=class extends bt{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=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new A);return}OM(o,n,s)}}):OM(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(gu.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(dl).multiplyScalar(.5),this.getCenter(ul),gu.copy(this.matrix).setPosition(ul),this.vertices=LM.map(e=>e.clone().multiply(dl).applyMatrix4(gu))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=vH.map(([e,n])=>new Nn(this.vertices[e],this.vertices[n])),this.centerEdges=this.edges.map(e=>e.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=xH.map(([e,n])=>this.vertices[e].clone().add(this.vertices[n]).multiplyScalar(.5))}};var Ui={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var Kx=class extends Hd{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 Zx=.001;function Jx(r,t,e){return t.clone().sub(r).cross(t.clone().sub(e)).length()<=Zx}function Qx(r,t){let e=new A(...r.position),n=new A(...r.controlNext.position),i=new A(...t.controlPrevious.position),s=new A(...t.position);return Jx(e,n,s)&&Jx(e,i,s)}function yg(r){let t=r.points.map(c=>new A(...c.data.position)),e=[r.points[0]],n=new A(...e[0].data.position);for(let c=0;c<r.points.length-1;c++)Jx(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 A(...d.position),f=new A(...d.controlPrevious.position),g=new A(...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,S=new A(...v.position),w=new A(...x.position),E=S.clone().sub(h).normalize(),_=w.clone().sub(h).normalize();Object.assign(p,{prevDir:E,nextDir:_});let b=Qx(v,d),T=Qx(d,x);if(!b||!T)a[c]={...p,removedLength:0};else{let M=E.clone().add(_).normalize(),D=M.clone().cross(E).length()/E.dot(M);a[c]={...p,tan:D,removedLength:d.roundness/D}}}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(!Qx(e[d].data,e[h].data))f.position.distanceTo(g.position)>Zx&&(p=new ka(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)>Zx&&(p=new ka(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),S=m.clone().multiplyScalar(-p).add(x),w=h.distanceTo(S)/h.distanceTo(y),E=d.prevDir.clone().multiplyScalar(w*h.distanceTo(f)).add(h),_=E.clone().lerp(S,2),b=f.clone().lerp(E,4/3),T=g.clone().lerp(_,4/3);l[2*c]=new ka(f,b,T,g)}let u=new Kx;return l.forEach(c=>{c&&u.add(c)}),u}var vt;(t=>{function r(e){return e&&e.__isEntity}t.is=r})(vt||(vt={}));var co=r=>vt.is(r),bH={type:"completeState",isfromEntity:!0},vg=r=>class extends mu(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 Mh;this._recursiveBBox=new Mh;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(vt.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(vt.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)io.toOps(this.data,o.data).forEach(l=>{let u=vm.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=io.patch(this.data,o),io.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=>{co(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(vt.is(i[s]))return i[s];if(vt.is(n))return n.traverseSortNextHelper()}}sortNext(){let n=this.children;return this.children.length>0&&vt.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)co(i)&&n(i)}traverseEntityAncestors(n){this.traverseAncestors(i=>{vt.is(i)&&n(i)})}traverseEntity(n,i=0){if(n(this,i)!==!0)for(let o of this.children)co(o)&&o.traverseEntity(n,i+1)}traverseVisibleEntity(n){n(this);for(let i of this.children)co(i)&&i.visible&&i.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(n,i=!1){return super.copy(n,i),this.dataPatched=n.dataPatched,this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),this}hasEntityChild(){return this.children.some(n=>co(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 Gc(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??Zo.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)vt.is(n)&&n.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(n=>{vt.is(n)&&n.disposeRecursively()})}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return Gc(i,n)}updateByOp(n,i,s,o){let a=this.data;this.data=i;let l=n,u=Li(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=Ar.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=Ar.removeOverridden(n.path,n.props,c);l={...n,props:d}}}if(this.updateByPatchedOpBase(l,io.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Li(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(to.apply(f.component.data,f.overrideData),s))}}else{let h=s.scene.findInstance([this.uuid,...c]);if(h){let f=Ar.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=eu.resolve(i.overrides,c),h.updateByOp(n,sr.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 $o.rootOverrideProps)h in n.props&&(d===void 0&&(d={}),d[h]=n.props[h]);d&&(c={...n,props:d})}else for(let d of $o.rootOverrideProps)if(Li(n.path,[d])){c=n;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let h=to.filterOp(d.overrideData,c);h&&d.updateByOp(h,sr.applySimple(d.data,h),s,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let h=to.filterOp(d.overrideData,n);if(h){let f;a===d.data&&n===h?f=i:f=sr.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&&!Ri.is(n.props.type)&&Ui.changeEntityProptotype(this,i,s);else if(n.path.length===1&&n.path[0]==="geometry"&&n.type===0&&"type"in n.props){Ui.changeEntityProptotype(this,i,s);for(let o of this.children)vt.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),Li(n.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Li(n.path,["cloner"])!==null){let o=sr.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}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(n){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let l=n.find(i);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data,c=yg(u.geometry.path),d=(s+o)%1;s+o===1&&d===0&&(d=1);let 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 A(0,1,0)),x=new Vt().setFromRotationMatrix(v);p={...p,rotation:[x.x,x.y,x.z]}}this.updateTransformState(p),this.traverseEntity(m=>{m._cameraType&&m.dispatchEvent(bH)})}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 Ui.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 Ui.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 NM=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:8,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 Ch(u,c,n,i,s,o,a,l*Math.PI/180,d,d,h,f):g=new za(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 ra(r,t,e){e.x=r.x*t.x,e.y=r.y,e.z=r.x*t.y}function RM(r){return new F(r.y,-r.x)}var Ch=class extends _e{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,S=new A,w=new A;f&&t==0&&(t=u),f&&e==0&&(e=c);let E=new F(t,x),_=new F(e,-x),b=null,T=null,M=null,D=null,P=E.clone().sub(_),C=0,I=0,R=0;h>0&&(C=Math.min(t,e)*(1-h),I=t-C,R=e-C);let G=E.clone();G.x-=C;let Y=Math.PI-P.angle(),W=P.angle(),q=Math.tan(W/2),j=Math.tan(Y/2),X=q+j,N=h?X:j,U=h?X:q;if(u=Math.min(u,(t-I)/N,P.length()/X),c=Math.min(c,(e-R)/U,P.length()/X),u>0){let Z=u/q;b=E.clone().sub(new F(Z,u)),h&&(M=b.clone(),M.x-=C-X*u),E.sub(P.clone().setLength(Z))}if(c>0){let Z=c/j;T=_.clone().sub(new F(Z,-c)),_.add(P.clone().setLength(Z)),h&&(D=T.clone(),D.x-=C-X*c,G.sub(P.clone().setLength(Z)))}P=E.clone().sub(_);let z=P.length()<.5,H=[];for(let Z=0;Z<=i;Z++){let k=[],ue=Z/i,he=ue*l+a,ae=new F(Math.sin(he),Math.cos(he));D&&T?(V(k,ue,ae,Y,c,D,-1,!0),V(k,ue,ae,W,c,T,-1,!1)):T?(re(k,ae,T.x,0,-1),V(k,ue,ae,W,c,T,-1,!1)):o||re(k,ae,e,R,-1);let me=RM(P).normalize();if(ra(me,ae,S),!z)for(let be=0;be<=s;be++){let ge=be/s,Ae=P.clone().multiplyScalar(ge).add(_);ra(Ae,ae,w),p.push(w.x,w.y,w.z),m.push(S.x,S.y,S.z),y.push(ue,.5+w.y/n),k.push(v++)}if(M&&b?(V(k,ue,ae,Y,u,b,1,!1),V(k,ue,ae,W,u,M,1,!0)):b?(V(k,ue,ae,Y,u,b,1,!1),re(k,ae,b.x,0,1)):o||re(k,ae,t,I,1),h&&!z){let be=RM(P).multiplyScalar(-1).normalize();ra(be,ae,S);for(let ge=0;ge<=s;ge++){let Ae=ge/s,Me=P.clone().multiplyScalar(-Ae).add(G);ra(Me,ae,w),p.push(w.x,w.y,w.z),m.push(S.x,S.y,S.z),y.push(ue,.5+w.y/n),k.push(v++)}}h&&!o&&k.push(k[0]),H.push(k)}for(let Z=0;Z<H.length-1;Z++)for(let k=0;k<H[0].length-1;k++){if(o&&h&&k==s)continue;let ue=H[Z][k],he=H[Z+1][k],ae=H[Z+1][k+1],me=H[Z][k+1],be=p[ae*3+0],ge=p[ae*3+2];g.push(ue,he,me),(be!=0||ge!=0)&&g.push(he,ae,me)}l<Math.PI*2&&(K(-1,H[0],a),K(1,H[H.length-1],a+l)),this.setIndex(g),this.setAttribute("position",new Se(p,3)),this.setAttribute("normal",new Se(m,3)),this.setAttribute("uv",new Se(y,2));function V(Z,k,ue,he,ae,me,be,ge){for(let Ae=0;Ae<d+1;Ae++){let Me=Ae/d,xe=be<0?Me:1-Me;ge&&(xe-=1),xe*=he;let Ge=new F(Math.sin(xe),Math.cos(xe)*be),ht=Ge.clone().multiplyScalar(ae).add(me);ra(ht,ue,w),p.push(w.x,w.y,w.z),ra(Ge,ue,S),m.push(S.x,S.y,S.z),y.push(k,.5+w.y/n),Z.push(v++)}}function re(Z,k,ue,he,ae){let me=new A,be=new F,ge=[ue,he];ae<0&&ge.reverse();for(let Ae of ge)be.set(Ae,x*ae),ra(be,k,me),p.push(me.x,me.y,me.z),m.push(0,ae,0),y.push(.5,.5),Z.push(v++)}function K(Z,k,ue){let he=new F(Math.sin(ue),Math.cos(ue)),ae=new F(-Math.cos(ue),Math.sin(ue)),me=new A,be=Z<0?(Me,xe,Ge)=>g.push(Me,xe,Ge):(Me,xe,Ge)=>g.push(Me,Ge,xe),ge=new F((t+e+I+R)/4,0);ra(ge,he,me),p.push(me.x,me.y,me.z),m.push(ae.x,0,ae.y),y.push(.5,.5);let Ae=v++;for(let Me of k){let xe=p.slice(Me*3,Me*3+3);p.push(...xe),m.push(ae.x,0,ae.y);let Ge=y.slice(Me*2,Me*2+2);y.push(...Ge),v++}for(let Me=Ae+1;Me<v-1;Me++)be(Ae,Me,Me+1);be(Ae,v-1,Ae+1)}}};var BM=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:8,cornerRadiusBottom:8,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 Ch(0,t/2,n,i,s,o,a,l*Math.PI/180,u,c,d,0,!0):h=new Jl(t/2,n,i,s,o),h.scale(1,1,e/t),Object.assign(h,{userData:{...r,type:"ConeGeometry"}})}};var FM=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:8,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 Xn(t,e,n,i,s,o):u=new eb(t,e,n,i,s,o,a,l),Object.assign(u,{userData:{...r,type:"CubeGeometry"}})}},$x=Math.PI/2,eb=class extends _e{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 Se(d,3)),this.setAttribute("normal",new Se(h,3)),this.setAttribute("uv",new Se(f,2));function m(x,S,w,E,_,b,T,M,D,P,C){let I=(b-2*a)/D,R=(T-2*a)/P,G=b/2-a,Y=T/2-a,W=M/2,q=D+1,j=P+1,X=0,N=0,U=new A;for(let z=0;z<j;z++){let H=z*R-Y;for(let V=0;V<q;V++){let re=V*I-G;U[x]=re*E,U[S]=H*_,U[w]=W,d.push(U.x,U.y,U.z),U[x]=0,U[S]=0,U[w]=M>0?1:-1,h.push(U.x,U.y,U.z),f.push(V/D),f.push(1-z/P),X+=1}}for(let z=0;z<P;z++)for(let H=0;H<D;H++){let V=g+H+q*z,re=g+H+q*(z+1),K=g+(H+1)+q*(z+1),Z=g+(H+1)+q*z;c.push(V,re,Z),c.push(re,K,Z),N+=6}u.addGroup(p,N,C),p+=N,g+=X}function y(x,S,w,E,_,b,T,M,D,P,C){let I=(T-2*a)/P,R=T/2-a,G=M/2-a,Y=D/2,W=P+1,q=0,j=0,X=new A,N=new A;for(let U=0;U<l+1;U++){let z=U/l*$x,H=Math.sin(z)*a,V=(1-Math.cos(z))*a,re=Math.sin(z),K=Math.cos(z);X[S]=(G+H)*_,X[w]=(Y-V)*b,N[x]=0,N[S]=re*Math.sign(X[S]),N[w]=K*Math.sign(X[w]);for(let Z=0;Z<W;Z++){let k=Z*I-R;X[x]=k*E,d.push(X.x,X.y,X.z),h.push(N.x,N.y,N.z),f.push(Z/P),f.push(0),q+=1}}for(let U=0;U<l;U++)for(let z=0;z<P;z++){let H=g+z+W*U,V=g+z+W*(U+1),re=g+(z+1)+W*(U+1),K=g+(z+1)+W*U;c.push(H,V,K),c.push(V,re,K),j+=6}u.addGroup(p,j,C),p+=j,g+=q}function v(x,S,w){let E=new A,_=new A(t/2,e/2,n/2);_.subScalar(a);let b=[],T=x*S*w>0?(D,P,C)=>c.push(D,P,C):(D,P,C)=>c.push(D,C,P);for(let D=0;D<=l;D++){let P=[],C=$x*(1-D/l),I=Math.cos(C),R=Math.sin(C),G=0;for(let Y=0;Y<=D;Y++){let W=Math.cos(G),q=Math.sin(G);E.x=I*W,E.y=R,E.z=I*q;let j=_.clone().addScaledVector(E,a);d.push(x*j.x,S*j.y,w*j.z),h.push(x*E.x,S*E.y,w*E.z),f.push(0,0),P.push(g++),G+=$x/D}b.push(P)}let M=b.length-1;for(let D=0;D<M;D++){let P=b[D],C=b[D+1],I=P.length-1;T(P[0],C[1],C[0]);for(let R=1;R<=I;R++)T(P[R-1],P[R],C[R]),T(P[R],C[R+1],C[R])}}}};var ia=class extends _e{constructor(t=[],e=[],n="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),d(),this.setAttribute("position",new Se(a,3)),this.setAttribute("normal",new Se(u,3)),this.setAttribute("uv",new Se(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],g=new A,p=g.clone(),m=new rn,y=s*i,v=i-y,x=o+1,S=new A,w=(q,j)=>S.subVectors(q,j).normalize(),E=(q,j)=>Array(q).fill(void 0).map(j),_=E(t.length/3,(q,j)=>new A().fromArray(t,j*3).setLength(i)),b=[],T=1e6;for(let q=0;q<_.length;q++){let j=_[q],X=[],N,U,z,H=1e10,V=-1;for(;(V=e.indexOf(q,V+1))!=-1;){let k=V-V%3;N=e[k+(V+1)%3],U=e[k+(V+2)%3],z=j.distanceToSquared(_[N]),H=Math.min(H,z),X.push([N,U,z])}H+=1e-6;let re=[],K=0,Z=X.length;for(let k=0;k<Z;k++){[N,U,z]=X[K];let ue=b[N]?.includes(q)==!0;z<=H&&re.push(N+ +ue*T),K=X.findIndex(he=>he[0]==U)}b.push(re)}let M=[];{let q=0,j=0,X,N,U=f==3;for(let z=0;z<=o;z++){X=z*(z+1)/2,N=(z+1)*(z+2)/2;for(let H=0;H<o-z;H++)[q,j]=[X+H+z+2,N+H+z+3],M.push(X,N,...U?[j,X]:[q,N],j,q),[X,N]=[q,j];M.push(X,N,X+o+2)}}let D=g.clone(),P=g.clone(),C=g.clone(),I=g.clone(),R=g.clone(),G=[],Y=E(_.length,()=>E(f,()=>g.clone()));for(let q=0;q<_.length;q++){g.copy(_[q]).normalize(),D.copy(g).multiplyScalar(v);let j=b[q];for(let re=0;re<j.length;re++){let K=j[re],Z=j[(re+1)%f];m.setFromPointsAndIndices(_,q,K%T,Z%T),m.b.sub(m.a).setLength(1e10).add(m.a),m.c.sub(m.a).setLength(1e10).add(m.a),m.closestPointToPoint(D,Y[q][re])}let X=[],N=[],U=[],z=new A;o==0&&[...Y[q]].reduce((re,K)=>re.add(K),z).multiplyScalar(1/f);for(let re=0;re<f;re++){let K=[],Z=(re-1+f)%f,k=Y[q][Z],ue=Y[q][re];g.copy(k).sub(D),p.copy(ue).sub(D);let he=D.angleTo(g),ae=g.angleTo(p),me=Math.cos(he)*y;o==0?P.copy(z):P.copy(D).setLength(v+me),N.push(me);let be=[P,k,ue];for(let ge=0;ge<2;ge++){let Ae=be[ge],Me=be[ge+1];I.subVectors(Ae,D),R.subVectors(Me,D),C.crossVectors(I,R).normalize();for(let xe=0;xe<x;xe++){let Ge=[he,ae][ge]*xe/x;g.copy(I).applyAxisAngle(C,Ge).add(D),X.push(g.clone()),ge&&(w(g,D),K.push([xe==0?Ae:g.clone(),S.clone()]))}ge&&(w(Me,D),K.push([Me,S.clone()]))}U.push(K)}G.push(U);let H=2*x,V=2;for(let re=0;re<f;re++){let K=H*re,Z=H*((re+1)%f),k=[X[K]];for(let he=1;he<x;he++){I=X[K+he],R=X[Z+he],k.push(I);for(let ae=1,me=he-V+1;ae<=me;ae++)g.lerpVectors(I,R,ae/(me+1)),g.sub(D).setLength(N[re]).add(D),k.push(g.clone());k.push(R)}for(let he=0;he<x;he++)k.push(X[he+x+K]);k.push(X[Z+x]);let ue=M.map(he=>k[he]);a.push(...ue.map(he=>[he.x,he.y,he.z]).flat()),u.push(...ue.map(he=>(w(he,D),[S.x,S.y,S.z])).flat())}}let W=[];for(let q=0;q<b.length;q++)for(let j=0;j<f;j++){let X=b[q][j];if(X<T){let N=b[X].findIndex(H=>H%T==q),U=G[q][j],z=G[X][N];for(let H=0;H<x;H++){let V=U[H],re=z[x-H],K=U[H+1],Z=z[x-(H+1)];[V,re,K,K,re,Z].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),u.push(k[1].x,k[1].y,k[1].z)})}W.push(U[0][0],z[x][0],U[x][0],z[0][0])}}for(;W.length;){let q,j,X,N;[q,j]=W.splice(0,2);let U=[q];for(;q!=j;)U.push(j),X=W.indexOf(j),N=X%2,j=W.splice(X-N,2)[1-N];S.subVectors(U[0],U[1]).cross(g.subVectors(U[0],U[2])).normalize();let z=S.dot(U[0])<0;z&&S.negate();for(let H=1;H<=U.length-2;H++)[U[H+ +z],U[H+1-+z],U[0]].forEach(V=>{a.push(V.x,V.y,V.z),u.push(S.x,S.y,S.z)})}}function d(){let h=new A;for(let _=0;_<a.length;_+=3){h.x=a[_+0],h.y=a[_+1],h.z=a[_+2];let b=w(h)/2/Math.PI+.5,T=E(h)/Math.PI+.5;l.push(b,1-T)}let f=new A,g=new A,p=new A,m=new A,y=new F,v=new F,x=new F,S=(_,b,T,M)=>{M<0&&_.x===1&&(l[b]=_.x-1),T.x===0&&T.z===0&&(l[b]=M/2/Math.PI+.5)};for(let _=0,b=0;_<a.length;_+=9,b+=6){f.set(a[_+0],a[_+1],a[_+2]),g.set(a[_+3],a[_+4],a[_+5]),p.set(a[_+6],a[_+7],a[_+8]),y.set(l[b+0],l[b+1]),v.set(l[b+2],l[b+3]),x.set(l[b+4],l[b+5]),m.copy(f).add(g).add(p).divideScalar(3);let T=w(m);S(y,b+0,f,T),S(v,b+2,g,T),S(x,b+4,p,T)}for(let _=0;_<l.length;_+=6){let b=l[_+0],T=l[_+2],M=l[_+4],D=Math.max(b,T,M),P=Math.min(b,T,M);D>.9&&P<.1&&(b<.2&&(l[_+0]+=1),T<.2&&(l[_+2]+=1),M<.2&&(l[_+4]+=1))}function w(_){return Math.atan2(_.z,-_.x)}function E(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(t){return new ia(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var UM=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 Ph(t*.5,s,o):new ec(t*.5,i);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...r,type:"DodecahedronGeometry"}})}},Ph=class extends ia{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 Ph(t.radius,t.corner,t.cornerSides)}};var Dh=1e-12,yu=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 yu(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},vu=class extends yu{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new vu(this.parent).copy(this)}},Gi=class extends yu{constructor(e,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new vu(this),new vu(this))}static create(e,n){let i=new Gi(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 Gi(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&&(GM(i,e),GM(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 GM(r,t=new F){let e=r.length();return t.set(-r.y/e,r.x/e)}var nb=r=>r,xu=new F,xg=new F,SH=new F,wH=new F,AH=new F,EH=new F,VM=new A,zM=new A;function HM(r){let t=new F;t.addVectors(r.v0,xu.subVectors(r.v1,r.v0).multiplyScalar(2/3));let e=new F;return e.addVectors(r.v2,xg.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new cr(r.v0,t,e,r.v2)}function Ih(r,t,e=Number.EPSILON){return Math.abs(r-t)<e}function _H(r,t,e=Number.EPSILON){return r.distanceTo(t)<e}function TH(r,t,e=Number.EPSILON){return r.distanceTo(t)<e}function rb(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 WM(r,t,e){return kM(r,t)&&kM(t,e)&&tb(r.position,t.position,e.position)}function tb(r,t,e){return xu.copy(t).sub(r).cross(xg.copy(e).sub(r))===0}function jM(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 qM(r,t,e){let n=r.distanceTo(e),i=t.distanceTo(e);return n<i?t:r}function XM(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 rb(t,r,e)>Math.PI&&(c*=-1),Ih(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 ib(r,t){return r.position.equals(r.controls[1].position)&&t.position.equals(t.controls[0].position)}function kM(r,t){return tb(r.position,r.controls[1].position,t.position)&&tb(r.position,t.controls[0].position,t.position)}function YM(r,t,e,n,i=.5){let s=xu.subVectors(t,r).multiplyScalar(i).add(r),o=xg.subVectors(e,t).multiplyScalar(i).add(t),a=SH.subVectors(n,e).multiplyScalar(i).add(e),l=s,u=wH.subVectors(o,s).multiplyScalar(i).add(s),c=AH.subVectors(a,o).multiplyScalar(i).add(o),d=a,h=EH.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 QM(r,t,e=12,n=!0){let i=zM.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=nb(t[l]),c=xu,d=sa(u,e);a.push(d);for(let h=0;h<=d;h++)if(u instanceof cr||u instanceof Jr||u instanceof ur){if(u.getPoint(h/d,c),i.set(c.x,c.y,0),s!==void 0&&TH(s,i))continue;s===void 0&&(s=VM),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 KM(r,t,e,n=12,i=!0){let s=zM.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=nb(t[l]),d=xu,h=sa(c,n);a.push(h);for(let f=0;f<=h;f++)if(c instanceof cr||c instanceof Jr||c instanceof ur){if(c.getPoint(f/h,d),s.set(d.x,d.y,0),u?.equals(s))continue;u===void 0?u=VM:(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 sb(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=sa(o.roundedCurveCorner,t)*.5;i>0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=sa(o.curveAfter,t)),n.push(a)}return r.length>0&&e&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=sa(r[0].roundedCurveCorner,t)*.5),n}function sa(r,t=12){return r&&r instanceof Ga?t*2:r&&(r instanceof ur||r instanceof zd)?1:r&&r instanceof Kl?t*r.points.length:t}function ZM(r,t,e=12,n=!0){let i,s=0;for(let o=0;o<t.length;o++){let a=nb(t[o]),l=sa(a,e),u=xu;for(let c=0;c<=l;c++)if(a instanceof cr||a instanceof Jr||a instanceof ur){if(a.getPoint(c/l,u),i!==void 0&&_H(i,u,Dh))continue;i===void 0&&(i=xg),i.copy(u),r.push(u.x,u.y),s++}}return Ih(r[0],r[r.length-2],Dh)&&Ih(r[1],r[r.length-1],Dh)&&(r.pop(),r.pop()),n&&s>1&&!(Ih(r[s-1],r[1],Dh)&&Ih(r[s-2],r[0],Dh))&&(r.push(r[0],r[1]),s++),r}var ob=new F,MH=new F,CH=new F,PH=new F,DH=new F,IH=new F,wt=class extends Ys{constructor(e=100,n=100){super();this.points=[];this.shapeHoles=[];this.plane=new dn(new A(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Ve.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=n}static createFromState(e,n,i){let s=new wt;return s.isClosed=e.isClosed,s.points=e.points.map(o=>Gi.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>wt.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=ob.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 Gi(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 QM(e,i?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=sb(this.points,e,!1),this.roundedCurveDivisions=sb(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,n,i=12){return KM(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),ZM(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=sa(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(ib(s,o)){let d=s.position.distanceTo(o.position);return s.position.distanceTo(ob.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){ib(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&&WM(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),S=1-x/p,w=x/m,E=d.getPointAt(S,ob),_=h.getPointAt(w,MH);this._subSplitCurve(d,f,S,E,void 0),this._subSplitCurve(h,g,w,void 0,_);let b;if(this.useCubicForRoundedCorners){let T=rb(E,o.position,_)/2,M=Math.tan(T)*E.distanceTo(o.position),[D,P]=jM(E,_,M,CH,PH),C=qM(D,P,o.position),[I,R]=XM(C,E,_,M,DH,IH);b=new cr(E.clone(),I.clone(),R.clone(),_.clone())}else b=new Jr(E.clone(),o.position.clone(),_.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(i+n,0,b),n++}}}}_subSplitCurve(e,n,i,s,o){if(e instanceof ur)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=YM(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 wt(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 Gi(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 wt;return s.fromJSON(i),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let n=(s,o)=>{o instanceof cr&&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 Jr&&(s[a]=HM(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 cr?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof ur&&(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 cr?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof ur&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=i(e.curves),e instanceof Ys&&(this.shapeHoles=e.holes.map(s=>{let o=new wt;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 lb=Math.PI*2;function ab({x:r,y:t},e,n,i,s){return{x:r*e+i,y:t*n+s}}function OH(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 JM(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 LH(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,S=(a-m)/s,w=(-o-p)/i,E=(-a-m)/s,_=JM(1,0,x,S),b=JM(x,S,w,E);return!u&&b>0&&(b-=lb),u&&b<0&&(b+=lb),{centerx:y,centery:v,ang1:_,ang2:b}}function $M({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=LH(r,t,e,n,i,s,u,c,o,a),{ang1:f,ang2:g}=h,{centerx:p,centery:m}=h,y=Math.abs(g)/(lb/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(OH(f,g)),f+=g;return l.map(x=>{let{x:S,y:w}=ab(x[0],i,s,p,m),{x:E,y:_}=ab(x[1],i,s,p,m),{x:b,y:T}=ab(x[2],i,s,p,m);return{x1:S,y1:w,x2:E,y2:_,x:b,y:T}})}var dt;(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"})(dt||(dt={}));var tn;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(tn||(tn={}));function Ke(r,t){if(!r)throw t||"Assertion Failed!"}var He=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){Ke(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){Ke(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){Ke(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){Ke(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}(),Oh=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}(),bg=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}(),bu=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}(),eC=function(){function r(){var t=new bu,e=new Oh,n=new bg(0),i=new bg(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 bg(0),n=new bg(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;Ke(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;Ke(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 bu,e=new bu,n=new Oh,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 bu;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!n){var o=new Oh;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 Oh;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 bu;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 Oh;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&&He.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&He.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){Ke(i.prev===s),l=i.anEdge;do Ke(l.Sym!==l),Ke(l.Sym.Sym===l),Ke(l.Lnext.Onext.Sym===l),Ke(l.Onext.Sym.Lnext===l),Ke(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(Ke(i.prev===s&&i.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){Ke(o.prev===a),l=o.anEdge;do Ke(l.Sym!==l),Ke(l.Sym.Sym===l),Ke(l.Lnext.Onext.Sym===l),Ke(l.Onext.Sym.Lnext===l),Ke(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(Ke(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)Ke(l.Sym.next===u.Sym),Ke(l.Sym!==l),Ke(l.Sym.Sym===l),Ke(l.Org!==null),Ke(l.Dst!==null),Ke(l.Lnext.Onext.Sym===l),Ke(l.Onext.Sym.Lnext===l);Ke(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}(),tC=function(){function r(){this.handle=null}return r}(),nC=function(){function r(){this.key=null,this.node=0}return r}(),RH=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 tC,this.handles[n]=new nC;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,Ke(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 tC;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new nC}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;Ke(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}(),cb=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}(),rC=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 rC,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 rC;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}(),BH=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?He.vertLeq(s.Org,o.Org)?He.edgeSign(o.Dst,s.Org,o.Org)<=0:He.edgeSign(s.Dst,o.Org,s.Org)>=0:He.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return He.edgeSign(s.Dst,i,s.Org)>=0;var a=He.edgeEval(s.Dst,i,s.Org),l=He.edgeEval(o.Dst,i,o.Org);return a>=l},r.deleteRegion=function(t,e){e.fixUpperEdge&&Ke(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},r.fixUpperEdge=function(t,e,n){Ke(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 cb;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 dt.ODD:return(e&1)!==0;case dt.NONZERO:return e!==0;case dt.POSITIVE:return e>0;case dt.NEGATIVE:return e<0;case dt.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 Ke(He.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,Ke(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=He.vertL1dist(e,t),s=He.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(He.vertLeq(i.Org,s.Org)){if(He.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;He.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(He.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(Ke(!He.vertEq(i.Dst,s.Dst)),He.vertLeq(i.Dst,s.Dst)){if(He.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(He.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 bu,f,g;if(Ke(!He.vertEq(u,l)),Ke(He.edgeSign(l,t.event,o)<=0),Ke(He.edgeSign(u,t.event,a)>=0),Ke(o!==t.event&&a!==t.event),Ke(!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(He.vertLeq(o,a)){if(He.edgeSign(u,o,a)>0)return!1}else if(He.edgeSign(l,a,o)<0)return!1;return r.debugEvent(t),He.intersect(l,o,u,a,h),Ke(Math.min(o.t,l.t)<=h.t),Ke(h.t<=Math.max(a.t,u.t)),Ke(Math.min(u.s,l.s)<=h.s),Ke(h.s<=Math.max(a.s,o.s)),He.vertLeq(h,t.event)&&(h.s=t.event.s,h.t=t.event.t),f=He.vertLeq(o,a)?o:a,He.vertLeq(f,h)&&(h.s=f.s,h.t=f.t),He.vertEq(h,o)||He.vertEq(h,a)?(r.checkForRightSplice(t,e),!1):!He.vertEq(l,t.event)&&He.edgeSign(l,t.event,h)>=0||!He.vertEq(u,t.event)&&He.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):(He.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),He.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),He.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),He.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}He.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,He.vertEq(i.Org,n)){Ke(!1),r.spliceMergeVertices(t,i,n.anEdge);return}if(!He.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}Ke(!1),e=r.topRightRegion(e),l=r.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(Ke(s!==o),r.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(n.anEdge,o),He.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 cb;if(u.eUp=e.anEdge.Sym,n=t.dict.search(u).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,He.edgeSign(o.Dst,e,o.Org)===0){r.connectLeftDegenerate(t,n,e);return}if(s=He.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);Ke(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 cb,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||(Ke(e.fixUpperEdge),Ke(++n===1)),Ke(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,He.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 RH(s,He.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,Ke(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||!He.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}(),FH=function(){function r(){this.mesh=new eC,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=dt.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(;He.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;He.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(He.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(He.edgeGoesLeft(i.Lnext)||He.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&&(He.edgeGoesRight(n.Lprev)||He.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===tn.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===tn.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 eC),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=dt.ODD),e===void 0&&(e=tn.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_(),BH.computeInterior(this,o);var a=this.mesh;return e===tn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===tn.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,n,i),!0},r}();function ki(r){var t=r.windingRule,e=t===void 0?dt.ODD:t,n=r.elementType,i=n===void 0?tn.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 FH;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 Ise=dt.ODD,Ose=dt.NONZERO,Lse=dt.POSITIVE,Rse=dt.NEGATIVE,Nse=dt.ABS_GEQ_TWO,Bse=tn.POLYGONS,Fse=tn.CONNECTED_POLYGONS,Use=tn.BOUNDARY_CONTOURS;var Sg=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*Sg.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*Sg.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)}},Lh=Sg;Lh.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Rh={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},db={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},hb={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},ub=(r,t)=>([e,n])=>(n<e&&(n+=t),(r>=e?r:r+t)<=n),Su=class extends _e{constructor(e,n,i=0,s=12,o=3,a=dt.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(_=>{let b=_.extractShapePointsToFlatArray([],s),T=[];for(let M=b.length-1;M>=1;M-=2){let D=b[M-1],P=b[M-0];T.push(D,P)}return T}),c;try{c=ki({windingRule:a,elementType:tn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]})}catch{c=Rh}let d;try{d=ki({windingRule:dt.ODD,elementType:tn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{d=db}if(!c)throw new Error("error generating geometry");let h=c.elementCount;if(d){c.elementCount+=d.elementCount;for(let _=0;_<d.elements.length;_++){let b=d.elements[_],T=_%2===0?c.vertexCount:0;c.elements.push(b+T)}for(let _=0;_<d.vertexIndices.length;_++){let b=d.vertexIndices[_],T=c.vertexCount;c.vertexIndices.push(b+T)}for(let _=0;_<d.vertices.length;_++){let b=d.vertices[_];c.vertices.push(b)}}let f=1/0,g=-1/0,p=1/0,m=-1/0;for(let _=0,b=c.vertexCount;_<b;_++){let T=_*2,M=c.vertices[T+0],D=c.vertices[T+1];M<f&&(f=M),M>g&&(g=M),D<p&&(p=D),D>m&&(m=D)}this._minX=f,this._minY=p,this._width=g-f,this._height=m-p,this._buffer=new Lh(this._computeBufferEstimatedSize(c));let y=[],v=[];for(let _=c.elementCount-1;_>=0;_--){let b=_>=h,T=_*2,M=c.elements[T+0],D=c.elements[T+1],P=M+D,C={start:M,count:D,normals:[],continuous:[],concave:[]},I=M,R=P-1,G=M+1,Y=this._shape.roundedCurves.length;do{let X=I-M,N=c.vertices[R*2+0],U=c.vertices[R*2+1],z=c.vertices[I*2+0],H=c.vertices[I*2+1],V=c.vertices[G*2+0],re=c.vertices[G*2+1],K=z-N,Z=H-U,k=Math.sqrt(K*K+Z*Z);K/=k,Z/=k;let ue=z-V,he=H-re,ae=Math.sqrt(ue*ue+he*he);ue/=ae,he/=ae,C.normals[X*2+0]=-he,C.normals[X*2+1]=ue,C.concave[X]=K*he-Z*ue>0;let me=c.vertexIndices[I];if(Array.isArray(me))C.continuous[X]=!1;else{let[be,ge]=this._shape.getCurveIndexFromVertexId(me-1,!0);if(ge>0&&ge<1)C.continuous[X]=!0;else{let Ae=ge===1?be+1:be-1;Ae=(Ae+Y)%Y;let Me=ge===1?0:1,xe=this._shape.roundedCurves[be].getTangent(ge),Ge=this._shape.roundedCurves[Ae].getTangent(Me);C.continuous[X]=xe.dot(Ge)>.95}}b&&(C.normals[X*2+0]*=-1,C.normals[X*2+1]*=-1),[R,I,G]=[I,G,G+1],G>=P&&(G-=D)}while(G!==M+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(M*2,P*2),vertexCount:D,vertexIndices:new Array(D).fill(!0).map((X,N)=>[N,N]),elements:[0,D],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(M*2,P*2)});for(let X=1;X<=this._bevelSegments;X++){let N=X/this._bevelSegments*Math.PI/2,U=(1-Math.cos(N))*this._bevelSize,z=[],H=[],V=[],re=[],K=0;for(let k=0;k<D;k++){let ue=k*2,he=(k-1+D)%D*2,ae=c.vertices[C.start*2+ue+0],me=c.vertices[C.start*2+ue+1],be=-C.normals[he+0]*U,ge=-C.normals[he+1]*U,Ae=-C.normals[ue+0]*U,Me=-C.normals[ue+1]*U;if(C.concave[k]||!C.concave[k]&&b){let xe=Math.atan2(ge,be),Ge=Math.atan2(Me,Ae);Ge>xe&&(Ge-=Math.PI*2);let ht=Ge-xe;if(C.continuous[k]||b){let L=xe+ht/2,O=Math.cos(L)*U,ee=Math.sin(L)*U;z[2*K+0]=ae+O*(b?-1:1),z[2*K+1]=me+ee*(b?-1:1),re[K]=k,K++}else{let L=Math.max(1,Math.floor(s/4*Math.abs(ht)/Math.PI));for(let O=0;O<=L;O++){let ee=xe+ht*(O/L),fe=Math.cos(ee)*U,ye=Math.sin(ee)*U;z[2*K+0]=ae+fe,z[2*K+1]=me+ye,re[K]=k,K++}}}else z[2*K+0]=ae+be,z[2*K+1]=me+ge,re[K]=k,H[k]=K,K++,z[2*K+0]=ae,z[2*K+1]=me,re[K]=k,K++,z[2*K+0]=ae+Ae,z[2*K+1]=me+Me,re[K]=k,V[k]=K,K++}let Z=ki({windingRule:dt.POSITIVE,elementType:tn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[z],edgeCreateCallback:k=>{let he=k.Org.idx,ae=re[he],me=re[(he+1)%re.length];k.idx=[ae,me],k.Sym.idx=[me,ae]},vertexIdCallback:k=>{let ue=k.Lprev.idx;return[ue?ue[1]:0,k.idx?k.idx[0]:0]}});if(!Z)throw console.log("Error"),new Error(`error generating bevel geometry for ${X}'th loop`);if(!Z.vertexCount)break;for(let k=0;k<Z.vertexIndices.length;k++){let[ue,he]=Z.vertexIndices[k];if(ue===he)continue;let ae=he;he<ue&&(ae+=D);for(let me=ue;me<ae;me++){let be=me%D,ge=(me+1)%D;if(!C.continuous[be]||!C.continuous[ge]){Z.vertexIndices[k]=[ue,be],Z.vertexIndices.splice(k+1,0,[ge,he]),Z.vertices.splice((k+1)*2,0,Z.vertices[k*2],Z.vertices[k*2+1]);break}}}W.push({bevelI:X,angle:N,size:U,boundary:Z,reverseMap:re,insetPoints:z})}let q=(X,N,U)=>{let z=0,H=X.boundary.vertexIndices.length;for(;z<H&&U(X.boundary.vertexIndices[N]);)N=(N+1)%H,z++;return z},j=y.length;for(let X=1;X<W.length;X++){let N=W[X-1],U=W[X],z=N.boundary.vertexIndices.length,H=U.boundary.vertexIndices.length;if(!z||!H)break;let V=C.concave.length,re=0,K=ub(re,D);for(;!N.boundary.vertexIndices.filter(K).length||!U.boundary.vertexIndices.filter(K).length;)re++,K=ub(re,D);let Z=N.boundary.vertexIndices.findIndex(K),k=U.boundary.vertexIndices.findIndex(K);do Z=(Z+1)%z;while(K(N.boundary.vertexIndices[Z]));do k=(k+1)%H;while(K(U.boundary.vertexIndices[k]));re=(re+1)%D;let ue=re,he=this._buildBevelVert(C,N,(Z-1+z)%z),ae=this._buildBevelVert(C,U,(k-1+H)%H),me=he,be=ae,ge,Ae,Me=!1;do{K=ub(re,D);let xe=q(N,Z,K),Ge=q(U,k,K),ht=Me;if(Me=!1,xe&&!Ge){for(let L=0;L<xe;L++)ge=this._buildBevelVert(C,N,(Z+L)%z,L/(xe-1)),y.push(me.topN,ge.topP,be.topN),y.push(ge.bottomP,me.bottomN,be.bottomN),me=ge;Me=!0}else if(!xe&&Ge)for(let L=0;L<Ge;L++)Ae=this._buildBevelVert(C,U,(k+L)%H,L/(Ge-1)),y.push(be.topN,me.topP,Ae.topP),y.push(me.bottomP,be.bottomN,Ae.bottomP),be=Ae;else if(xe&&Ge)if(ge=this._buildBevelVert(C,N,Z,0),Ae=this._buildBevelVert(C,U,k,0),ht?(y.push(me.topN,Ae.topP,be.topN),y.push(me.topN,ge.topP,Ae.topP),y.push(Ae.bottomP,me.bottomN,be.bottomN),y.push(Ae.bottomP,ge.bottomP,me.bottomN)):(y.push(be.topN,me.topN,ge.topP),y.push(be.topN,ge.topP,Ae.topP),y.push(ge.bottomP,me.bottomN,be.bottomN),y.push(ge.bottomP,be.bottomN,Ae.bottomP)),me=ge,be=Ae,xe===Ge)for(let L=1;L<xe;L++)ge=this._buildBevelVert(C,N,(Z+L)%z,L/(xe-1)),Ae=this._buildBevelVert(C,U,(k+L)%H,L/(Ge-1)),y.push(me.topN,ge.topP,be.topN),y.push(be.topN,ge.topP,Ae.topP),y.push(ge.bottomP,me.bottomN,be.bottomN),y.push(ge.bottomP,be.bottomN,Ae.bottomP),me=ge,be=Ae;else if(xe>Ge){let L=xe/Ge,O=0;for(let ee=1;ee<xe;ee++)ge=this._buildBevelVert(C,N,(Z+ee)%z,ee/(xe-1)),y.push(me.topN,ge.topP,be.topN),y.push(ge.bottomP,me.bottomN,be.bottomN),me=ge,ee>(O+1)*L&&(O++,Ae=this._buildBevelVert(C,U,(k+O)%H,O/(Ge-1)),y.push(be.topN,ge.topP,Ae.topP),y.push(ge.bottomP,be.bottomN,Ae.bottomP),be=Ae)}else{let L=Ge/xe,O=0;for(let ee=1;ee<Ge;ee++)Ae=this._buildBevelVert(C,U,(k+ee)%H,ee/(Ge-1)),y.push(be.topN,ge.topP,Ae.topP),y.push(ge.bottomP,be.bottomN,Ae.bottomP),be=Ae,ee>(O+1)*L&&(O++,ge=this._buildBevelVert(C,N,(Z+O)%z,O/(xe-1)),y.push(me.topN,ge.topP,be.topN),y.push(ge.bottomP,me.bottomN,be.bottomN),me=ge)}Z=(Z+xe)%z,k=(k+Ge)%H,re=(re+1)%V}while(re!==ue)}if(this._buildWall(W,C,y),b){let X=[];for(let N=y.length-1;N>=j+2;N-=3){let U=y[N-2],z=y[N-1],H=y[N-0];X.push(H,z,U)}y.splice(j,y.length-j,...X)}if(b){let X=[];for(let N=W[W.length-1].boundary.vertices.length-1;N>=1;N-=2){let U=W[W.length-1].boundary.vertices[N-1],z=W[W.length-1].boundary.vertices[N-0];X.push(U,z)}v.push(X)}if(!b){let X=W[W.length-1],N;try{N=ki({windingRule:W.length>1?dt.POSITIVE:dt.ODD,elementType:tn.POLYGONS,vertexSize:2,strict:!0,contours:[X.insetPoints,...v]})}catch{N=hb}if(!N)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:y.length});for(let U=0;U<N.elementCount*3;U+=3){let z=this._buildSurfaceVert(N,N.elements[U+0]),H=this._buildSurfaceVert(N,N.elements[U+1]),V=this._buildSurfaceVert(N,N.elements[U+2]);y.push(z.top,H.top,V.top),y.push(V.bottom,H.bottom,z.bottom)}}this.vertexCache={}}this._buffer.shrink();let x=new Fe(Uint32Array.from(y),1),S=new Fe(this._buffer.positions,3),w=new Fe(this._buffer.normals,3),E=new Fe(this._buffer.uvs,2);S.needsUpdate=!0,w.needsUpdate=!0,E.needsUpdate=!0,x.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",w),this.setAttribute("uv",E),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],S=(1-g)*this._bevelSize,w=(v-this._minX)/this._width,E=(x-this._minY)/this._height,_=e.normals[m+0],b=e.normals[m+1],T=e.normals[y+0],M=e.normals[y+1];if(h){let R=T-_,G=M-b;_=_+R*(1-s),b=b+G*(1-s);let Y=Math.sqrt(_*_+b*b);_/=Y,b/=Y}let D=this._buffer.get(d?2:4),P=D*3,C=D*2,I={i,fi:u,topP:D+0,topN:D+0,bottomP:D+1,bottomN:D+1};return this._buffer.positions[P+0]=v,this._buffer.positions[P+1]=x,this._buffer.positions[P+2]=this._depth-S,this._buffer.normals[P+0]=_*f,this._buffer.normals[P+1]=b*f,this._buffer.normals[P+2]=g,this._buffer.uvs[C+0]=w,this._buffer.uvs[C+1]=E,this._buffer.positions[P+3]=v,this._buffer.positions[P+4]=x,this._buffer.positions[P+5]=S,this._buffer.normals[P+3]=_*f,this._buffer.normals[P+4]=b*f,this._buffer.normals[P+5]=-g,this._buffer.uvs[C+2]=E,this._buffer.uvs[C+3]=w,d||(D+=2,P+=6,C+=4,I.topP=D+0,I.bottomP=D+1,this._buffer.positions[P+0]=v,this._buffer.positions[P+1]=x,this._buffer.positions[P+2]=this._depth-S,this._buffer.normals[P+0]=T*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]=E,this._buffer.positions[P+3]=v,this._buffer.positions[P+4]=x,this._buffer.positions[P+5]=S,this._buffer.normals[P+3]=T*f,this._buffer.normals[P+4]=M*f,this._buffer.normals[P+5]=-g,this._buffer.uvs[C+2]=E,this._buffer.uvs[C+3]=w),this.vertexCache[o]=I,I}clone(){let e=new Su(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=eo(this.userData),e}};var wu=class extends _e{constructor(e,n=12,i={}){super();this.type="ShapeGeometry";this.windingRule=dt.ODD;this.elementType=tn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:dt.ODD,elementType:tn.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=ki({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=Rh}let h=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Fe(new Float32Array(h*3),3),this._normalAttribute=new Fe(new Float32Array(h*3),3),this._uvAttribute=new Fe(new Float32Array(h*2),2),this._indexAttribute=new Fe(new Uint32Array(f*3),1),a){let g=1/0,p=-1/0,m=1/0,y=-1/0;for(let S=0,w=h;S<w;S++){let E=S*2,_=a.vertices[E+0],b=a.vertices[E+1];_<g&&(g=_),_>p&&(p=_),b<m&&(m=b),b>y&&(y=b)}let v=p-g,x=y-m;for(let S=0,w=h;S<w;S++){let E=S*2,_=a.vertices[E+0],b=a.vertices[E+1],T=(_-g)/v,M=(b-m)/x;this._positionAttribute.setXYZ(S,_,b,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,T,M)}for(let S=0,w=f;S<w;S++){let E=S*3,_=a.elements[E+0],b=a.elements[E+1],T=a.elements[E+2];this._indexAttribute.setX(E+0,_),this._indexAttribute.setX(E+1,b),this._indexAttribute.setX(E+2,T)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new wu(this._shape,this._curveSegments);return e.userData=eo(this.userData),e}};var Au=class extends Su{constructor(e,n,i=0,s=12,o=3,a=dt.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 Au(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=eo(this.userData),e}};var Ur=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:dt.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 wt?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new wt(n,i).fromJSON(o),r.parameters?.roundness!==void 0&&r.parameters?.roundness>0&&o.update());let l=o??new wt(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 wu(r.shape,i,{windingRule:o}):a=new Au(r.shape,t,e,i,n,o),Object.assign(a,{userData:{...r,type:"VectorGeometry"}})}};var sC=Math.PI*2,_u=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 wt?r.shape:new wt,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=UH(u,c,d,i*Math.PI/180,n,s);u.isClosed=!0,u.update();let f=Ur.create({shape:u,parameters:{subdivisions:h,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...r,type:"EllipseGeometry"}})}};function UH(r,t,e,n,i,s){if(n>=sC)return i>30||i%4===0?(kH(r,t,e,s),Math.round(i/4)):iC(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=$M({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?GH(r,o.x,o.y,u,i,t,e,s):iC(r,n,i,t,e,s)}function GH(r,t,e,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint(Eu(t,e));for(let u=0,c=n.length;u<c;u++){let d=n[u],h=r.points[u],f=Eu(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?oC(r,s,o,a):r.addPoint(Eu(0,0)),l}function iC(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(Eu(u,c))}return t<sC?s>0?oC(r,n,i,s):r.addPoint(Eu(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&aC(r,n,i,s)),1}function kH(r,t,e,n=0,i=0,s=0){let o=.5522847498,a=t*o,l=e*o;r.addPoint(wg(i-t,s,i-t,s-l,i-t,s+l)),r.addPoint(wg(i,s+e,i-a,s+e,i+a,s+e)),r.addPoint(wg(i+t,s,i+t,s+l,i+t,s-l)),r.addPoint(wg(i,s-e,i+a,s-e,i-a,s-e)),n>0&&aC(r,t,e,n)}function Eu(r,t){return new Gi(Ve.generateUUID(),new F(r,t))}function wg(r,t,e,n,i,s){let o=Eu(r,t);return o.controls[0].position.set(e,n),o.controls[1].position.set(i,s),o}function oC(r,t,e,n){lC(r,t,e,n).forEach(s=>r.addPoint(s))}function aC(r,t,e,n){let i=lC(r,t,e,n),s=new wt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function lC(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 cC=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 Nh(!1,t,e,n,i,s,o,a,l,u,c,d);return Object.assign(h,{userData:{...r,type:"HelixGeometry"}})}},Nh=class extends _e{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){if(super(),o===0)return;let f=t&&o===1;f&&(h=0),d>100&&(d=100),d===0&&(h=0);let g=()=>new A,p=new A,m=g(),y=g(),v=g(),x,S,w,E,_,b,T,M,D=g(),P=g(),C=g(),I=g(),R=g(),G=g(),Y=g(),W=g(),q=n-2*l+.001,j=q/o,X=Math.ceil(a*o),N=X+1,U=q/X,z=-q/2,H=c+1,V=2*Math.PI/c,re=Math.PI/2/h,K=.01,Z=Math.min((1-d/100)*l,l-K),k=l-Z,ue=0,he=2,ae=h*he+he,me=H*ae/he,be=me+H*N,ge=H*(N+ae),[Ae,Me,xe]=[3,3,2].map(Le=>Array(ge*Le).fill(0)),Ge=[],ht=s-l;function L(Le,De){let Be=Math.PI/2;b=De*U,M=2*Math.PI*(b%j)/j+Be,b+=z,T=Math.sin(M)*ht,_=Math.cos(M)*ht,t?Le.set(_,T,b):Le.set(_,b,T)}L(p,-1e-10),L(m,0),D.copy(p),L(p,1);let O=p.distanceTo(m),ee=f?0:k+Z,fe=O*X+2*ee,ye=Z,Ce=fe-ee;for(let Le=0;Le<=X;Le++){L(y,Le),W.subVectors(y,D).normalize(),D.copy(y),G.copy(y).setComponent(+t+1,0).normalize(),Y.crossVectors(W,G).normalize();let De=Le===0,Be=Le===X,qe=De?3*Math.PI/2:re,ft=De?ye:Ce,Ft=De?H:be,bn=De?0:ge-H,Q=W.clone().multiplyScalar(De?-k:k).add(y),ie=W.clone().multiplyScalar(De?-1:1).normalize();for(let pe=0;pe<H;pe++){let Re=pe*V;if(P.addVectors(p.copy(G).multiplyScalar(l*Math.cos(Re)),m.copy(Y).multiplyScalar(l*Math.sin(Re))),C.copy(P).normalize(),De||Be){f||(ue=bn+pe,[0,1,2].forEach(Oe=>{Ae[ue*3+Oe]=Q.getComponent(Oe),Me[ue*3+Oe]=ie.getComponent(Oe)}),xe[ue*2]=+Be,xe[ue*2+1]=pe/c),m.copy(C).multiplyScalar(Z),v.addVectors(y,m);for(let Oe=0;Oe<h;Oe++){let pt=Oe*re+qe;I.addVectors(p.copy(W).multiplyScalar(k*Math.sin(pt)),m.copy(C).multiplyScalar(k*Math.cos(pt))),R.copy(I).normalize(),m.addVectors(v,I),I.normalize(),ue=Ft+Oe*H+pe,[0,1,2].forEach(ln=>{Ae[ue*3+ln]=m.getComponent(ln),Me[ue*3+ln]=R.getComponent(ln)});let Sn=+De+Math.sin(pt);xe[ue*2]=(ft+k*Sn)/fe,xe[ue*2+1]=pe/c}}m.addVectors(y,P),ue=me+Le*H+pe,[0,1,2].forEach(Oe=>{Ae[ue*3+Oe]=m.getComponent(Oe),Me[ue*3+Oe]=C.getComponent(Oe)}),xe[ue*2]=(ee+Le*O)/fe,xe[ue*2+1]=pe/c}}let ke=N+2*h+he,Pe=1,[ce,je]=[+f,ke-1];f&&(je-=1);for(let Le=ce;Le<=je-1;Le++){let De=f&&Le===je-1;for(let Be=0;Be<H-1;Be++)x=Le*H+Be,S=x+1,w=(De?Be:x)+H,E=(De?Be+1:S)+H,Le===0?Ge.push(S,E,w):Le===ke-2?Ge.push(x,S,w):Ge.push(x,S,w,S,E,w)}this.setIndex(Ge),this.setAttribute("position",new Se(Ae,3)),this.setAttribute("normal",new Se(Me,3)),this.setAttribute("uv",new Se(xe,2))}};var uC=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 Bh(t*.5,s,o):new nc(t*.5,i);return a.scale(1,e/t,n/t),Object.assign(a,{userData:{...r,type:"IcosahedronGeometry"}})}},Bh=class extends ia{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 Bh(t.radius,t.corner,t.cornerSides)}};var dC=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 Ys;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 Zl(i.extractPoints(n).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...r,type:"LatheGeometry"}})}};var ms=new de,fb=new ct,Ag=new A,oa=class extends kt{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 Yt().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 ms.makeRotationX(t),this.applyMatrix4(ms),this}rotateY(t){return ms.makeRotationY(t),this.applyMatrix4(ms),this}rotateZ(t){return ms.makeRotationZ(t),this.applyMatrix4(ms),this}translate(t,e,n){return ms.makeTranslation(t,e,n),this.applyMatrix4(ms),this}scale(t,e,n){return ms.makeScale(t,e,n),this.applyMatrix4(ms),this}lookAt(t){return fb.lookAt(t),fb.updateMatrix(),this.applyMatrix4(fb.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 A().fromBufferAttribute(s,h)),a!==void 0&&e.colors.push(new Ne().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 A().fromBufferAttribute(o,h),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,g)],v=new Tu(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(Ag).negate(),this.translate(Ag.x,Ag.y,Ag.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 A,e=new A;for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];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 A;if(t){let n=new A,i=new A;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];n.subVectors(c,u),i.subVectors(l,u),n.cross(i),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 oa;t.faces=this.faces;for(let e=0,n=this.morphTargets.length;e<n;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new A,c={a:new A,b:new A,c:new A};s.push(u),o.push(c)}}let 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 bt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Tn),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 Yt().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 Tu(g.a+s,g.b+s,g.c+s);x.normal.copy(g.normal),i!==void 0&&x.normal.applyMatrix3(i).normalize();for(let S=0,w=y.length;S<w;S++)p=y[S].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),x.vertexNormals.push(p);x.color.copy(g.color);for(let S=0,w=v.length;S<w;S++)m=v[S],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,S=y.length;x<S;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 A(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,S=p.vertexNormals.length>0,w=p.color.r!==1||p.color.g!==1||p.color.b!==1,E=p.vertexColors.length>0,_=0;if(_=c(_,0,0),_=c(_,1,m),_=c(_,2,y),_=c(_,3,v),_=c(_,4,x),_=c(_,5,S),_=c(_,6,w),_=c(_,7,E),n.push(_),n.push(p.a,p.b,p.c),n.push(p.materialIndex),v){let b=this.faceVertexUvs[0][g];n.push(f(b[0]),f(b[1]),f(b[2]))}if(x&&n.push(d(p.normal)),S){let b=p.vertexNormals;n.push(d(b[0]),d(b[1]),d(b[2]))}if(w&&n.push(h(p.color)),E){let b=p.vertexColors;n.push(h(b[0]),h(b[1]),h(b[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 oa().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,S=y.length;x<S;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 pb().fromGeometry(this),e=new _e,n=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Eg.call(new Fe(n,3),t.vertices)),t.normals.length>0){let i=new Float32Array(t.normals.length*3);e.setAttribute("normal",Eg.call(new Fe(i,3),t.normals))}if(t.colors.length>0){let i=new Float32Array(t.colors.length*3);e.setAttribute("color",hC.call(new Fe(i,3),t.colors))}if(t.uvs.length>0){let i=new Float32Array(t.uvs.length*2);e.setAttribute("uv",fC.call(new Fe(i,2),t.uvs))}if(t.uvs2.length>0){let i=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",fC.call(new Fe(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 Se(u.data.length*3,3);c.name=u.name,s.push(Eg.call(c,u.data))}e.morphAttributes[i]=s}if(t.skinIndices.length>0){let i=new Se(t.skinIndices.length*4,4);e.setAttribute("skinIndex",pC.call(i,t.skinIndices))}if(t.skinWeights.length>0){let i=new Se(t.skinWeights.length*4,4);e.setAttribute("skinWeight",pC.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 _e,n=t.geometry;if(t.isPoints||t.isLine){let i=new Se(n.vertices.length*3,3),s=new Se(n.colors.length*3,3);if(e.setAttribute("position",Eg.call(i,n.vertices)),e.setAttribute("color",hC.call(s,n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new Se(n.lineDistances.length,1);e.setAttribute("lineDistance",VH.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}};oa.prototype.isGeometry=!0;var pb=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 S=v.vertexColors;if(S.length===3)this.colors.push(S[0],S[1],S[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 E=a[w].vertices;u[w].data.push(E[v.a],E[v.b],E[v.c])}for(let w=0;w<d;w++){let E=c[w].vertexNormals[y];h[w].data.push(E.a,E.b,E.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}},Tu=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 A,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Ne,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 VH(r){return this.array.set(r),this}function hC(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 Ne),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function fC(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 Eg(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 A),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function pC(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 $e),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var zH=["a","b","c"];function HH(r,t){switch(t){case"c":return r.c;case"b":return r.b;case"a":default:return r.a}}function mb(r,t,e){let n=Math.min(r,t),i=Math.max(r,t),s=n+"_"+i;return e.get(s)}function gb(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 WH(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],gb(o.a,o.b,r,n,o,e),gb(o.b,o.c,r,n,o,e),gb(o.c,o.a,r,n,o,e)}function _g(r,t,e,n,i){r.push(new Tu(t,e,n,void 0,void 0,i))}function Mu(r,t){return Math.abs(t-r)/2+Math.min(r,t)}function Tg(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 _e?t=new oa().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new A,n,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;WH(l,u,h,f);let g=[],p,m,y,v,x,S,w;for(let K of Array.from(f.keys())){for(m=f.get(K),y=new A,x=3/8,S=1/8,w=m.faces.length,w!=2&&(x=.5,S=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[HH(v,zH[a])],!(p!==m.a&&p!==m.b));a++);p&&e.add(p)}e.multiplyScalar(S),y.add(e),m.newEdge=g.length,g.push(y)}let E,_,b,T,M,D,P,C=[];for(i=0,s=l.length;i<s;i++){for(D=l[i],M=h[i].edges,n=M.length,n==3?E=3/16:n>3&&(E=3/(8*n)),_=1-n*Number(E),b=E,n<=2&&(n==2?(_=3/4,b=1/8):n==1||n==0),P=D.clone().multiplyScalar(_),e.set(0,0,0),o=0;o<n;o++)T=M[o],p=T.a!==D?T.a:T.b,e.add(p);e.multiplyScalar(Number(b)),P.add(e),C.push(P)}let I=C.concat(g),R=C.length,G,Y,W,q=[],j=[],X,N,U,z,H=new F,V=new F,re=new F;for(i=0,s=u.length;i<s;i++)v=u[i],G=Number(mb(v.a,v.b,f).newEdge)+R,Y=Number(mb(v.b,v.c,f).newEdge)+R,W=Number(mb(v.c,v.a,f).newEdge)+R,_g(q,G,Y,W,v.materialIndex),_g(q,v.a,G,W,v.materialIndex),_g(q,v.b,Y,G,v.materialIndex),_g(q,v.c,W,Y,v.materialIndex),d&&(X=c[i],N=X[0],U=X[1],z=X[2],H.set(Mu(N.x,U.x),Mu(N.y,U.y)),V.set(Mu(U.x,z.x),Mu(U.y,z.y)),re.set(Mu(N.x,z.x),Mu(N.y,z.y)),Tg(j,H,V,re),Tg(j,N,H,re),Tg(j,U,V,H),Tg(j,z,re,V));t.vertices=I,t.faces=q,d&&(t.faceVertexUvs[0]=j)}};var Un=new A,mC=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,t){let e=r.geometry??t?.geometry??new _e().copy(new Xn(100,100,100)),n;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Un),n={width:Un.x,height:Un.y,depth:Un.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 _e().copy(new Xn(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Un)):Un.set(o.width,o.height,o.depth),(t!==Un.x||e!==Un.y||n!==Un.z)&&s.scale(Un.x===0?1:t/Un.x,Un.y===0?1:e/Un.y,Un.z===0?1:n/Un.z);let a=s.originalGeometry;try{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())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete r.geometry,Object.assign(s,{userData:{...r,type:"NonParametricGeometry"}})}static loadFromUrl(r,t,e){new ac(e).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(Un);let o=100/Un.x;Object.assign(s.parameters,{width:100,height:Un.y*o,depth:Un.z*o}),t(this.build(s))})}};var Cg=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 wt?r.shape:new wt,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=Ur.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(g,{userData:{...r,type:"PolygonGeometry"}})}};var gC=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 vb(t*.5,e,i,s,o,a,l);return u.scale(1,1,n/t),Object.assign(u,{userData:{...r,type:"PyramidGeometry"}})}};function Fh(r,t,e){e.x=r.x*t.x,e.y=r.y,e.z=r.x*t.y}function yb(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 jH(r,t,e){let n=r.clone().sub(t),i=e.clone().sub(t);return n.projectOnVector(i),n.add(t)}var vb=class extends _e{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 A(0,-f,0),S=new A(0,f,0),w=new F(t,-f),E=new F(p,-f),_=new F(0,S.y).sub(E),b=new F(0,S.y).sub(w),T=new F(_.y,-_.x).normalize(),M=new F(b.y,-b.x).normalize(),P=t*Math.cos(Math.PI/n)*Math.tan((Math.PI-_.angle())/2)-1e-8;o=Math.min(o,P);let C;{let j=new A(T.x,T.y,0),X=new A(Math.cos(m)*j.x,j.y,Math.sin(m)*j.x);C=j.angleTo(X)}let I=o/Math.tan((Math.PI-_.angle())/2),R=o/Math.tan((Math.PI-C)/2),G=new A;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),d.push(0,0);let j=h++,X=[],N=w.clone(),U=I/Math.cos(Math.PI/n);N.x-=U;for(let z=0;z<n;z++){let H=z/n*Math.PI*2+g,V=new F(Math.sin(H),Math.cos(H));Fh(N,V,G),u.push(G.x,G.y,G.z),c.push(0,-1,0),d.push(0,0),X.push(h++)}for(let z=0;z<X.length;z++)l.push(X[z],j,X[(z+1)%X.length])}let Y=[];{let j=new A,X=new A,N=new A,U=new A,z=new A,H=new A;for(let V=0;V<n;V++){let re=V/n*Math.PI*2+g,K=(V+.5)/n*Math.PI*2+g,Z=(V+1)/n*Math.PI*2+g,k=new F(Math.sin(re),Math.cos(re)),ue=new F(Math.sin(K),Math.cos(K)),he=new F(Math.sin(Z),Math.cos(Z));Fh(w,k,X),Fh(w,he,N),Fh(T,ue,j),yb(S,X,N,R,R,U),u.push(U.x,U.y,U.z),yb(X,S,N,R,I,z),u.push(z.x,z.y,z.z),yb(N,X,S,I,R,H),u.push(H.x,H.y,H.z),c.push(j.x,j.y,j.z),c.push(j.x,j.y,j.z),c.push(j.x,j.y,j.z),d.push(0,0),d.push(0,0),d.push(0,0);let ae=h++,me=h++,be=h++;if(l.push(ae,me,be),o>0){{let Me=X.clone().add(N).multiplyScalar(.5),xe=S.clone().sub(Me).normalize(),ht=x.clone().sub(Me).normalize().add(xe).normalize().multiplyScalar(-1),L=H.clone().sub(z);W(Me,L,ht,_.angle())}let ge,Ae;{let Me=new A;Fh(M,he,Me);let xe=H.clone().add(U).multiplyScalar(.5);xe=jH(xe,N,S);let Ge=H.clone().sub(U);[ge,Ae]=W(xe,Ge,Me,C,U.y)}{let Me=ge,xe=Me.clone().setY(0).normalize(),Ge=new A(0,-1,0),ht=xe.clone().cross(Ge);q(Me,xe,Ge,ht)}Y.concat(Ae);{let Me=_.angle(),xe=Math.PI-Me,Ge=S.clone();Ge.y-=o/Math.sin(Me-Math.PI/2);let ht=new A,L=[];for(let ee=0;ee<a;ee++){let fe=[],ye=Math.PI/2-xe*ee/a,Ce=Math.cos(ye),ke=Math.sin(ye),Pe=K;for(let ce=0;ce<=ee;ce++){let je=Math.cos(Pe),Le=Math.sin(Pe);j.x=Ce*Le,j.y=ke,j.z=Ce*je,ht.copy(Ge).addScaledVector(j,o),u.push(ht.x,ht.y,ht.z),c.push(j.x,j.y,j.z),d.push(0,0),fe.push(h++),Pe+=Math.PI*2/ee/n}L.push(fe)}Ae.reverse(),L.push(Ae);let O=L.length-1;for(let ee=0;ee<O;ee++){let fe=L[ee],ye=L[ee+1],Ce=fe.length-1;l.push(ye[1],fe[0],ye[0]);for(let ke=1;ke<=Ce;ke++)l.push(fe[ke],fe[ke-1],ye[ke]),l.push(ye[ke+1],fe[ke],ye[ke])}}}}}this.setIndex(l),this.setAttribute("position",new Se(u,3)),this.setAttribute("normal",new Se(c,3)),this.setAttribute("uv",new Se(d,2));function W(j,X,N,U,z){let H=-U/2,V=(Math.PI-U)/2,re=X.clone().normalize().cross(N);j.addScaledVector(N,-o/Math.sin(V));let K=new A,Z=new A,k=1,ue=h,he=[];for(let ae=0;ae<=a;ae++){let me=H+ae/a*U;Z.set(0,0,0),Z.addScaledVector(re,Math.sin(me)),Z.addScaledVector(N,Math.cos(me));for(let be=0;be<=k;be++){let ge=be/k-.5;if(K.copy(j),K.addScaledVector(X,ge),K.addScaledVector(Z,o),z!=null){let Ae=Math.max(0,K.y-z);K.addScaledVector(X,-Ae/X.y)}u.push(K.x,K.y,K.z),c.push(Z.x,Z.y,Z.z),d.push(0,0),be===0&&he.push(h),h++}}for(let ae=0;ae<a;ae++)for(let me=0;me<k;me++){let be=ue+me+(k+1)*ae,ge=be+(k+1),Ae=ge+1,Me=be+1;l.push(be,ge,Me),l.push(ge,Ae,Me)}return[j.clone().addScaledVector(X,.5),he]}function q(j,X,N,U){let z=Math.PI/2,H=b.angle()-z,V=[],re=new A,K=new A;for(let k=0;k<=a;k++){let ue=[],he=k/a;for(let ae=0;ae<=k;ae++){let be=((k?ae/k:0)-.5)*v,ge=Math.cos(be),Ae=Math.sin(be),Me=Math.atan(Math.tan(H)*ge),xe=(z+Me)*he,Ge=Math.cos(xe),ht=Math.sin(xe);re.set(0,0,0),re.addScaledVector(X,ht*ge),re.addScaledVector(N,Ge),re.addScaledVector(U,ht*Ae),K.copy(j).addScaledVector(re,o),u.push(K.x,K.y,K.z),c.push(re.x,re.y,re.z),d.push(0,0),ue.push(h++)}V.push(ue)}let Z=V.length-1;for(let k=0;k<Z;k++){let ue=V[k],he=V[k+1],ae=ue.length-1;l.push(ue[0],he[1],he[0]);for(let me=1;me<=ae;me++)l.push(ue[me-1],ue[me],he[me]),l.push(ue[me],he[me+1],he[me])}}}};var Pg=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 wt?r.shape:new wt,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(S,w,E){return w>e&&E>n?Math.min(S*e/w,S*n/E):w>e?S*e/w:E>n?S*n/E:S}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 S=0,w=t.points.length;S<w;S++)t.points[S].roundness=f[S],S>0&&f[S]!==f[S-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=Ur.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...r,type:"RectangleGeometry"}})}};var yC=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 Wa(.5*t,i,s,o,a,l,u);return c.scale(1,e/t,n/t),Object.assign(c,{userData:{...r,type:"SphereGeometry"}})}};var vC=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 Xs(t,e,n,i);return s.scale(1,1,1),Object.assign(s,{userData:{...r,type:"PlaneGeometry"}})}};var xC=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 xb(t,e,n,i,s,o);return Object.assign(a,{userData:{...r,type:"BackdropGeometry"}})}},xb=class extends _e{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=(K=0,Z=0,k=0)=>new A(K,Z,k),g=f(),p=f(),[m,y,v]=[e/2,t/2,n/2],x=-y,S=+y,[w,E,_]=[f(x,-m,+v),f(x,-m,-v),f(x,+m,-v)],b=(K,Z=!1)=>Math.sin(K-Math.PI/(1+ +Z)),T=(K,Z=!1)=>Math.cos(K-Math.PI/(1+ +Z));_.y=Math.sin(i)*e-m;let M=Math.cos(i)*e-v,D=w.z-c;i<=h?(_.z=Math.min(M,D),_.z==D&&(_.y-=(M-D)/Math.tan(h-i))):E.z=Math.min(E.z-M-v,w.z-c),g.subVectors(w,E),p.subVectors(_,E);let P=Math.min(g.length(),p.length())*s/100,C=P*Math.tan(i/2),I=P/Math.cos(i/2),R=g.clone().normalize().add(p.normalize()).setLength(I).add(E);g.set(0,b(i,!0),T(i,!0)),d.push([_,g.clone()]);let G=(Math.PI-i)/o;for(let K=0;K<=o;K++){let Z=h+i+K*G;g.set(0,Math.sin(Z)*C,Math.cos(Z)*C),g.add(R),p.set(0,b(Z),T(Z)),d.push([g.clone(),p.clone()])}d.push([w,f(0,1,0)]);let Y=Math.sin(G/2)*C*2,W=d.length-1,q=d[0][0].distanceTo(d[1][0]),j=d[W-1][0].distanceTo(d[W][0]),X=q+Y*o+j;d[0].push(1);for(let K=0;K<=o;K++)d[K+1].push(1-(q+K*Y)/X);d[W].push(0);let[N,U,z]=d[0],H,V,re;for(let K=1;K<d.length;K++)[H,V,re]=d[K],a.push(x,N.y,N.z,x,H.y,H.z,S,N.y,N.z,S,N.y,N.z,x,H.y,H.z,S,H.y,H.z),l.push(0,U.y,U.z,0,V.y,V.z,0,U.y,U.z,0,U.y,U.z,0,V.y,V.z,0,V.y,V.z),u.push(0,z,0,re,1,z,1,z,0,re,1,re),[N,U,z]=[H,V,re];this.setAttribute("position",new Se(a,3)),this.setAttribute("normal",new Se(l,3)),this.setAttribute("uv",new Se(u,2))}};var Dg=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 wt?r.shape:new wt,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 S=0;S<i;S++){let w=p*S,E=f+Math.sin(w)*d,_=g+Math.cos(w)*h;c.addPoint(c.createPoint(E,_))}}else for(let S=0;S<i;S++){let w=f+Math.cos(m)*d,E=g+Math.sin(m)*h;c.addPoint(c.createPoint(w,E)),m+=p,w=f+Math.cos(m)*y,E=g+Math.sin(m)*v,S<=i,c.addPoint(c.createPoint(w,E)),m+=p}c.isClosed=!0;for(let S=0,w=c.points.length;S<w;S++)c.points[S].roundness=s;c.roundness=s,c.update();let x=Ur.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...r,type:"StarGeometry"}})}};var bC=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 Xs(t,e);return Object.assign(n,{userData:{...r,type:"TextFrameGeometry"}})}};var SC=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=qH(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 qH(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 Nh(!0,r,t,e,n,i,s,o,a,l,u,c)}var wC=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 rc(a,e,n,i,s,o);return Object.assign(l,{userData:{...r,type:"TorusKnotGeometry"}})}};var AC=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 wt?r.shape:new wt,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=Ur.create({shape:l,parameters:{roundness:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(d,{userData:{...r,type:"TriangleGeometry"}})}};function EC(r,t){let e=2*Math.PI;return(r%e+e)%e===(t%e+e)%e}function XH(r,t,e){let n=[new A,new A,new A],i=[new A,new A,new A];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 _C=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??_u.create({parameters:Tx}).userData.shape;return{path:r.path??Kc.defaultData(),parameters:Object.assign(e,{width:n,height:i,depth:s,extrusion:{...Hm,...e.extrusion}}),shapeData:o}}static build(r){if(r.path.points.length>=2){let e=new bb(r);return Object.assign(e,{userData:{...r,type:"PathGeometry"}})}else return Object.assign(new _e,{userData:{...r,type:"PathGeometry"}})}},bb=class extends _e{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)||!EC(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,I)=>{c[P]=c[P].clone().lerp(c[C],I),d[P]=XH(d[P],d[C],I)},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),S=0,w=0;v.sort((P,C)=>P.start-C.start),v.forEach(P=>{P.verticesStart=S,P.verticesCount=P.continuous.reduce((C,I,R)=>C+(R===0||!I?2:1),0),w+=P.verticesCount,S=w});let E=w*u,_,b=0;if(this._isOpenEnded()){try{_=ki({windingRule:dt.ODD,elementType:tn.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:y})}catch{_=hb}b=_.vertexCount}let T=E+2*b,M={positions:new Float32Array(T*3),normals:new Float32Array(T*3),uvs:new Float32Array(T*2)},D=[];v.forEach(P=>{this._extrudeRegion(P,x,d,c,M,D,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,E,D,M,d[0],c[0],!1),this._closeEnd(_,E+b,D,M,d[d.length-1],c[c.length-1],!0)),this.setAttribute("position",new Fe(M.positions,3)),this.setAttribute("normal",new Fe(M.normals,3)),this.setAttribute("uv",new Fe(M.uvs,2)),this.setIndex(D)}_extractPathPoints(){let n=yg(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,a=new A,l=new A,u=new A,c=new A(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 S=y.clone().sub(v).normalize(),w=x.clone().sub(y).normalize(),E=S.clone().add(w).normalize();l.copy(E),m===0&&(E.equals(c)||E.clone().negate().equals(c))&&c.set(0,0,1);let _=c.clone().cross(E).normalize(),b=E.clone().cross(_).normalize();c.copy(b),u.copy(_),m===0&&(o.copy(b),a.copy(E));let T=new de().makeBasis(_,b,E);n.push(T)}let d=s?a:l,h=s?o:new A(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=dt.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],S=m[v-0];y.push(x,S)}return y}),a;try{a=ki({windingRule:n,elementType:tn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=Rh}let l;try{l=ki({windingRule:dt.ODD,elementType:tn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=db}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],S=v+x,w={start:v,count:x,normals:[],isHole:m,continuous:[],verticesStart:0,verticesCount:0};g.push(w);let E=v,_=S-1,b=v+1,T=i.roundedCurves.length;do{let M=E-v,D=a.vertices[_*2+0],P=a.vertices[_*2+1],C=a.vertices[E*2+0],I=a.vertices[E*2+1],R=a.vertices[b*2+0],G=a.vertices[b*2+1],Y=C-D,W=I-P,q=Math.sqrt(Y*Y+W*W);Y/=q,W/=q;let j=C-R,X=I-G,N=Math.sqrt(j*j+X*X);j/=N,X/=N,w.normals[M*2+0]=-X,w.normals[M*2+1]=j;let U=a.vertexIndices[E];if(Array.isArray(U))w.continuous[M]=!1;else{let[z,H]=i.getCurveIndexFromVertexId(U-1,!0);if(H>0&&H<1)w.continuous[M]=!0;else{let V=H===1?z+1:z-1;V=(V+T)%T;let re=H===1?0:1,K=i.roundedCurves[z].getTangent(H),Z=i.roundedCurves[V].getTangent(re);w.continuous[M]=K.dot(Z)>.95}}m&&(w.normals[M*2+0]*=-1,w.normals[M*2+1]*=-1),[_,E,b]=[E,b,b+1],b>=S&&(b-=x)}while(b!==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 A,c=new A,d=new A,h=new A,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 S=(e.start+x)*2;if(u.set(n[S+0],n[S+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:S-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:S+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 S=x===e.count-1?0:v+1,w=m+v,E=m+S,_=y+S,b=y+v;e.isHole?a.push(w,_,E,w,b,_):a.push(w,E,_,w,_,b),v++}}}_closeEnd(e,n,i,s,o,a,l){let u=e.vertexCount,c=new A(0,0,l?-1:1).applyMatrix4(o),d=new A,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 TC(){let r=new _e;return r.setAttribute("position",new Fe(new Float32Array([]),3)),r.setIndex(new Fe(new Uint16Array([]),1)),r}var YH=TC().attributes,QH=12,KH=1,Cu=class extends _e{constructor(e,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,YH),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=ZH(e,n,d),{shapes:f,charWidths:g,charCoords:p}=n.generateShapes(h,e),m=i*.5,y=s*.5,v=f.map(w=>new wt().fromShape(w));this.vectorShapes=v;let x=v.map(w=>Ur.create({shape:w,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?dt.NONZERO:dt.ODD,subdivisions:this.isLowResolution&&o>0?KH:QH}})),S=x.length?oo(x):TC();S.translate(-m,y,0),this.dispose(),this.wrappedText=h,this.charCoords=p,this.charWidths=g,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([w,E])=>{this.setAttribute(w,E)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=Bi(new _e,Cu.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 ZH(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 CC,Pu=new Promise(r=>{CC=r}),MC=!1;async function PC(){if(MC)return;let t=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.339/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});CC(s),MC=!0}function hl(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=wt.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 ac().parse(r);else{if(r.type==="SubdivGeometry")return new fn(r,e);if(r.type==="TextGeometry")return new Cu(r,t)}let i;try{i=Sb(n)}catch(s){console.error(s)}if(!i){let s=wt.createFromState(Qc.defaultData(),100,100);n.shape=s,i=Sb(n)}return i}var JH=new de;function Uh(r,t,e,n){let i=r.position.array,s=r.normal.array,o=JH.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 Ig=new bt,Du=new A,Xe;Pu.then(r=>{Xe=r});var DC=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),IC=new Uint32Array([0,1,2,3]),OC=new Uint8Array([4]),fn=class extends _e{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=ds.div(n,i);this.subdividedGeometry&&Uh(this.subdividedGeometry.attributes,...s),this.originalGeometry&&Uh(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(Du.fromArray(s));let a=Du.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}=fn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Xn(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&&(fn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Tn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,i=e.boundingSphere.center;Ig.setFromBufferAttribute(n),Ig.getCenter(i),e.boundingSphere.radius=i.distanceTo(Ig.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ig.getSize(Du);let s={width:Du.x,height:Du.y,depth:Du.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&&(Xe.free_bvh(n),Xe.free_subdivision_surface(n));try{o=fn.allocate(e,s)}catch(c){console.error(c,e),o=fn.allocate({positionWASM:DC,indexWASM:IC,verticesPerFaceWASM:OC},s)}if(Xe.set_destination_refinement_level(o,0),a=fn.buildLevel(o,!0,u),e.subdivisions>0)try{Xe.set_destination_refinement_level(o,e.subdivisions),l=fn.buildLevel(o,!1,u)}catch{try{Xe.set_destination_refinement_level(o,e.subdivisions-1),l=fn.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=e.shape!==void 0?n.geometry:hl(e,i,!1),o,a,l,u;({positions:o,triIndices:u}=Gh(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}=_b(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=DC,s=IC,o=OC);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=Xe._malloc(g),v=new Float32Array(Xe.HEAPF32.buffer,y,h),x=new Uint32Array(Xe.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 S;e?.scaleBaked?.some(E=>E!==1)&&(S=new de().makeScale(...e.scaleBaked)),n&&(S?S.premultiply(n):S=n);let w=S?Xe.alloc_subdivision_surface2(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d,S.elements):Xe.alloc_subdivision_surface(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return Xe._free(y),w}static buildLevel(e,n,i,s,o){let a=o?Xe.get_mesh_data2(e,n?Xe.Level.CONTROL:Xe.Level.REFINED,i,o.elements):Xe.get_mesh_data(e,n?Xe.Level.CONTROL:Xe.Level.REFINED,i),l=8,u=Xe.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=Xe.HEAPU32[u[d]>>2],f=Xe.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let g=Xe.HEAPU32[u[d]>>2],p=Xe.HEAPF32.subarray(g>>2,(g>>2)+c[d]);d++;let m=Xe.HEAPU32[u[d]>>2],y=Xe.HEAPU32.subarray(m>>2,(m>>2)+c[d]);d++;let v=Xe.HEAPU32[u[d]>>2],x=Xe.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let S=new _e;if(S.setIndex(new Ro(x,1)),S.setAttribute("position",new Se(f,3)),S.setAttribute("normal",new Se(p,3)),n){S.setAttribute("faceMap",new Ro(y,1));let w=new Float32Array(p.length/3*4).fill(0);S.setAttribute("color",new Fe(w,4))}return Xe.free_mesh_data(a),S.userData.type="SubdivGeometry",S}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(p),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,Xe.free_mesh_data(a)}static freeSubdivPointer(e){Xe.free_bvh(e),Xe.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,i){let s=Xe.get_wireframe_data_for_base_level(e),o=4,a=Xe.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=Xe.HEAPU32[a[u]>>2],d=Xe.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=Xe.HEAPU32[a[u]>>2],f=Xe.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let g=new _e;g.setAttribute("position",new Se(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 Fe(p,3)),g.setIndex(new Ro(f,1)),Xe.free_wireframe_data_for_base_level(s),g}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,Xe.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,i){let s=n===0;s||Xe.set_destination_refinement_level(e,n);let o=i?Xe.get_topological_data2(e,s?Xe.Level.CONTROL:Xe.Level.REFINED,i.elements):Xe.get_topological_data(e,s?Xe.Level.CONTROL:Xe.Level.REFINED),a=6,l=Xe.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=Xe.HEAPU32[l[c]>>2],h=new Float32Array(Xe.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=Xe.HEAPU32[l[c]>>2],g=new Uint32Array(Xe.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let p=Xe.HEAPU32[l[c]>>2],m=new Uint8Array(Xe.HEAPU32.subarray(p>>2,(p>>2)+u[c]));return Xe.free_topological_data(o),{positions:h,indices:g,verticesPerFace:m}}};var LC=["getX","getY","getZ"];function Gh(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[LC[h]](c)*a)},`;if(d in e)s.push(e[d]);else{for(let h=0;h<3;h++)o.push(r[LC[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 Og=new A,wb=new A,Ab=new A,Eb=new A;function _b(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]){Og.set(r[t[o]*3],r[t[o]*3+1],r[t[o]*3+2]),wb.set(r[t[o+1]*3],r[t[o+1]*3+1],r[t[o+1]*3+2]),Ab.set(r[t[o+4]*3],r[t[o+4]*3+1],r[t[o+4]*3+2]),Eb.set(r[t[o+5]*3],r[t[o+5]*3+1],r[t[o+5]*3+2]),wb.sub(Og).normalize(),Ab.sub(Og).normalize(),Eb.sub(Og).normalize();let l=wb.cross(Ab).dot(Eb);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 Vi={};vw(Vi,{calcBoolean:()=>t5,calcBooleanTopological:()=>e5,freeMeshSet:()=>i5,getMeshSet:()=>n5,transformMeshSet:()=>r5});var NC,BC=new Promise(r=>{NC=r}),RC=!1;async function FC(){if(RC)return;let t=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.339/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});NC(s),RC=!0}var at,Iu;BC.then(r=>at=r);function $H(r,t,e){let n,{positions:i,triIndices:s}=Gh(r.getAttribute("position"),r.getIndex()),o;if(t&&e){let{indices:a,verticesPerFace:l}=_b(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=at._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(at.HEAPU32.buffer,s,t):new Float32Array(at.HEAPF32.buffer,s,t)).set(r,0),s}function GC(r){switch(r){case 0:return at.OP.UNION;case 1:return at.OP.INTERSECTION;case 2:return at.OP.A_MINUS_B;case 3:return at.OP.B_MINUS_A;case 4:return at.OP.SYMMETRIC_DIFFERENCE;case 5:return at.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function e5(r,t){Iu===void 0&&(Iu=at.init_csg());let e=UC(r),n=at.csg_calc_topological(Iu,e,r.length,GC(t));at._free(e);let i=6,s=at.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=at.HEAPU32[s[a]>>2],u=new Float32Array(at.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=at.HEAPU32[s[a]>>2],d=new Uint32Array(at.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let h=at.HEAPU32[s[a]>>2],f=new Uint8Array(at.HEAPU32.subarray(h>>2,(h>>2)+o[a]));return at.free_mesh_data(n),{positions:u,indices:d,verticesPerFace:f}}function t5(r,t,e,n){Iu===void 0&&(Iu=at.init_csg());let i=UC(r),s=at.csg_calc(Iu,i,r.length,n,GC(t));at._free(i);let o=5,a=at.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=at.HEAPU32[a[u]>>2],d=at.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=at.HEAPU32[a[u]>>2],f=at.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let g=l[u];e.setAttribute("position",new Se(d,3)),e.setAttribute("normal",new Se(f,3));let p=at.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Tn),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},at.free_mesh_data(s),g}function n5(r,t,e){if(at===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 S=0;S<m.verticesPerFace[y];S++)i[x++]=m.indices[v++]}}else({positions:n,faceIndices:i,nFaces:s}=$H(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=at._malloc(c),g=new Float32Array(at.HEAPF32.buffer,f,l),p=new Uint32Array(at.HEAPU32.buffer,f+d,u);return g.set(n,0),p.set(i,0),at.get_csg_mesh(f,o,f+d,a,s)}function r5(r,t){at.transform_csg_mesh(r,t.elements)}function i5(r){at.free_csg_mesh(r)}var s5={ConeGeometry:BM,CubeGeometry:FM,CylinderGeometry:NM,DodecahedronGeometry:UM,EllipseGeometry:_u,HelixGeometry:cC,IcosahedronGeometry:uC,LatheGeometry:dC,NonParametricGeometry:mC,PolygonGeometry:Cg,PyramidGeometry:gC,RectangleGeometry:Pg,SphereGeometry:yC,PlaneGeometry:vC,BackdropGeometry:xC,StarGeometry:Dg,TextFrameGeometry:bC,TorusGeometry:SC,TorusKnotGeometry:wC,TriangleGeometry:AC,PathGeometry:_C,VectorGeometry:Ur},Sb=r=>s5[r.type].create(r);function kh(r){return r!==null&&"booleanOp"in r}var Ou=class extends vg(qn){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new de}updateVisible(){super.updateVisible(),this.visible=!kh(this.parent)&&this.visible,kh(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Vi.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),kh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ou&&(e.freeBooleanPointer(),kh(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let n=super.updateTransformState(e);return n&&kh(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}};var Lg=new bt;function Vh(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)}Lg.min.set(s,o,a),Lg.max.set(l,u,c),Lg.getCenter(n),Lg.getSize(i).multiplyScalar(.5)}var o5=new _e,a5=new qs,Bt=class extends Ou{constructor(t,e){super(o5,a5),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?Vh(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var zh=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 er=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 er&&(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 Tb=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}},Gn=new Tb;var We=class extends er{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 Rt=class extends We{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 tr=class extends Rt{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 ar=class extends Rt{constructor(e=0,n,i){super("v3");this.nodeType="Vector3";this.value=e instanceof A?e:new A(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 Zt=class extends Ne{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 yi=class extends Rt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Zt?e:new Zt(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 l5=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,kC=/[a-z_0-9]+/gi,Ee=class extends We{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=kC.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&&Gn.containsKeyword(f)){let m=this.keywords[f];if(!m){let y=Gn.getKeywordData(f);y.cache&&(m=e.keywords[f]),m=m||Gn.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&&Gn.contains(p)&&e.include(Gn.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=l5.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(kC);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 c5=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Mb=class extends We{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Mb.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=c5.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)}},xt=Mb;xt.PI="PI",xt.PI2="PI2",xt.RECIPROCAL_PI="RECIPROCAL_PI",xt.RECIPROCAL_PI2="RECIPROCAL_PI2",xt.LOG2="LOG2",xt.EPSILON="EPSILON";var u5=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 CC,Pu=new Promise(r=>{CC=r}),MC=!1;async function PC(){if(MC)return;let t=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.341/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});CC(s),MC=!0}function hl(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=wt.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 ac().parse(r);else{if(r.type==="SubdivGeometry")return new fn(r,e);if(r.type==="TextGeometry")return new Cu(r,t)}let i;try{i=Sb(n)}catch(s){console.error(s)}if(!i){let s=wt.createFromState(Qc.defaultData(),100,100);n.shape=s,i=Sb(n)}return i}var JH=new de;function Uh(r,t,e,n){let i=r.position.array,s=r.normal.array,o=JH.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 Ig=new bt,Du=new A,Xe;Pu.then(r=>{Xe=r});var DC=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),IC=new Uint32Array([0,1,2,3]),OC=new Uint8Array([4]),fn=class extends _e{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=ds.div(n,i);this.subdividedGeometry&&Uh(this.subdividedGeometry.attributes,...s),this.originalGeometry&&Uh(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(Du.fromArray(s));let a=Du.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}=fn.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Xn(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&&(fn.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Tn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let n=e.attributes.position,i=e.boundingSphere.center;Ig.setFromBufferAttribute(n),Ig.getCenter(i),e.boundingSphere.radius=i.distanceTo(Ig.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ig.getSize(Du);let s={width:Du.x,height:Du.y,depth:Du.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&&(Xe.free_bvh(n),Xe.free_subdivision_surface(n));try{o=fn.allocate(e,s)}catch(c){console.error(c,e),o=fn.allocate({positionWASM:DC,indexWASM:IC,verticesPerFaceWASM:OC},s)}if(Xe.set_destination_refinement_level(o,0),a=fn.buildLevel(o,!0,u),e.subdivisions>0)try{Xe.set_destination_refinement_level(o,e.subdivisions),l=fn.buildLevel(o,!1,u)}catch{try{Xe.set_destination_refinement_level(o,e.subdivisions-1),l=fn.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=e.shape!==void 0?n.geometry:hl(e,i,!1),o,a,l,u;({positions:o,triIndices:u}=Gh(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}=_b(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=DC,s=IC,o=OC);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=Xe._malloc(g),v=new Float32Array(Xe.HEAPF32.buffer,y,h),x=new Uint32Array(Xe.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 S;e?.scaleBaked?.some(E=>E!==1)&&(S=new de().makeScale(...e.scaleBaked)),n&&(S?S.premultiply(n):S=n);let w=S?Xe.alloc_subdivision_surface2(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d,S.elements):Xe.alloc_subdivision_surface(y,u,y+p,c,y+p+s.length*Uint32Array.BYTES_PER_ELEMENT,d);return Xe._free(y),w}static buildLevel(e,n,i,s,o){let a=o?Xe.get_mesh_data2(e,n?Xe.Level.CONTROL:Xe.Level.REFINED,i,o.elements):Xe.get_mesh_data(e,n?Xe.Level.CONTROL:Xe.Level.REFINED,i),l=8,u=Xe.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),d=0,h=Xe.HEAPU32[u[d]>>2],f=Xe.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let g=Xe.HEAPU32[u[d]>>2],p=Xe.HEAPF32.subarray(g>>2,(g>>2)+c[d]);d++;let m=Xe.HEAPU32[u[d]>>2],y=Xe.HEAPU32.subarray(m>>2,(m>>2)+c[d]);d++;let v=Xe.HEAPU32[u[d]>>2],x=Xe.HEAPU32.subarray(v>>2,(v>>2)+c[d]);if(d++,s===void 0){let S=new _e;if(S.setIndex(new Ro(x,1)),S.setAttribute("position",new Se(f,3)),S.setAttribute("normal",new Se(p,3)),n){S.setAttribute("faceMap",new Ro(y,1));let w=new Float32Array(p.length/3*4).fill(0);S.setAttribute("color",new Fe(w,4))}return Xe.free_mesh_data(a),S.userData.type="SubdivGeometry",S}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(p),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,Xe.free_mesh_data(a)}static freeSubdivPointer(e){Xe.free_bvh(e),Xe.free_subdivision_surface(e)}static buildControlCageWireframe(e,n,i){let s=Xe.get_wireframe_data_for_base_level(e),o=4,a=Xe.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=Xe.HEAPU32[a[u]>>2],d=Xe.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=Xe.HEAPU32[a[u]>>2],f=Xe.HEAPU32.subarray(h>>2,(h>>2)+l[u]);if(n===void 0){let g=new _e;g.setAttribute("position",new Se(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 Fe(p,3)),g.setIndex(new Ro(f,1)),Xe.free_wireframe_data_for_base_level(s),g}n.getAttribute("position").copyArray(d),n.attributes.position.needsUpdate=!0,Xe.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,n,i){let s=n===0;s||Xe.set_destination_refinement_level(e,n);let o=i?Xe.get_topological_data2(e,s?Xe.Level.CONTROL:Xe.Level.REFINED,i.elements):Xe.get_topological_data(e,s?Xe.Level.CONTROL:Xe.Level.REFINED),a=6,l=Xe.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,d=Xe.HEAPU32[l[c]>>2],h=new Float32Array(Xe.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=Xe.HEAPU32[l[c]>>2],g=new Uint32Array(Xe.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let p=Xe.HEAPU32[l[c]>>2],m=new Uint8Array(Xe.HEAPU32.subarray(p>>2,(p>>2)+u[c]));return Xe.free_topological_data(o),{positions:h,indices:g,verticesPerFace:m}}};var LC=["getX","getY","getZ"];function Gh(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[LC[h]](c)*a)},`;if(d in e)s.push(e[d]);else{for(let h=0;h<3;h++)o.push(r[LC[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 Og=new A,wb=new A,Ab=new A,Eb=new A;function _b(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]){Og.set(r[t[o]*3],r[t[o]*3+1],r[t[o]*3+2]),wb.set(r[t[o+1]*3],r[t[o+1]*3+1],r[t[o+1]*3+2]),Ab.set(r[t[o+4]*3],r[t[o+4]*3+1],r[t[o+4]*3+2]),Eb.set(r[t[o+5]*3],r[t[o+5]*3+1],r[t[o+5]*3+2]),wb.sub(Og).normalize(),Ab.sub(Og).normalize(),Eb.sub(Og).normalize();let l=wb.cross(Ab).dot(Eb);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 Vi={};vw(Vi,{calcBoolean:()=>t5,calcBooleanTopological:()=>e5,freeMeshSet:()=>i5,getMeshSet:()=>n5,transformMeshSet:()=>r5});var NC,BC=new Promise(r=>{NC=r}),RC=!1;async function FC(){if(RC)return;let t=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.341/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});NC(s),RC=!0}var at,Iu;BC.then(r=>at=r);function $H(r,t,e){let n,{positions:i,triIndices:s}=Gh(r.getAttribute("position"),r.getIndex()),o;if(t&&e){let{indices:a,verticesPerFace:l}=_b(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=at._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(at.HEAPU32.buffer,s,t):new Float32Array(at.HEAPF32.buffer,s,t)).set(r,0),s}function GC(r){switch(r){case 0:return at.OP.UNION;case 1:return at.OP.INTERSECTION;case 2:return at.OP.A_MINUS_B;case 3:return at.OP.B_MINUS_A;case 4:return at.OP.SYMMETRIC_DIFFERENCE;case 5:return at.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function e5(r,t){Iu===void 0&&(Iu=at.init_csg());let e=UC(r),n=at.csg_calc_topological(Iu,e,r.length,GC(t));at._free(e);let i=6,s=at.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=at.HEAPU32[s[a]>>2],u=new Float32Array(at.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=at.HEAPU32[s[a]>>2],d=new Uint32Array(at.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let h=at.HEAPU32[s[a]>>2],f=new Uint8Array(at.HEAPU32.subarray(h>>2,(h>>2)+o[a]));return at.free_mesh_data(n),{positions:u,indices:d,verticesPerFace:f}}function t5(r,t,e,n){Iu===void 0&&(Iu=at.init_csg());let i=UC(r),s=at.csg_calc(Iu,i,r.length,n,GC(t));at._free(i);let o=5,a=at.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=at.HEAPU32[a[u]>>2],d=at.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let h=at.HEAPU32[a[u]>>2],f=at.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let g=l[u];e.setAttribute("position",new Se(d,3)),e.setAttribute("normal",new Se(f,3));let p=at.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Tn),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},at.free_mesh_data(s),g}function n5(r,t,e){if(at===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 S=0;S<m.verticesPerFace[y];S++)i[x++]=m.indices[v++]}}else({positions:n,faceIndices:i,nFaces:s}=$H(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=at._malloc(c),g=new Float32Array(at.HEAPF32.buffer,f,l),p=new Uint32Array(at.HEAPU32.buffer,f+d,u);return g.set(n,0),p.set(i,0),at.get_csg_mesh(f,o,f+d,a,s)}function r5(r,t){at.transform_csg_mesh(r,t.elements)}function i5(r){at.free_csg_mesh(r)}var s5={ConeGeometry:BM,CubeGeometry:FM,CylinderGeometry:NM,DodecahedronGeometry:UM,EllipseGeometry:_u,HelixGeometry:cC,IcosahedronGeometry:uC,LatheGeometry:dC,NonParametricGeometry:mC,PolygonGeometry:Cg,PyramidGeometry:gC,RectangleGeometry:Pg,SphereGeometry:yC,PlaneGeometry:vC,BackdropGeometry:xC,StarGeometry:Dg,TextFrameGeometry:bC,TorusGeometry:SC,TorusKnotGeometry:wC,TriangleGeometry:AC,PathGeometry:_C,VectorGeometry:Ur},Sb=r=>s5[r.type].create(r);function kh(r){return r!==null&&"booleanOp"in r}var Ou=class extends vg(qn){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new de}updateVisible(){super.updateVisible(),this.visible=!kh(this.parent)&&this.visible,kh(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Vi.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),kh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ou&&(e.freeBooleanPointer(),kh(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let n=super.updateTransformState(e);return n&&kh(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}};var Lg=new bt;function Vh(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)}Lg.min.set(s,o,a),Lg.max.set(l,u,c),Lg.getCenter(n),Lg.getSize(i).multiplyScalar(.5)}var o5=new _e,a5=new qs,Bt=class extends Ou{constructor(t,e){super(o5,a5),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?Vh(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,t,e):super.updateEntityBoxSize(t,e)}};var zh=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 er=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 er&&(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 Tb=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}},Gn=new Tb;var We=class extends er{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 Rt=class extends We{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 tr=class extends Rt{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 ar=class extends Rt{constructor(e=0,n,i){super("v3");this.nodeType="Vector3";this.value=e instanceof A?e:new A(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 Zt=class extends Ne{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 yi=class extends Rt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Zt?e:new Zt(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 l5=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,kC=/[a-z_0-9]+/gi,Ee=class extends We{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=kC.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&&Gn.containsKeyword(f)){let m=this.keywords[f];if(!m){let y=Gn.getKeywordData(f);y.cache&&(m=e.keywords[f]),m=m||Gn.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&&Gn.contains(p)&&e.include(Gn.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=l5.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(kC);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 c5=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Mb=class extends We{constructor(e="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Mb.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=c5.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)}},xt=Mb;xt.PI="PI",xt.PI2="PI2",xt.RECIPROCAL_PI="RECIPROCAL_PI",xt.RECIPROCAL_PI2="RECIPROCAL_PI2",xt.LOG2="LOG2",xt.EPSILON="EPSILON";var u5=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3141
3141
  )*?)}`,"gim"),d5=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Lu=class extends We{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=u5.exec(e);if(n){let i=n[2],s;for(;s=d5.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=n[1]}else this.name="";this.type=this.name}};var Ru=class extends We{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)}};Gn.addKeyword("uv",function(){return new Ru});Gn.addKeyword("uv2",function(){return new Ru(1)});var fl=class extends We{constructor(e,n){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=n??fl.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Zr:return["Linear"];case Ye:return["sRGB"];default:return[]}}generate(e,n){let i=this.input.build(e,"v4"),s=this.getType(e),o=fl.Nodes[this.method],a=e.include(o);if(a===fl.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=fl.getEncodingComponents(e);this.method="LinearTo"+n[0],this.factor=n[1]}fromDecoding(e){let n=fl.getEncodingComponents(e);this.method=n[0]+"ToLinear",this.factor=n[1]}},Mr=fl;Mr.Nodes={LinearToLinear:new Ee(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3142
3142
  `)),sRGBToLinear:new Ee(["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 Ee(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
@@ -5209,4 +5209,4 @@ outputColor=vec4(color,inputColor.a);}`,Qy={DEFAULT:0,ESKIL:1},DI=class extends
5209
5209
  void main() {
5210
5210
  gl_FragColor = vec4(0.0);
5211
5211
  }
5212
- `}),xd=class extends jr{constructor(e,n){super("OpaquePass",e??II,n);this.hasTransmissionPass=!1;this.clear=!0;this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??II}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 Bt&&(this.originalMaterials.set(s.id,s.material),s.material=s8)}),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 OI(r,t){return t&&t.enabled&&r.push(t.effect),r}var o8=r=>Object.values(st).includes(r)?r:st.NORMAL,Uf=class extends kt{constructor(e){super();this.postprocessingState=il.defaultData;this._scene=new Sr;this._camera=new Ht;this.effects=new Map;this._renderToScreen=!0;this.clock=new Lp,this.renderer=e,this.debug=!1,this.effects.set("bloom",new ud),this.effects.set("chromaticAberration",new hd),this.effects.set("vignette",new gd),this.effects.set("noise",new md),this.effects.set("colorAverage",new fd),this.effects.set("hueSaturation",new pd),this.effects.set("brightnessContrast",new dd),this.effects.set("depthOfField",new yd),this.effects.set("pixelation",new vd),this.effectComposer=new bI(this.renderer),this.opaquePass=new xd(this.scene,this.camera),this.transmissionPass=new Jy(this.scene,this.camera,this.renderer),this.helperPass=new xd(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Ff(!1,!0,!1),this.helperPassOnTop=new xd(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 PI({preset:Tl.ULTRA,edgeDetectionMode:Ky.COLOR}),n=()=>{e.removeEventListener("load",n),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",n),e.edgeDetectionMaterial.predicationMode=dw.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new Zy(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(OI,[]);e.length>0&&(this.uvEffectPass=new Zy(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(OI,[]);n.length>0&&(this.effectPass=new Zy(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 Et(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:ql,wrapT:ql}),this._rt.samples=0,this._savePass=new cd(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=o8(c):l[u]=c}}this.postprocessingState=e,s&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,n,i,s){e instanceof $e?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,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 $e?(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 LI=new Wt,$y=class extends I0{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new F;this.pipeline=new Uf(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 Et(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{generateMipmaps:!0,minFilter:Ra,magFilter:it,wrapS:xr,wrapT:xr,depthBuffer:!1}),this.transmissionDepthTarget=new Et(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Ut,magFilter:Ut,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new Et(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Ut,magFilter:Ut,type:ns,depthTexture:new No(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 Ht?ay.uniforms.depthContrast.value=(n.far-n.near)/1e4:ay.uniforms.depthContrast.value=1,e.overrideMaterial=ay,this.render(e,n),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?cy: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)=>{Ot.penumbraSize.value[u]=l}),Ot.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Ot.resolution.value.set(this.resolution.x,this.resolution.y):Ot.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(Ot.normalRenderTarget.value=this.overrideNormal,Ot.normalRenderTargetDepth.value=LI):e.needsNormal()&&(this.createNormalRenderTarget(),Ot.normalRenderTarget.value=this.normalRenderTarget.texture,Ot.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,n));let a=!1;if(this.overrideTransmission!==void 0)Ot.transmissionRenderTarget.value=this.overrideTransmission,Ot.transmissionRenderTargetDepth.value=LI,this.pipeline.setTransmissionPassEnabled(!1);else{let l=e.needsTransmission();l&&(this.transmissionRenderTarget===void 0&&(a=!0),this.createTransmissionRenderTarget(),Ot.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Ot.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?cy:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var ev=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new ho(t.shared,e),this.scene=new pn(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 Jt&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var tv=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 a8(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 Gf(r){return r instanceof ji?"SubdivObject":r.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function l8(r,t){let e={};return r.traverseEntity(n=>{if(!n.visible||!(n instanceof Bt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let i=n.parent;for(;i;){if(i instanceof Bt&&n.states&&Object.keys(n.states).length)return;i=i.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!$n.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!$n.isMergable(u.material))return;s=$n.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][Gf(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][Gf(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][Gf(n)].push(u)}),e}function c8(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=l8(t,r),n=c8(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 Bt&&(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&&a8(o[m]);let p=oo(o.slice(0,a),!1);if(p){let m;switch(h){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new qn(p,l[0].material);break}default:{m=new qn(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 Bt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][Gf(x)]&&e[x.material.uuid][Gf(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 FI=Bs(BI(),1);var u8=new F;function d8(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 pw=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._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),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.DragDrop.onAnimationFrameDamping(),(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1)),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this._perfs?.end()))};this._resize=Za(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=u8.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 tv({x:10,y:10})),WT(t)}async load(t,e){d8(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 cI(t);this._data=n,n.version&&(0,FI.default)(n.version,"0.9.339")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([aS(n)&&FC(),eP(n)&&PC(),n.scene.environment.usePhysics&&Y_(),Jb(n)&&JC()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let i=new ev(n);if(this._scene=i.scene,this._sharedAssetsManager=i.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();RI(n,i.scene);let a=performance.now();console.log("Merged geometries in ",a-o," ms")}aS(n)&&this._scene.traverse(o=>{Dr(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this.requestRender(),this._scene?.traverse(o=>{o instanceof si&&o.pendingMediaLoad&&o.update()})});let s=Object.keys(n.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);if(Promise.all(s).then(()=>{i.scene.markNeedsUpdateRendererDirty(),this.requestRender()}),Jb(n)&&JD(n)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),by(n.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new $y({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?Gp:M0,IP(n.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let o=Object.values(n.frames)[0];o.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=o.size[0],this._viewportHeight=o.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new Xy(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight))}e&&(this._scene.updateMatrixWorld(!0),this._controls=new Vy(n,this._scene,this._renderer,this.requestRender,this._sharedAssetsManager,!0),this._eventManager=new qy(this._renderer,this._scene,this._camera,n.scene.publish,this._sharedAssetsManager,this.requestRender,this._controls,!0),this._controls.init(this._eventManager)),this._resize(),!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._resize()}),this._resizeObserver.observe(this.canvas.parentElement)),this._rafId===void 0?this.render(performance.now()):this.requestRender()}findObjectById(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 od&&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 Zt(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._rafId=void 0),this._proxyObjectCache.forEach(t=>{W0.unsubscribe(t)}),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.dispose(),jT(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=W0(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}};
5212
+ `}),xd=class extends jr{constructor(e,n){super("OpaquePass",e??II,n);this.hasTransmissionPass=!1;this.clear=!0;this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??II}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 Bt&&(this.originalMaterials.set(s.id,s.material),s.material=s8)}),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 OI(r,t){return t&&t.enabled&&r.push(t.effect),r}var o8=r=>Object.values(st).includes(r)?r:st.NORMAL,Uf=class extends kt{constructor(e){super();this.postprocessingState=il.defaultData;this._scene=new Sr;this._camera=new Ht;this.effects=new Map;this._renderToScreen=!0;this.clock=new Lp,this.renderer=e,this.debug=!1,this.effects.set("bloom",new ud),this.effects.set("chromaticAberration",new hd),this.effects.set("vignette",new gd),this.effects.set("noise",new md),this.effects.set("colorAverage",new fd),this.effects.set("hueSaturation",new pd),this.effects.set("brightnessContrast",new dd),this.effects.set("depthOfField",new yd),this.effects.set("pixelation",new vd),this.effectComposer=new bI(this.renderer),this.opaquePass=new xd(this.scene,this.camera),this.transmissionPass=new Jy(this.scene,this.camera,this.renderer),this.helperPass=new xd(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Ff(!1,!0,!1),this.helperPassOnTop=new xd(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 PI({preset:Tl.ULTRA,edgeDetectionMode:Ky.COLOR}),n=()=>{e.removeEventListener("load",n),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",n),e.edgeDetectionMaterial.predicationMode=dw.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new Zy(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(OI,[]);e.length>0&&(this.uvEffectPass=new Zy(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(OI,[]);n.length>0&&(this.effectPass=new Zy(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 Et(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:ql,wrapT:ql}),this._rt.samples=0,this._savePass=new cd(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=o8(c):l[u]=c}}this.postprocessingState=e,s&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,n,i,s){e instanceof $e?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,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 $e?(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 LI=new Wt,$y=class extends I0{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new F;this.pipeline=new Uf(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 Et(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{generateMipmaps:!0,minFilter:Ra,magFilter:it,wrapS:xr,wrapT:xr,depthBuffer:!1}),this.transmissionDepthTarget=new Et(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Ut,magFilter:Ut,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new Et(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Ut,magFilter:Ut,type:ns,depthTexture:new No(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 Ht?ay.uniforms.depthContrast.value=(n.far-n.near)/1e4:ay.uniforms.depthContrast.value=1,e.overrideMaterial=ay,this.render(e,n),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?cy: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)=>{Ot.penumbraSize.value[u]=l}),Ot.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Ot.resolution.value.set(this.resolution.x,this.resolution.y):Ot.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(Ot.normalRenderTarget.value=this.overrideNormal,Ot.normalRenderTargetDepth.value=LI):e.needsNormal()&&(this.createNormalRenderTarget(),Ot.normalRenderTarget.value=this.normalRenderTarget.texture,Ot.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,n));let a=!1;if(this.overrideTransmission!==void 0)Ot.transmissionRenderTarget.value=this.overrideTransmission,Ot.transmissionRenderTargetDepth.value=LI,this.pipeline.setTransmissionPassEnabled(!1);else{let l=e.needsTransmission();l&&(this.transmissionRenderTarget===void 0&&(a=!0),this.createTransmissionRenderTarget(),Ot.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Ot.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?cy:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var ev=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new ho(t.shared,e),this.scene=new pn(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 Jt&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var tv=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 a8(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 Gf(r){return r instanceof ji?"SubdivObject":r.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function l8(r,t){let e={};return r.traverseEntity(n=>{if(!n.visible||!(n instanceof Bt)||n.type!=="Mesh"||Array.isArray(n.material)||n.states&&Object.keys(n.states).length)return;let i=n.parent;for(;i;){if(i instanceof Bt&&n.states&&Object.keys(n.states).length)return;i=i.parent}let s=n.material.uuid,o=t.shared.materials[s];if(o){if(!$n.isMergable(o))return}else{let u=t.scene.objects.get(n.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!$n.isMergable(u.material))return;s=$n.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][Gf(n)];if(l){if(l.push(n),n.cloner)for(let u of n.cloner.children)l.push(u)}else if(e[s][Gf(n)]=[n],n.cloner)for(let u of n.cloner.children)e[s][Gf(n)].push(u)}),e}function c8(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=l8(t,r),n=c8(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 Bt&&(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&&a8(o[m]);let p=oo(o.slice(0,a),!1);if(p){let m;switch(h){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new qn(p,l[0].material);break}default:{m=new qn(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 Bt&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][Gf(x)]&&e[x.material.uuid][Gf(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 FI=Bs(BI(),1);var u8=new F;function d8(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 pw=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._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),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.DragDrop.onAnimationFrameDamping(),(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1)),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this._perfs?.end()))};this._resize=Za(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=u8.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 tv({x:10,y:10})),WT(t)}async load(t,e){d8(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 cI(t);this._data=n,n.version&&(0,FI.default)(n.version,"0.9.341")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([aS(n)&&FC(),eP(n)&&PC(),n.scene.environment.usePhysics&&Y_(),Jb(n)&&JC()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let i=new ev(n);if(this._scene=i.scene,this._sharedAssetsManager=i.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();RI(n,i.scene);let a=performance.now();console.log("Merged geometries in ",a-o," ms")}aS(n)&&this._scene.traverse(o=>{Dr(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this.requestRender(),this._scene?.traverse(o=>{o instanceof si&&o.pendingMediaLoad&&o.update()})});let s=Object.keys(n.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);if(Promise.all(s).then(()=>{i.scene.markNeedsUpdateRendererDirty(),this.requestRender()}),Jb(n)&&JD(n)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),by(n.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new $y({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?Gp:M0,IP(n.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let o=Object.values(n.frames)[0];o.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=o.size[0],this._viewportHeight=o.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new Xy(this._renderer,this._camera,new F(this._viewportWidth,this._viewportHeight),new F(window.innerWidth,window.innerHeight))}e&&(this._scene.updateMatrixWorld(!0),this._controls=new Vy(n,this._scene,this._renderer,this.requestRender,this._sharedAssetsManager,!0),this._eventManager=new qy(this._renderer,this._scene,this._camera,n.scene.publish,this._sharedAssetsManager,this.requestRender,this._controls,!0),this._controls.init(this._eventManager)),this._resize(),this._rafId===void 0?this.render(performance.now()):this.requestRender(),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._resize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(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 od&&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 Zt(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._rafId=void 0),this._proxyObjectCache.forEach(t=>{W0.unsubscribe(t)}),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.dispose(),jT(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=W0(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}};