@splinetool/viewer 1.0.84 → 1.0.85

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.
@@ -3833,10 +3833,10 @@ void main() {
3833
3833
 
3834
3834
  }
3835
3835
 
3836
- }`,m5=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){let r=new Ki,a=e.properties.get(r);a.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}render(e,t){if(this.texture!==null){if(this.mesh===null){let i=t.cameras[0].viewport,r=new vi({extensions:{fragDepth:!0},vertexShader:p5,fragmentShader:f5,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new xr(new Pl(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}},g5=class extends ua{constructor(e,t){super();let i=this,r=null,a=1,s=null,n="local-floor",o=1,l=null,h=null,c=null,u=null,d=null,p=null,f=new m5,m=t.getContextAttributes(),g=null,v=null,x=[],b=[],_=new ae,M=null,A=new va;A.layers.enable(1),A.viewport=new Nt;let S=new va;S.layers.enable(2),S.viewport=new Nt;let P=[A,S],L=new u5;L.layers.enable(1),L.layers.enable(2);let E=null,T=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(re){let se=x[re];return se===void 0&&(se=new S0,x[re]=se),se.getTargetRaySpace()},this.getControllerGrip=function(re){let se=x[re];return se===void 0&&(se=new S0,x[re]=se),se.getGripSpace()},this.getHand=function(re){let se=x[re];return se===void 0&&(se=new S0,x[re]=se),se.getHandSpace()};function B(re){let se=b.indexOf(re.inputSource);if(se===-1)return;let he=x[se];he!==void 0&&(he.update(re.inputSource,re.frame,l||s),he.dispatchEvent({type:re.type,data:re.inputSource}))}function V(){r.removeEventListener("select",B),r.removeEventListener("selectstart",B),r.removeEventListener("selectend",B),r.removeEventListener("squeeze",B),r.removeEventListener("squeezestart",B),r.removeEventListener("squeezeend",B),r.removeEventListener("end",V),r.removeEventListener("inputsourceschange",I);for(let re=0;re<x.length;re++){let se=b[re];se!==null&&(b[re]=null,x[re].disconnect(se))}E=null,T=null,f.reset(),e.setRenderTarget(g),d=null,u=null,c=null,r=null,v=null,ue.stop(),i.isPresenting=!1,e.setPixelRatio(M),e.setSize(_.width,_.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(re){a=re,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(re){n=re,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(re){l=re},this.getBaseLayer=function(){return u!==null?u:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(re){if(r=re,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",B),r.addEventListener("selectstart",B),r.addEventListener("selectend",B),r.addEventListener("squeeze",B),r.addEventListener("squeezestart",B),r.addEventListener("squeezeend",B),r.addEventListener("end",V),r.addEventListener("inputsourceschange",I),m.xrCompatible!==!0&&await t.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(_),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let se={antialias:r.renderState.layers===void 0?m.antialias:!0,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:a};d=new XRWebGLLayer(r,t,se),r.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),v=new _i(d.framebufferWidth,d.framebufferHeight,{format:Qr,type:la,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let se=null,he=null,_e=null;m.depth&&(_e=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=m.stencil?Sh:gh,he=m.stencil?wl:En);let Ee={colorFormat:t.RGBA8,depthFormat:_e,scaleFactor:a};c=new XRWebGLBinding(r,t),u=c.createProjectionLayer(Ee),r.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),v=new _i(u.textureWidth,u.textureHeight,{format:Qr,type:la,depthTexture:new Ah(u.textureWidth,u.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0});let fe=e.properties.get(v);fe.__ignoreDepthValues=u.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await r.requestReferenceSpace(n),ue.setContext(r),ue.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function I(re){for(let se=0;se<re.removed.length;se++){let he=re.removed[se],_e=b.indexOf(he);_e>=0&&(b[_e]=null,x[_e].disconnect(he))}for(let se=0;se<re.added.length;se++){let he=re.added[se],_e=b.indexOf(he);if(_e===-1){for(let fe=0;fe<x.length;fe++)if(fe>=b.length){b.push(he),_e=fe;break}else if(b[fe]===null){b[fe]=he,_e=fe;break}if(_e===-1)break}let Ee=x[_e];Ee&&Ee.connect(he)}}let H=new O,q=new O;function X(re,se,he){H.setFromMatrixPosition(se.matrixWorld),q.setFromMatrixPosition(he.matrixWorld);let _e=H.distanceTo(q),Ee=se.projectionMatrix.elements,fe=he.projectionMatrix.elements,Re=Ee[14]/(Ee[10]-1),Pe=Ee[14]/(Ee[10]+1),te=(Ee[9]+1)/Ee[5],We=(Ee[9]-1)/Ee[5],Be=(Ee[8]-1)/Ee[0],Ue=(fe[8]+1)/fe[0],Ge=Re*Be,tt=Re*Ue,Fe=_e/(-Be+Ue),He=Fe*-Be;se.matrixWorld.decompose(re.position,re.quaternion,re.scale),re.translateX(He),re.translateZ(Fe),re.matrixWorld.compose(re.position,re.quaternion,re.scale),re.matrixWorldInverse.copy(re.matrixWorld).invert();let nt=Re+Fe,ht=Pe+Fe,Z=Ge-He,j=tt+(_e-He),ye=te*Pe/ht*nt,Me=We*Pe/ht*nt;re.projectionMatrix.makePerspective(Z,j,ye,Me,nt,ht),re.projectionMatrixInverse.copy(re.projectionMatrix).invert()}function Y(re,se){se===null?re.matrixWorld.copy(re.matrix):re.matrixWorld.multiplyMatrices(se.matrixWorld,re.matrix),re.matrixWorldInverse.copy(re.matrixWorld).invert()}this.updateCamera=function(re){if(r===null)return;f.texture!==null&&(re.near=f.depthNear,re.far=f.depthFar),L.near=S.near=A.near=re.near,L.far=S.far=A.far=re.far,(E!==L.near||T!==L.far)&&(r.updateRenderState({depthNear:L.near,depthFar:L.far}),E=L.near,T=L.far,A.near=E,A.far=T,S.near=E,S.far=T,A.updateProjectionMatrix(),S.updateProjectionMatrix(),re.updateProjectionMatrix());let se=re.parent,he=L.cameras;Y(L,se);for(let _e=0;_e<he.length;_e++)Y(he[_e],se);he.length===2?X(L,A,S):L.projectionMatrix.copy(A.projectionMatrix),ie(re,L,se)};function ie(re,se,he){he===null?re.matrix.copy(se.matrixWorld):(re.matrix.copy(he.matrixWorld),re.matrix.invert(),re.matrix.multiply(se.matrixWorld)),re.matrix.decompose(re.position,re.quaternion,re.scale),re.updateMatrixWorld(!0),re.projectionMatrix.copy(se.projectionMatrix),re.projectionMatrixInverse.copy(se.projectionMatrixInverse),re.isPerspectiveCamera&&(re.fov=hu*2*Math.atan(1/re.projectionMatrix.elements[5]),re.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(u===null&&d===null))return o},this.setFoveation=function(re){o=re,u!==null&&(u.fixedFoveation=re),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=re)},this.hasDepthSensing=function(){return f.texture!==null};let ce=null;function de(re,se){if(h=se.getViewerPose(l||s),p=se,h!==null){let he=h.views;d!==null&&(e.setRenderTargetFramebuffer(v,d.framebuffer),e.setRenderTarget(v));let _e=!1;he.length!==L.cameras.length&&(L.cameras.length=0,_e=!0);for(let fe=0;fe<he.length;fe++){let Re=he[fe],Pe=null;if(d!==null)Pe=d.getViewport(Re);else{let We=c.getViewSubImage(u,Re);Pe=We.viewport,fe===0&&(e.setRenderTargetTextures(v,We.colorTexture,u.ignoreDepthValues?void 0:We.depthStencilTexture),e.setRenderTarget(v))}let te=P[fe];te===void 0&&(te=new va,te.layers.enable(fe),te.viewport=new Nt,P[fe]=te),te.matrix.fromArray(Re.transform.matrix),te.matrix.decompose(te.position,te.quaternion,te.scale),te.projectionMatrix.fromArray(Re.projectionMatrix),te.projectionMatrixInverse.copy(te.projectionMatrix).invert(),te.viewport.set(Pe.x,Pe.y,Pe.width,Pe.height),fe===0&&(L.matrix.copy(te.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),_e===!0&&L.cameras.push(te)}let Ee=r.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")){let fe=c.getDepthInformation(he[0]);fe&&fe.isValid&&fe.texture&&f.init(e,fe,r.renderState)}}for(let he=0;he<x.length;he++){let _e=b[he],Ee=x[he];_e!==null&&Ee!==void 0&&Ee.update(_e,se,l||s)}f.render(e,L),ce&&ce(re,se),se.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:se}),p=null}let ue=new LT;ue.setAnimationLoop(de),this.setAnimationLoop=function(re){ce=re},this.dispose=function(){}}},Wl=new Qi,v5=new je;function y5(e,t){function i(g,v){g.matrixAutoUpdate===!0&&g.updateMatrix(),v.value.copy(g.matrix)}function r(g,v){v.color.getRGB(g.fogColor.value,OT(e)),v.isFog?(g.fogNear.value=v.near,g.fogFar.value=v.far):v.isFogExp2&&(g.fogDensity.value=v.density)}function a(g,v,x,b,_){v.isMeshBasicMaterial||v.isMeshLambertMaterial?s(g,v):v.isMeshToonMaterial?(s(g,v),u(g,v)):v.isMeshPhongMaterial?(s(g,v),c(g,v)):v.isMeshStandardMaterial?(s(g,v),d(g,v),v.isMeshPhysicalMaterial&&p(g,v,_)):v.isMeshMatcapMaterial?(s(g,v),f(g,v)):v.isMeshDepthMaterial?s(g,v):v.isMeshDistanceMaterial?(s(g,v),m(g,v)):v.isMeshNormalMaterial?s(g,v):v.isLineBasicMaterial?(n(g,v),v.isLineDashedMaterial&&o(g,v)):v.isPointsMaterial?l(g,v,x,b):v.isSpriteMaterial?h(g,v):v.isShadowMaterial?(g.color.value.copy(v.color),g.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(g,v){g.opacity.value=v.opacity,v.color&&g.diffuse.value.copy(v.color),v.emissive&&g.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(g.map.value=v.map,i(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,i(v.alphaMap,g.alphaMapTransform)),v.bumpMap&&(g.bumpMap.value=v.bumpMap,i(v.bumpMap,g.bumpMapTransform),g.bumpScale.value=v.bumpScale,v.side===Fr&&(g.bumpScale.value*=-1)),v.normalMap&&(g.normalMap.value=v.normalMap,i(v.normalMap,g.normalMapTransform),g.normalScale.value.copy(v.normalScale),v.side===Fr&&g.normalScale.value.negate()),v.displacementMap&&(g.displacementMap.value=v.displacementMap,i(v.displacementMap,g.displacementMapTransform),g.displacementScale.value=v.displacementScale,g.displacementBias.value=v.displacementBias),v.emissiveMap&&(g.emissiveMap.value=v.emissiveMap,i(v.emissiveMap,g.emissiveMapTransform)),v.specularMap&&(g.specularMap.value=v.specularMap,i(v.specularMap,g.specularMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest);let x=t.get(v),b=x.envMap,_=x.envMapRotation;if(b&&(g.envMap.value=b,Wl.copy(_),Wl.x*=-1,Wl.y*=-1,Wl.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Wl.y*=-1,Wl.z*=-1),g.envMapRotation.value.setFromMatrix4(v5.makeRotationFromEuler(Wl)),g.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=v.reflectivity,g.ior.value=v.ior,g.refractionRatio.value=v.refractionRatio),v.lightMap){g.lightMap.value=v.lightMap;let M=e._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=v.lightMapIntensity*M,i(v.lightMap,g.lightMapTransform)}v.aoMap&&(g.aoMap.value=v.aoMap,g.aoMapIntensity.value=v.aoMapIntensity,i(v.aoMap,g.aoMapTransform))}function n(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,v.map&&(g.map.value=v.map,i(v.map,g.mapTransform))}function o(g,v){g.dashSize.value=v.dashSize,g.totalSize.value=v.dashSize+v.gapSize,g.scale.value=v.scale}function l(g,v,x,b){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.size.value=v.size*x,g.scale.value=b*.5,v.map&&(g.map.value=v.map,i(v.map,g.uvTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,i(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function h(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.rotation.value=v.rotation,v.map&&(g.map.value=v.map,i(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,i(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function c(g,v){g.specular.value.copy(v.specular),g.shininess.value=Math.max(v.shininess,1e-4)}function u(g,v){v.gradientMap&&(g.gradientMap.value=v.gradientMap)}function d(g,v){g.metalness.value=v.metalness,v.metalnessMap&&(g.metalnessMap.value=v.metalnessMap,i(v.metalnessMap,g.metalnessMapTransform)),g.roughness.value=v.roughness,v.roughnessMap&&(g.roughnessMap.value=v.roughnessMap,i(v.roughnessMap,g.roughnessMapTransform)),t.get(v).envMap&&(g.envMapIntensity.value=v.envMapIntensity)}function p(g,v,x){g.ior.value=v.ior,v.sheen>0&&(g.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),g.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(g.sheenColorMap.value=v.sheenColorMap,i(v.sheenColorMap,g.sheenColorMapTransform)),v.sheenRoughnessMap&&(g.sheenRoughnessMap.value=v.sheenRoughnessMap,i(v.sheenRoughnessMap,g.sheenRoughnessMapTransform))),v.clearcoat>0&&(g.clearcoat.value=v.clearcoat,g.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(g.clearcoatMap.value=v.clearcoatMap,i(v.clearcoatMap,g.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,i(v.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(g.clearcoatNormalMap.value=v.clearcoatNormalMap,i(v.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Fr&&g.clearcoatNormalScale.value.negate())),v.iridescence>0&&(g.iridescence.value=v.iridescence,g.iridescenceIOR.value=v.iridescenceIOR,g.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(g.iridescenceMap.value=v.iridescenceMap,i(v.iridescenceMap,g.iridescenceMapTransform)),v.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=v.iridescenceThicknessMap,i(v.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),v.transmission>0&&(g.transmission.value=v.transmission,g.transmissionSamplerMap.value=x.texture,g.transmissionSamplerSize.value.set(x.width,x.height),v.transmissionMap&&(g.transmissionMap.value=v.transmissionMap,i(v.transmissionMap,g.transmissionMapTransform)),g.thickness.value=v.thickness,v.thicknessMap&&(g.thicknessMap.value=v.thicknessMap,i(v.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=v.attenuationDistance,g.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(g.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(g.anisotropyMap.value=v.anisotropyMap,i(v.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=v.specularIntensity,g.specularColor.value.copy(v.specularColor),v.specularColorMap&&(g.specularColorMap.value=v.specularColorMap,i(v.specularColorMap,g.specularColorMapTransform)),v.specularIntensityMap&&(g.specularIntensityMap.value=v.specularIntensityMap,i(v.specularIntensityMap,g.specularIntensityMapTransform))}function f(g,v){v.matcap&&(g.matcap.value=v.matcap)}function m(g,v){let x=t.get(v).light;g.referencePosition.value.setFromMatrixPosition(x.matrixWorld),g.nearDistance.value=x.shadow.camera.near,g.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:a}}function x5(e,t,i,r){let a={},s={},n=[],o=i.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(x,b){let _=b.program;r.uniformBlockBinding(x,_)}function h(x,b){let _=a[x.id];_===void 0&&(f(x),_=c(x),a[x.id]=_,x.addEventListener("dispose",g));let M=b.program;r.updateUBOMapping(x,M);let A=t.render.frame;s[x.id]!==A&&(d(x),s[x.id]=A)}function c(x){let b=u();x.__bindingPointIndex=b;let _=e.createBuffer(),M=x.__size,A=x.usage;return e.bindBuffer(e.UNIFORM_BUFFER,_),e.bufferData(e.UNIFORM_BUFFER,M,A),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,b,_),_}function u(){for(let x=0;x<o;x++)if(n.indexOf(x)===-1)return n.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){let b=a[x.id],_=x.uniforms,M=x.__cache;e.bindBuffer(e.UNIFORM_BUFFER,b);for(let A=0,S=_.length;A<S;A++){let P=Array.isArray(_[A])?_[A]:[_[A]];for(let L=0,E=P.length;L<E;L++){let T=P[L];if(p(T,A,L,M)===!0){let B=T.__offset,V=Array.isArray(T.value)?T.value:[T.value],I=0;for(let H=0;H<V.length;H++){let q=V[H],X=m(q);typeof q=="number"||typeof q=="boolean"?(T.__data[0]=q,e.bufferSubData(e.UNIFORM_BUFFER,B+I,T.__data)):q.isMatrix3?(T.__data[0]=q.elements[0],T.__data[1]=q.elements[1],T.__data[2]=q.elements[2],T.__data[3]=0,T.__data[4]=q.elements[3],T.__data[5]=q.elements[4],T.__data[6]=q.elements[5],T.__data[7]=0,T.__data[8]=q.elements[6],T.__data[9]=q.elements[7],T.__data[10]=q.elements[8],T.__data[11]=0):(q.toArray(T.__data,I),I+=X.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,B,T.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}function p(x,b,_,M){let A=x.value,S=b+"_"+_;if(M[S]===void 0)return typeof A=="number"||typeof A=="boolean"?M[S]=A:M[S]=A.clone(),!0;{let P=M[S];if(typeof A=="number"||typeof A=="boolean"){if(P!==A)return M[S]=A,!0}else if(P.equals(A)===!1)return P.copy(A),!0}return!1}function f(x){let b=x.uniforms,_=0,M=16;for(let S=0,P=b.length;S<P;S++){let L=Array.isArray(b[S])?b[S]:[b[S]];for(let E=0,T=L.length;E<T;E++){let B=L[E],V=Array.isArray(B.value)?B.value:[B.value];for(let I=0,H=V.length;I<H;I++){let q=V[I],X=m(q),Y=_%M;Y!==0&&M-Y<X.boundary&&(_+=M-Y),B.__data=new Float32Array(X.storage/Float32Array.BYTES_PER_ELEMENT),B.__offset=_,_+=X.storage}}}let A=_%M;return A>0&&(_+=M-A),x.__size=_,x.__cache={},this}function m(x){let b={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(b.boundary=4,b.storage=4):x.isVector2?(b.boundary=8,b.storage=8):x.isVector3||x.isColor?(b.boundary=16,b.storage=12):x.isVector4?(b.boundary=16,b.storage=16):x.isMatrix3?(b.boundary=48,b.storage=48):x.isMatrix4?(b.boundary=64,b.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),b}function g(x){let b=x.target;b.removeEventListener("dispose",g);let _=n.indexOf(b.__bindingPointIndex);n.splice(_,1),e.deleteBuffer(a[b.id]),delete a[b.id],delete s[b.id]}function v(){for(let x in a)e.deleteBuffer(a[x]);n=[],a={},s={}}return{bind:l,update:h,dispose:v}}var kT=class{constructor(e={}){let{canvas:t=oU(),context:i=null,depth:r=!0,stencil:a=!0,alpha:s=!1,antialias:n=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:c=!1}=e;this.isWebGLRenderer=!0;let u;i!==null?u=i.getContextAttributes().alpha:u=s;let d=new Uint32Array(4),p=new Int32Array(4),f=null,m=null,g=[],v=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=wi,this._useLegacyLights=!1,this.toneMapping=bl,this.toneMappingExposure=1;let x=this,b=!1,_=0,M=0,A=null,S=-1,P=null,L=new Nt,E=new Nt,T=null,B=new _t(0),V=0,I=t.width,H=t.height,q=1,X=null,Y=null,ie=new Nt(0,0,I,H),ce=new Nt(0,0,I,H),de=!1,ue=new rb,re=!1,se=!1,he=null,_e=new je,Ee=new ae,fe=new O,Re={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Pe(){return A===null?q:1}let te=i;function We(Q,xe){for(let Ce=0;Ce<Q.length;Ce++){let De=Q[Ce],Ae=t.getContext(De,xe);if(Ae!==null)return Ae}return null}try{let Q={alpha:!0,depth:r,stencil:a,antialias:n,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:c};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Su}`),t.addEventListener("webglcontextlost",gi,!1),t.addEventListener("webglcontextrestored",Jt,!1),t.addEventListener("webglcontextcreationerror",pe,!1),te===null){let xe=["webgl2","webgl","experimental-webgl"];if(x.isWebGL1Renderer===!0&&xe.shift(),te=We(xe,Q),te===null)throw We(xe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&te instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),te.getShaderPrecisionFormat===void 0&&(te.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Q){throw console.error("THREE.WebGLRenderer: "+Q.message),Q}let Be,Ue,Ge,tt,Fe,He,nt,ht,Z,j,ye,Me,Je,z,qe,ct,ze,at,Qe,Ze,Zt,Ot,Pt,At;function bt(){Be=new Mz(te),Ue=new bz(te,Be,e),Be.init(Ue),Ot=new c5(te,Be,Ue),Ge=new l5(te,Be,Ue),tt=new Pz(te),Fe=new Qk,He=new h5(te,Be,Ge,Fe,Ue,Ot,tt),nt=new _z(x),ht=new Ez(x),Z=new BU(te,Ue),Pt=new yz(te,Be,Z,Ue),j=new Cz(te,Z,tt,Pt),ye=new Lz(te,j,Z,tt),Qe=new Oz(te,Ue,He),ct=new wz(Fe),Me=new Yk(x,nt,ht,Be,Ue,Pt,ct),Je=new y5(x,Fe),z=new Zk,qe=new r5(Be,Ue),at=new vz(x,nt,ht,Ge,ye,u,o),ze=new o5(x,ye,Ue),At=new x5(te,tt,Ue,Ge),Ze=new xz(te,Be,tt,Ue),Zt=new Tz(te,Be,tt,Ue),tt.programs=Me.programs,x.capabilities=Ue,x.extensions=Be,x.properties=Fe,x.renderLists=z,x.shadowMap=ze,x.state=Ge,x.info=tt}bt();let mt=new g5(x,te);this.xr=mt,this.getContext=function(){return te},this.getContextAttributes=function(){return te.getContextAttributes()},this.forceContextLoss=function(){let Q=Be.get("WEBGL_lose_context");Q&&Q.loseContext()},this.forceContextRestore=function(){let Q=Be.get("WEBGL_lose_context");Q&&Q.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(Q){Q!==void 0&&(q=Q,this.setSize(I,H,!1))},this.getSize=function(Q){return Q.set(I,H)},this.setSize=function(Q,xe,Ce=!0){if(mt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}I=Q,H=xe,t.width=Math.floor(Q*q),t.height=Math.floor(xe*q),Ce===!0&&(t.style.width=Q+"px",t.style.height=xe+"px"),this.setViewport(0,0,Q,xe)},this.getDrawingBufferSize=function(Q){return Q.set(I*q,H*q).floor()},this.setDrawingBufferSize=function(Q,xe,Ce){I=Q,H=xe,q=Ce,t.width=Math.floor(Q*Ce),t.height=Math.floor(xe*Ce),this.setViewport(0,0,Q,xe)},this.getCurrentViewport=function(Q){return Q.copy(L)},this.getViewport=function(Q){return Q.copy(ie)},this.setViewport=function(Q,xe,Ce,De){Q.isVector4?ie.set(Q.x,Q.y,Q.z,Q.w):ie.set(Q,xe,Ce,De),Ge.viewport(L.copy(ie).multiplyScalar(q).round())},this.getScissor=function(Q){return Q.copy(ce)},this.setScissor=function(Q,xe,Ce,De){Q.isVector4?ce.set(Q.x,Q.y,Q.z,Q.w):ce.set(Q,xe,Ce,De),Ge.scissor(E.copy(ce).multiplyScalar(q).round())},this.getScissorTest=function(){return de},this.setScissorTest=function(Q){Ge.setScissorTest(de=Q)},this.setOpaqueSort=function(Q){X=Q},this.setTransparentSort=function(Q){Y=Q},this.getClearColor=function(Q){return Q.copy(at.getClearColor())},this.setClearColor=function(){at.setClearColor.apply(at,arguments)},this.getClearAlpha=function(){return at.getClearAlpha()},this.setClearAlpha=function(){at.setClearAlpha.apply(at,arguments)},this.clear=function(Q=!0,xe=!0,Ce=!0){let De=0;if(Q){let Ae=!1;if(A!==null){let it=A.texture.format;Ae=it===Kx||it===xT||it===yT}if(Ae){let it=A.texture.type,Mt=it===la||it===En||it===Qx||it===wl||it===mT||it===gT,yt=at.getClearColor(),Et=at.getClearAlpha(),$t=yt.r,wt=yt.g,jt=yt.b;Mt?(d[0]=$t,d[1]=wt,d[2]=jt,d[3]=Et,te.clearBufferuiv(te.COLOR,0,d)):(p[0]=$t,p[1]=wt,p[2]=jt,p[3]=Et,te.clearBufferiv(te.COLOR,0,p))}else De|=te.COLOR_BUFFER_BIT}xe&&(De|=te.DEPTH_BUFFER_BIT),Ce&&(De|=te.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),te.clear(De)},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",gi,!1),t.removeEventListener("webglcontextrestored",Jt,!1),t.removeEventListener("webglcontextcreationerror",pe,!1),z.dispose(),qe.dispose(),Fe.dispose(),nt.dispose(),ht.dispose(),ye.dispose(),Pt.dispose(),At.dispose(),Me.dispose(),mt.dispose(),mt.removeEventListener("sessionstart",Zi),mt.removeEventListener("sessionend",_r),he&&(he.dispose(),he=null),oi.stop()};function gi(Q){Q.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function Jt(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;let Q=tt.autoReset,xe=ze.enabled,Ce=ze.autoUpdate,De=ze.needsUpdate,Ae=ze.type;bt(),tt.autoReset=Q,ze.enabled=xe,ze.autoUpdate=Ce,ze.needsUpdate=De,ze.type=Ae}function pe(Q){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Q.statusMessage)}function et(Q){let xe=Q.target;xe.removeEventListener("dispose",et),Se(xe)}function Se(Q){Ke(Q),Fe.remove(Q)}function Ke(Q){let xe=Fe.get(Q).programs;xe!==void 0&&(xe.forEach(function(Ce){Me.releaseProgram(Ce)}),Q.isShaderMaterial&&Me.releaseShaderCache(Q))}this.renderBufferDirect=function(Q,xe,Ce,De,Ae,it){xe===null&&(xe=Re);let Mt=Ae.isMesh&&Ae.matrixWorld.determinant()<0,yt=qu(Q,xe,Ce,De,Ae);Ge.setMaterial(De,Mt);let Et=Ce.index,$t=1;if(De.wireframe===!0){if(Et=j.getWireframeAttribute(Ce),Et===void 0)return;$t=2}let wt=Ce.drawRange,jt=Ce.attributes.position,Gi=wt.start*$t,Xi=(wt.start+wt.count)*$t;it!==null&&(Gi=Math.max(Gi,it.start*$t),Xi=Math.min(Xi,(it.start+it.count)*$t)),Et!==null?(Gi=Math.max(Gi,0),Xi=Math.min(Xi,Et.count)):jt!=null&&(Gi=Math.max(Gi,0),Xi=Math.min(Xi,jt.count));let Ft=Xi-Gi;if(Ft<0||Ft===1/0)return;Pt.setup(Ae,De,yt,Ce,Et);let Yi,Ni=Ze;if(Et!==null&&(Yi=Z.get(Et),Ni=Zt,Ni.setIndex(Yi)),Ae.isMesh)De.wireframe===!0?(Ge.setLineWidth(De.wireframeLinewidth*Pe()),Ni.setMode(te.LINES)):Ni.setMode(te.TRIANGLES);else if(Ae.isLine){let Qt=De.linewidth;Qt===void 0&&(Qt=1),Ge.setLineWidth(Qt*Pe()),Ae.isLineSegments?Ni.setMode(te.LINES):Ae.isLineLoop?Ni.setMode(te.LINE_LOOP):Ni.setMode(te.LINE_STRIP)}else Ae.isPoints?Ni.setMode(te.POINTS):Ae.isSprite&&Ni.setMode(te.TRIANGLES);if(Ae.isBatchedMesh)Ni.renderMultiDraw(Ae._multiDrawStarts,Ae._multiDrawCounts,Ae._multiDrawCount);else if(Ae.isInstancedMesh)Ni.renderInstances(Gi,Ft,Ae.count);else if(Ce.isInstancedBufferGeometry){let Qt=Ce._maxInstanceCount!==void 0?Ce._maxInstanceCount:1/0,Bo=Math.min(Ce.instanceCount,Qt);Ni.renderInstances(Gi,Ft,Bo)}else Ni.render(Gi,Ft)};function rt(Q,xe,Ce){Q.transparent===!0&&Q.side===Oa&&Q.forceSinglePass===!1?(Q.side=Fr,Q.needsUpdate=!0,Vn(Q,xe,Ce),Q.side=Qs,Q.needsUpdate=!0,Vn(Q,xe,Ce),Q.side=Oa):Vn(Q,xe,Ce)}this.compile=function(Q,xe,Ce=null){Ce===null&&(Ce=Q),m=qe.get(Ce),m.init(),v.push(m),Ce.traverseVisible(function(Ae){Ae.isLight&&Ae.layers.test(xe.layers)&&(m.pushLight(Ae),Ae.castShadow&&m.pushShadow(Ae))}),Q!==Ce&&Q.traverseVisible(function(Ae){Ae.isLight&&Ae.layers.test(xe.layers)&&(m.pushLight(Ae),Ae.castShadow&&m.pushShadow(Ae))}),m.setupLights(x._useLegacyLights);let De=new Set;return Q.traverse(function(Ae){let it=Ae.material;if(it)if(Array.isArray(it))for(let Mt=0;Mt<it.length;Mt++){let yt=it[Mt];rt(yt,Ce,Ae),De.add(yt)}else rt(it,Ce,Ae),De.add(it)}),v.pop(),m=null,De},this.compileAsync=function(Q,xe,Ce=null){let De=this.compile(Q,xe,Ce);return new Promise(Ae=>{function it(){if(De.forEach(function(Mt){Fe.get(Mt).currentProgram.isReady()&&De.delete(Mt)}),De.size===0){Ae(Q);return}setTimeout(it,10)}Be.get("KHR_parallel_shader_compile")!==null?it():setTimeout(it,10)})};let ni=null;function hi(Q){ni&&ni(Q)}function Zi(){oi.stop()}function _r(){oi.start()}let oi=new LT;oi.setAnimationLoop(hi),typeof self<"u"&&oi.setContext(self),this.setAnimationLoop=function(Q){ni=Q,mt.setAnimationLoop(Q),Q===null?oi.stop():oi.start()},mt.addEventListener("sessionstart",Zi),mt.addEventListener("sessionend",_r),this.render=function(Q,xe){if(xe!==void 0&&xe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;Q.matrixWorldAutoUpdate===!0&&Q.updateMatrixWorld(),xe.parent===null&&xe.matrixWorldAutoUpdate===!0&&xe.updateMatrixWorld(),mt.enabled===!0&&mt.isPresenting===!0&&(mt.cameraAutoUpdate===!0&&mt.updateCamera(xe),xe=mt.getCamera()),Q.isScene===!0&&Q.onBeforeRender(x,Q,xe,A),m=qe.get(Q,v.length),m.init(),v.push(m),_e.multiplyMatrices(xe.projectionMatrix,xe.matrixWorldInverse),ue.setFromProjectionMatrix(_e),se=this.localClippingEnabled,re=ct.init(this.clippingPlanes,se),f=z.get(Q,g.length),f.init(),g.push(f),da(Q,xe,0,x.sortObjects),f.finish(),x.sortObjects===!0&&f.sort(X,Y),this.info.render.frame++,re===!0&&ct.beginShadows();let Ce=m.state.shadowsArray;if(ze.render(Ce,Q,xe),re===!0&&ct.endShadows(),this.info.autoReset===!0&&this.info.reset(),(mt.enabled===!1||mt.isPresenting===!1||mt.hasDepthSensing()===!1)&&at.render(f,Q),m.setupLights(x._useLegacyLights),xe.isArrayCamera){let De=xe.cameras;for(let Ae=0,it=De.length;Ae<it;Ae++){let Mt=De[Ae];Va(f,Q,Mt,Mt.viewport)}}else Va(f,Q,xe);A!==null&&(He.updateMultisampleRenderTarget(A),He.updateRenderTargetMipmap(A)),Q.isScene===!0&&Q.onAfterRender(x,Q,xe),Pt.resetDefaultState(),S=-1,P=null,v.pop(),v.length>0?m=v[v.length-1]:m=null,g.pop(),g.length>0?f=g[g.length-1]:f=null};function da(Q,xe,Ce,De){if(Q.visible===!1)return;if(Q.layers.test(xe.layers)){if(Q.isGroup)Ce=Q.renderOrder;else if(Q.isLOD)Q.autoUpdate===!0&&Q.update(xe);else if(Q.isLight)m.pushLight(Q),Q.castShadow&&m.pushShadow(Q);else if(Q.isSprite){if(!Q.frustumCulled||ue.intersectsSprite(Q)){De&&fe.setFromMatrixPosition(Q.matrixWorld).applyMatrix4(_e);let it=ye.update(Q),Mt=Q.material;Mt.visible&&f.push(Q,it,Mt,Ce,fe.z,null)}}else if((Q.isMesh||Q.isLine||Q.isPoints)&&(!Q.frustumCulled||ue.intersectsObject(Q))){let it=ye.update(Q),Mt=Q.material;if(De&&(Q.boundingSphere!==void 0?(Q.boundingSphere===null&&Q.computeBoundingSphere(),fe.copy(Q.boundingSphere.center)):(it.boundingSphere===null&&it.computeBoundingSphere(),fe.copy(it.boundingSphere.center)),fe.applyMatrix4(Q.matrixWorld).applyMatrix4(_e)),Array.isArray(Mt)){let yt=it.groups;for(let Et=0,$t=yt.length;Et<$t;Et++){let wt=yt[Et],jt=Mt[wt.materialIndex];jt&&jt.visible&&f.push(Q,it,jt,Ce,fe.z,wt)}}else Mt.visible&&f.push(Q,it,Mt,Ce,fe.z,null)}}let Ae=Q.children;for(let it=0,Mt=Ae.length;it<Mt;it++)da(Ae[it],xe,Ce,De)}function Va(Q,xe,Ce,De){let Ae=Q.opaque,it=Q.transmissive,Mt=Q.transparent;m.setupLightsView(Ce),re===!0&&ct.setGlobalState(x.clippingPlanes,Ce),it.length>0&&Il(Ae,it,xe,Ce),De&&Ge.viewport(L.copy(De)),Ae.length>0&&kn(Ae,xe,Ce),it.length>0&&kn(it,xe,Ce),Mt.length>0&&kn(Mt,xe,Ce),Ge.buffers.depth.setTest(!0),Ge.buffers.depth.setMask(!0),Ge.buffers.color.setMask(!0),Ge.setPolygonOffset(!1)}function Il(Q,xe,Ce,De){if((Ce.isScene===!0?Ce.overrideMaterial:null)!==null)return;let Ae=Ue.isWebGL2;he===null&&(he=new _i(1,1,{generateMipmaps:!0,type:Be.has("EXT_color_buffer_half_float")?_h:la,minFilter:cl,samples:Ae?4:0})),x.getDrawingBufferSize(Ee),Ae?he.setSize(Ee.x,Ee.y):he.setSize(Km(Ee.x),Km(Ee.y));let it=x.getRenderTarget();x.setRenderTarget(he),x.getClearColor(B),V=x.getClearAlpha(),V<1&&x.setClearColor(16777215,.5),x.clear();let Mt=x.toneMapping;x.toneMapping=bl,kn(Q,Ce,De),He.updateMultisampleRenderTarget(he),He.updateRenderTargetMipmap(he);let yt=!1;for(let Et=0,$t=xe.length;Et<$t;Et++){let wt=xe[Et],jt=wt.object,Gi=wt.geometry,Xi=wt.material,Ft=wt.group;if(Xi.side===Oa&&jt.layers.test(De.layers)){let Yi=Xi.side;Xi.side=Fr,Xi.needsUpdate=!0,Vh(jt,Ce,De,Gi,Xi,Ft),Xi.side=Yi,Xi.needsUpdate=!0,yt=!0}}yt===!0&&(He.updateMultisampleRenderTarget(he),He.updateRenderTargetMipmap(he)),x.setRenderTarget(it),x.setClearColor(B,V),x.toneMapping=Mt}function kn(Q,xe,Ce){let De=xe.isScene===!0?xe.overrideMaterial:null;for(let Ae=0,it=Q.length;Ae<it;Ae++){let Mt=Q[Ae],yt=Mt.object,Et=Mt.geometry,$t=De===null?Mt.material:De,wt=Mt.group;yt.layers.test(Ce.layers)&&Vh(yt,xe,Ce,Et,$t,wt)}}function Vh(Q,xe,Ce,De,Ae,it){Q.onBeforeRender(x,xe,Ce,De,Ae,it),Q.modelViewMatrix.multiplyMatrices(Ce.matrixWorldInverse,Q.matrixWorld),Q.normalMatrix.getNormalMatrix(Q.modelViewMatrix),Ae.onBeforeRender(x,xe,Ce,De,Q,it),Ae.transparent===!0&&Ae.side===Oa&&Ae.forceSinglePass===!1?(Ae.side=Fr,Ae.needsUpdate=!0,x.renderBufferDirect(Ce,xe,De,Ae,Q,it),Ae.side=Qs,Ae.needsUpdate=!0,x.renderBufferDirect(Ce,xe,De,Ae,Q,it),Ae.side=Oa):x.renderBufferDirect(Ce,xe,De,Ae,Q,it),Q.onAfterRender(x,xe,Ce,De,Ae,it)}function Vn(Q,xe,Ce){xe.isScene!==!0&&(xe=Re);let De=Fe.get(Q),Ae=m.state.lights,it=m.state.shadowsArray,Mt=Ae.state.version,yt=Me.getParameters(Q,Ae.state,it,xe,Ce),Et=Me.getProgramCacheKey(yt),$t=De.programs;De.environment=Q.isMeshStandardMaterial?xe.environment:null,De.fog=xe.fog,De.envMap=(Q.isMeshStandardMaterial?ht:nt).get(Q.envMap||De.environment),De.envMapRotation=De.environment!==null&&Q.envMap===null?xe.environmentRotation:Q.envMapRotation,$t===void 0&&(Q.addEventListener("dispose",et),$t=new Map,De.programs=$t);let wt=$t.get(Et);if(wt!==void 0){if(De.currentProgram===wt&&De.lightsStateVersion===Mt)return Bl(Q,yt),wt}else yt.uniforms=Me.getUniforms(Q),Q.onBuild(Ce,yt,x),Q.onBeforeCompile(yt,x),wt=Me.acquireProgram(yt,Et),$t.set(Et,wt),De.uniforms=yt.uniforms;let jt=De.uniforms;return(!Q.isShaderMaterial&&!Q.isRawShaderMaterial||Q.clipping===!0)&&(jt.clippingPlanes=ct.uniform),Bl(Q,yt),De.needsLights=jh(Q),De.lightsStateVersion=Mt,De.needsLights&&(jt.ambientLightColor.value=Ae.state.ambient,jt.lightProbe.value=Ae.state.probe,jt.directionalLights.value=Ae.state.directional,jt.directionalLightShadows.value=Ae.state.directionalShadow,jt.spotLights.value=Ae.state.spot,jt.spotLightShadows.value=Ae.state.spotShadow,jt.rectAreaLights.value=Ae.state.rectArea,jt.ltc_1.value=Ae.state.rectAreaLTC1,jt.ltc_2.value=Ae.state.rectAreaLTC2,jt.pointLights.value=Ae.state.point,jt.pointLightShadows.value=Ae.state.pointShadow,jt.hemisphereLights.value=Ae.state.hemi,jt.directionalShadowMap.value=Ae.state.directionalShadowMap,jt.directionalShadowMatrix.value=Ae.state.directionalShadowMatrix,jt.spotShadowMap.value=Ae.state.spotShadowMap,jt.spotLightMatrix.value=Ae.state.spotLightMatrix,jt.spotLightMap.value=Ae.state.spotLightMap,jt.pointShadowMap.value=Ae.state.pointShadowMap,jt.pointShadowMatrix.value=Ae.state.pointShadowMatrix),De.currentProgram=wt,De.uniformsList=null,wt}function Aa(Q){if(Q.uniformsList===null){let xe=Q.currentProgram.getUniforms();Q.uniformsList=Mm.seqWithValue(xe.seq,Q.uniforms)}return Q.uniformsList}function Bl(Q,xe){let Ce=Fe.get(Q);Ce.outputColorSpace=xe.outputColorSpace,Ce.batching=xe.batching,Ce.instancing=xe.instancing,Ce.instancingColor=xe.instancingColor,Ce.instancingMorph=xe.instancingMorph,Ce.skinning=xe.skinning,Ce.morphTargets=xe.morphTargets,Ce.morphNormals=xe.morphNormals,Ce.morphColors=xe.morphColors,Ce.morphTargetsCount=xe.morphTargetsCount,Ce.numClippingPlanes=xe.numClippingPlanes,Ce.numIntersection=xe.numClipIntersection,Ce.vertexAlphas=xe.vertexAlphas,Ce.vertexTangents=xe.vertexTangents,Ce.toneMapping=xe.toneMapping}function qu(Q,xe,Ce,De,Ae){xe.isScene!==!0&&(xe=Re),He.resetTextureUnits();let it=xe.fog,Mt=De.isMeshStandardMaterial?xe.environment:null,yt=A===null?x.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:Cs,Et=(De.isMeshStandardMaterial?ht:nt).get(De.envMap||Mt),$t=De.vertexColors===!0&&!!Ce.attributes.color&&Ce.attributes.color.itemSize===4,wt=!!Ce.attributes.tangent&&(!!De.normalMap||De.anisotropy>0),jt=!!Ce.morphAttributes.position,Gi=!!Ce.morphAttributes.normal,Xi=!!Ce.morphAttributes.color,Ft=bl;De.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(Ft=x.toneMapping);let Yi=Ce.morphAttributes.position||Ce.morphAttributes.normal||Ce.morphAttributes.color,Ni=Yi!==void 0?Yi.length:0,Qt=Fe.get(De),Bo=m.state.lights;if(re===!0&&(se===!0||Q!==P)){let G=Q===P&&De.id===S;ct.setState(De,Q,G)}let jn=!1;De.version===Qt.__version?(Qt.needsLights&&Qt.lightsStateVersion!==Bo.state.version||Qt.outputColorSpace!==yt||Ae.isBatchedMesh&&Qt.batching===!1||!Ae.isBatchedMesh&&Qt.batching===!0||Ae.isInstancedMesh&&Qt.instancing===!1||!Ae.isInstancedMesh&&Qt.instancing===!0||Ae.isSkinnedMesh&&Qt.skinning===!1||!Ae.isSkinnedMesh&&Qt.skinning===!0||Ae.isInstancedMesh&&Qt.instancingColor===!0&&Ae.instanceColor===null||Ae.isInstancedMesh&&Qt.instancingColor===!1&&Ae.instanceColor!==null||Ae.isInstancedMesh&&Qt.instancingMorph===!0&&Ae.morphTexture===null||Ae.isInstancedMesh&&Qt.instancingMorph===!1&&Ae.morphTexture!==null||Qt.envMap!==Et||De.fog===!0&&Qt.fog!==it||Qt.numClippingPlanes!==void 0&&(Qt.numClippingPlanes!==ct.numPlanes||Qt.numIntersection!==ct.numIntersection)||Qt.vertexAlphas!==$t||Qt.vertexTangents!==wt||Qt.morphTargets!==jt||Qt.morphNormals!==Gi||Qt.morphColors!==Xi||Qt.toneMapping!==Ft||Ue.isWebGL2===!0&&Qt.morphTargetsCount!==Ni)&&(jn=!0):(jn=!0,Qt.__version=De.version);let ia=Qt.currentProgram;jn===!0&&(ia=Vn(De,xe,Ae));let ii=!1,Gn=!1,tn=!1,zi=ia.getUniforms(),Dr=Qt.uniforms;if(Ge.useProgram(ia.program)&&(ii=!0,Gn=!0,tn=!0),De.id!==S&&(S=De.id,Gn=!0),ii||P!==Q){zi.setValue(te,"projectionMatrix",Q.projectionMatrix),zi.setValue(te,"viewMatrix",Q.matrixWorldInverse);let G=zi.map.cameraPosition;G!==void 0&&G.setValue(te,fe.setFromMatrixPosition(Q.matrixWorld)),Ue.logarithmicDepthBuffer&&zi.setValue(te,"logDepthBufFC",2/(Math.log(Q.far+1)/Math.LN2)),(De.isMeshPhongMaterial||De.isMeshToonMaterial||De.isMeshLambertMaterial||De.isMeshBasicMaterial||De.isMeshStandardMaterial||De.isShaderMaterial)&&zi.setValue(te,"isOrthographic",Q.isOrthographicCamera===!0),P!==Q&&(P=Q,Gn=!0,tn=!0)}if(Ae.isSkinnedMesh){zi.setOptional(te,Ae,"bindMatrix"),zi.setOptional(te,Ae,"bindMatrixInverse");let G=Ae.skeleton;G&&(Ue.floatVertexTextures?(G.boneTexture===null&&G.computeBoneTexture(),zi.setValue(te,"boneTexture",G.boneTexture,He)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Ae.isBatchedMesh&&(zi.setOptional(te,Ae,"batchingTexture"),zi.setValue(te,"batchingTexture",Ae._matricesTexture,He));let F=Ce.morphAttributes;if((F.position!==void 0||F.normal!==void 0||F.color!==void 0&&Ue.isWebGL2===!0)&&Qe.update(Ae,Ce,ia),(Gn||Qt.receiveShadow!==Ae.receiveShadow)&&(Qt.receiveShadow=Ae.receiveShadow,zi.setValue(te,"receiveShadow",Ae.receiveShadow)),De.isMeshGouraudMaterial&&De.envMap!==null&&(Dr.envMap.value=Et,Dr.flipEnvMap.value=Et.isCubeTexture&&Et.isRenderTargetTexture===!1?-1:1),Gn&&(zi.setValue(te,"toneMappingExposure",x.toneMappingExposure),Qt.needsLights&&nr(Dr,tn),it&&De.fog===!0&&Je.refreshFogUniforms(Dr,it),Je.refreshMaterialUniforms(Dr,De,q,H,he),Mm.upload(te,Aa(Qt),Dr,He)),De.isShaderMaterial&&De.uniformsNeedUpdate===!0&&(Mm.upload(te,Aa(Qt),Dr,He),De.uniformsNeedUpdate=!1),De.isSpriteMaterial&&zi.setValue(te,"center",Ae.center),zi.setValue(te,"modelViewMatrix",Ae.modelViewMatrix),zi.setValue(te,"normalMatrix",Ae.normalMatrix),zi.setValue(te,"modelMatrix",Ae.matrixWorld),Ae.previousModelViewMatrix&&zi.setValue(te,"previousModelViewMatrix",Ae.previousModelViewMatrix),Q.previousProjectionMatrix&&zi.setValue(te,"previousProjectionMatrix",Q.previousProjectionMatrix),De.isShaderMaterial||De.isRawShaderMaterial){let G=De.uniformsGroups;for(let oe=0,K=G.length;oe<K;oe++)if(Ue.isWebGL2){let ve=G[oe];At.update(ve,ia),At.bind(ve,ia)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return ia}function nr(Q,xe){Q.ambientLightColor.needsUpdate=xe,Q.lightProbe.needsUpdate=xe,Q.directionalLights.needsUpdate=xe,Q.directionalLightShadows.needsUpdate=xe,Q.pointLights.needsUpdate=xe,Q.pointLightShadows.needsUpdate=xe,Q.spotLights.needsUpdate=xe,Q.spotLightShadows.needsUpdate=xe,Q.rectAreaLights.needsUpdate=xe,Q.hemisphereLights.needsUpdate=xe}function jh(Q){return Q.isMeshLambertMaterial||Q.isMeshToonMaterial||Q.isMeshPhongMaterial||Q.isMeshStandardMaterial||Q.isShadowMaterial||Q.isShaderMaterial&&Q.lights===!0}this.getActiveCubeFace=function(){return _},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(Q,xe,Ce){Fe.get(Q.texture).__webglTexture=xe,Fe.get(Q.depthTexture).__webglTexture=Ce;let De=Fe.get(Q);De.__hasExternalTextures=!0,De.__autoAllocateDepthBuffer=Ce===void 0,De.__autoAllocateDepthBuffer||Be.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),De.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(Q,xe){let Ce=Fe.get(Q);Ce.__webglFramebuffer=xe,Ce.__useDefaultFramebuffer=xe===void 0},this.setRenderTarget=function(Q,xe=0,Ce=0){A=Q,_=xe,M=Ce;let De=!0,Ae=null,it=!1,Mt=!1;if(Q){let yt=Fe.get(Q);yt.__useDefaultFramebuffer!==void 0?(Ge.bindFramebuffer(te.FRAMEBUFFER,null),De=!1):yt.__webglFramebuffer===void 0?He.setupRenderTarget(Q):yt.__hasExternalTextures&&He.rebindTextures(Q,Fe.get(Q.texture).__webglTexture,Fe.get(Q.depthTexture).__webglTexture);let Et=Q.texture;(Et.isData3DTexture||Et.isDataArrayTexture||Et.isCompressedArrayTexture)&&(Mt=!0);let $t=Fe.get(Q).__webglFramebuffer;Q.isWebGLCubeRenderTarget?(Array.isArray($t[xe])?Ae=$t[xe][Ce]:Ae=$t[xe],it=!0):Ue.isWebGL2&&Q.samples>0&&He.useMultisampledRTT(Q)===!1?Ae=Fe.get(Q).__webglMultisampledFramebuffer:Array.isArray($t)?Ae=$t[Ce]:Ae=$t,L.copy(Q.viewport),E.copy(Q.scissor),T=Q.scissorTest}else L.copy(ie).multiplyScalar(q).floor(),E.copy(ce).multiplyScalar(q).floor(),T=de;if(Ge.bindFramebuffer(te.FRAMEBUFFER,Ae)&&Ue.drawBuffers&&De&&Ge.drawBuffers(Q,Ae),Ge.viewport(L),Ge.scissor(E),Ge.setScissorTest(T),it){let yt=Fe.get(Q.texture);te.framebufferTexture2D(te.FRAMEBUFFER,te.COLOR_ATTACHMENT0,te.TEXTURE_CUBE_MAP_POSITIVE_X+xe,yt.__webglTexture,Ce)}else if(Mt){let yt=Fe.get(Q.texture),Et=xe||0;te.framebufferTextureLayer(te.FRAMEBUFFER,te.COLOR_ATTACHMENT0,yt.__webglTexture,Ce||0,Et)}S=-1},this.readRenderTargetPixels=function(Q,xe,Ce,De,Ae,it,Mt){if(!(Q&&Q.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let yt=Fe.get(Q).__webglFramebuffer;if(Q.isWebGLCubeRenderTarget&&Mt!==void 0&&(yt=yt[Mt]),yt){Ge.bindFramebuffer(te.FRAMEBUFFER,yt);try{let Et=Q.texture,$t=Et.format,wt=Et.type;if($t!==Qr&&Ot.convert($t)!==te.getParameter(te.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let jt=wt===_h&&(Be.has("EXT_color_buffer_half_float")||Ue.isWebGL2&&Be.has("EXT_color_buffer_float"));if(wt!==la&&Ot.convert(wt)!==te.getParameter(te.IMPLEMENTATION_COLOR_READ_TYPE)&&!(wt===ir&&(Ue.isWebGL2||Be.has("OES_texture_float")||Be.has("WEBGL_color_buffer_float")))&&!jt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}xe>=0&&xe<=Q.width-De&&Ce>=0&&Ce<=Q.height-Ae&&te.readPixels(xe,Ce,De,Ae,Ot.convert($t),Ot.convert(wt),it)}finally{let Et=A!==null?Fe.get(A).__webglFramebuffer:null;Ge.bindFramebuffer(te.FRAMEBUFFER,Et)}}},this.copyFramebufferToTexture=function(Q,xe,Ce=0){let De=Math.pow(2,-Ce),Ae=Math.floor(xe.image.width*De),it=Math.floor(xe.image.height*De);He.setTexture2D(xe,0),te.copyTexSubImage2D(te.TEXTURE_2D,Ce,0,0,Q.x,Q.y,Ae,it),Ge.unbindTexture()},this.copyTextureToTexture=function(Q,xe,Ce,De=0){let Ae=xe.image.width,it=xe.image.height,Mt=Ot.convert(Ce.format),yt=Ot.convert(Ce.type);He.setTexture2D(Ce,0),te.pixelStorei(te.UNPACK_FLIP_Y_WEBGL,Ce.flipY),te.pixelStorei(te.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ce.premultiplyAlpha),te.pixelStorei(te.UNPACK_ALIGNMENT,Ce.unpackAlignment),xe.isDataTexture?te.texSubImage2D(te.TEXTURE_2D,De,Q.x,Q.y,Ae,it,Mt,yt,xe.image.data):xe.isCompressedTexture?te.compressedTexSubImage2D(te.TEXTURE_2D,De,Q.x,Q.y,xe.mipmaps[0].width,xe.mipmaps[0].height,Mt,xe.mipmaps[0].data):te.texSubImage2D(te.TEXTURE_2D,De,Q.x,Q.y,Mt,yt,xe.image),De===0&&Ce.generateMipmaps&&te.generateMipmap(te.TEXTURE_2D),Ge.unbindTexture()},this.copyTextureToTexture3D=function(Q,xe,Ce,De,Ae=0){if(x.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let it=Math.round(Q.max.x-Q.min.x),Mt=Math.round(Q.max.y-Q.min.y),yt=Q.max.z-Q.min.z+1,Et=Ot.convert(De.format),$t=Ot.convert(De.type),wt;if(De.isData3DTexture)He.setTexture3D(De,0),wt=te.TEXTURE_3D;else if(De.isDataArrayTexture||De.isCompressedArrayTexture)He.setTexture2DArray(De,0),wt=te.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}te.pixelStorei(te.UNPACK_FLIP_Y_WEBGL,De.flipY),te.pixelStorei(te.UNPACK_PREMULTIPLY_ALPHA_WEBGL,De.premultiplyAlpha),te.pixelStorei(te.UNPACK_ALIGNMENT,De.unpackAlignment);let jt=te.getParameter(te.UNPACK_ROW_LENGTH),Gi=te.getParameter(te.UNPACK_IMAGE_HEIGHT),Xi=te.getParameter(te.UNPACK_SKIP_PIXELS),Ft=te.getParameter(te.UNPACK_SKIP_ROWS),Yi=te.getParameter(te.UNPACK_SKIP_IMAGES),Ni=Ce.isCompressedTexture?Ce.mipmaps[Ae]:Ce.image;te.pixelStorei(te.UNPACK_ROW_LENGTH,Ni.width),te.pixelStorei(te.UNPACK_IMAGE_HEIGHT,Ni.height),te.pixelStorei(te.UNPACK_SKIP_PIXELS,Q.min.x),te.pixelStorei(te.UNPACK_SKIP_ROWS,Q.min.y),te.pixelStorei(te.UNPACK_SKIP_IMAGES,Q.min.z),Ce.isDataTexture||Ce.isData3DTexture?te.texSubImage3D(wt,Ae,xe.x,xe.y,xe.z,it,Mt,yt,Et,$t,Ni.data):De.isCompressedArrayTexture?te.compressedTexSubImage3D(wt,Ae,xe.x,xe.y,xe.z,it,Mt,yt,Et,Ni.data):te.texSubImage3D(wt,Ae,xe.x,xe.y,xe.z,it,Mt,yt,Et,$t,Ni),te.pixelStorei(te.UNPACK_ROW_LENGTH,jt),te.pixelStorei(te.UNPACK_IMAGE_HEIGHT,Gi),te.pixelStorei(te.UNPACK_SKIP_PIXELS,Xi),te.pixelStorei(te.UNPACK_SKIP_ROWS,Ft),te.pixelStorei(te.UNPACK_SKIP_IMAGES,Yi),Ae===0&&De.generateMipmaps&&te.generateMipmap(wt),Ge.unbindTexture()},this.initTexture=function(Q){Q.isCubeTexture?He.setTextureCube(Q,0):Q.isData3DTexture?He.setTexture3D(Q,0):Q.isDataArrayTexture||Q.isCompressedArrayTexture?He.setTexture2DArray(Q,0):He.setTexture2D(Q,0),Ge.unbindTexture()},this.resetState=function(){_=0,M=0,A=null,Ge.reset(),Pt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return bo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===$x?"display-p3":"srgb",t.unpackColorSpace=Di.workingColorSpace===Yg?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}},b5=class extends kT{};b5.prototype.isWebGL1Renderer=!0;var VT=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new _t(e),this.near=t,this.far=i}clone(){return new VT(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},So=class extends Mi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Qi,this.environmentRotation=new Qi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentRotation=this.environmentRotation.toArray(),t}},w5=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=$y,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=As()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return MT("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,a=this.stride;r<a;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=As()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=As()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ca=new O,r1=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ca.fromBufferAttribute(this,t),Ca.applyMatrix4(e),this.setXYZ(t,Ca.x,Ca.y,Ca.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ca.fromBufferAttribute(this,t),Ca.applyNormalMatrix(e),this.setXYZ(t,Ca.x,Ca.y,Ca.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ca.fromBufferAttribute(this,t),Ca.transformDirection(e),this.setXYZ(t,Ca.x,Ca.y,Ca.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Gs(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Pi(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=Pi(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Pi(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Pi(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Pi(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Gs(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Gs(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Gs(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Gs(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array),r=Pi(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,a){return e=e*this.data.stride+this.offset,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array),r=Pi(r,this.array),a=Pi(a,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=a,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[r+a])}return new Ut(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new r1(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[r+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},jT=class extends Mi{constructor(){super(),this.isBone=!0,this.type="Bone"}},is=class extends Ki{constructor(e=null,t=1,i=1,r,a,s,n,o,l=bi,h=bi,c,u){super(null,s,n,o,l,h,r,a,c,u),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},b2=new je,_5=new je,nb=class{constructor(e=[],t=[]){this.uuid=As(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new je)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new je;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let a=0,s=e.length;a<s;a++){let n=e[a]?e[a].matrixWorld:_5;b2.multiplyMatrices(n,t[a]),b2.toArray(i,a*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new nb(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new is(t,e,e,Qr,ir);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let a=e.bones[i],s=t[a];s===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",a),s=new jT),this.bones.push(s),this.boneInverses.push(new je().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,a=t.length;r<a;r++){let s=t[r];e.bones.push(s.uuid);let n=i[r];e.boneInverses.push(n.toArray())}return e}},Jd=class extends Ut{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},pc=new je,w2=new je,_f=[],_2=new sr,S5=new je,nd=new xr,od=new Sa,A5=class extends xr{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Jd(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,S5)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new sr),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,pc),_2.copy(e.boundingBox).applyMatrix4(pc),this.boundingBox.union(_2)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Sa),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,pc),od.copy(e.boundingSphere).applyMatrix4(pc),this.boundingSphere.union(od)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,a=i.length+1,s=e*a+1;for(let n=0;n<i.length;n++)i[n]=r[s+n]}raycast(e,t){let i=this.matrixWorld,r=this.count;if(nd.geometry=this.geometry,nd.material=this.material,nd.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),od.copy(this.boundingSphere),od.applyMatrix4(i),e.ray.intersectsSphere(od)!==!1))for(let a=0;a<r;a++){this.getMatrixAt(a,pc),w2.multiplyMatrices(i,pc),nd.matrixWorld=w2,nd.raycast(e,_f);for(let s=0,n=_f.length;s<n;s++){let o=_f[s];o.instanceId=a,o.object=this,t.push(o)}_f.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Jd(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new is(new Float32Array(r*this.count),r,this.count,vT,ir));let a=this.morphTexture.source.data.data,s=0;for(let l=0;l<i.length;l++)s+=i[l];let n=this.geometry.morphTargetsRelative?1:1-s,o=r*e;a[o]=n,a.set(i,o+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}},Dl=class extends bp{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new _t(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},S2=new O,A2=new O,E2=new je,A0=new Au,Sf=new Sa,Zm=class extends Mi{constructor(e=new St,t=new Dl){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,a=t.count;r<a;r++)S2.fromBufferAttribute(t,r-1),A2.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=S2.distanceTo(A2);e.setAttribute("lineDistance",new ut(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,a=e.params.Line.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Sf.copy(i.boundingSphere),Sf.applyMatrix4(r),Sf.radius+=a,e.ray.intersectsSphere(Sf)===!1)return;E2.copy(r).invert(),A0.copy(e.ray).applyMatrix4(E2);let n=a/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,l=new O,h=new O,c=new O,u=new O,d=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let m=Math.max(0,s.start),g=Math.min(p.count,s.start+s.count);for(let v=m,x=g-1;v<x;v+=d){let b=p.getX(v),_=p.getX(v+1);if(l.fromBufferAttribute(f,b),h.fromBufferAttribute(f,_),A0.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);let M=e.ray.origin.distanceTo(u);M<e.near||M>e.far||t.push({distance:M,point:c.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let m=Math.max(0,s.start),g=Math.min(f.count,s.start+s.count);for(let v=m,x=g-1;v<x;v+=d){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),A0.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);let b=e.ray.origin.distanceTo(u);b<e.near||b>e.far||t.push({distance:b,point:c.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){let s=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=r}}}}},M2=new O,C2=new O,wp=class extends Zm{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,a=t.count;r<a;r+=2)M2.fromBufferAttribute(t,r),C2.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+M2.distanceTo(C2);e.setAttribute("lineDistance",new ut(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},E5=class extends Ki{constructor(e,t,i,r,a,s,n,o,l){super(e,t,i,r,a,s,n,o,l),this.isVideoTexture=!0,this.minFilter=s!==void 0?s:Wt,this.magFilter=a!==void 0?a:Wt,this.generateMipmaps=!1;let h=this;function c(){h.needsUpdate=!0,e.requestVideoFrameCallback(c)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(c)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},M5=class extends Ki{constructor(e,t,i,r,a,s,n,o,l){super(e,t,i,r,a,s,n,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Fn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),a=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),a+=i.distanceTo(r),t.push(a),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,a=i.length,s;t?s=t:s=e*i[a-1];let n=0,o=a-1,l;for(;n<=o;)if(r=Math.floor(n+(o-n)/2),l=i[r]-s,l<0)n=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===s)return r/(a-1);let h=i[r],c=i[r+1]-h,u=(s-h)/c;return(r+u)/(a-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let a=this.getPoint(i),s=this.getPoint(r),n=t||(a.isVector2?new ae:new O);return n.copy(s).sub(a).normalize(),n}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new O,r=[],a=[],s=[],n=new O,o=new je;for(let d=0;d<=e;d++){let p=d/e;r[d]=this.getTangentAt(p,new O)}a[0]=new O,s[0]=new O;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),c=Math.abs(r[0].y),u=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),u<=l&&i.set(0,0,1),n.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],n),s[0].crossVectors(r[0],a[0]);for(let d=1;d<=e;d++){if(a[d]=a[d-1].clone(),s[d]=s[d-1].clone(),n.crossVectors(r[d-1],r[d]),n.length()>Number.EPSILON){n.normalize();let p=Math.acos(yr(r[d-1].dot(r[d]),-1,1));a[d].applyMatrix4(o.makeRotationAxis(n,p))}s[d].crossVectors(r[d],a[d])}if(t===!0){let d=Math.acos(yr(a[0].dot(a[e]),-1,1));d/=e,r[0].dot(n.crossVectors(a[0],a[e]))>0&&(d=-d);for(let p=1;p<=e;p++)a[p].applyMatrix4(o.makeRotationAxis(r[p],d*p)),s[p].crossVectors(r[p],a[p])}return{tangents:r,normals:a,binormals:s}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Kg=class extends Fn{constructor(e=0,t=0,i=1,r=1,a=0,s=Math.PI*2,n=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=a,this.aEndAngle=s,this.aClockwise=n,this.aRotation=o}getPoint(e,t=new ae){let i=t,r=Math.PI*2,a=this.aEndAngle-this.aStartAngle,s=Math.abs(a)<Number.EPSILON;for(;a<0;)a+=r;for(;a>r;)a-=r;a<Number.EPSILON&&(s?a=0:a=r),this.aClockwise===!0&&!s&&(a===r?a=-r:a=a-r);let n=this.aStartAngle+e*a,o=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);if(this.aRotation!==0){let h=Math.cos(this.aRotation),c=Math.sin(this.aRotation),u=o-this.aX,d=l-this.aY;o=u*h-d*c+this.aX,l=u*c+d*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},C5=class extends Kg{constructor(e,t,i,r,a,s){super(e,t,i,i,r,a,s),this.isArcCurve=!0,this.type="ArcCurve"}};function ob(){let e=0,t=0,i=0,r=0;function a(s,n,o,l){e=s,t=o,i=-3*s+3*n-2*o-l,r=2*s-2*n+o+l}return{initCatmullRom:function(s,n,o,l,h){a(n,o,h*(o-s),h*(l-n))},initNonuniformCatmullRom:function(s,n,o,l,h,c,u){let d=(n-s)/h-(o-s)/(h+c)+(o-n)/c,p=(o-n)/c-(l-n)/(c+u)+(l-o)/u;d*=c,p*=c,a(n,o,d,p)},calc:function(s){let n=s*s,o=n*s;return e+t*s+i*n+r*o}}}var Af=new O,E0=new ob,M0=new ob,C0=new ob,T5=class extends Fn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new O){let i=t,r=this.points,a=r.length,s=(a-(this.closed?0:1))*e,n=Math.floor(s),o=s-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/a)+1)*a:o===0&&n===a-1&&(n=a-2,o=1);let l,h;this.closed||n>0?l=r[(n-1)%a]:(Af.subVectors(r[0],r[1]).add(r[0]),l=Af);let c=r[n%a],u=r[(n+1)%a];if(this.closed||n+2<a?h=r[(n+2)%a]:(Af.subVectors(r[a-1],r[a-2]).add(r[a-1]),h=Af),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(c),d),f=Math.pow(c.distanceToSquared(u),d),m=Math.pow(u.distanceToSquared(h),d);f<1e-4&&(f=1),p<1e-4&&(p=f),m<1e-4&&(m=f),E0.initNonuniformCatmullRom(l.x,c.x,u.x,h.x,p,f,m),M0.initNonuniformCatmullRom(l.y,c.y,u.y,h.y,p,f,m),C0.initNonuniformCatmullRom(l.z,c.z,u.z,h.z,p,f,m)}else this.curveType==="catmullrom"&&(E0.initCatmullRom(l.x,c.x,u.x,h.x,this.tension),M0.initCatmullRom(l.y,c.y,u.y,h.y,this.tension),C0.initCatmullRom(l.z,c.z,u.z,h.z,this.tension));return i.set(E0.calc(o),M0.calc(o),C0.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new O().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function T2(e,t,i,r,a){let s=(r-t)*.5,n=(a-i)*.5,o=e*e,l=e*o;return(2*i-2*r+s+n)*l+(-3*i+3*r-2*s-n)*o+s*e+i}function P5(e,t){let i=1-e;return i*i*t}function D5(e,t){return 2*(1-e)*e*t}function R5(e,t){return e*e*t}function kd(e,t,i,r){return P5(e,t)+D5(e,i)+R5(e,r)}function O5(e,t){let i=1-e;return i*i*i*t}function L5(e,t){let i=1-e;return 3*i*i*e*t}function I5(e,t){return 3*(1-e)*e*e*t}function B5(e,t){return e*e*e*t}function Vd(e,t,i,r,a){return O5(e,t)+L5(e,i)+I5(e,r)+B5(e,a)}var Ws=class extends Fn{constructor(e=new ae,t=new ae,i=new ae,r=new ae){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new ae){let i=t,r=this.v0,a=this.v1,s=this.v2,n=this.v3;return i.set(Vd(e,r.x,a.x,s.x,n.x),Vd(e,r.y,a.y,s.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Cm=class extends Fn{constructor(e=new O,t=new O,i=new O,r=new O){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new O){let i=t,r=this.v0,a=this.v1,s=this.v2,n=this.v3;return i.set(Vd(e,r.x,a.x,s.x,n.x),Vd(e,r.y,a.y,s.y,n.y),Vd(e,r.z,a.z,s.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Pn=class extends Fn{constructor(e=new ae,t=new ae){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ae){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ae){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},GT=class extends Fn{constructor(e=new O,t=new O){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new O){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new O){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Ml=class extends Fn{constructor(e=new ae,t=new ae,i=new ae){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new ae){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(kd(e,r.x,a.x,s.x),kd(e,r.y,a.y,s.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},U5=class extends Fn{constructor(e=new O,t=new O,i=new O){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new O){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(kd(e,r.x,a.x,s.x),kd(e,r.y,a.y,s.y),kd(e,r.z,a.z,s.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},lb=class extends Fn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ae){let i=t,r=this.points,a=(r.length-1)*e,s=Math.floor(a),n=a-s,o=r[s===0?s:s-1],l=r[s],h=r[s>r.length-2?r.length-1:s+1],c=r[s>r.length-3?r.length-1:s+2];return i.set(T2(n,o.x,l.x,h.x,c.x),T2(n,o.y,l.y,h.y,c.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new ae().fromArray(r))}return this}},P2=Object.freeze({__proto__:null,ArcCurve:C5,CatmullRomCurve3:T5,CubicBezierCurve:Ws,CubicBezierCurve3:Cm,EllipseCurve:Kg,LineCurve:Pn,LineCurve3:GT,QuadraticBezierCurve:Ml,QuadraticBezierCurve3:U5,SplineCurve:lb}),HT=class extends Fn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new P2[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),a=0;for(;a<r.length;){if(r[a]>=i){let s=r[a]-i,n=this.curves[a],o=n.getLength(),l=o===0?0:1-s/o;return n.getPointAt(l,t)}a++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,a=this.curves;r<a.length;r++){let s=a[r],n=s.isEllipseCurve?e*2:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,o=s.getPoints(n);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new P2[r.type]().fromJSON(r))}return this}},Jm=class extends HT{constructor(e){super(),this.type="Path",this.currentPoint=new ae,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new Pn(this.currentPoint.clone(),new ae(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let a=new Ml(this.currentPoint.clone(),new ae(e,t),new ae(i,r));return this.curves.push(a),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,a,s){let n=new Ws(this.currentPoint.clone(),new ae(e,t),new ae(i,r),new ae(a,s));return this.curves.push(n),this.currentPoint.set(a,s),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new lb(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,a,s){let n=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+n,t+o,i,r,a,s),this}absarc(e,t,i,r,a,s){return this.absellipse(e,t,i,i,r,a,s),this}ellipse(e,t,i,r,a,s,n,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,a,s,n,o),this}absellipse(e,t,i,r,a,s,n,o){let l=new Kg(e,t,i,r,a,s,n,o);if(this.curves.length>0){let c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},WT=class extends St{constructor(e=[new ae(0,-.5),new ae(.5,0),new ae(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=yr(r,0,Math.PI*2);let a=[],s=[],n=[],o=[],l=[],h=1/t,c=new O,u=new ae,d=new O,p=new O,f=new O,m=0,g=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=g*1,d.y=-m,d.z=g*0,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=g*1,d.y=-m,d.z=g*0,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let v=0;v<=t;v++){let x=i+v*h*r,b=Math.sin(x),_=Math.cos(x);for(let M=0;M<=e.length-1;M++){c.x=e[M].x*b,c.y=e[M].y,c.z=e[M].x*_,s.push(c.x,c.y,c.z),u.x=v/t,u.y=M/(e.length-1),n.push(u.x,u.y);let A=o[3*M+0]*b,S=o[3*M+1],P=o[3*M+0]*_;l.push(A,S,P)}}for(let v=0;v<t;v++)for(let x=0;x<e.length-1;x++){let b=x+v*e.length,_=b,M=b+e.length,A=b+e.length+1,S=b+1;a.push(_,M,S),a.push(A,S,M)}this.setIndex(a),this.setAttribute("position",new ut(s,3)),this.setAttribute("uv",new ut(n,2)),this.setAttribute("normal",new ut(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new WT(e.points,e.segments,e.phiStart,e.phiLength)}},hb=class extends St{constructor(e=1,t=1,i=1,r=32,a=1,s=!1,n=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:a,openEnded:s,thetaStart:n,thetaLength:o};let l=this;r=Math.floor(r),a=Math.floor(a);let h=[],c=[],u=[],d=[],p=0,f=[],m=i/2,g=0;v(),s===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new ut(c,3)),this.setAttribute("normal",new ut(u,3)),this.setAttribute("uv",new ut(d,2));function v(){let b=new O,_=new O,M=0,A=(t-e)/i;for(let S=0;S<=a;S++){let P=[],L=S/a,E=L*(t-e)+e;for(let T=0;T<=r;T++){let B=T/r,V=B*o+n,I=Math.sin(V),H=Math.cos(V);_.x=E*I,_.y=-L*i+m,_.z=E*H,c.push(_.x,_.y,_.z),b.set(I,A,H).normalize(),u.push(b.x,b.y,b.z),d.push(B,1-L),P.push(p++)}f.push(P)}for(let S=0;S<r;S++)for(let P=0;P<a;P++){let L=f[P][S],E=f[P+1][S],T=f[P+1][S+1],B=f[P][S+1];h.push(L,E,B),h.push(E,T,B),M+=6}l.addGroup(g,M,0),g+=M}function x(b){let _=p,M=new ae,A=new O,S=0,P=b===!0?e:t,L=b===!0?1:-1;for(let T=1;T<=r;T++)c.push(0,m*L,0),u.push(0,L,0),d.push(.5,.5),p++;let E=p;for(let T=0;T<=r;T++){let B=T/r*o+n,V=Math.cos(B),I=Math.sin(B);A.x=P*I,A.y=m*L,A.z=P*V,c.push(A.x,A.y,A.z),u.push(0,L,0),M.x=V*.5+.5,M.y=I*.5*L+.5,d.push(M.x,M.y),p++}for(let T=0;T<r;T++){let B=_+T,V=E+T;b===!0?h.push(V,V+1,B):h.push(V+1,V,B),S+=3}l.addGroup(g,S,b===!0?1:2),g+=S}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new hb(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},cb=class extends hb{constructor(e=1,t=1,i=32,r=1,a=!1,s=0,n=Math.PI*2){super(0,e,t,i,r,a,s,n),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:n}}static fromJSON(e){return new cb(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},ub=class extends St{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let a=[],s=[];n(r),l(i),h(),this.setAttribute("position",new ut(a,3)),this.setAttribute("normal",new ut(a.slice(),3)),this.setAttribute("uv",new ut(s,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function n(v){let x=new O,b=new O,_=new O;for(let M=0;M<t.length;M+=3)d(t[M+0],x),d(t[M+1],b),d(t[M+2],_),o(x,b,_,v)}function o(v,x,b,_){let M=_+1,A=[];for(let S=0;S<=M;S++){A[S]=[];let P=v.clone().lerp(b,S/M),L=x.clone().lerp(b,S/M),E=M-S;for(let T=0;T<=E;T++)T===0&&S===M?A[S][T]=P:A[S][T]=P.clone().lerp(L,T/E)}for(let S=0;S<M;S++)for(let P=0;P<2*(M-S)-1;P++){let L=Math.floor(P/2);P%2===0?(u(A[S][L+1]),u(A[S+1][L]),u(A[S][L])):(u(A[S][L+1]),u(A[S+1][L+1]),u(A[S+1][L]))}}function l(v){let x=new O;for(let b=0;b<a.length;b+=3)x.x=a[b+0],x.y=a[b+1],x.z=a[b+2],x.normalize().multiplyScalar(v),a[b+0]=x.x,a[b+1]=x.y,a[b+2]=x.z}function h(){let v=new O;for(let x=0;x<a.length;x+=3){v.x=a[x+0],v.y=a[x+1],v.z=a[x+2];let b=m(v)/2/Math.PI+.5,_=g(v)/Math.PI+.5;s.push(b,1-_)}p(),c()}function c(){for(let v=0;v<s.length;v+=6){let x=s[v+0],b=s[v+2],_=s[v+4],M=Math.max(x,b,_),A=Math.min(x,b,_);M>.9&&A<.1&&(x<.2&&(s[v+0]+=1),b<.2&&(s[v+2]+=1),_<.2&&(s[v+4]+=1))}}function u(v){a.push(v.x,v.y,v.z)}function d(v,x){let b=v*3;x.x=e[b+0],x.y=e[b+1],x.z=e[b+2]}function p(){let v=new O,x=new O,b=new O,_=new O,M=new ae,A=new ae,S=new ae;for(let P=0,L=0;P<a.length;P+=9,L+=6){v.set(a[P+0],a[P+1],a[P+2]),x.set(a[P+3],a[P+4],a[P+5]),b.set(a[P+6],a[P+7],a[P+8]),M.set(s[L+0],s[L+1]),A.set(s[L+2],s[L+3]),S.set(s[L+4],s[L+5]),_.copy(v).add(x).add(b).divideScalar(3);let E=m(_);f(M,L+0,v,E),f(A,L+2,x,E),f(S,L+4,b,E)}}function f(v,x,b,_){_<0&&v.x===1&&(s[x]=v.x-1),b.x===0&&b.z===0&&(s[x]=_/2/Math.PI+.5)}function m(v){return Math.atan2(v.z,-v.x)}function g(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ub(e.vertices,e.indices,e.radius,e.details)}},qT=class extends ub{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],s=[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(a,s,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new qT(e.radius,e.detail)}},$m=class extends Jm{constructor(e){super(e),this.uuid=As(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Jm().fromJSON(r))}return this}},F5={triangulate:function(e,t,i=2){let r=t&&t.length,a=r?t[0]*i:e.length,s=XT(e,0,a,i,!0),n=[];if(!s||s.next===s.prev)return n;let o,l,h,c,u,d,p;if(r&&(s=j5(e,t,s,i)),e.length>80*i){o=h=e[0],l=c=e[1];for(let f=i;f<a;f+=i)u=e[f],d=e[f+1],u<o&&(o=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);p=Math.max(h-o,c-l),p=p!==0?32767/p:0}return $d(s,n,i,o,l,p,0),n}};function XT(e,t,i,r,a){let s,n;if(a===$5(e,t,i,r)>0)for(s=t;s<i;s+=r)n=D2(s,e[s],e[s+1],n);else for(s=i-r;s>=t;s-=r)n=D2(s,e[s],e[s+1],n);return n&&Zg(n,n.next)&&(tp(n),n=n.next),n}function Eh(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(Zg(i,i.next)||rr(i.prev,i,i.next)===0)){if(tp(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function $d(e,t,i,r,a,s,n){if(!e)return;!n&&s&&X5(e,r,a,s);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,s?z5(e,r,a,s):N5(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),tp(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=k5(Eh(e),t,i),$d(e,t,i,r,a,s,2)):n===2&&V5(e,t,i,r,a,s):$d(Eh(e),t,i,r,a,s,1);break}}}function N5(e){let t=e.prev,i=e,r=e.next;if(rr(t,i,r)>=0)return!1;let a=t.x,s=i.x,n=r.x,o=t.y,l=i.y,h=r.y,c=a<s?a<n?a:n:s<n?s:n,u=o<l?o<h?o:h:l<h?l:h,d=a>s?a>n?a:n:s>n?s:n,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&Gc(a,o,s,l,n,h,f.x,f.y)&&rr(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function z5(e,t,i,r){let a=e.prev,s=e,n=e.next;if(rr(a,s,n)>=0)return!1;let o=a.x,l=s.x,h=n.x,c=a.y,u=s.y,d=n.y,p=o<l?o<h?o:h:l<h?l:h,f=c<u?c<d?c:d:u<d?u:d,m=o>l?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=a1(p,f,t,i,r),x=a1(m,g,t,i,r),b=e.prevZ,_=e.nextZ;for(;b&&b.z>=v&&_&&_.z<=x;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==a&&b!==n&&Gc(o,c,l,u,h,d,b.x,b.y)&&rr(b.prev,b,b.next)>=0||(b=b.prevZ,_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==a&&_!==n&&Gc(o,c,l,u,h,d,_.x,_.y)&&rr(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;b&&b.z>=v;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==a&&b!==n&&Gc(o,c,l,u,h,d,b.x,b.y)&&rr(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==a&&_!==n&&Gc(o,c,l,u,h,d,_.x,_.y)&&rr(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function k5(e,t,i){let r=e;do{let a=r.prev,s=r.next.next;!Zg(a,s)&&YT(a,r,r.next,s)&&ep(a,s)&&ep(s,a)&&(t.push(a.i/i|0),t.push(r.i/i|0),t.push(s.i/i|0),tp(r),tp(r.next),r=e=s),r=r.next}while(r!==e);return Eh(r)}function V5(e,t,i,r,a,s){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&K5(n,o)){let l=QT(n,o);n=Eh(n,n.next),l=Eh(l,l.next),$d(n,t,i,r,a,s,0),$d(l,t,i,r,a,s,0);return}o=o.next}n=n.next}while(n!==e)}function j5(e,t,i,r){let a=[],s,n,o,l,h;for(s=0,n=t.length;s<n;s++)o=t[s]*r,l=s<n-1?t[s+1]*r:e.length,h=XT(e,o,l,r,!1),h===h.next&&(h.steiner=!0),a.push(Q5(h));for(a.sort(G5),s=0;s<a.length;s++)i=H5(a[s],i);return i}function G5(e,t){return e.x-t.x}function H5(e,t){let i=W5(e,t);if(!i)return t;let r=QT(i,e);return Eh(r,r.next),Eh(i,i.next)}function W5(e,t){let i=t,r=-1/0,a,s=e.x,n=e.y;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){let d=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(d<=s&&d>r&&(r=d,a=i.x<i.next.x?i:i.next,d===s))return a}i=i.next}while(i!==t);if(!a)return null;let o=a,l=a.x,h=a.y,c=1/0,u;i=a;do s>=i.x&&i.x>=l&&s!==i.x&&Gc(n<h?s:r,n,l,h,n<h?r:s,n,i.x,i.y)&&(u=Math.abs(n-i.y)/(s-i.x),ep(i,e)&&(u<c||u===c&&(i.x>a.x||i.x===a.x&&q5(a,i)))&&(a=i,c=u)),i=i.next;while(i!==o);return a}function q5(e,t){return rr(e.prev,e,t.prev)<0&&rr(t.next,e,e.next)<0}function X5(e,t,i,r){let a=e;do a.z===0&&(a.z=a1(a.x,a.y,t,i,r)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==e);a.prevZ.nextZ=null,a.prevZ=null,Y5(a)}function Y5(e){let t,i,r,a,s,n,o,l,h=1;do{for(i=e,e=null,s=null,n=0;i;){for(n++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(a=i,i=i.nextZ,o--):(a=r,r=r.nextZ,l--),s?s.nextZ=a:e=a,a.prevZ=s,s=a;i=r}s.nextZ=null,h*=2}while(n>1);return e}function a1(e,t,i,r,a){return e=(e-i)*a|0,t=(t-r)*a|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Q5(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function Gc(e,t,i,r,a,s,n,o){return(a-n)*(t-o)>=(e-n)*(s-o)&&(e-n)*(r-o)>=(i-n)*(t-o)&&(i-n)*(s-o)>=(a-n)*(r-o)}function K5(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Z5(e,t)&&(ep(e,t)&&ep(t,e)&&J5(e,t)&&(rr(e.prev,e,t.prev)||rr(e,t.prev,t))||Zg(e,t)&&rr(e.prev,e,e.next)>0&&rr(t.prev,t,t.next)>0)}function rr(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Zg(e,t){return e.x===t.x&&e.y===t.y}function YT(e,t,i,r){let a=Mf(rr(e,t,i)),s=Mf(rr(e,t,r)),n=Mf(rr(i,r,e)),o=Mf(rr(i,r,t));return!!(a!==s&&n!==o||a===0&&Ef(e,i,t)||s===0&&Ef(e,r,t)||n===0&&Ef(i,e,r)||o===0&&Ef(i,t,r))}function Ef(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Mf(e){return e>0?1:e<0?-1:0}function Z5(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&YT(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function ep(e,t){return rr(e.prev,e,e.next)<0?rr(e,t,e.next)>=0&&rr(e,e.prev,t)>=0:rr(e,t,e.prev)<0||rr(e,e.next,t)<0}function J5(e,t){let i=e,r=!1,a=(e.x+t.x)/2,s=(e.y+t.y)/2;do i.y>s!=i.next.y>s&&i.next.y!==i.y&&a<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function QT(e,t){let i=new s1(e.i,e.x,e.y),r=new s1(t.i,t.x,t.y),a=e.next,s=t.prev;return e.next=t,t.prev=e,i.next=a,a.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function D2(e,t,i,r){let a=new s1(e,t,i);return r?(a.next=r.next,a.prev=r,r.next.prev=a,r.next=a):(a.prev=a,a.next=a),a}function tp(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function s1(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function $5(e,t,i,r){let a=0;for(let s=t,n=i-r;s<i;s+=r)a+=(e[n]-e[s])*(e[s+1]+e[n+1]),n=s;return a}var KT=class{static area(e){let t=e.length,i=0;for(let r=t-1,a=0;a<t;r=a++)i+=e[r].x*e[a].y-e[a].x*e[r].y;return i*.5}static isClockWise(e){return KT.area(e)<0}static triangulateShape(e,t){let i=[],r=[],a=[];R2(e),O2(i,e);let s=e.length;t.forEach(R2);for(let o=0;o<t.length;o++)r.push(s),s+=t[o].length,O2(i,t[o]);let n=F5.triangulate(i,r);for(let o=0;o<n.length;o+=3)a.push(n.slice(o,o+3));return a}};function R2(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function O2(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var ZT=class extends ub{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,a,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ZT(e.radius,e.detail)}},Qc=class extends St{constructor(e=1,t=32,i=16,r=0,a=Math.PI*2,s=0,n=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:a,thetaStart:s,thetaLength:n},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(s+n,Math.PI),l=0,h=[],c=new O,u=new O,d=[],p=[],f=[],m=[];for(let g=0;g<=i;g++){let v=[],x=g/i,b=0;g===0&&s===0?b=.5/t:g===i&&o===Math.PI&&(b=-.5/t);for(let _=0;_<=t;_++){let M=_/t;c.x=-e*Math.cos(r+M*a)*Math.sin(s+x*n),c.y=e*Math.cos(s+x*n),c.z=e*Math.sin(r+M*a)*Math.sin(s+x*n),p.push(c.x,c.y,c.z),u.copy(c).normalize(),f.push(u.x,u.y,u.z),m.push(M+b,1-x),v.push(l++)}h.push(v)}for(let g=0;g<i;g++)for(let v=0;v<t;v++){let x=h[g][v+1],b=h[g][v],_=h[g+1][v],M=h[g+1][v+1];(g!==0||s>0)&&d.push(x,b,M),(g!==i-1||o<Math.PI)&&d.push(b,_,M)}this.setIndex(d),this.setAttribute("position",new ut(p,3)),this.setAttribute("normal",new ut(f,3)),this.setAttribute("uv",new ut(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qc(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},JT=class extends St{constructor(e=1,t=.4,i=12,r=48,a=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:a},i=Math.floor(i),r=Math.floor(r);let s=[],n=[],o=[],l=[],h=new O,c=new O,u=new O;for(let d=0;d<=i;d++)for(let p=0;p<=r;p++){let f=p/r*a,m=d/i*Math.PI*2;c.x=(e+t*Math.cos(m))*Math.cos(f),c.y=(e+t*Math.cos(m))*Math.sin(f),c.z=t*Math.sin(m),n.push(c.x,c.y,c.z),h.x=e*Math.cos(f),h.y=e*Math.sin(f),u.subVectors(c,h).normalize(),o.push(u.x,u.y,u.z),l.push(p/r),l.push(d/i)}for(let d=1;d<=i;d++)for(let p=1;p<=r;p++){let f=(r+1)*d+p-1,m=(r+1)*(d-1)+p-1,g=(r+1)*(d-1)+p,v=(r+1)*d+p;s.push(f,m,v),s.push(m,g,v)}this.setIndex(s),this.setAttribute("position",new ut(n,3)),this.setAttribute("normal",new ut(o,3)),this.setAttribute("uv",new ut(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new JT(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},$T=class extends St{constructor(e=1,t=.4,i=64,r=8,a=2,s=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:a,q:s},i=Math.floor(i),r=Math.floor(r);let n=[],o=[],l=[],h=[],c=new O,u=new O,d=new O,p=new O,f=new O,m=new O,g=new O;for(let x=0;x<=i;++x){let b=x/i*a*Math.PI*2;v(b,a,s,e,d),v(b+.01,a,s,e,p),m.subVectors(p,d),g.addVectors(p,d),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let _=0;_<=r;++_){let M=_/r*Math.PI*2,A=-t*Math.cos(M),S=t*Math.sin(M);c.x=d.x+(A*g.x+S*f.x),c.y=d.y+(A*g.y+S*f.y),c.z=d.z+(A*g.z+S*f.z),o.push(c.x,c.y,c.z),u.subVectors(c,d).normalize(),l.push(u.x,u.y,u.z),h.push(x/i),h.push(_/r)}}for(let x=1;x<=i;x++)for(let b=1;b<=r;b++){let _=(r+1)*(x-1)+(b-1),M=(r+1)*x+(b-1),A=(r+1)*x+b,S=(r+1)*(x-1)+b;n.push(_,M,S),n.push(M,A,S)}this.setIndex(n),this.setAttribute("position",new ut(o,3)),this.setAttribute("normal",new ut(l,3)),this.setAttribute("uv",new ut(h,2));function v(x,b,_,M,A){let S=Math.cos(x),P=Math.sin(x),L=_/b*x,E=Math.cos(L);A.x=M*(2+E)*.5*S,A.y=M*(2+E)*P*.5,A.z=M*Math.sin(L)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $T(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function Cf(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function e6(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function t6(e){function t(a,s){return e[a]-e[s]}let i=e.length,r=new Array(i);for(let a=0;a!==i;++a)r[a]=a;return r.sort(t),r}function L2(e,t,i){let r=e.length,a=new e.constructor(r);for(let s=0,n=0;n!==r;++s){let o=i[s]*t;for(let l=0;l!==t;++l)a[n++]=e[o+l]}return a}function eP(e,t,i,r){let a=1,s=e[0];for(;s!==void 0&&s[r]===void 0;)s=e[a++];if(s===void 0)return;let n=s[r];if(n!==void 0)if(Array.isArray(n))do n=s[r],n!==void 0&&(t.push(s.time),i.push.apply(i,n)),s=e[a++];while(s!==void 0);else if(n.toArray!==void 0)do n=s[r],n!==void 0&&(t.push(s.time),n.toArray(i,i.length)),s=e[a++];while(s!==void 0);else do n=s[r],n!==void 0&&(t.push(s.time),i.push(n)),s=e[a++];while(s!==void 0)}var Jg=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],a=t[i-1];e:{t:{let s;i:{r:if(!(e<r)){for(let n=i+2;;){if(r===void 0){if(e<a)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===n)break;if(a=r,r=t[++i],e<r)break t}s=t.length;break i}if(!(e>=a)){let n=t[1];e<n&&(i=2,a=n);for(let o=i-2;;){if(a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=a,a=t[--i-1],e>=a)break t}s=i,i=0;break i}break e}for(;i<s;){let n=i+s>>>1;e<t[n]?s=n:i=n+1}if(r=t[i],a=t[i-1],a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,a,r)}return this.interpolate_(i,a,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r;for(let s=0;s!==r;++s)t[s]=i[a+s];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},i6=class extends Jg{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:zc,endingEnd:zc}}intervalChanged_(e,t,i){let r=this.parameterPositions,a=e-2,s=e+1,n=r[a],o=r[s];if(n===void 0)switch(this.getSettings_().endingStart){case kc:a=e,n=2*t-i;break;case Wm:a=r.length-2,n=t+r[a]-r[a+1];break;default:a=e,n=i}if(o===void 0)switch(this.getSettings_().endingEnd){case kc:s=e,o=2*i-t;break;case Wm:s=1,o=i+r[1]-r[0];break;default:s=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-n),this._weightNext=l/(o-i),this._offsetPrev=a*h,this._offsetNext=s*h}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=this._offsetPrev,c=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-t)/(r-t),f=p*p,m=f*p,g=-u*m+2*u*f-u*p,v=(1+u)*m+(-1.5-2*u)*f+(-.5+u)*p+1,x=(-1-d)*m+(1.5+d)*f+.5*p,b=d*m-d*f;for(let _=0;_!==n;++_)a[_]=g*s[h+_]+v*s[l+_]+x*s[o+_]+b*s[c+_];return a}},tP=class extends Jg{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=(i-t)/(r-t),c=1-h;for(let u=0;u!==n;++u)a[u]=s[l+u]*c+s[o+u]*h;return a}},r6=class extends Jg{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Nn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Cf(t,this.TimeBufferType),this.values=Cf(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Cf(e.times,Array),values:Cf(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new r6(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new tP(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new i6(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Gm:t=this.InterpolantFactoryMethodDiscrete;break;case Hm:t=this.InterpolantFactoryMethodLinear;break;case Jv:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Gm;case this.InterpolantFactoryMethodLinear:return Hm;case this.InterpolantFactoryMethodSmooth:return Jv}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,a=0,s=r-1;for(;a!==r&&i[a]<e;)++a;for(;s!==-1&&i[s]>t;)--s;if(++s,a!==0||s!==r){a>=s&&(s=Math.max(s,1),a=s-1);let n=this.getValueSize();this.times=i.slice(a,s),this.values=this.values.slice(a*n,s*n)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,a=i.length;a===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let n=0;n!==a;n++){let o=i[n];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,o),e=!1;break}if(s!==null&&s>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,o,s),e=!1;break}s=o}if(r!==void 0&&e6(r))for(let n=0,o=r.length;n!==o;++n){let l=r[n];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Jv,a=e.length-1,s=1;for(let n=1;n<a;++n){let o=!1,l=e[n],h=e[n+1];if(l!==h&&(n!==1||l!==e[0]))if(r)o=!0;else{let c=n*i,u=c-i,d=c+i;for(let p=0;p!==i;++p){let f=t[c+p];if(f!==t[u+p]||f!==t[d+p]){o=!0;break}}}if(o){if(n!==s){e[s]=e[n];let c=n*i,u=s*i;for(let d=0;d!==i;++d)t[u+d]=t[c+d]}++s}}if(a>0){e[s]=e[a];for(let n=a*i,o=s*i,l=0;l!==i;++l)t[o+l]=t[n+l];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=t.slice(0,s*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Nn.prototype.TimeBufferType=Float32Array;Nn.prototype.ValueBufferType=Float32Array;Nn.prototype.DefaultInterpolation=Hm;var Cu=class extends Nn{};Cu.prototype.ValueTypeName="bool";Cu.prototype.ValueBufferType=Array;Cu.prototype.DefaultInterpolation=Gm;Cu.prototype.InterpolantFactoryMethodLinear=void 0;Cu.prototype.InterpolantFactoryMethodSmooth=void 0;var iP=class extends Nn{};iP.prototype.ValueTypeName="color";var eg=class extends Nn{};eg.prototype.ValueTypeName="number";var a6=class extends Jg{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=(i-t)/(r-t),l=e*n;for(let h=l+n;l!==h;l+=4)zt.slerpFlat(a,0,s,l-n,s,l,o);return a}},_p=class extends Nn{InterpolantFactoryMethodLinear(e){return new a6(this.times,this.values,this.getValueSize(),e)}};_p.prototype.ValueTypeName="quaternion";_p.prototype.DefaultInterpolation=Hm;_p.prototype.InterpolantFactoryMethodSmooth=void 0;var Tu=class extends Nn{};Tu.prototype.ValueTypeName="string";Tu.prototype.ValueBufferType=Array;Tu.prototype.DefaultInterpolation=Gm;Tu.prototype.InterpolantFactoryMethodLinear=void 0;Tu.prototype.InterpolantFactoryMethodSmooth=void 0;var tg=class extends Nn{};tg.prototype.ValueTypeName="vector";var n1=class{constructor(e,t=-1,i,r=Jx){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=As(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let s=0,n=i.length;s!==n;++s)t.push(n6(i[s]).scale(r));let a=new this(e.name,e.duration,t,e.blendMode);return a.uuid=e.uuid,a}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let a=0,s=i.length;a!==s;++a)t.push(Nn.toJSON(i[a]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let a=t.length,s=[];for(let n=0;n<a;n++){let o=[],l=[];o.push((n+a-1)%a,n,(n+1)%a),l.push(0,1,0);let h=t6(o);o=L2(o,1,h),l=L2(l,1,h),!r&&o[0]===0&&(o.push(a),l.push(l[0])),s.push(new eg(".morphTargetInfluences["+t[n].name+"]",o,l).scale(1/i))}return new this(e,-1,s)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},a=/^([\w-]*?)([\d]+)$/;for(let n=0,o=e.length;n<o;n++){let l=e[n],h=l.name.match(a);if(h&&h.length>1){let c=h[1],u=r[c];u||(r[c]=u=[]),u.push(l)}}let s=[];for(let n in r)s.push(this.CreateFromMorphTargetSequence(n,r[n],t,i));return s}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,c,u,d,p){if(u.length!==0){let f=[],m=[];eP(u,f,m,d),f.length!==0&&p.push(new h(c,f,m))}},r=[],a=e.name||"default",s=e.fps||30,n=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let c=l[h].keys;if(!(!c||c.length===0))if(c[0].morphTargets){let u={},d;for(d=0;d<c.length;d++)if(c[d].morphTargets)for(let p=0;p<c[d].morphTargets.length;p++)u[c[d].morphTargets[p]]=-1;for(let p in u){let f=[],m=[];for(let g=0;g!==c[d].morphTargets.length;++g){let v=c[d];f.push(v.time),m.push(v.morphTarget===p?1:0)}r.push(new eg(".morphTargetInfluence["+p+"]",f,m))}o=u.length*s}else{let u=".bones["+t[h].name+"]";i(tg,u+".position",c,"pos",r),i(_p,u+".quaternion",c,"rot",r),i(tg,u+".scale",c,"scl",r)}}return r.length===0?null:new this(a,o,r,n)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let a=this.tracks[i];t=Math.max(t,a.times[a.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function s6(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return eg;case"vector":case"vector2":case"vector3":case"vector4":return tg;case"color":return iP;case"quaternion":return _p;case"bool":case"boolean":return Cu;case"string":return Tu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function n6(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=s6(e.type);if(e.times===void 0){let i=[],r=[];eP(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var ig={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},rP=class{constructor(e,t,i){let r=this,a=!1,s=0,n=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){n++,a===!1&&r.onStart!==void 0&&r.onStart(h,s,n),a=!0},this.itemEnd=function(h){s++,r.onProgress!==void 0&&r.onProgress(h,s,n),s===n&&(a=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,c){return l.push(h,c),this},this.removeHandler=function(h){let c=l.indexOf(h);return c!==-1&&l.splice(c,2),this},this.getHandler=function(h){for(let c=0,u=l.length;c<u;c+=2){let d=l[c],p=l[c+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}},o6=new rP,Pu=class{constructor(e){this.manager=e!==void 0?e:o6,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,a){i.load(e,r,t,a)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};Pu.DEFAULT_MATERIAL_NAME="__DEFAULT";var eo={},l6=class extends Error{constructor(e,t){super(e),this.response=t}},o1=class extends Pu{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let a=ig.get(e);if(a!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(a),this.manager.itemEnd(e)},0),a;if(eo[e]!==void 0){eo[e].push({onLoad:t,onProgress:i,onError:r});return}eo[e]=[],eo[e].push({onLoad:t,onProgress:i,onError:r});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),n=this.mimeType,o=this.responseType;fetch(s).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=eo[e],c=l.body.getReader(),u=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=u?parseInt(u):0,p=d!==0,f=0,m=new ReadableStream({start(g){v();function v(){c.read().then(({done:x,value:b})=>{if(x)g.close();else{f+=b.byteLength;let _=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:d});for(let M=0,A=h.length;M<A;M++){let S=h[M];S.onProgress&&S.onProgress(_)}g.enqueue(b),v()}})}}});return new Response(m)}else throw new l6(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,n));case"json":return l.json();default:if(n===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(n),c=h&&h[1]?h[1].toLowerCase():void 0,u=new TextDecoder(c);return l.arrayBuffer().then(d=>u.decode(d))}}}).then(l=>{ig.add(e,l);let h=eo[e];delete eo[e];for(let c=0,u=h.length;c<u;c++){let d=h[c];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=eo[e];if(h===void 0)throw this.manager.itemError(e),l;delete eo[e];for(let c=0,u=h.length;c<u;c++){let d=h[c];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},h6=class extends Pu{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let a=this,s=ig.get(e);if(s!==void 0)return a.manager.itemStart(e),setTimeout(function(){t&&t(s),a.manager.itemEnd(e)},0),s;let n=Zd("img");function o(){h(),ig.add(e,this),t&&t(this),a.manager.itemEnd(e)}function l(c){h(),r&&r(c),a.manager.itemError(e),a.manager.itemEnd(e)}function h(){n.removeEventListener("load",o,!1),n.removeEventListener("error",l,!1)}return n.addEventListener("load",o,!1),n.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(n.crossOrigin=this.crossOrigin),a.manager.itemStart(e),n.src=e,n}},c6=class extends Pu{constructor(e){super(e)}load(e,t,i,r){let a=new Ki,s=new h6(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(n){a.image=n,a.needsUpdate=!0,t!==void 0&&t(a)},i,r),a}},Sp=class extends Mi{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new _t(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},u6=class extends Sp{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Mi.DEFAULT_UP),this.updateMatrix(),this.groundColor=new _t(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},T0=new je,I2=new O,B2=new O,db=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ae(512,512),this.map=null,this.mapPass=null,this.matrix=new je,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new rb,this._frameExtents=new ae(1,1),this._viewportCount=1,this._viewports=[new Nt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;I2.setFromMatrixPosition(e.matrixWorld),t.position.copy(I2),B2.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(B2),t.updateMatrixWorld(),T0.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(T0),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(T0)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},d6=class extends db{constructor(){super(new va(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=hu*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,a=e.distance||t.far;(i!==t.fov||r!==t.aspect||a!==t.far)&&(t.fov=i,t.aspect=r,t.far=a,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},p6=class extends Sp{constructor(e,t,i=0,r=Math.PI/3,a=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Mi.DEFAULT_UP),this.updateMatrix(),this.target=new Mi,this.distance=i,this.angle=r,this.penumbra=a,this.decay=s,this.map=null,this.shadow=new d6}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},U2=new je,ld=new O,P0=new O,f6=class extends db{constructor(){super(new va(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ae(4,2),this._viewportCount=6,this._viewports=[new Nt(2,1,1,1),new Nt(0,1,1,1),new Nt(3,1,1,1),new Nt(1,1,1,1),new Nt(3,0,1,1),new Nt(1,0,1,1)],this._cubeDirections=[new O(1,0,0),new O(-1,0,0),new O(0,0,1),new O(0,0,-1),new O(0,1,0),new O(0,-1,0)],this._cubeUps=[new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,0,1),new O(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,a=e.distance||i.far;a!==i.far&&(i.far=a,i.updateProjectionMatrix()),ld.setFromMatrixPosition(e.matrixWorld),i.position.copy(ld),P0.copy(i.position),P0.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(P0),i.updateMatrixWorld(),r.makeTranslation(-ld.x,-ld.y,-ld.z),U2.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(U2)}},m6=class extends Sp{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new f6}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},g6=class extends db{constructor(){super(new ab(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},v6=class extends Sp{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Mi.DEFAULT_UP),this.updateMatrix(),this.target=new Mi,this.shadow=new g6}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},aP=class extends St{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},sP=class extends Pu{constructor(e){super(e)}load(e,t,i,r){let a=this,s=new o1(a.manager);s.setPath(a.path),s.setRequestHeader(a.requestHeader),s.setWithCredentials(a.withCredentials),s.load(e,function(n){try{t(a.parse(JSON.parse(n)))}catch(o){r?r(o):console.error(o),a.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(u,d){if(t[d]!==void 0)return t[d];let p=u.interleavedBuffers[d],f=a(u,p.buffer),m=$p(p.type,f),g=new w5(m,p.stride);return g.uuid=p.uuid,t[d]=g,g}function a(u,d){if(i[d]!==void 0)return i[d];let p=u.arrayBuffers[d],f=new Uint32Array(p).buffer;return i[d]=f,f}let s=e.isInstancedBufferGeometry?new aP:new St,n=e.data.index;if(n!==void 0){let u=$p(n.type,n.array);s.setIndex(new Ut(u,1))}let o=e.data.attributes;for(let u in o){let d=o[u],p;if(d.isInterleavedBufferAttribute){let f=r(e.data,d.data);p=new r1(f,d.itemSize,d.offset,d.normalized)}else{let f=$p(d.type,d.array),m=d.isInstancedBufferAttribute?Jd:Ut;p=new m(f,d.itemSize,d.normalized)}d.name!==void 0&&(p.name=d.name),d.usage!==void 0&&p.setUsage(d.usage),s.setAttribute(u,p)}let l=e.data.morphAttributes;if(l)for(let u in l){let d=l[u],p=[];for(let f=0,m=d.length;f<m;f++){let g=d[f],v;if(g.isInterleavedBufferAttribute){let x=r(e.data,g.data);v=new r1(x,g.itemSize,g.offset,g.normalized)}else{let x=$p(g.type,g.array);v=new Ut(x,g.itemSize,g.normalized)}g.name!==void 0&&(v.name=g.name),p.push(v)}s.morphAttributes[u]=p}e.data.morphTargetsRelative&&(s.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let u=0,d=h.length;u!==d;++u){let p=h[u];s.addGroup(p.start,p.count,p.materialIndex)}let c=e.data.boundingSphere;if(c!==void 0){let u=new O;c.center!==void 0&&u.fromArray(c.center),s.boundingSphere=new Sa(u,c.radius)}return e.name&&(s.name=e.name),e.userData&&(s.userData=e.userData),s}},y6=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=F2(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=F2();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function F2(){return(typeof performance>"u"?Date:performance).now()}var x6=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,a,s;switch(t){case"quaternion":r=this._slerp,a=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,a=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,a=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=a,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,a=e*r+r,s=this.cumulativeWeight;if(s===0){for(let n=0;n!==r;++n)i[a+n]=i[n];s=t}else{s+=t;let n=t/s;this._mixBufferRegion(i,a,0,n,r)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,a=this.cumulativeWeight,s=this.cumulativeWeightAdditive,n=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,a<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-a,t)}s>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){n.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let a=i,s=r;a!==s;++a)t[a]=t[r+a%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,a){if(r>=.5)for(let s=0;s!==a;++s)e[t+s]=e[i+s]}_slerp(e,t,i,r){zt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,a){let s=this._workIndex*a;zt.multiplyQuaternionsFlat(e,s,e,t,e,i),zt.slerpFlat(e,t,e,t,e,s,r)}_lerp(e,t,i,r,a){let s=1-r;for(let n=0;n!==a;++n){let o=t+n;e[o]=e[o]*s+e[i+n]*r}}_lerpAdditive(e,t,i,r,a){for(let s=0;s!==a;++s){let n=t+s;e[n]=e[n]+e[i+s]*r}}},pb="\\[\\]\\.:\\/",b6=new RegExp("["+pb+"]","g"),fb="[^"+pb+"]",w6="[^"+pb.replace("\\.","")+"]",_6=/((?:WC+[\/:])*)/.source.replace("WC",fb),S6=/(WCOD+)?/.source.replace("WCOD",w6),A6=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",fb),E6=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",fb),M6=new RegExp("^"+_6+S6+A6+E6+"$"),C6=["material","materials","bones","map"],T6=class{constructor(e,t,i){let r=i||Bi.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,a=i.length;r!==a;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Bi=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Bi.parseTrackName(t),this.node=Bi.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Bi.Composite(e,t,i):new Bi(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(b6,"")}static parseTrackName(e){let t=M6.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let a=i.nodeName.substring(r+1);C6.indexOf(a)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=a)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(a){for(let s=0;s<a.length;s++){let n=a[s];if(n.name===t||n.uuid===t)return n;let o=i(n.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,a=t.propertyIndex;if(e||(e=Bi.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let s=e[r];if(s===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let n=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?n=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(n=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(a!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[a]!==void 0&&(a=e.morphTargetDictionary[a])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=a}else s.fromArray!==void 0&&s.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][n]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Bi.Composite=T6;Bi.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Bi.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Bi.prototype.GetterByBindingType=[Bi.prototype._getValue_direct,Bi.prototype._getValue_array,Bi.prototype._getValue_arrayElement,Bi.prototype._getValue_toArray];Bi.prototype.SetterByBindingTypeAndVersioning=[[Bi.prototype._setValue_direct,Bi.prototype._setValue_direct_setNeedsUpdate,Bi.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Bi.prototype._setValue_array,Bi.prototype._setValue_array_setNeedsUpdate,Bi.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Bi.prototype._setValue_arrayElement,Bi.prototype._setValue_arrayElement_setNeedsUpdate,Bi.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Bi.prototype._setValue_fromArray,Bi.prototype._setValue_fromArray_setNeedsUpdate,Bi.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var P6=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let a=t.tracks,s=a.length,n=new Array(s),o={endingStart:zc,endingEnd:zc};for(let l=0;l!==s;++l){let h=a[l].createInterpolant(null);n[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=n,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=_T,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,a=e._clip.duration,s=a/r,n=r/a;e.warp(1,s,t),this.warp(n,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,a=r.time,s=this.timeScale,n=this._timeScaleInterpolant;n===null&&(n=r._lendControlInterpolant(),this._timeScaleInterpolant=n);let o=n.parameterPositions,l=n.sampleValues;return o[0]=a,o[1]=a+i,l[0]=e/s,l[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let a=this._startTime;if(a!==null){let o=(e-a)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let s=this._updateTime(t),n=this._updateWeight(e);if(n>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case B4:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(s),l[h].accumulateAdditive(n);break;case Jx:default:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(s),l[h].accumulate(r,n)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,a=this._loopCount,s=i===Zx;if(e===0)return a===-1?r:s&&(a&1)===1?t-r:r;if(i===wT){a===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(a===-1&&(e>=0?(a=0,this._setEndings(!0,this.repetitions===0,s)):this._setEndings(this.repetitions===0,!0,s)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,a+=Math.abs(n);let o=this.repetitions-a;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,s)}else this._setEndings(!1,!1,s);this._loopCount=a,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(s&&(a&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=kc,r.endingEnd=kc):(e?r.endingStart=this.zeroSlopeAtStart?kc:zc:r.endingStart=Wm,t?r.endingEnd=this.zeroSlopeAtEnd?kc:zc:r.endingEnd=Wm)}_scheduleFading(e,t,i){let r=this._mixer,a=r.time,s=this._weightInterpolant;s===null&&(s=r._lendControlInterpolant(),this._weightInterpolant=s);let n=s.parameterPositions,o=s.sampleValues;return n[0]=a,o[0]=t,n[1]=a+e,o[1]=i,this}},D6=new Float32Array(1),R6=class extends ua{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,a=r.length,s=e._propertyBindings,n=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let c=0;c!==a;++c){let u=r[c],d=u.name,p=h[d];if(p!==void 0)++p.referenceCount,s[c]=p;else{if(p=s[c],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,d));continue}let f=t&&t._propertyBindings[c].binding.parsedPath;p=new x6(Bi.create(i,d,f),u.ValueTypeName,u.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,d),s[c]=p}n[c].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,a=this._actionsByClip[r];this._bindAction(e,a&&a.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let a=t[i];a.useCount++===0&&(this._lendBinding(a),a.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let a=t[i];--a.useCount===0&&(a.restoreOriginalState(),this._takeBackBinding(a))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,a=this._actionsByClip,s=a[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,a[t]=s;else{let n=s.knownActions;e._byClipCacheIndex=n.length,n.push(e)}e._cacheIndex=r.length,r.push(e),s.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let a=e._clip.uuid,s=this._actionsByClip,n=s[a],o=n.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let c=n.actionByRoot,u=(e._localRoot||this._root).uuid;delete c[u],o.length===0&&delete s[a],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let a=t[i];--a.referenceCount===0&&this._removeInactiveBinding(a)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,a=this._bindings,s=r[t];s===void 0&&(s={},r[t]=s),s[i]=e,e._cacheIndex=a.length,a.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,a=i.path,s=this._bindingsByRootAndName,n=s[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete n[a],Object.keys(n).length===0&&delete s[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new tP(new Float32Array(2),new Float32Array(2),1,D6),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,a=t[r];e.__cacheIndex=r,t[r]=e,a.__cacheIndex=i,t[i]=a}clipAction(e,t,i){let r=t||this._root,a=r.uuid,s=typeof e=="string"?n1.findByName(r,e):e,n=s!==null?s.uuid:e,o=this._actionsByClip[n],l=null;if(i===void 0&&(s!==null?i=s.blendMode:i=Jx),o!==void 0){let c=o.actionByRoot[a];if(c!==void 0&&c.blendMode===i)return c;l=o.knownActions[0],s===null&&(s=l._clip)}if(s===null)return null;let h=new P6(this,s,t,i);return this._bindAction(h,l),this._addInactiveAction(h,n,a),h}existingAction(e,t){let i=t||this._root,r=i.uuid,a=typeof e=="string"?n1.findByName(i,e):e,s=a?a.uuid:e,n=this._actionsByClip[s];return n!==void 0&&n.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,a=Math.sign(e),s=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,a,s);let n=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)n[l].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,a=r[i];if(a!==void 0){let s=a.knownActions;for(let n=0,o=s.length;n!==o;++n){let l=s[n];this._deactivateAction(l);let h=l._cacheIndex,c=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,c._cacheIndex=h,t[h]=c,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let s in i){let n=i[s].actionByRoot,o=n[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,a=r[t];if(a!==void 0)for(let s in a){let n=a[s];n.restoreOriginalState(),this._removeInactiveBinding(n)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},Ve=class{constructor(e){this.value=e}clone(){return new Ve(this.value.clone===void 0?this.value:this.value.clone())}},N2=new je,nP=class{constructor(e,t,i=0,r=1/0){this.ray=new Au(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new tb,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return N2.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(N2),this}intersectObject(e,t=!0,i=[]){return l1(e,this,i,t),i.sort(z2),i}intersectObjects(e,t=!0,i=[]){for(let r=0,a=e.length;r<a;r++)l1(e[r],this,i,t);return i.sort(z2),i}};function z2(e,t){return e.distance-t.distance}function l1(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let a=e.children;for(let s=0,n=a.length;s<n;s++)l1(a[s],t,i,!0)}}var k2=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(yr(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},V2=new ae,oP=class{constructor(e=new ae(1/0,1/0),t=new ae(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=V2.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,V2).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},j2=new O,Tf=new O,Es=class{constructor(e=new O,t=new O){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){j2.subVectors(e,this.start),Tf.subVectors(this.end,this.start);let i=Tf.dot(Tf),r=Tf.dot(j2)/i;return t&&(r=yr(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},G2=new O,O6=class extends Mi{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new St,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let s=0,n=1,o=32;s<o;s++,n++){let l=s/o*Math.PI*2,h=n/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new ut(r,3));let a=new Dl({fog:!1,toneMapped:!1});this.cone=new wp(i,a),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),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),G2.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(G2),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},L6=class extends xr{constructor(e,t,i){let r=new Qc(t,4,2),a=new Dh({wireframe:!0,fog:!1,toneMapped:!1});super(r,a),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},H2=new O,Pf=new O,W2=new O,I6=class extends Mi{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new St;r.setAttribute("position",new ut([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let a=new Dl({fog:!1,toneMapped:!1});this.lightPlane=new Zm(r,a),this.add(this.lightPlane),r=new St,r.setAttribute("position",new ut([0,0,0,0,0,1],3)),this.targetLine=new Zm(r,a),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),H2.setFromMatrixPosition(this.light.matrixWorld),Pf.setFromMatrixPosition(this.light.target.matrixWorld),W2.subVectors(Pf,H2),this.lightPlane.lookAt(Pf),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(Pf),this.targetLine.scale.z=W2.length()}},Df=new O,lr=new Rh,rg=class extends wp{constructor(e){let t=new St,i=new Dl({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],a=[],s={};n("n1","n2"),n("n2","n4"),n("n4","n3"),n("n3","n1"),n("f1","f2"),n("f2","f4"),n("f4","f3"),n("f3","f1"),n("n1","f1"),n("n2","f2"),n("n3","f3"),n("n4","f4"),n("p","n1"),n("p","n2"),n("p","n3"),n("p","n4"),n("u1","u2"),n("u2","u3"),n("u3","u1"),n("c","t"),n("p","c"),n("cn1","cn2"),n("cn3","cn4"),n("cf1","cf2"),n("cf3","cf4");function n(p,f){o(p),o(f)}function o(p){r.push(0,0,0),a.push(0,0,0),s[p]===void 0&&(s[p]=[]),s[p].push(r.length/3-1)}t.setAttribute("position",new ut(r,3)),t.setAttribute("color",new ut(a,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();let l=new _t(16755200),h=new _t(16711680),c=new _t(43775),u=new _t(16777215),d=new _t(3355443);this.setColors(l,h,c,u,d)}setColors(e,t,i,r,a){let s=this.geometry.getAttribute("color");s.setXYZ(0,e.r,e.g,e.b),s.setXYZ(1,e.r,e.g,e.b),s.setXYZ(2,e.r,e.g,e.b),s.setXYZ(3,e.r,e.g,e.b),s.setXYZ(4,e.r,e.g,e.b),s.setXYZ(5,e.r,e.g,e.b),s.setXYZ(6,e.r,e.g,e.b),s.setXYZ(7,e.r,e.g,e.b),s.setXYZ(8,e.r,e.g,e.b),s.setXYZ(9,e.r,e.g,e.b),s.setXYZ(10,e.r,e.g,e.b),s.setXYZ(11,e.r,e.g,e.b),s.setXYZ(12,e.r,e.g,e.b),s.setXYZ(13,e.r,e.g,e.b),s.setXYZ(14,e.r,e.g,e.b),s.setXYZ(15,e.r,e.g,e.b),s.setXYZ(16,e.r,e.g,e.b),s.setXYZ(17,e.r,e.g,e.b),s.setXYZ(18,e.r,e.g,e.b),s.setXYZ(19,e.r,e.g,e.b),s.setXYZ(20,e.r,e.g,e.b),s.setXYZ(21,e.r,e.g,e.b),s.setXYZ(22,e.r,e.g,e.b),s.setXYZ(23,e.r,e.g,e.b),s.setXYZ(24,t.r,t.g,t.b),s.setXYZ(25,t.r,t.g,t.b),s.setXYZ(26,t.r,t.g,t.b),s.setXYZ(27,t.r,t.g,t.b),s.setXYZ(28,t.r,t.g,t.b),s.setXYZ(29,t.r,t.g,t.b),s.setXYZ(30,t.r,t.g,t.b),s.setXYZ(31,t.r,t.g,t.b),s.setXYZ(32,i.r,i.g,i.b),s.setXYZ(33,i.r,i.g,i.b),s.setXYZ(34,i.r,i.g,i.b),s.setXYZ(35,i.r,i.g,i.b),s.setXYZ(36,i.r,i.g,i.b),s.setXYZ(37,i.r,i.g,i.b),s.setXYZ(38,r.r,r.g,r.b),s.setXYZ(39,r.r,r.g,r.b),s.setXYZ(40,a.r,a.g,a.b),s.setXYZ(41,a.r,a.g,a.b),s.setXYZ(42,a.r,a.g,a.b),s.setXYZ(43,a.r,a.g,a.b),s.setXYZ(44,a.r,a.g,a.b),s.setXYZ(45,a.r,a.g,a.b),s.setXYZ(46,a.r,a.g,a.b),s.setXYZ(47,a.r,a.g,a.b),s.setXYZ(48,a.r,a.g,a.b),s.setXYZ(49,a.r,a.g,a.b),s.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;lr.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),mr("c",t,e,lr,0,0,-1),mr("t",t,e,lr,0,0,1),mr("n1",t,e,lr,-i,-r,-1),mr("n2",t,e,lr,i,-r,-1),mr("n3",t,e,lr,-i,r,-1),mr("n4",t,e,lr,i,r,-1),mr("f1",t,e,lr,-i,-r,1),mr("f2",t,e,lr,i,-r,1),mr("f3",t,e,lr,-i,r,1),mr("f4",t,e,lr,i,r,1),mr("u1",t,e,lr,i*.7,r*1.1,-1),mr("u2",t,e,lr,-i*.7,r*1.1,-1),mr("u3",t,e,lr,0,r*2,-1),mr("cf1",t,e,lr,-i,0,1),mr("cf2",t,e,lr,i,0,1),mr("cf3",t,e,lr,0,-r,1),mr("cf4",t,e,lr,0,r,1),mr("cn1",t,e,lr,-i,0,-1),mr("cn2",t,e,lr,i,0,-1),mr("cn3",t,e,lr,0,-r,-1),mr("cn4",t,e,lr,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function mr(e,t,i,r,a,s,n){Df.set(a,s,n).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,c=o.length;h<c;h++)l.setXYZ(o[h],Df.x,Df.y,Df.z)}}var ag=class extends wp{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],a=new St;a.setIndex(new Ut(i,1)),a.setAttribute("position",new ut(r,3)),super(a,new Dl({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},B6=class extends wp{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new St;r.setAttribute("position",new ut(t,3)),r.setAttribute("color",new ut(i,3));let a=new Dl({vertexColors:!0,toneMapped:!1});super(r,a),this.type="AxesHelper"}setColors(e,t,i){let r=new _t,a=this.geometry.attributes.color.array;return r.set(e),r.toArray(a,0),r.toArray(a,3),r.set(t),r.toArray(a,6),r.toArray(a,9),r.set(i),r.toArray(a,12),r.toArray(a,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:Su}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Su);var hd=".",mb=Symbol("target"),lP=Symbol("unsubscribe");function h1(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function U6(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var _n=Array.isArray;function gb(e){return typeof e=="symbol"}var F6={after:(e,t)=>_n(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>_n(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=hd),gb(t)?e+t.toString():e+t):e,initial:e=>{if(_n(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(hd);return t===-1?"":e.slice(0,t)},last:e=>{if(_n(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(hd);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(_n(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(hd);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(hd,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},xs=F6;function N6(e){return typeof e=="object"&&typeof e.next=="function"}function z6(e,t,i,r,a){let s=e.next;if(t.name==="entries")e.next=function(){let n=s.call(this);return n.done===!1&&(n.value[0]=a(n.value[0],t,n.value[0],r),n.value[1]=a(n.value[1],t,n.value[0],r)),n};else if(t.name==="values"){let n=i[mb].keys();e.next=function(){let o=s.call(this);return o.done===!1&&(o.value=a(o.value,t,n.next().value,r)),o}}else e.next=function(){let n=s.call(this);return n.done===!1&&(n.value=a(n.value,t,n.value,r)),n};return e}function q2(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&gb(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var k6=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let a=e[r],s=a||e;this._pathCache.set(s,t);let n=this._proxyCache.get(s);return n===void 0&&(n=a===void 0?new Proxy(e,i):e,this._proxyCache.set(s,n)),n}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,xs.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,a){if(!this._equals(a,i)||!(t in e)){let s=this._getOwnPropertyDescriptor(e,t);return s!==void 0&&"set"in s?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function c1(e){return toString.call(e)==="[object Object]"}function Rf(){return!0}function fc(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var hP=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),V6=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),cP={push:Rf,pop:Rf,shift:Rf,unshift:Rf,copyWithin:fc,reverse:fc,sort:fc,splice:fc,flat:fc,fill:fc},j6=new Set([...hP,...V6,...Object.keys(cP)]);function Of(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var uP=["keys","values","entries"],dP=new Set(["has","toString"]),pP={add:Of,clear:Of,delete:Of,forEach:Of},G6=new Set([...dP,...Object.keys(pP),...uP]);function Lf(e,t){if(e.size!==t.size)return!0;let i;for(let[r,a]of e)if(i=t.get(r),i!==a||i===void 0&&!t.has(r))return!0;return!1}var H6=new Set([...dP,"get"]),fP={set:Lf,clear:Lf,delete:Lf,forEach:Lf},W6=new Set([...H6,...Object.keys(fP),...uP]),Cl=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return hP.has(e)}_shallowClone(e){let t=e;if(c1(e))t={...e};else if(_n(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(_n(r)?this._onIsChanged=cP[t]:r instanceof Set?this._onIsChanged=pP[t]:r instanceof Map&&(this._onIsChanged=fP[t]),r):i}update(e,t,i){let r=xs.after(e,this._path);if(t!=="length"){let a=this.clone;xs.walk(r,s=>{a&&a[s]&&(this._clonedCache.has(a[s])||(a[s]=this._shallowClone(a[s])),a=a[s])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),a&&a[t]&&(a[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],xs.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},X2=class extends Cl{static isHandledMethod(e){return j6.has(e)}},q6=class extends Cl{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},Y2=class extends Cl{static isHandledMethod(e){return G6.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},Q2=class extends Cl{static isHandledMethod(e){return W6.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},X6=class extends Cl{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},Y6=class extends Cl{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},Lc=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return c1(e)||_n(e)||h1(e)}static isHandledMethod(e,t){return c1(e)?Cl.isHandledMethod(t):_n(e)?X2.isHandledMethod(t):e instanceof Set?Y2.isHandledMethod(t):e instanceof Map?Q2.isHandledMethod(t):h1(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=Cl;_n(e)?r=X2:e instanceof Date?r=q6:e instanceof Set?r=Y2:e instanceof Map?r=Q2:e instanceof WeakSet?r=X6:e instanceof WeakMap&&(r=Y6),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,a=Lc.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(a,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},Q6={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},vb=(e,t,i={})=>{i={...Q6,...i};let r=Symbol("ProxyTarget"),{equals:a,isShallow:s,ignoreDetached:n,details:o}=i,l=new k6(a),h=typeof i.onValidate=="function",c=new Lc(h),u=(x,b,_,M,A)=>!h||c.isCloning||i.onValidate(xs.concat(l.getPath(x),b),_,M,A)===!0,d=(x,b,_,M)=>{!q2(l,i,b)&&!(n&&l.isDetached(x,e))&&p(l.getPath(x),b,_,M)},p=(x,b,_,M,A)=>{c.isCloning?c.update(x,b,M):t(xs.concat(x,b),_,M,A)},f=x=>x&&(x[r]||x),m=(x,b,_,M)=>U6(x)||_==="constructor"||s&&!Lc.isHandledMethod(b,_)||q2(l,i,_)||l.isGetInvariant(b,_)||n&&l.isDetached(b,e)?x:(M===void 0&&(M=l.getPath(b)),l.getProxy(x,xs.concat(M,_),g,r)),g={get(x,b,_){if(gb(b)){if(b===r||b===mb)return x;if(b===lP&&!l.isUnsubscribed&&l.getPath(x).length===0)return l.unsubscribe(),x}let M=h1(x)?Reflect.get(x,b):Reflect.get(x,b,_);return m(M,x,b)},set(x,b,_,M){_=f(_);let A=x[r]||x,S=A[b];if(a(S,_)&&b in x)return!0;let P=u(x,b,_,S);return P&&l.setProperty(A,b,_,M,S)?(d(x,b,x[b],S),!0):!P},defineProperty(x,b,_){if(!l.isSameDescriptor(_,x,b)){let M=x[b];u(x,b,_.value,M)&&l.defineProperty(x,b,_,M)&&d(x,b,_.value,M)}return!0},deleteProperty(x,b){if(!Reflect.has(x,b))return!0;let _=Reflect.get(x,b),M=u(x,b,void 0,_);return M&&l.deleteProperty(x,b,_)?(d(x,b,void 0,_),!0):!M},apply(x,b,_){let M=b[r]||b;if(l.isUnsubscribed)return Reflect.apply(x,M,_);if((o===!1||o!==!0&&!o.includes(x.name))&&Lc.isHandledType(M)){let A=xs.initial(l.getPath(x)),S=Lc.isHandledMethod(M,x.name);c.start(M,A,_);let P=Reflect.apply(x,c.preferredThisArg(x,b,M),S?_.map(T=>f(T)):_),L=c.isChanged(M,a),E=c.stop();if(Lc.isHandledType(P)&&S&&(b instanceof Map&&x.name==="get"&&(A=xs.concat(A,_[0])),P=l.getProxy(P,A,g)),L){let T={name:x.name,args:_,result:P},B=c.isCloning?xs.initial(A):A,V=c.isCloning?xs.last(A):"";u(xs.get(e,B),V,M,E,T)?p(B,V,M,E,T):c.undo(M)}return(b instanceof Map||b instanceof Set)&&N6(P)?z6(P,x,b,A,m):P}return Reflect.apply(x,b,_)}},v=l.getProxy(e,i.pathAsArray?[]:"",g);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};vb.target=e=>e&&e[mb]||e;vb.unsubscribe=e=>e[lP]||e;var K2=vb,K6=typeof global=="object"&&global&&global.Object===Object&&global,mP=K6,Z6=typeof self=="object"&&self&&self.Object===Object&&self,J6=mP||Z6||Function("return this")(),Js=J6,$6=Js.Symbol,Ts=$6,gP=Object.prototype,eV=gP.hasOwnProperty,tV=gP.toString,cd=Ts?Ts.toStringTag:void 0;function iV(e){var t=eV.call(e,cd),i=e[cd];try{e[cd]=void 0;var r=!0}catch{}var a=tV.call(e);return r&&(t?e[cd]=i:delete e[cd]),a}var rV=iV,aV=Object.prototype,sV=aV.toString;function nV(e){return sV.call(e)}var oV=nV,lV="[object Null]",hV="[object Undefined]",Z2=Ts?Ts.toStringTag:void 0;function cV(e){return e==null?e===void 0?hV:lV:Z2&&Z2 in Object(e)?rV(e):oV(e)}var Oh=cV;function uV(e){return e!=null&&typeof e=="object"}var Co=uV,dV="[object Symbol]";function pV(e){return typeof e=="symbol"||Co(e)&&Oh(e)==dV}var $g=pV;function fV(e,t){for(var i=-1,r=e==null?0:e.length,a=Array(r);++i<r;)a[i]=t(e[i],i,e);return a}var vP=fV,mV=Array.isArray,On=mV,gV=1/0,J2=Ts?Ts.prototype:void 0,$2=J2?J2.toString:void 0;function yP(e){if(typeof e=="string")return e;if(On(e))return vP(e,yP)+"";if($g(e))return $2?$2.call(e):"";var t=e+"";return t=="0"&&1/e==-gV?"-0":t}var vV=yP,yV=/\s/;function xV(e){for(var t=e.length;t--&&yV.test(e.charAt(t)););return t}var bV=xV,wV=/^\s+/;function _V(e){return e&&e.slice(0,bV(e)+1).replace(wV,"")}var SV=_V;function AV(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Zs=AV,eA=0/0,EV=/^[-+]0x[0-9a-f]+$/i,MV=/^0b[01]+$/i,CV=/^0o[0-7]+$/i,TV=parseInt;function PV(e){if(typeof e=="number")return e;if($g(e))return eA;if(Zs(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Zs(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=SV(e);var i=MV.test(e);return i||CV.test(e)?TV(e.slice(2),i?2:8):EV.test(e)?eA:+e}var tA=PV;function DV(e){return e}var RV=DV,OV="[object AsyncFunction]",LV="[object Function]",IV="[object GeneratorFunction]",BV="[object Proxy]";function UV(e){if(!Zs(e))return!1;var t=Oh(e);return t==LV||t==IV||t==OV||t==BV}var xP=UV,FV=Js["__core-js_shared__"],D0=FV,iA=function(){var e=/[^.]+$/.exec(D0&&D0.keys&&D0.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function NV(e){return!!iA&&iA in e}var zV=NV,kV=Function.prototype,VV=kV.toString;function jV(e){if(e!=null){try{return VV.call(e)}catch{}try{return e+""}catch{}}return""}var Lh=jV,GV=/[\\^$.*+?()[\]{}|]/g,HV=/^\[object .+?Constructor\]$/,WV=Function.prototype,qV=Object.prototype,XV=WV.toString,YV=qV.hasOwnProperty,QV=RegExp("^"+XV.call(YV).replace(GV,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function KV(e){if(!Zs(e)||zV(e))return!1;var t=xP(e)?QV:HV;return t.test(Lh(e))}var ZV=KV;function JV(e,t){return e?.[t]}var $V=JV;function e8(e,t){var i=$V(e,t);return ZV(i)?i:void 0}var Ih=e8,t8=Ih(Js,"WeakMap"),u1=t8,rA=Object.create,i8=function(){function e(){}return function(t){if(!Zs(t))return{};if(rA)return rA(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),r8=i8;function a8(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var s8=a8;function n8(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var o8=n8,l8=800,h8=16,c8=Date.now;function u8(e){var t=0,i=0;return function(){var r=c8(),a=h8-(r-i);if(i=r,a>0){if(++t>=l8)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var d8=u8;function p8(e){return function(){return e}}var f8=p8,m8=function(){try{var e=Ih(Object,"defineProperty");return e({},"",{}),e}catch{}}(),sg=m8,g8=sg?function(e,t){return sg(e,"toString",{configurable:!0,enumerable:!1,value:f8(t),writable:!0})}:RV,v8=g8,y8=d8(v8),x8=y8;function b8(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var w8=b8,_8=9007199254740991,S8=/^(?:0|[1-9]\d*)$/;function A8(e,t){var i=typeof e;return t=t??_8,!!t&&(i=="number"||i!="symbol"&&S8.test(e))&&e>-1&&e%1==0&&e<t}var yb=A8;function E8(e,t,i){t=="__proto__"&&sg?sg(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var bP=E8;function M8(e,t){return e===t||e!==e&&t!==t}var xb=M8,C8=Object.prototype,T8=C8.hasOwnProperty;function P8(e,t,i){var r=e[t];(!(T8.call(e,t)&&xb(r,i))||i===void 0&&!(t in e))&&bP(e,t,i)}var bb=P8;function D8(e,t,i,r){var a=!i;i||(i={});for(var s=-1,n=t.length;++s<n;){var o=t[s],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),a?bP(i,o,l):bb(i,o,l)}return i}var Ap=D8,aA=Math.max;function R8(e,t,i){return t=aA(t===void 0?e.length-1:t,0),function(){for(var r=arguments,a=-1,s=aA(r.length-t,0),n=Array(s);++a<s;)n[a]=r[t+a];a=-1;for(var o=Array(t+1);++a<t;)o[a]=r[a];return o[t]=i(n),s8(e,this,o)}}var O8=R8,L8=9007199254740991;function I8(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=L8}var wb=I8;function B8(e){return e!=null&&wb(e.length)&&!xP(e)}var wP=B8,U8=Object.prototype;function F8(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||U8;return e===i}var _b=F8;function N8(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var z8=N8,k8="[object Arguments]";function V8(e){return Co(e)&&Oh(e)==k8}var sA=V8,_P=Object.prototype,j8=_P.hasOwnProperty,G8=_P.propertyIsEnumerable,H8=sA(function(){return arguments}())?sA:function(e){return Co(e)&&j8.call(e,"callee")&&!G8.call(e,"callee")},Sb=H8;function W8(){return!1}var q8=W8,SP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,nA=SP&&typeof module=="object"&&module&&!module.nodeType&&module,X8=nA&&nA.exports===SP,oA=X8?Js.Buffer:void 0,Y8=oA?oA.isBuffer:void 0,Q8=Y8||q8,ng=Q8,K8="[object Arguments]",Z8="[object Array]",J8="[object Boolean]",$8="[object Date]",ej="[object Error]",tj="[object Function]",ij="[object Map]",rj="[object Number]",aj="[object Object]",sj="[object RegExp]",nj="[object Set]",oj="[object String]",lj="[object WeakMap]",hj="[object ArrayBuffer]",cj="[object DataView]",uj="[object Float32Array]",dj="[object Float64Array]",pj="[object Int8Array]",fj="[object Int16Array]",mj="[object Int32Array]",gj="[object Uint8Array]",vj="[object Uint8ClampedArray]",yj="[object Uint16Array]",xj="[object Uint32Array]",Wi={};Wi[uj]=Wi[dj]=Wi[pj]=Wi[fj]=Wi[mj]=Wi[gj]=Wi[vj]=Wi[yj]=Wi[xj]=!0;Wi[K8]=Wi[Z8]=Wi[hj]=Wi[J8]=Wi[cj]=Wi[$8]=Wi[ej]=Wi[tj]=Wi[ij]=Wi[rj]=Wi[aj]=Wi[sj]=Wi[nj]=Wi[oj]=Wi[lj]=!1;function bj(e){return Co(e)&&wb(e.length)&&!!Wi[Oh(e)]}var wj=bj;function _j(e){return function(t){return e(t)}}var Ab=_j,AP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,jd=AP&&typeof module=="object"&&module&&!module.nodeType&&module,Sj=jd&&jd.exports===AP,R0=Sj&&mP.process,Aj=function(){try{var e=jd&&jd.require&&jd.require("util").types;return e||R0&&R0.binding&&R0.binding("util")}catch{}}(),uu=Aj,lA=uu&&uu.isTypedArray,Ej=lA?Ab(lA):wj,EP=Ej,Mj=Object.prototype,Cj=Mj.hasOwnProperty;function Tj(e,t){var i=On(e),r=!i&&Sb(e),a=!i&&!r&&ng(e),s=!i&&!r&&!a&&EP(e),n=i||r||a||s,o=n?z8(e.length,String):[],l=o.length;for(var h in e)(t||Cj.call(e,h))&&!(n&&(h=="length"||a&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||yb(h,l)))&&o.push(h);return o}var MP=Tj;function Pj(e,t){return function(i){return e(t(i))}}var CP=Pj,Dj=CP(Object.keys,Object),Rj=Dj,Oj=Object.prototype,Lj=Oj.hasOwnProperty;function Ij(e){if(!_b(e))return Rj(e);var t=[];for(var i in Object(e))Lj.call(e,i)&&i!="constructor"&&t.push(i);return t}var Bj=Ij;function Uj(e){return wP(e)?MP(e):Bj(e)}var Eb=Uj;function Fj(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var Nj=Fj,zj=Object.prototype,kj=zj.hasOwnProperty;function Vj(e){if(!Zs(e))return Nj(e);var t=_b(e),i=[];for(var r in e)r=="constructor"&&(t||!kj.call(e,r))||i.push(r);return i}var jj=Vj;function Gj(e){return wP(e)?MP(e,!0):jj(e)}var oh=Gj,Hj=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Wj=/^\w*$/;function qj(e,t){if(On(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||$g(e)?!0:Wj.test(e)||!Hj.test(e)||t!=null&&e in Object(t)}var Xj=qj,Yj=Ih(Object,"create"),ip=Yj;function Qj(){this.__data__=ip?ip(null):{},this.size=0}var Kj=Qj;function Zj(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Jj=Zj,$j="__lodash_hash_undefined__",eG=Object.prototype,tG=eG.hasOwnProperty;function iG(e){var t=this.__data__;if(ip){var i=t[e];return i===$j?void 0:i}return tG.call(t,e)?t[e]:void 0}var rG=iG,aG=Object.prototype,sG=aG.hasOwnProperty;function nG(e){var t=this.__data__;return ip?t[e]!==void 0:sG.call(t,e)}var oG=nG,lG="__lodash_hash_undefined__";function hG(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=ip&&t===void 0?lG:t,this}var cG=hG;function Du(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Du.prototype.clear=Kj;Du.prototype.delete=Jj;Du.prototype.get=rG;Du.prototype.has=oG;Du.prototype.set=cG;var hA=Du;function uG(){this.__data__=[],this.size=0}var dG=uG;function pG(e,t){for(var i=e.length;i--;)if(xb(e[i][0],t))return i;return-1}var ev=pG,fG=Array.prototype,mG=fG.splice;function gG(e){var t=this.__data__,i=ev(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():mG.call(t,i,1),--this.size,!0}var vG=gG;function yG(e){var t=this.__data__,i=ev(t,e);return i<0?void 0:t[i][1]}var xG=yG;function bG(e){return ev(this.__data__,e)>-1}var wG=bG;function _G(e,t){var i=this.__data__,r=ev(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var SG=_G;function Ru(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Ru.prototype.clear=dG;Ru.prototype.delete=vG;Ru.prototype.get=xG;Ru.prototype.has=wG;Ru.prototype.set=SG;var tv=Ru,AG=Ih(Js,"Map"),rp=AG;function EG(){this.size=0,this.__data__={hash:new hA,map:new(rp||tv),string:new hA}}var MG=EG;function CG(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var TG=CG;function PG(e,t){var i=e.__data__;return TG(t)?i[typeof t=="string"?"string":"hash"]:i.map}var iv=PG;function DG(e){var t=iv(this,e).delete(e);return this.size-=t?1:0,t}var RG=DG;function OG(e){return iv(this,e).get(e)}var LG=OG;function IG(e){return iv(this,e).has(e)}var BG=IG;function UG(e,t){var i=iv(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var FG=UG;function Ou(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Ou.prototype.clear=MG;Ou.prototype.delete=RG;Ou.prototype.get=LG;Ou.prototype.has=BG;Ou.prototype.set=FG;var rv=Ou,NG="Expected a function";function Mb(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(NG);var i=function(){var r=arguments,a=t?t.apply(this,r):r[0],s=i.cache;if(s.has(a))return s.get(a);var n=e.apply(this,r);return i.cache=s.set(a,n)||s,n};return i.cache=new(Mb.Cache||rv),i}Mb.Cache=rv;var zG=Mb,kG=500;function VG(e){var t=zG(e,function(r){return i.size===kG&&i.clear(),r}),i=t.cache;return t}var jG=VG,GG=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,HG=/\\(\\)?/g,WG=jG(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(GG,function(i,r,a,s){t.push(a?s.replace(HG,"$1"):r||i)}),t}),qG=WG;function XG(e){return e==null?"":vV(e)}var YG=XG;function QG(e,t){return On(e)?e:Xj(e,t)?[e]:qG(YG(e))}var Lu=QG,KG=1/0;function ZG(e){if(typeof e=="string"||$g(e))return e;var t=e+"";return t=="0"&&1/e==-KG?"-0":t}var av=ZG;function JG(e,t){t=Lu(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[av(t[i++])];return i&&i==r?e:void 0}var TP=JG;function $G(e,t){for(var i=-1,r=t.length,a=e.length;++i<r;)e[a+i]=t[i];return e}var Cb=$G,cA=Ts?Ts.isConcatSpreadable:void 0;function eH(e){return On(e)||Sb(e)||!!(cA&&e&&e[cA])}var tH=eH;function PP(e,t,i,r,a){var s=-1,n=e.length;for(i||(i=tH),a||(a=[]);++s<n;){var o=e[s];t>0&&i(o)?t>1?PP(o,t-1,i,r,a):Cb(a,o):r||(a[a.length]=o)}return a}var iH=PP;function rH(e){var t=e==null?0:e.length;return t?iH(e,1):[]}var aH=rH;function sH(e){return x8(O8(e,void 0,aH),e+"")}var DP=sH,nH=CP(Object.getPrototypeOf,Object),Tb=nH,oH="[object Object]",lH=Function.prototype,hH=Object.prototype,RP=lH.toString,cH=hH.hasOwnProperty,uH=RP.call(Object);function dH(e){if(!Co(e)||Oh(e)!=oH)return!1;var t=Tb(e);if(t===null)return!0;var i=cH.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&RP.call(i)==uH}var pH=dH;function fH(e,t,i){var r=-1,a=e.length;t<0&&(t=-t>a?0:a+t),i=i>a?a:i,i<0&&(i+=a),a=t>i?0:i-t>>>0,t>>>=0;for(var s=Array(a);++r<a;)s[r]=e[r+t];return s}var mH=fH;function gH(){this.__data__=new tv,this.size=0}var vH=gH;function yH(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var xH=yH;function bH(e){return this.__data__.get(e)}var wH=bH;function _H(e){return this.__data__.has(e)}var SH=_H,AH=200;function EH(e,t){var i=this.__data__;if(i instanceof tv){var r=i.__data__;if(!rp||r.length<AH-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new rv(r)}return i.set(e,t),this.size=i.size,this}var MH=EH;function Iu(e){var t=this.__data__=new tv(e);this.size=t.size}Iu.prototype.clear=vH;Iu.prototype.delete=xH;Iu.prototype.get=wH;Iu.prototype.has=SH;Iu.prototype.set=MH;var Tm=Iu;function CH(e,t){return e&&Ap(t,Eb(t),e)}var TH=CH;function PH(e,t){return e&&Ap(t,oh(t),e)}var DH=PH,OP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,uA=OP&&typeof module=="object"&&module&&!module.nodeType&&module,RH=uA&&uA.exports===OP,dA=RH?Js.Buffer:void 0,pA=dA?dA.allocUnsafe:void 0;function OH(e,t){if(t)return e.slice();var i=e.length,r=pA?pA(i):new e.constructor(i);return e.copy(r),r}var LH=OH;function IH(e,t){for(var i=-1,r=e==null?0:e.length,a=0,s=[];++i<r;){var n=e[i];t(n,i,e)&&(s[a++]=n)}return s}var BH=IH;function UH(){return[]}var LP=UH,FH=Object.prototype,NH=FH.propertyIsEnumerable,fA=Object.getOwnPropertySymbols,zH=fA?function(e){return e==null?[]:(e=Object(e),BH(fA(e),function(t){return NH.call(e,t)}))}:LP,Pb=zH;function kH(e,t){return Ap(e,Pb(e),t)}var VH=kH,jH=Object.getOwnPropertySymbols,GH=jH?function(e){for(var t=[];e;)Cb(t,Pb(e)),e=Tb(e);return t}:LP,IP=GH;function HH(e,t){return Ap(e,IP(e),t)}var WH=HH;function qH(e,t,i){var r=t(e);return On(e)?r:Cb(r,i(e))}var BP=qH;function XH(e){return BP(e,Eb,Pb)}var d1=XH;function YH(e){return BP(e,oh,IP)}var UP=YH,QH=Ih(Js,"DataView"),p1=QH,KH=Ih(Js,"Promise"),f1=KH,ZH=Ih(Js,"Set"),m1=ZH,mA="[object Map]",JH="[object Object]",gA="[object Promise]",vA="[object Set]",yA="[object WeakMap]",xA="[object DataView]",$H=Lh(p1),eW=Lh(rp),tW=Lh(f1),iW=Lh(m1),rW=Lh(u1),Zl=Oh;(p1&&Zl(new p1(new ArrayBuffer(1)))!=xA||rp&&Zl(new rp)!=mA||f1&&Zl(f1.resolve())!=gA||m1&&Zl(new m1)!=vA||u1&&Zl(new u1)!=yA)&&(Zl=function(e){var t=Oh(e),i=t==JH?e.constructor:void 0,r=i?Lh(i):"";if(r)switch(r){case $H:return xA;case eW:return mA;case tW:return gA;case iW:return vA;case rW:return yA}return t});var ap=Zl,aW=Object.prototype,sW=aW.hasOwnProperty;function nW(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&sW.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var oW=nW,lW=Js.Uint8Array,og=lW;function hW(e){var t=new e.constructor(e.byteLength);return new og(t).set(new og(e)),t}var Db=hW;function cW(e,t){var i=t?Db(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var uW=cW,dW=/\w*$/;function pW(e){var t=new e.constructor(e.source,dW.exec(e));return t.lastIndex=e.lastIndex,t}var fW=pW,bA=Ts?Ts.prototype:void 0,wA=bA?bA.valueOf:void 0;function mW(e){return wA?Object(wA.call(e)):{}}var gW=mW;function vW(e,t){var i=t?Db(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var yW=vW,xW="[object Boolean]",bW="[object Date]",wW="[object Map]",_W="[object Number]",SW="[object RegExp]",AW="[object Set]",EW="[object String]",MW="[object Symbol]",CW="[object ArrayBuffer]",TW="[object DataView]",PW="[object Float32Array]",DW="[object Float64Array]",RW="[object Int8Array]",OW="[object Int16Array]",LW="[object Int32Array]",IW="[object Uint8Array]",BW="[object Uint8ClampedArray]",UW="[object Uint16Array]",FW="[object Uint32Array]";function NW(e,t,i){var r=e.constructor;switch(t){case CW:return Db(e);case xW:case bW:return new r(+e);case TW:return uW(e,i);case PW:case DW:case RW:case OW:case LW:case IW:case BW:case UW:case FW:return yW(e,i);case wW:return new r;case _W:case EW:return new r(e);case SW:return fW(e);case AW:return new r;case MW:return gW(e)}}var zW=NW;function kW(e){return typeof e.constructor=="function"&&!_b(e)?r8(Tb(e)):{}}var VW=kW,jW="[object Map]";function GW(e){return Co(e)&&ap(e)==jW}var HW=GW,_A=uu&&uu.isMap,WW=_A?Ab(_A):HW,qW=WW,XW="[object Set]";function YW(e){return Co(e)&&ap(e)==XW}var QW=YW,SA=uu&&uu.isSet,KW=SA?Ab(SA):QW,ZW=KW,JW=1,$W=2,e9=4,FP="[object Arguments]",t9="[object Array]",i9="[object Boolean]",r9="[object Date]",a9="[object Error]",NP="[object Function]",s9="[object GeneratorFunction]",n9="[object Map]",o9="[object Number]",zP="[object Object]",l9="[object RegExp]",h9="[object Set]",c9="[object String]",u9="[object Symbol]",d9="[object WeakMap]",p9="[object ArrayBuffer]",f9="[object DataView]",m9="[object Float32Array]",g9="[object Float64Array]",v9="[object Int8Array]",y9="[object Int16Array]",x9="[object Int32Array]",b9="[object Uint8Array]",w9="[object Uint8ClampedArray]",_9="[object Uint16Array]",S9="[object Uint32Array]",Vi={};Vi[FP]=Vi[t9]=Vi[p9]=Vi[f9]=Vi[i9]=Vi[r9]=Vi[m9]=Vi[g9]=Vi[v9]=Vi[y9]=Vi[x9]=Vi[n9]=Vi[o9]=Vi[zP]=Vi[l9]=Vi[h9]=Vi[c9]=Vi[u9]=Vi[b9]=Vi[w9]=Vi[_9]=Vi[S9]=!0;Vi[a9]=Vi[NP]=Vi[d9]=!1;function Pm(e,t,i,r,a,s){var n,o=t&JW,l=t&$W,h=t&e9;if(i&&(n=a?i(e,r,a,s):i(e)),n!==void 0)return n;if(!Zs(e))return e;var c=On(e);if(c){if(n=oW(e),!o)return o8(e,n)}else{var u=ap(e),d=u==NP||u==s9;if(ng(e))return LH(e,o);if(u==zP||u==FP||d&&!a){if(n=l||d?{}:VW(e),!o)return l?WH(e,DH(n,e)):VH(e,TH(n,e))}else{if(!Vi[u])return a?e:{};n=zW(e,u,o)}}s||(s=new Tm);var p=s.get(e);if(p)return p;s.set(e,n),ZW(e)?e.forEach(function(g){n.add(Pm(g,t,i,g,e,s))}):qW(e)&&e.forEach(function(g,v){n.set(v,Pm(g,t,i,v,e,s))});var f=h?l?UP:d1:l?oh:Eb,m=c?void 0:f(e);return w8(m||e,function(g,v){m&&(v=g,g=e[v]),bb(n,v,Pm(g,t,i,v,e,s))}),n}var kP=Pm,A9=1,E9=4;function M9(e){return kP(e,A9|E9)}var sv=M9,C9="__lodash_hash_undefined__";function T9(e){return this.__data__.set(e,C9),this}var P9=T9;function D9(e){return this.__data__.has(e)}var R9=D9;function lg(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new rv;++t<i;)this.add(e[t])}lg.prototype.add=lg.prototype.push=P9;lg.prototype.has=R9;var O9=lg;function L9(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var I9=L9;function B9(e,t){return e.has(t)}var U9=B9,F9=1,N9=2;function z9(e,t,i,r,a,s){var n=i&F9,o=e.length,l=t.length;if(o!=l&&!(n&&l>o))return!1;var h=s.get(e),c=s.get(t);if(h&&c)return h==t&&c==e;var u=-1,d=!0,p=i&N9?new O9:void 0;for(s.set(e,t),s.set(t,e);++u<o;){var f=e[u],m=t[u];if(r)var g=n?r(m,f,u,t,e,s):r(f,m,u,e,t,s);if(g!==void 0){if(g)continue;d=!1;break}if(p){if(!I9(t,function(v,x){if(!U9(p,x)&&(f===v||a(f,v,i,r,s)))return p.push(x)})){d=!1;break}}else if(!(f===m||a(f,m,i,r,s))){d=!1;break}}return s.delete(e),s.delete(t),d}var VP=z9;function k9(e){var t=-1,i=Array(e.size);return e.forEach(function(r,a){i[++t]=[a,r]}),i}var V9=k9;function j9(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var G9=j9,H9=1,W9=2,q9="[object Boolean]",X9="[object Date]",Y9="[object Error]",Q9="[object Map]",K9="[object Number]",Z9="[object RegExp]",J9="[object Set]",$9="[object String]",e7="[object Symbol]",t7="[object ArrayBuffer]",i7="[object DataView]",AA=Ts?Ts.prototype:void 0,O0=AA?AA.valueOf:void 0;function r7(e,t,i,r,a,s,n){switch(i){case i7:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case t7:return!(e.byteLength!=t.byteLength||!s(new og(e),new og(t)));case q9:case X9:case K9:return xb(+e,+t);case Y9:return e.name==t.name&&e.message==t.message;case Z9:case $9:return e==t+"";case Q9:var o=V9;case J9:var l=r&H9;if(o||(o=G9),e.size!=t.size&&!l)return!1;var h=n.get(e);if(h)return h==t;r|=W9,n.set(e,t);var c=VP(o(e),o(t),r,a,s,n);return n.delete(e),c;case e7:if(O0)return O0.call(e)==O0.call(t)}return!1}var a7=r7,s7=1,n7=Object.prototype,o7=n7.hasOwnProperty;function l7(e,t,i,r,a,s){var n=i&s7,o=d1(e),l=o.length,h=d1(t),c=h.length;if(l!=c&&!n)return!1;for(var u=l;u--;){var d=o[u];if(!(n?d in t:o7.call(t,d)))return!1}var p=s.get(e),f=s.get(t);if(p&&f)return p==t&&f==e;var m=!0;s.set(e,t),s.set(t,e);for(var g=n;++u<l;){d=o[u];var v=e[d],x=t[d];if(r)var b=n?r(x,v,d,t,e,s):r(v,x,d,e,t,s);if(!(b===void 0?v===x||a(v,x,i,r,s):b)){m=!1;break}g||(g=d=="constructor")}if(m&&!g){var _=e.constructor,M=t.constructor;_!=M&&"constructor"in e&&"constructor"in t&&!(typeof _=="function"&&_ instanceof _&&typeof M=="function"&&M instanceof M)&&(m=!1)}return s.delete(e),s.delete(t),m}var h7=l7,c7=1,EA="[object Arguments]",MA="[object Array]",If="[object Object]",u7=Object.prototype,CA=u7.hasOwnProperty;function d7(e,t,i,r,a,s){var n=On(e),o=On(t),l=n?MA:ap(e),h=o?MA:ap(t);l=l==EA?If:l,h=h==EA?If:h;var c=l==If,u=h==If,d=l==h;if(d&&ng(e)){if(!ng(t))return!1;n=!0,c=!1}if(d&&!c)return s||(s=new Tm),n||EP(e)?VP(e,t,i,r,a,s):a7(e,t,l,i,r,a,s);if(!(i&c7)){var p=c&&CA.call(e,"__wrapped__"),f=u&&CA.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,g=f?t.value():t;return s||(s=new Tm),a(m,g,i,r,s)}}return d?(s||(s=new Tm),h7(e,t,i,r,a,s)):!1}var p7=d7;function jP(e,t,i,r,a){return e===t?!0:e==null||t==null||!Co(e)&&!Co(t)?e!==e&&t!==t:p7(e,t,i,r,jP,a)}var f7=jP;function m7(e,t){return e!=null&&t in Object(e)}var g7=m7;function v7(e,t,i){t=Lu(t,e);for(var r=-1,a=t.length,s=!1;++r<a;){var n=av(t[r]);if(!(s=e!=null&&i(e,n)))break;e=e[n]}return s||++r!=a?s:(a=e==null?0:e.length,!!a&&wb(a)&&yb(n,a)&&(On(e)||Sb(e)))}var y7=v7;function x7(e,t){return e!=null&&y7(e,t,g7)}var b7=x7,w7=function(){return Js.Date.now()},L0=w7,_7="Expected a function",S7=Math.max,A7=Math.min;function E7(e,t,i){var r,a,s,n,o,l,h=0,c=!1,u=!1,d=!0;if(typeof e!="function")throw new TypeError(_7);t=tA(t)||0,Zs(i)&&(c=!!i.leading,u="maxWait"in i,s=u?S7(tA(i.maxWait)||0,t):s,d="trailing"in i?!!i.trailing:d);function p(A){var S=r,P=a;return r=a=void 0,h=A,n=e.apply(P,S),n}function f(A){return h=A,o=setTimeout(v,t),c?p(A):n}function m(A){var S=A-l,P=A-h,L=t-S;return u?A7(L,s-P):L}function g(A){var S=A-l,P=A-h;return l===void 0||S>=t||S<0||u&&P>=s}function v(){var A=L0();if(g(A))return x(A);o=setTimeout(v,m(A))}function x(A){return o=void 0,d&&r?p(A):(r=a=void 0,n)}function b(){o!==void 0&&clearTimeout(o),h=0,r=l=a=o=void 0}function _(){return o===void 0?n:x(L0())}function M(){var A=L0(),S=g(A);if(r=arguments,a=this,l=A,S){if(o===void 0)return f(l);if(u)return clearTimeout(o),o=setTimeout(v,t),p(l)}return o===void 0&&(o=setTimeout(v,t)),n}return M.cancel=b,M.flush=_,M}var Rb=E7;function M7(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var C7=M7;function T7(e,t){return t.length<2?e:TP(e,mH(t,0,-1))}var P7=T7;function D7(e,t){return f7(e,t)}var GP=D7;function R7(e,t){return t=Lu(t,e),e=P7(e,t),e==null||delete e[av(C7(t))]}var O7=R7;function L7(e){return pH(e)?void 0:e}var I7=L7,B7=1,U7=2,F7=4,N7=DP(function(e,t){var i={};if(e==null)return i;var r=!1;t=vP(t,function(s){return s=Lu(s,e),r||(r=s.length>1),s}),Ap(e,UP(e),i),r&&(i=kP(i,B7|U7|F7,I7));for(var a=t.length;a--;)O7(i,t[a]);return i}),g1=N7;function z7(e,t,i,r){if(!Zs(e))return e;t=Lu(t,e);for(var a=-1,s=t.length,n=s-1,o=e;o!=null&&++a<s;){var l=av(t[a]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(a!=n){var c=o[l];h=r?r(c,l,o):void 0,h===void 0&&(h=Zs(c)?c:yb(t[a+1])?[]:{})}bb(o,l,h),o=o[l]}return e}var k7=z7;function V7(e,t,i){for(var r=-1,a=t.length,s={};++r<a;){var n=t[r],o=TP(e,n);i(o,n)&&k7(s,Lu(n,e),o)}return s}var j7=V7;function G7(e,t){return j7(e,t,function(i,r){return b7(e,r)})}var H7=G7,W7=DP(function(e,t){return e==null?{}:H7(e,t)}),Ao=W7,q7="Expected a function";function X7(e,t,i){var r=!0,a=!0;if(typeof e!="function")throw new TypeError(q7);return Zs(i)&&(r="leading"in i?!!i.leading:r,a="trailing"in i?!!i.trailing:a),Rb(e,t,{leading:r,maxWait:t,trailing:a})}var Y7=X7;function HP(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Ln(e,t){return Object.setPrototypeOf(e,t),e}var Q7=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),K7=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),Z7=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||nv&&"ontouchend"in document,J7=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,$7=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,eq=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},tq=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},iq=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},rq=Q7(),yse=rq?iq():void 0,nv=K7(),Ob=Z7(),aq=J7(),rs=$7(),TA=eq(),PA=Number(tq());function WP(e){return Array.isArray(e)?e:[e]}function qP(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function Bf(e){return nv?e.metaKey:e.ctrlKey}function sq(e){return e.wheelDeltaY===0||e.deltaY===0?nv&&e.shiftKey&&Math.abs(e.wheelDeltaX)>=120?!1:e.wheelDeltaX?e.wheelDeltaX===-3*e.deltaX||e.wheelDeltaX===-3*window.devicePixelRatio*e.deltaX:e.deltaMode===0:e.wheelDeltaY?e.wheelDeltaY===-3*e.deltaY||e.wheelDeltaY===-3*window.devicePixelRatio*e.deltaY:e.deltaMode===0}var Lt=[],hg={},Dd={},Dm={};function XP(e){Lt.includes(e)||Lt.push(e)}function Kc(e){delete hg[e.pointerId];for(let t=0;t<Lt.length;t++)if(Lt[t].pointerId===e.pointerId){Lt.splice(t,1);break}}function nq(){Lt.splice(0,Lt.length)}function cg(e){if(e.pointerType!=="touch")return;let t=hg[e.pointerId];t===void 0&&(t={x:0,y:0},hg[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function I0(e){let t=e.pointerId===Lt[0].pointerId?Lt[1]:Lt[0];return hg[t.pointerId]}function YP(e){Dd[e.key]=!0,Dm[e.key]=Dm[e.key]===void 0?1:Dm[e.key]+1}function QP(e){if(nv&&Dd.Meta)for(let t in Dd)Dd[t]=!1;else Dd[e.key]=!1;Dm={}}function oq(e){e.addEventListener("pointerdown",XP,!0),e.addEventListener("pointerdown",cg,!0),e.addEventListener("pointermove",cg,!0),e.addEventListener("pointerup",Kc,!0),e.addEventListener("pointercancel",Kc,!0),e.addEventListener("pointerleave",Kc,!0),window.addEventListener("keydown",YP,!0),window.addEventListener("keyup",QP,!0)}function lq(e){e.removeEventListener("pointerdown",XP,!0),e.removeEventListener("pointerdown",cg,!0),e.removeEventListener("pointermove",cg,!0),e.removeEventListener("pointerup",Kc,!0),e.removeEventListener("pointercancel",Kc,!0),e.removeEventListener("pointerleave",Kc,!0),window.removeEventListener("keydown",YP,!0),window.removeEventListener("keyup",QP,!0)}var KP,hq=new Promise(e=>{KP=e}),Uf;function cq(){if(Uf)return Uf;async function e(){let t="https://unpkg.com/@splinetool/navmesh-wasm@1.0.84/build",i=import("./navmesh.js"),[r,a]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),s=r.default,n=await s({wasmBinary:a});KP(n)}return Uf=e(),Uf}var ZP,uq=new Promise(e=>{ZP=e}),Ff;function dq(){if(Ff)return Ff;async function e(){let t=await import("./physics.js");await t.init(),ZP(t)}return Ff=e(),Ff}var Vt=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,Vt.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:a,data:s}=e,n={...t,[a]:s};return Object.setPrototypeOf(n,Vt.prototype),{data:n,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let a={...t};return Object.setPrototypeOf(a,Vt.prototype),delete a[i],{data:a,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function Lb(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&Lb(r)}return Object.freeze(e)}function pq(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var JP=class extends Error{};function B0(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function ul(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let s=e;e=t,t=s}let r=[],a=1/(i+1);for(let s=0;s<i;s++){let n=e+(t-e)*(s+.75+Math.random()*.5)*a;r.push(n)}return r}function Ib(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function fq(){return typeof process<"u"}function $P(e,t){for(let i of e)t(i.id,i.data)!==!0&&$P(i.children,t)}function e3(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)e3(i,t)}var oa=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,oa.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Lb(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&e3(i,t)}}traverse(e){$P(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),a=r.findIndex(n=>n.id===e);if(a<0)throw new Error("not expected");let s=r[a];return r=[...r],r[a]={...s,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let s=r,n=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===n);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:s}}Object.setPrototypeOf(r,oa.prototype);let a=r;return a.fillCaches(),a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:a,children:s}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let n=t,o=this.childrenArray(n),l={fi:i,id:r,data:a,children:s};return o=[...o,l],o.sort((h,c)=>h.fi-c.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(n,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),a=r.findIndex(n=>n.id===t);e.localIndex=a,r=[...r];let s=r.splice(a,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...s,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let u=t;for(;u!==null;){if(u===void 0)throw new Error;if(u===r)throw new JP("cyclic tree");u=this.parent(u)}}let a=this.parent(r);if(a===void 0)return null;let s=a,n=this.childrenArray(a),o=n.findIndex(u=>u.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(a,n);a=t,n=h.childrenArray(a);let c=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((u,d)=>u.fi-d.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(a,n),{data:h,actual:e,reverse:{type:9,parent:s,fi:c,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(a=>a.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(a=>a.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>pq(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),a=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...a,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return ul(0,i,i);{let a=r[0].fi;return ul(a-i,a,i)}}else{let a=this.get(t);if(a===void 0||this.parent(t)!==e)throw new Error("illegal args");let s=r.find(n=>n.fi>a.fi);if(s===void 0){let n=r[r.length-1].fi;return ul(n,n+i,i)}else return ul(a.fi,s.fi,i)}}},ug;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let a=r.props,s={},n=[...i],o=!1;if(a)for(let l of Object.keys(a)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");s[l]=n[h],n[h]=a[l],o=!0}return o?{data:n,actual:r,reverse:{type:0,props:s}}:null}else{let a=r.props,s={},n={...i},o=!1;if(a)for(let l of Object.keys(a)){s[l]=n[l];let h=a[l];h===void 0?delete n[l]:n[l]=h,o=!0}return o?{data:n,actual:r,reverse:{type:0,props:s}}:null}}e.runOp=t})(ug||(ug={}));var Tt=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Tt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Lb(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(s=>s.id===e);if(r<0)throw new Error("not expected");let a=i[r];return i=[...i],i[r]={...a,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,Tt.prototype);let t=e;return fq()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,a=this,s={fi:t,id:i,data:r};return a=[...a,s],a.sort((n,o)=>n.fi-o.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(s=>s.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let a=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let a=r.findIndex(o=>o.id===i);if(a===-1)return null;let s=r[a].fi,n={...r[a],fi:t};return r[a]=n,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(n),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:s,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return ul(0,t,t);{let r=i[0].fi;return ul(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let a=i.find(s=>s.fi>r.fi);if(a===void 0){let s=i[i.length-1].fi;return ul(s,s+t,t)}else return ul(r.fi,a.fi,t)}}};function du(e){return e&&typeof e=="object"&&e instanceof Tr}var Tr=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,a={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!du(i))return null;r+=1}i=i?B0(i):new Tr;for(let[o,l]of Object.entries(e.props)){let h=i[o];a[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=B0(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=B0(o);l[e.path[r-1]]=i,i=l}else{let l=new Tr;l[e.path[r-1]]=i,i=l}}r-=1}let s=Object.setPrototypeOf(i,Tr.prototype),n={...e,props:a};return{data:s,actual:e,reverse:n}}},_l;(e=>{function t(a,s){return sp(a,s)??a}e.apply=t;function i(a,s){return Ub(a,s)}e.merge=i;function r(a,s){let n=0,o=s.path,l=a;for(;n<o.length&&l!==void 0;){if(l=na.zoomOnce(l,o[n]),l===void 0)return s;if(!du(l))return;n+=1}if(l===void 0)return s;if(du(l))if(s.type===0){let h={...s.props};for(let c of Object.keys(l))delete h[c];return{...s,props:h}}else if(s.type===1||s.type===4||s.type===7){let h=Bb([s],l);return h?(console.log(h),h):s}else return s}e.filterOp=r})(_l||(_l={}));function Bb(e,t){if(t===void 0)return;let i=!1,r=e.map(a=>{let s=a.id,n=sp(a.data,t[s]);if(i=i||n!==void 0,n===void 0&&(n=a.data),a.children){let o=Bb(a.children,t);return o!==void 0?i=!0:o=a.children,{...a,id:s,data:n,children:o}}else return{...a,id:s,data:n}});if(i)return r}function mq(e,t){if(t===void 0)return;let i=!1,r=e.map(a=>{let s=a.id,n=sp(a.data,t[s]);return i=i||n!==void 0,n===void 0&&(n=a.data),{...a,id:s,data:n}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function sp(e,t){if(!du(t))return t;if(e instanceof oa){let i=Bb(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof Tt)return mq(e,t);if(Array.isArray(e)){let i=!1,r=e.map((a,s)=>{let n=sp(a,t[s]);return i=i||n!==void 0,n===void 0&&(n=a),n});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof Tr)return Ub(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[a,s]of Object.entries(e)){let n=sp(s,t[a]);r=r||n!==void 0,n===void 0&&(n=s),i[a]=n}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function Ub(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!du(t))return t;if(!du(e))return _l.apply(e,t);let i=new Set;for(let a of Object.keys(e))i.add(a);for(let a of Object.keys(t))i.add(a);let r=new Tr;for(let a of i){let s=Ub(e===void 0?void 0:e[a],t===void 0?void 0:t[a]);r[a]=s}return r}function gq(e,t){let i={cur:[],result:[],len:0};return e=np(e,t,i)??e,[e,i.result]}function dg(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function pg(e){e&&(e.len-=1)}function vq(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function t3(e,t,i){let r=!1,a=e.map(s=>{let n=s.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=np(s.data,t,dg(i,n));pg(i),r=r||l!==void 0,l===void 0&&(l=s.data);let h=t3(s.children,t,i);return h!==void 0?r=!0:h=s.children,{...s,id:n,data:l,children:h}});if(r)return a}function yq(e,t,i){let r=!1,a=e.map(s=>{let n=s.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=np(s.data,t,dg(i,n));return pg(i),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:n,data:l}});if(r)return Object.setPrototypeOf(a,Object.getPrototypeOf(e)),a}function np(e,t,i){if(e instanceof oa){let r=t3(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof Tt)return yq(e,t,i);if(Array.isArray(e)){let r=!1,a=e.map((s,n)=>{let o=np(s,t,dg(i,n));return pg(i),r=r||o!==void 0,o===void 0&&(o=s),o});return r?(Object.setPrototypeOf(a,Object.getPrototypeOf(e)),a):void 0}else if(e&&typeof e=="object"&&!Ib(e)){let r={},a=!1;for(let[s,n]of Object.entries(e))if(s!=="name"){let o=t[s];if(typeof o=="string"){if(i!==null)throw new Error("not supported");a=!0,s=o}let l=np(n,t,dg(i,s));pg(i),a=a||l!==void 0,l===void 0&&(l=n),r[s]=l}else r[s]=n;return a?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&vq(i),r}else return}}var fg;(e=>{function t(i,r){let a=na.zoom(r,i.path);if(typeof a=="object"){let s={};for(let n of Object.keys(i.props))s[n]=a[n];return{...i,props:s}}else return{...i,props:{}}}e.replaceProps=t})(fg||(fg={}));var Zr;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let c=h.path;for(var u=[];;){let d;if(l instanceof Tr&&h.type===0&&(d=l.runOp({...h,path:c.slice(u.length)}),d===null&&(d=void 0)),d===void 0&&u.length===c.length&&(l instanceof oa||l instanceof Tt||l instanceof Vt?d=l.runOp(h):d=ug.runOp(l,h)),d!==void 0)if(d!==null){let m=d.data;for(let g=u.length-1;g>=0;g--){let v=c[g],x=u[g];if(x instanceof oa){if(typeof v=="number")throw new Error("illegal arg");m=x.modifyById(v,m)}else if(x instanceof Tt){if(typeof v=="number")throw new Error("illegal arg");m=x.modifyById(v,m)}else if(x instanceof Vt){if(typeof v=="number")throw new Error("illegal arg");m=x.modifyById(v,m)}else if(x instanceof Tr){let b={...x,[v]:m};m=Object.setPrototypeOf(b,Tr.prototype)}else if(typeof x=="object")if(Array.isArray(x)){if(typeof v=="string"&&(v=parseInt(v),isNaN(v)))throw new Error("Invalid path");let b=m;m=[...x],m[v]=b}else m={...x,[v]:m};else return null}return{data:m,actual:{...d.actual,path:c},reverse:{...d.reverse,path:c}}}else return null;let p=c[u.length],f;if(l instanceof oa){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof Tt){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else l!==null&&(f=l[p]);if(f!==void 0)u.push(l),l=f;else return null}}e.apply=r;function a(l,h){for(let c=0;c<l.length&&c<h.length;c++)if(l[c]!==h[c])return!0;return!1}e.pathDisjoint=a;function s(l,h){if(l.length!==h.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==h[c])return!1;return!0}e.pathEq=s;function n(l,h){return a(l.path,h.path)}e.commutative=n;function o(l,h){return l.type===0&&h.type===0&&s(l.path,h.path)?Object.keys(l.props).every(c=>h.props[c]!==void 0):!1}e.subsumed=o})(Zr||(Zr={}));var v1;(e=>{function t(){return[]}e.empty=t;function i(h,c){let u=[];for(let d of h){let[p,...f]=d.path;p===c&&u.push({...d,path:f})}return u}e.removePrefix=i;function r(h,c){return h.map(u=>({...u,path:[c,...u.path]}))}e.addPrefix=r;function a(h,c){return[...h,...c]}e.concat=a;function s(h,c){return[...h.filter(u=>!c.some(d=>Zr.subsumed(u,d))),...c]}e.compress=s;function n(h,c){return h.every(u=>c.every(d=>Zr.commutative(u,d)))}e.commutative=n;function o(h,c){for(let u of c){let d=l(h,u);d!==null&&(h=d.data)}return h}e.applyAll=o;function l(h,c){var u=h;let d=[],p=[];for(let f of c)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let m,g,v;if(f.type===3?(m=na.zoom(u,[...f.path,f.id]),v=Zr.apply(u,{...f,type:2})):(m=na.zoom(u,[...f.path,f.id,"value"]),v=Zr.apply(u,f)),v!==null){u=v.data;let[x,b]=gq(u,{[f.id]:m});u=x;for(let _=0;_<b.length;_++){let M=b[_],A=M.pop();if(typeof A=="number"){let S=[A];for(let L=_+1;L<b.length;L++){let E=b[L],T=E[E.length-1];if(typeof T=="number"&&na.equal(M,E.slice(0,E.length-1)))S.push(T),b.splice(L,1);else break}let P=na.zoom(u,M);g=P.map((L,E)=>S.includes(E)?f.id:L),m=P,A=M.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let S=m,P=na.zoom(u,M.slice(0,M.length-2)),L=P.layers.map(E=>E.id===M[M.length-1]?{...E,data:{...E.data,[A]:S}}:E);Object.setPrototypeOf(L,Object.getPrototypeOf(P.layers)),P.layers=L}g=f.id}d.push({type:0,path:M,props:{[A]:m}}),p.push({type:0,path:M,props:{[A]:g}})}p.push(v.reverse),d.push(v.actual)}}else{let m=Zr.apply(u,f);m!==null&&(d.push(m.actual),u=m.data,p.push(m.reverse))}}catch(m){if(m instanceof JP)return null;throw m}return{data:u,actual:d,reverse:p.reverse()}}e.apply=l})(v1||(v1={}));var i3=Symbol(),xq=Symbol(),ov=Symbol(),Ep=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let a=i;for(;!(r instanceof a3);){let s=r._path,n=r._current;if(s!==""&&a.splice(0,0,s),r=r._parent,r===null)return;r.update(s,n)}r.push(a,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[ov];i&&i(),delete this._children[e]}}}},bq=class extends Ep{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,ug.runOp(this._current,e),e.path)}},wq=class extends Ep{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,Vt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},r3={get(e,t){if(t===ov)return()=>{e._parent=null};if(t===i3)return e._current;if(t===xq)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let a=r===void 0?void 0:r[t];if(a!==void 0)return a;let s=i[t],n=lv(e,t,s);return n!==s?(r===void 0&&(r={},e._children=r),r[t]=n,n):s},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},_q={...r3,set(e,t,i){let r={type:0,props:{[t]:Pr(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},Sq={...r3,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},Fb=class extends Ep{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[ov]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let a=t.get(e)?.data,s=lv(this,e,a);return s!==a?(i===void 0&&(i={},this._children=i),i[e]=s,s):a}add(e,t,i,r,a){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:a})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.add(e,r[a],s.id,s.data,s.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.add(e,r[a],s.id,s.data,s.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.move(e,r[a],s)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.move(e,r[a],s)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Nb=class extends Ep{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[ov]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,a=this._current[i].fi;e(this.data(this._current[i].id),r,a)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let a=t.get(e)?.data,s=lv(this,e,a);return s!==a?(i===void 0&&(i={},this._children=i),i[e]=s,s):a}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.add(i[r],a.id,a.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.add(i[r],a.id,a.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.move(i[r],a)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.move(i[r],a)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function U0(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&na.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var a3=class extends Ep{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){U0(this.ts,t,e),U0(this.actual,i,e),U0(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function lv(e,t,i){return i instanceof oa?new Fb(e,t,i):i instanceof Tt?new Nb(e,t,i):i instanceof Vt?new Proxy(new wq(e,t,i),Sq):i!==null&&typeof i=="object"?Ib(i)?i:new Proxy(new bq(e,t,i),_q):i}function s3(e){let t=new a3(e);return[lv(t,"",e),t]}function op(e,t){let[i,r]=s3(e);return t(i),r.result()}function Pr(e){return e instanceof Fb||e instanceof Nb?e._current:e!==null&&typeof e=="object"?e[i3]:e}var na;(e=>{function t(s,n){if(n.length===s.length)for(var o=0;o<s.length;){if(s[o]!==n[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(s,n,o){let l=a(o,s);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...n};return Object.keys(l).forEach(c=>{delete h[c]}),h}else return n}e.removeOverridden=i;function r(s,n){if((s instanceof oa||s instanceof Fb)&&typeof n=="string"||(s instanceof Tt||s instanceof Nb)&&typeof n=="string")return s.data(n);if(typeof n=="number"&&Array.isArray(s)||typeof n=="string"&&typeof s=="object"&&s!==null)return s[n]}e.zoomOnce=r;function a(s,n,o=0){for(;o<n.length&&s!==void 0;)s=r(s,n[o]),o+=1;return s}e.zoom=a})(na||(na={}));function Aq(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function Fi(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var n3=class{},DA=class extends n3{constructor(e){super(),this.id=e}},RA=class extends n3{constructor(e){super(),this.data=e}},y1;try{y1=new TextDecoder}catch{}var ft,Sl,we=0,o3=[],x1=o3,b1=0,qa={},yi,dl,bs=0,Sn=0,es,Eo,Ua=[],Ei,OA={useRecords:!1,mapsAsObjects:!0},l3=class{},h3=new l3;h3.name="MessagePack 0xC1";var pu=!1,mg=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(ft)return m3(()=>(_1(),this?this.unpack(e,t):mg.prototype.unpack.call(OA,e,t)));Sl=t>-1?t:e.length,we=0,b1=0,Sn=0,dl=null,x1=o3,es=null,ft=e;try{Ei=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw ft=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof mg){if(qa=this,this.structures)return yi=this.structures,Nf();(!yi||yi.length>0)&&(yi=[])}else qa=OA,(!yi||yi.length>0)&&(yi=[]);return Nf()}unpackMultiple(e,t){let i,r=0;try{pu=!0;let a=e.length,s=this?this.unpack(e,a):cv.unpack(e,a);if(t){for(t(s);we<a;)if(r=we,t(Nf())===!1)return}else{for(i=[s];we<a;)r=we,i.push(Nf());return i}}catch(a){throw a.lastPosition=r,a.values=i,a}finally{pu=!1,_1()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let a=e[i];a&&(a.isShared=!0,i>=32&&(a.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],a=t[i];a&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=a)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Nf(){try{if(!qa.trusted&&!pu){let t=yi.sharedLength||0;t<yi.length&&(yi.length=t)}let e=cr();if(we==Sl)yi.restoreStructures&&LA(),yi=null,ft=null,Eo&&(Eo=null);else if(we>Sl){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!pu)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw yi.restoreStructures&&LA(),_1(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function LA(){for(let e in yi.restoreStructures)yi[e]=yi.restoreStructures[e];yi.restoreStructures=null}function cr(){let e=ft[we++];if(e<160)if(e<128){if(e<64)return e;{let t=yi[e&63]||qa.getStructures&&c3()[e&63];return t?(t.read||(t.read=zb(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,qa.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[d3()]=cr();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(cr(),cr());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=cr();return t}else if(e<192){let t=e-160;if(Sn>=we)return dl.slice(we-bs,(we+=t)-bs);if(Sn==0&&Sl<140){let i=t<16?kb(t):u3(t);if(i!=null)return i}return w1(t)}else{let t;switch(e){case 192:return null;case 193:return es?(t=cr(),t>0?es[1].slice(es.position1,es.position1+=t):es[0].slice(es.position0,es.position0-=t)):h3;case 194:return!1;case 195:return!0;case 196:return F0(ft[we++]);case 197:return t=Ei.getUint16(we),we+=2,F0(t);case 198:return t=Ei.getUint32(we),we+=4,F0(t);case 199:return ql(ft[we++]);case 200:return t=Ei.getUint16(we),we+=2,ql(t);case 201:return t=Ei.getUint32(we),we+=4,ql(t);case 202:if(t=Ei.getFloat32(we),qa.useFloat32>2){let i=Vb[(ft[we]&127)<<1|ft[we+1]>>7];return we+=4,(i*t+(t>0?.5:-.5)>>0)/i}return we+=4,t;case 203:return t=Ei.getFloat64(we),we+=8,t;case 204:return ft[we++];case 205:return t=Ei.getUint16(we),we+=2,t;case 206:return t=Ei.getUint32(we),we+=4,t;case 207:return qa.int64AsNumber?(t=Ei.getUint32(we)*4294967296,t+=Ei.getUint32(we+4)):t=Ei.getBigUint64(we),we+=8,t;case 208:return Ei.getInt8(we++);case 209:return t=Ei.getInt16(we),we+=2,t;case 210:return t=Ei.getInt32(we),we+=4,t;case 211:return qa.int64AsNumber?(t=Ei.getInt32(we)*4294967296,t+=Ei.getUint32(we+4)):t=Ei.getBigInt64(we),we+=8,t;case 212:if(t=ft[we++],t==114)return NA(ft[we++]&63);{let i=Ua[t];if(i)return i.read?(we++,i.read(cr())):i.noBuffer?(we++,i()):i(ft.subarray(we,++we));throw new Error("Unknown extension "+t)}case 213:return t=ft[we],t==114?(we++,NA(ft[we++]&63,ft[we++])):ql(2);case 214:return ql(4);case 215:return ql(8);case 216:return ql(16);case 217:return t=ft[we++],Sn>=we?dl.slice(we-bs,(we+=t)-bs):Mq(t);case 218:return t=Ei.getUint16(we),we+=2,Sn>=we?dl.slice(we-bs,(we+=t)-bs):Cq(t);case 219:return t=Ei.getUint32(we),we+=4,Sn>=we?dl.slice(we-bs,(we+=t)-bs):Tq(t);case 220:return t=Ei.getUint16(we),we+=2,BA(t);case 221:return t=Ei.getUint32(we),we+=4,BA(t);case 222:return t=Ei.getUint16(we),we+=2,UA(t);case 223:return t=Ei.getUint32(we),we+=4,UA(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var Eq=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function zb(e,t){function i(){if(i.count++>2){let a=e.read=new Function("r","return function(){return {"+e.map(s=>Eq.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(cr);return e.highByte===0&&(e.read=IA(t,e.read)),a()}let r={};for(let a=0,s=e.length;a<s;a++){let n=e[a];r[n]=cr()}return r}return i.count=0,e.highByte===0?IA(t,i):i}var IA=(e,t)=>function(){let i=ft[we++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),a=yi[r]||c3()[r];if(!a)throw new Error("Record id is not defined for "+r);return a.read||(a.read=zb(a,e)),a.read()};function c3(){let e=m3(()=>(ft=null,qa.getStructures()));return yi=qa._mergeStructures(e,yi)}var w1=hv,Mq=hv,Cq=hv,Tq=hv;function hv(e){let t;if(e<16&&(t=kb(e)))return t;if(e>64&&y1)return y1.decode(ft.subarray(we,we+=e));let i=we+e,r=[];for(t="";we<i;){let a=ft[we++];if((a&128)===0)r.push(a);else if((a&224)===192){let s=ft[we++]&63;r.push((a&31)<<6|s)}else if((a&240)===224){let s=ft[we++]&63,n=ft[we++]&63;r.push((a&31)<<12|s<<6|n)}else if((a&248)===240){let s=ft[we++]&63,n=ft[we++]&63,o=ft[we++]&63,l=(a&7)<<18|s<<12|n<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(a);r.length>=4096&&(t+=Wr.apply(String,r),r.length=0)}return r.length>0&&(t+=Wr.apply(String,r)),t}function BA(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=cr();return t}function UA(e){if(qa.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[d3()]=cr();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(cr(),cr());return t}}var Wr=String.fromCharCode;function u3(e){let t=we,i=new Array(e);for(let r=0;r<e;r++){let a=ft[we++];if((a&128)>0){we=t;return}i[r]=a}return Wr.apply(String,i)}function kb(e){if(e<4)if(e<2){if(e===0)return"";{let t=ft[we++];if((t&128)>1){we-=1;return}return Wr(t)}}else{let t=ft[we++],i=ft[we++];if((t&128)>0||(i&128)>0){we-=2;return}if(e<3)return Wr(t,i);let r=ft[we++];if((r&128)>0){we-=3;return}return Wr(t,i,r)}else{let t=ft[we++],i=ft[we++],r=ft[we++],a=ft[we++];if((t&128)>0||(i&128)>0||(r&128)>0||(a&128)>0){we-=4;return}if(e<6){if(e===4)return Wr(t,i,r,a);{let s=ft[we++];if((s&128)>0){we-=5;return}return Wr(t,i,r,a,s)}}else if(e<8){let s=ft[we++],n=ft[we++];if((s&128)>0||(n&128)>0){we-=6;return}if(e<7)return Wr(t,i,r,a,s,n);let o=ft[we++];if((o&128)>0){we-=7;return}return Wr(t,i,r,a,s,n,o)}else{let s=ft[we++],n=ft[we++],o=ft[we++],l=ft[we++];if((s&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){we-=8;return}if(e<10){if(e===8)return Wr(t,i,r,a,s,n,o,l);{let h=ft[we++];if((h&128)>0){we-=9;return}return Wr(t,i,r,a,s,n,o,l,h)}}else if(e<12){let h=ft[we++],c=ft[we++];if((h&128)>0||(c&128)>0){we-=10;return}if(e<11)return Wr(t,i,r,a,s,n,o,l,h,c);let u=ft[we++];if((u&128)>0){we-=11;return}return Wr(t,i,r,a,s,n,o,l,h,c,u)}else{let h=ft[we++],c=ft[we++],u=ft[we++],d=ft[we++];if((h&128)>0||(c&128)>0||(u&128)>0||(d&128)>0){we-=12;return}if(e<14){if(e===12)return Wr(t,i,r,a,s,n,o,l,h,c,u,d);{let p=ft[we++];if((p&128)>0){we-=13;return}return Wr(t,i,r,a,s,n,o,l,h,c,u,d,p)}}else{let p=ft[we++],f=ft[we++];if((p&128)>0||(f&128)>0){we-=14;return}if(e<15)return Wr(t,i,r,a,s,n,o,l,h,c,u,d,p,f);let m=ft[we++];if((m&128)>0){we-=15;return}return Wr(t,i,r,a,s,n,o,l,h,c,u,d,p,f,m)}}}}}function F0(e){return qa.copyBuffers?Uint8Array.prototype.slice.call(ft,we,we+=e):ft.subarray(we,we+=e)}function ql(e){let t=ft[we++];if(Ua[t])return Ua[t](ft.subarray(we,we+=e));throw new Error("Unknown extension type "+t)}var FA=new Array(4096);function d3(){let e=ft[we++];if(e>=160&&e<192){if(e=e-160,Sn>=we)return dl.slice(we-bs,(we+=e)-bs);if(!(Sn==0&&Sl<180))return w1(e)}else return we--,cr();let t=(e<<5^(e>1?Ei.getUint16(we):e>0?ft[we]:0))&4095,i=FA[t],r=we,a=we+e-3,s,n=0;if(i&&i.bytes==e){for(;r<a;){if(s=Ei.getUint32(r),s!=i[n++]){r=1879048192;break}r+=4}for(a+=3;r<a;)if(s=ft[r++],s!=i[n++]){r=1879048192;break}if(r===a)return we=r,i.string;a-=3,r=we}for(i=[],FA[t]=i,i.bytes=e;r<a;)s=Ei.getUint32(r),i.push(s),r+=4;for(a+=3;r<a;)s=ft[r++],i.push(s);let o=e<16?kb(e):u3(e);return o!=null?i.string=o:i.string=w1(e)}var NA=(e,t)=>{var i=cr();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let a=yi[e];return a&&a.isShared&&((yi.restoreStructures||(yi.restoreStructures=[]))[e]=a),yi[e]=i,i.read=zb(i,r),i.read()},p3=typeof self=="object"?self:global;Ua[0]=()=>{};Ua[0].noBuffer=!0;Ua[101]=()=>{let e=cr();return(p3[e[0]]||Error)(e[1])};Ua[105]=e=>{let t=Ei.getUint32(we-4);Eo||(Eo=new Map);let i=ft[we],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let a={target:r};Eo.set(t,a);let s=cr();return a.used?Object.assign(r,s):(a.target=s,s)};Ua[112]=e=>{let t=Ei.getUint32(we-4),i=Eo.get(t);return i.used=!0,i.target};Ua[115]=()=>new Set(cr());var f3=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Ua[116]=e=>{let t=e[0],i=f3[t];if(!i)throw new Error("Could not find typed array for code "+t);return new p3[i](Uint8Array.prototype.slice.call(e,1).buffer)};Ua[120]=()=>{let e=cr();return new RegExp(e[0],e[1])};Ua[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=we;we+=t-4,es=[cr(),cr()],es.position0=0,es.position1=0;let r=we;we=i;try{return cr()}finally{we=r}};Ua[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function m3(e){let t=Sl,i=we,r=b1,a=bs,s=Sn,n=dl,o=x1,l=Eo,h=es,c=new Uint8Array(ft.slice(0,Sl)),u=yi,d=yi.slice(0,yi.length),p=qa,f=pu,m=e();return Sl=t,we=i,b1=r,bs=a,Sn=s,dl=n,x1=o,Eo=l,es=h,ft=c,pu=f,yi=u,yi.splice(0,yi.length,...d),qa=p,Ei=new DataView(ft.buffer,ft.byteOffset,ft.byteLength),m}function _1(){ft=null,Eo=null,yi=null}function Pq(e){e.unpack?Ua[e.type]=e.unpack:Ua[e.type]=e}var Vb=new Array(147);for(let e=0;e<256;e++)Vb[e]=+("1e"+Math.floor(45.15-e*.30103));var cv=new mg({useRecords:!1}),xse=cv.unpack,bse=cv.unpackMultiple,wse=cv.unpack,Dq={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Rq=new Float32Array(1),_se=new Uint8Array(Rq.buffer,0,4),Rm;try{Rm=new TextEncoder}catch{}var gg,jb,uv=typeof Buffer<"u",N0=uv?Buffer.allocUnsafeSlow:Uint8Array,g3=uv?Buffer:Uint8Array,zA=uv?4294967296:2144337920,Ne,gr,Te=0,on,ln=null,Oq=/[\u0080-\uFFFF]/,ud=Symbol("record-id"),v3=class extends mg{constructor(e){super(e),this.offset=0;let t,i,r,a,s,n,o=0,l=g3.prototype.utf8Write?function(S,P,L){return Ne.utf8Write(S,P,L)}:Rm&&Rm.encodeInto?function(S,P){return Rm.encodeInto(S,Ne.subarray(P)).written}:!1,h=this;e||(e={});let c=e&&e.sequential,u=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=u?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=u?32:64),c&&!e.saveStructures&&(this.structures=[]);let f=d>32||p+d>64,m=d+64,g=d+p+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,b=0;this.pack=this.encode=function(S,P){if(Ne||(Ne=new N0(8192),gr=new DataView(Ne.buffer,0,8192),Te=0),on=Ne.length-10,on-Te<2048?(Ne=new N0(Ne.length),gr=new DataView(Ne.buffer,0,Ne.length),on=Ne.length-10,Te=0):Te=Te+7&2147483640,i=Te,n=h.structuredClone?new Map:null,h.bundleStrings?(ln=["",""],Ne[Te++]=214,Ne[Te++]=98,ln.position=Te-i,Te+=4):ln=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let L=r.sharedLength||0;if(L>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let E=0;E<L;E++){let T=r[E];if(!T)continue;let B,V=r.transitions;for(let I=0,H=T.length;I<H;I++){let q=T[I];B=V[q],B||(B=V[q]=Object.create(null)),V=B}V[ud]=E+64}o=L}c||(r.nextId=L+64)}a&&(a=!1),s=r||[];try{if(_(S),ln){gr.setUint32(ln.position+i,Te-ln.position-i);let L=ln;ln=null,_(L[0]),_(L[1])}if(h.offset=Te,n&&n.idsToInsert){Te+=n.idsToInsert.length*6,Te>on&&A(Te),h.offset=Te;let L=Iq(Ne.subarray(i,Te),n.idsToInsert);return n=null,L}return P&Bq?(Ne.start=i,Ne.end=Te,Ne):Ne.subarray(i,Te)}finally{if(r){if(b<10&&b++,x>1e4)r.transitions=null,b=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!c){for(let L=0,E=v.length;L<E;L++)v[L][ud]=0;v=[]}if(a&&h.saveStructures){let L=r.sharedLength||d;r.length>L&&(r=r.slice(0,L));let E=Ne.subarray(i,Te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(S)):(o=L,E)}}P&Uq&&(Te=i)}};let _=S=>{Te>on&&(Ne=A(Te));var P=typeof S,L;if(P==="string"){let E=S.length;if(ln&&E>=8&&E<4096){let V=Oq.test(S);ln[V?0:1]+=S,Ne[Te++]=193,_(V?-E:E);return}let T;E<32?T=1:E<256?T=2:E<65536?T=3:T=5;let B=E*3;if(Te+B>on&&(Ne=A(Te+B)),E<64||!l){let V,I,H,q=Te+T;for(V=0;V<E;V++)I=S.charCodeAt(V),I<128?Ne[q++]=I:I<2048?(Ne[q++]=I>>6|192,Ne[q++]=I&63|128):(I&64512)===55296&&((H=S.charCodeAt(V+1))&64512)===56320?(I=65536+((I&1023)<<10)+(H&1023),V++,Ne[q++]=I>>18|240,Ne[q++]=I>>12&63|128,Ne[q++]=I>>6&63|128,Ne[q++]=I&63|128):(Ne[q++]=I>>12|224,Ne[q++]=I>>6&63|128,Ne[q++]=I&63|128);L=q-Te-T}else L=l(S,Te+T,B);L<32?Ne[Te++]=160|L:L<256?(T<2&&Ne.copyWithin(Te+2,Te+1,Te+1+L),Ne[Te++]=217,Ne[Te++]=L):L<65536?(T<3&&Ne.copyWithin(Te+3,Te+2,Te+2+L),Ne[Te++]=218,Ne[Te++]=L>>8,Ne[Te++]=L&255):(T<5&&Ne.copyWithin(Te+5,Te+3,Te+3+L),Ne[Te++]=219,gr.setUint32(Te,L),Te+=4),Te+=L}else if(P==="number")if(S>>>0===S)S<64?Ne[Te++]=S:S<256?(Ne[Te++]=204,Ne[Te++]=S):S<65536?(Ne[Te++]=205,Ne[Te++]=S>>8,Ne[Te++]=S&255):(Ne[Te++]=206,gr.setUint32(Te,S),Te+=4);else if(S>>0===S)S>=-32?Ne[Te++]=256+S:S>=-128?(Ne[Te++]=208,Ne[Te++]=S+256):S>=-32768?(Ne[Te++]=209,gr.setInt16(Te,S),Te+=2):(Ne[Te++]=210,gr.setInt32(Te,S),Te+=4);else{let E;if((E=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){Ne[Te++]=202,gr.setFloat32(Te,S);let T;if(E<4||(T=S*Vb[(Ne[Te]&127)<<1|Ne[Te+1]>>7])>>0===T){Te+=4;return}else Te--}Ne[Te++]=203,gr.setFloat64(Te,S),Te+=8}else if(P==="object")if(!S)Ne[Te++]=192;else{if(n){let T=n.get(S);if(T){if(!T.id){let B=n.idsToInsert||(n.idsToInsert=[]);T.id=B.push(T)}Ne[Te++]=214,Ne[Te++]=112,gr.setUint32(Te,T.id),Te+=4;return}else n.set(S,{offset:Te-i})}let E=S.constructor;if(E===Object)M(S,!0);else if(E===Array){L=S.length,L<16?Ne[Te++]=144|L:L<65536?(Ne[Te++]=220,Ne[Te++]=L>>8,Ne[Te++]=L&255):(Ne[Te++]=221,gr.setUint32(Te,L),Te+=4);for(let T=0;T<L;T++)_(S[T])}else if(E===Map){L=S.size,L<16?Ne[Te++]=128|L:L<65536?(Ne[Te++]=222,Ne[Te++]=L>>8,Ne[Te++]=L&255):(Ne[Te++]=223,gr.setUint32(Te,L),Te+=4);for(let[T,B]of S)_(T),_(B)}else{for(let T=0,B=gg.length;T<B;T++){let V=jb[T];if(S instanceof V){let I=gg[T];if(I.write){I.type&&(Ne[Te++]=212,Ne[Te++]=I.type,Ne[Te++]=0),_(I.write.call(this,S));return}let H=Ne,q=gr,X=Te;Ne=null;let Y;try{Y=I.pack.call(this,S,ie=>(Ne=H,H=null,Te+=ie,Te>on&&A(Te),{target:Ne,targetView:gr,position:Te-ie}),_)}finally{H&&(Ne=H,gr=q,Te=X,on=Ne.length-10)}Y&&(Y.length+Te>on&&A(Y.length+Te),Te=Lq(Y,Ne,Te,I.type));return}}M(S,!S.hasOwnProperty)}}else if(P==="boolean")Ne[Te++]=S?195:194;else if(P==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))Ne[Te++]=211,gr.setBigInt64(Te,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)Ne[Te++]=207,gr.setBigUint64(Te,S);else if(this.largeBigIntToFloat)Ne[Te++]=203,gr.setFloat64(Te,Number(S));else throw new RangeError(S+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");Te+=8}else if(P==="undefined")this.encodeUndefinedAsNil?Ne[Te++]=192:(Ne[Te++]=212,Ne[Te++]=0,Ne[Te++]=0);else if(P==="function")_(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+P)},M=this.useRecords===!1?this.variableMapSize?S=>{let P=Object.keys(S),L=P.length;L<16?Ne[Te++]=128|L:L<65536?(Ne[Te++]=222,Ne[Te++]=L>>8,Ne[Te++]=L&255):(Ne[Te++]=223,gr.setUint32(Te,L),Te+=4);let E;for(let T=0;T<L;T++)_(E=P[T]),_(S[E])}:(S,P)=>{Ne[Te++]=222;let L=Te-i;Te+=2;let E=0;for(let T in S)(P||S.hasOwnProperty(T))&&(_(T),_(S[T]),E++);Ne[L+++i]=E>>8,Ne[L+i]=E&255}:S=>{let P=Object.keys(S),L,E=s.transitions||(s.transitions=Object.create(null)),T=0;for(let V=0,I=P.length;V<I;V++){let H=P[V];L=E[H],L||(L=E[H]=Object.create(null),T++),E=L}let B=E[ud];if(B)B>=96&&f?(Ne[Te++]=((B-=96)&31)+96,Ne[Te++]=B>>5):Ne[Te++]=B;else{B=s.nextId,B||(B=64),B<m&&this.shouldShareStructure&&!this.shouldShareStructure(P)?(B=s.nextOwnId,B<g||(B=m),s.nextOwnId=B+1):(B>=g&&(B=m),s.nextId=B+1);let V=P.highByte=B>=96&&f?B-96>>5:-1;E[ud]=B,s[B-64]=P,B<m?(P.isShared=!0,s.sharedLength=B-63,a=!0,V>=0?(Ne[Te++]=(B&31)+96,Ne[Te++]=V):Ne[Te++]=B):(V>=0?(Ne[Te++]=213,Ne[Te++]=114,Ne[Te++]=(B&31)+96,Ne[Te++]=V):(Ne[Te++]=212,Ne[Te++]=114,Ne[Te++]=B),T&&(x+=b*T),v.length>=p&&(v.shift()[ud]=0),v.push(E),_(P))}for(let V=0,I=P.length;V<I;V++)_(S[P[V]])},A=S=>{let P;if(S>16777216){if(S-i>zA)throw new Error("Packed buffer would be larger than maximum buffer size");P=Math.min(zA,Math.round(Math.max((S-i)*(S>67108864?1.25:2),4194304)/4096)*4096)}else P=(Math.max(S-i<<2,Ne.length-1)>>12)+1<<12;let L=new N0(P);return gr=new DataView(L.buffer,0,P),Ne.copy?Ne.copy(L,0,i,S):L.set(Ne.slice(i,S)),Te-=i,i=0,on=L.length-10,Ne=L}}useBuffer(e){Ne=e,gr=new DataView(Ne.buffer,Ne.byteOffset,Ne.byteLength),Te=0}};jb=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,l3];gg=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:a,targetView:s,position:n}=t(6);a[n++]=214,a[n++]=255,s.setUint32(n,r)}else if(r>0&&r<17179869184){let{target:a,targetView:s,position:n}=t(10);a[n++]=215,a[n++]=255,s.setUint32(n,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(n+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:a,targetView:s,position:n}=t(3);a[n++]=212,a[n++]=255,a[n++]=255}else{let{target:a,targetView:s,position:n}=t(15);a[n++]=199,a[n++]=12,a[n++]=255,s.setUint32(n,e.getMilliseconds()*1e6),s.setBigInt64(n+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:a,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(a[s++]=212,a[s++]=115,a[s++]=0),i(r)}},{pack(e,t,i){let{target:r,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(r[a++]=212,r[a++]=101,r[a++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(r[a++]=212,r[a++]=120,r[a++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?kA(e,16,t):VA(uv?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==g3&&this.structuredClone?kA(e,f3.indexOf(i.name),t):VA(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function kA(e,t,i,r){let a=e.byteLength;if(a+1<256){var{target:s,position:n}=i(4+a);s[n++]=199,s[n++]=a+1}else if(a+1<65536){var{target:s,position:n}=i(5+a);s[n++]=200,s[n++]=a+1>>8,s[n++]=a+1&255}else{var{target:s,position:n,targetView:o}=i(7+a);s[n++]=201,o.setUint32(n,a+1),n+=4}s[n++]=116,s[n++]=t,s.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n)}function VA(e,t){let i=e.byteLength;var r,a;if(i<256){var{target:r,position:a}=t(i+2);r[a++]=196,r[a++]=i}else if(i<65536){var{target:r,position:a}=t(i+3);r[a++]=197,r[a++]=i>>8,r[a++]=i&255}else{var{target:r,position:a,targetView:s}=t(i+5);r[a++]=198,s.setUint32(a,i),a+=4}r.set(e,a)}function Lq(e,t,i,r){let a=e.length;switch(a){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:a<256?(t[i++]=199,t[i++]=a):a<65536?(t[i++]=200,t[i++]=a>>8,t[i++]=a&255):(t[i++]=201,t[i++]=a>>24,t[i++]=a>>16&255,t[i++]=a>>8&255,t[i++]=a&255)}return t[i++]=r,t.set(e,i),i+=a,i}function Iq(e,t){let i,r=t.length*6,a=e.length-r;for(t.sort((s,n)=>s.offset>n.offset?1:-1);i=t.pop();){let s=i.offset,n=i.id;e.copyWithin(s+r,s,a),r-=6;let o=s+r;e[o++]=214,e[o++]=105,e[o++]=n>>24,e[o++]=n>>16&255,e[o++]=n>>8&255,e[o++]=n&255,a=s}return e}function Bu(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");jb.unshift(e.Class),gg.unshift(e)}Pq(e)}var y3=new v3({useRecords:!1}),Sse=y3.pack,Ase=y3.pack,{NEVER:Ese,ALWAYS:Mse,DECIMAL_ROUND:Cse,DECIMAL_FIT:Tse}=Dq,Bq=512,Uq=1024,jA=new v3({structuredClone:!0});Bu({Class:Vt.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Vt.prototype),e}});Bu({Class:Tt.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,Tt.prototype),e}});Bu({Class:oa.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,oa.prototype),e}});Bu({Class:DA.prototype.constructor,type:4,write(e){return e.id},read(e){return new DA(e)}});Bu({Class:RA.prototype.constructor,type:5,write(e){return e.data},read(e){return new RA(e)}});Bu({Class:Tr.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Tr.prototype),e}});function Fq(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function S1(e){if(Ib(e))return e;if(Array.isArray(e))return e.map(S1);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=S1(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var A1;(e=>{function t(a){return jA.pack(a)}e.serialize=t;function i(a){return jA.unpack(a)}e.deserialize=i;function r(a){return Fq(t(S1(a))).toString()}e.checksum=r})(A1||(A1={}));var GA;(e=>{function t(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=t;function i(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=i})(GA||(GA={}));var ja={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional"],MouseHover:["Transition","Animation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],Scroll:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional"],Start:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],Conditional:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MousePress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional"],GameControl:["Transition","Animation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],VariableChange:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"]},HA;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,runMode:"Once",actions:new Tt}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new Tt}}e.defaultData=i})(HA||(HA={}));var vg;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(vg||(vg={}));var E1;(e=>{function t(a){return{type:"Comparison",operator:"==",lOperand:vg.propertyDefaultData(a),rOperand:{...vg.valueDefaultData}}}e.comparisonDefaultData=t;function i(a){return{type:"Distance",toObject:a??null,fromObject:a??null,distance:200}}e.distanceDefaultData=i;function r(a,s){return{type:"State",object:a??null,state:s??null}}e.stateDefaultData=r})(E1||(E1={}));var WA;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new Tt,outActions:new Tt,condition:E1.distanceDefaultData(r)}}e.defaultData=i})(WA||(WA={}));var qA;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new Tt,drop:new Tt}})(qA||(qA={}));var M1;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new Tt})(M1||(M1={}));var C1;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(C1||(C1={}));var XA;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new Tt}}e.defaultData=i})(XA||(XA={}));var YA;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Tt}}e.defaultData=i})(YA||(YA={}));var QA;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new Tt}}e.defaultData=i})(QA||(QA={}));var KA;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new Tt}}e.defaultData=i})(KA||(KA={}));var ZA;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,a){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new Tt,triggerZone:"box",position:a.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(ZA||(ZA={}));var T1;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(n){return n.type==="Resize"}e.is=t;function i(n){return typeof n=="string"?n:"custom"}e.sizeToDevice=i;function r(n){return typeof n=="string"?[...e.defaultSizes[n]]:[...n]}e.deviceToSize=r;function a(){let n={size:"mobile",operator:"<",actions:new Tt},o={size:"tablet",operator:"<",actions:new Tt},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new Tt},h=new Tt;return h.push({id:dt.generateUUID(),fi:0,data:n},{id:dt.generateUUID(),fi:1,data:o},{id:dt.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:h}}e.defaultData=a;function s(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new Tt}}e.defaultBreakpointData=s})(T1||(T1={}));var P1;(e=>{e.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}e.is=t;function i(){return{disabled:!1,type:"VariableChange",actions:new Tt,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(P1||(P1={}));var Uu="personal camera",Gd="a218fcc3-276b-49b9-b485-49037fd14f5f",Nq=2960946,ss=5526619,wo;(e=>{function t(f,m){return f[0]===m[0]&&f[1]===m[1]}e.isEqual=t;function i(f,m,g){return[f[0]+(m[0]-f[0])*g,f[1]+(m[1]-f[1])*g]}e.lerp=i;function r(f,m){return[f[0]+m[0],f[1]+m[1]]}e.add=r;function a(f,m){return[f[0]-m[0],f[1]-m[1]]}e.sub=a;function s(f,m){return[f[0]*m[0],f[1]*m[1]]}e.multiply=s;function n(f,m){return[f[0]/m[0],f[1]/m[1]]}e.divide=n;function o(f,m){return Math.pow(m[0]-f[0],2)+Math.pow(m[1]-f[1],2)}e.distanceSquared=o;function l(f,m){return Math.sqrt(o(f,m))}e.distance=l;function h(f,m){return f[0]*m[0]+f[1]*m[1]}e.dot=h;function c(f,m){return[f[0]*m,f[1]*m]}e.scalarMultiply=c;function u(f,m,g){let v=e.sub(m,f),x=e.sub(g,f),b=e.dot(v,x)/e.dot(v,v),_=e.scalarMultiply(v,b);return e.add(f,_)}e.projectionOnto=u;function d(f,m,g){return l(f,u(f,m,g))}e.projectionOntoDistance=d;function p(f,m){return[(f[0]+m[0])*.5,(f[1]+m[1])*.5]}e.center=p})(wo||(wo={}));var vh;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function a(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=a;function s(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=s;function n(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=n;function o(l,h,c){return[l[0]+(h[0]-l[0])*c,l[1]+(h[1]-l[1])*c,l[2]+(h[2]-l[2])*c]}e.lerp=o})(vh||(vh={}));var yg;(e=>{function t(r,a){return r[0]===a[0]&&r[1]===a[1]&&r[2]===a[2]&&r[3]===a[3]}e.isEqual=t;function i(r,a,s){return[r[0]+(a[0]-r[0])*s,r[1]+(a[1]-r[1])*s,r[2]+(a[2]-r[2])*s,r[3]+(a[3]-r[3])*s]}e.lerp=i})(yg||(yg={}));var fu;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(a,s){for(let n=0;n<16;n++)if(a[n]!==s[n])return!1;return!0}e.isEqual=t;function i(a){return a??e.identity}e.simplify=i;function r(a,s){let n=s.slice(0);for(var o=0,l=s.length;o<l;o+=3){let h=a[3]*s[o]+a[7]*s[o+1]+a[11]*s[o+2]+a[15];n[o]=(a[0]*s[o]+a[4]*s[o+1]+a[8]*s[o+2]+a[12])/h,n[o+1]=(a[1]*s[o]+a[5]*s[o+1]+a[9]*s[o+2]+a[13])/h,n[o+2]=(a[2]*s[o]+a[6]*s[o+1]+a[10]*s[o+2]+a[14])/h}return n}e.applyMatrix4=r})(fu||(fu={}));var ga;(e=>{function t(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}e.toRgb255a1=i;function r(h){return{r:h.r,g:h.g,b:h.b}}e.clone=r;function a(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}e.fromHex=a;function s(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}e.toHex=s;function n(h,c){return h.r===c.r&&h.g===c.g&&h.b===c.b}e.equals=n;function o(h,c){return h.r.toFixed(2)===c.r.toFixed(2)&&h.g.toFixed(2)===c.g.toFixed(2)&&h.b.toFixed(2)===c.b.toFixed(2)}e.equalsFixed=o;function l(h,c,u){return{r:h.r+(c.r-h.r)*u,g:h.g+(c.g-h.g)*u,b:h.b+(c.b-h.b)*u}}e.lerp=l})(ga||(ga={}));var Li;(e=>{e.white={...ga.white,a:1},e.transparent={...ga.white,a:0};function t(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}e.from0to1=t;function i(l,h){return{...ga.fromHex(l),a:h}}e.fromHexAndA=i;function r(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}e.toRgb255a1=r;function a(l,h){return ga.equals(l,h)&&l.a===h.a}e.equals=a;function s(l,h){return ga.equalsFixed(l,h)&&l.a.toFixed(2)===h.a.toFixed(2)}e.equalsFixed=s;function n(l,h,c){return{r:l.r+(h.r-l.r)*c,g:l.g+(h.g-l.g)*c,b:l.b+(h.b-l.b)*c,a:l.a+(h.a-l.a)*c}}e.lerp=n;function o({r:l,g:h,b:c,a:u}=e.white){return`rgba(${l*255}, ${h*255}, ${c*255}, ${u})`}e.toStyle=o})(Li||(Li={}));var D1;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(D1||(D1={}));var JA;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(JA||(JA={}));var $A;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})($A||($A={}));var rl;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(rl||(rl={}));function eE(e){return typeof e=="string"&&e.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!1}var Mh;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Mh||(Mh={}));var mu;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective?.zoom??1:i.orthographic?.zoom??1}e.getZoom=t})(mu||(mu={}));var pl;(e=>{function t(r,a=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*a,0,0]},grid:{count:[2,2,2],size:r.map(s=>s*(1+a)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(r,a){let s={...r};if(x3.forEach(n=>{Object.assign(s,{[n]:a[n]??r[n]})}),s.radial={...r.radial},a.radial){let n=r.radial,o=a.radial;b3.forEach(l=>{Object.assign(s.radial,{[l]:o[l]??n[l]})})}if(s.linear={...r.linear},a.linear){let n=r.linear,o=a.linear;w3.forEach(l=>{Object.assign(s.linear,{[l]:o[l]??n[l]})})}if(s.grid={...r.grid},a.grid){let n=r.grid,o=a.grid;_3.forEach(l=>{Object.assign(s.grid,{[l]:o[l]??n[l]})})}if(s.toObject={...r.toObject},a.toObject){let n=r.toObject,o=a.toObject;S3.forEach(l=>{Object.assign(s.toObject,{[l]:o[l]??n[l]})})}if(s.randomnessObject={...r.randomnessObject},a.randomnessObject){let n=r.randomnessObject,o=a.randomnessObject;A3.forEach(l=>{Object.assign(s.randomnessObject,{[l]:o[l]??n[l]})})}return s}e.merge=i})(pl||(pl={}));var R1;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,a){let s=[];r.count!==void 0&&s.push({type:0,path:a,props:{count:r.count}});for(let n of t){let o=r[n];o&&Object.keys(o).length>0&&s.push({type:0,path:[...a,n],props:o})}return s}e.toOps=i})(R1||(R1={}));var x3=["count"],b3=["radius","start","end","position","scale","rotation"],w3=["position","scale","rotation"],_3=["count","size"],S3=["count","position","scale","rotation"],A3=["strength","scale","rotation","position","movement","seed","freqScale"],O1;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(O1||(O1={}));var L1;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:Li.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Li.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Li.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(L1||(L1={}));var xg;(e=>(e.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},e.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},e.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:e.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...e.defaultCollisionData}))(xg||(xg={}));var gu;(e=>e.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(gu||(gu={}));var I1;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(I1||(I1={}));var B1;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})(B1||(B1={}));var U1;(e=>e.defaultData={...B1.defaultData,...I1.defaultData})(U1||(U1={}));var tE;(e=>{function t(i,r){let a=[];if("material"in i){let s=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;s&&a.push(s)}else if("materials"in i)for(let s of i.materials){let n=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;n&&a.push(n)}return a}e.getMaterialData=t})(tE||(tE={}));var bg;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(bg||(bg={}));var iE;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="particle"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(iE||(iE={}));function zq(e){return e.type!=="displace"}var rE;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(rE||(rE={}));var E3=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],kq=["wrapping","image","video","name","minFilter"],qr;(e=>{function t(s,n){let{texture:o,...l}=n;if(Object.assign(s,l),o){let h=s.texture;h&&Object.assign(h,o)}}e.patch=t;function i(s,n){return s==="light"&&n?r(n):a(s)}e.defaultData=i;function r(s){let n={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...n,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...n,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...n,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...n,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function a(s){let n={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...n,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"video":return{...n,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:bg.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"color":return{...n,type:"color",color:ga.fromHex(ss)};case"depth":return{...n,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...n,type:"normal",cnormal:[1,1,1]};case"gradient":return{...n,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...n,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...ga.fromHex(6710886),a:1},colorB:{...ga.fromHex(6710886),a:1},colorC:{...ga.fromHex(16777215),a:1},colorD:{...ga.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...n,type:"fresnel",color:Li.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...n,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...n,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Li.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...n,type:"outline",outlineColor:Li.fromHexAndA(0,1),contourColor:Li.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{...n,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008}};case"transmission":return{...n,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...n,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...ga.fromHex(0),a:1},colorB:{...ga.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(qr||(qr={}));var wa;(e=>{function t(c){return!c.layers.some(u=>u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")}e.isMergable=t;function i(c){let u="";return c.layers.forEach(d=>{Object.entries(d.data).forEach(([p,f])=>{u+=`${p}${f}`,Array.isArray(f)?f.forEach(m=>u+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?u+=`${m.toFixed(4)}`:u+=`${m}`}):u+=`${f}`})}),u}e.getHash=i;function r(){return{layers:new Tt}}e.defaultEmptyData=r;function a(c="layer1",u="layer2"){return n("phong",c,u)}e.defaultData=a;function s(c,u){return{...c,name:u}}e.withName=s;function n(c,u="layer1",d="layer2"){let p=new Tt;return p.push({fi:0,data:qr.defaultData("light",c),id:u}),p.push({fi:1,data:qr.defaultData("color"),id:d}),{layers:p}}e.defaultTwoLayerData=n;function o(c){let u=qr.defaultData("texture");c&&Object.assign(u.texture,{image:c});let d=new Tt;return d.push({fi:0,data:u,id:"layer1"}),d.push({fi:1,data:{...qr.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...qr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}e.defaultUIObjectMaterial=o;function l(c,u="phong",d="layer1",p="layer2"){let f=qr.defaultData("texture");Object.assign(f.texture,{image:c});let m=new Tt;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:qr.defaultData("light",u),id:p}),{layers:m}}e.defaultTwoLayerTextureData=l;function h(c,u="phong",d="layer1",p="layer2"){let f=qr.defaultData("video");Object.assign(f.texture,{video:c});let m=new Tt;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:qr.defaultData("light",u),id:p}),{layers:m}}e.defaultTwoLayerVideoTextureData=h})(wa||(wa={}));var wg;(e=>{function t(){return{points:new Tt,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(wg||(wg={}));var _g;(e=>{function t(){return{points:new Tt,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(_g||(_g={}));var M3={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},F1;(e=>{function t(i,r){let a={...i};return T3.forEach(s=>{Object.assign(a,{[s]:r[s]??i[s]})}),a}e.merge=t})(F1||(F1={}));var C3={shape:M3,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},T3=["depth","offset","angle","twist","startScale","endScale"],Sg;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=i})(Sg||(Sg={}));var N1;(e=>{function t(i,r){let a={...i};return Object.assign(a,r),a.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(a.extrusion={...i.extrusion},Object.assign(a.extrusion,F1.merge(a.extrusion,r.extrusion))),a}e.merge=t})(N1||(N1={}));var Zc;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:_g.defaultData(),extrusion:C3};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:wg.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}e.defaultData=t})(Zc||(Zc={}));var aE=["width","height","depth"],z1;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:ga.white,near:.1,far:2e3})(z1||(z1={}));var Ag;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})(Ag||(Ag={}));var k1;(e=>e.defaultData={softShadowQuality:"low"})(k1||(k1={}));var V1;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(V1||(V1={}));var j1;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(j1||(j1={}));var vu;(e=>e.defaultData={usePhysics:!1,gravity:-10})(vu||(vu={}));var G1;(e=>e.defaultData={playCamera:Uu,gameControlObject:null})(G1||(G1={}));var H1;(e=>e.defaultData={backgroundColor:Li.fromHexAndA(Nq,1),postprocessing:Ag.defaultData,fog:z1.defaultData,globalPhysics:vu.defaultData,ambient:V1.defaultData,ao:j1.defaultData,shadow:k1.defaultData,publish:G1.defaultData})(H1||(H1={}));var W1;(e=>e.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(W1||(W1={}));var sE;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(sE||(sE={}));var yu;(e=>{e.identity={...D1.identity,hiddenMatrix:fu.identity};function t(a){return{position:a.position,rotation:a.rotation,scale:a.scale,hiddenMatrix:a.hiddenMatrix}}e.fromObject=t;function i(a,s){return{position:s?.position||a.position,rotation:s?.rotation||a.rotation,scale:s?.scale||a.scale,hiddenMatrix:s?.hiddenMatrix||a.hiddenMatrix}}e.merge=i;function r(a,s){return HP({position:vh.isEqual(a.position,s.position)?void 0:s.position,rotation:vh.isEqual(a.rotation,s.rotation)?void 0:s.rotation,scale:vh.isEqual(a.scale,s.scale)?null:s.scale,hiddenMatrix:fu.isEqual(a.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})}e.diff=r})(yu||(yu={}));var ha;(e=>e.defaultData={states:new Tt,events:new Tt,visible:!0,raycastLock:!1,physics:gu.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...yu.identity,cloner:null})(ha||(ha={}));var q1;(e=>e.defaultData={type:"Empty",...ha.defaultData})(q1||(q1={}));var nE;(e=>e.defaultData={type:"ParticleCollider",...W1.defaultData,...ha.defaultData})(nE||(nE={}));var oE;(e=>e.defaultData={type:"Component",...ha.defaultData})(oE||(oE={}));var lE;(e=>e.defaultData={type:"Particle",...ha.defaultData,...xg.defaultData})(lE||(lE={}));var Jc;(e=>e.defaultData={type:"Mesh",...ha.defaultData,...U1.defaultData})(Jc||(Jc={}));var lp;(e=>e.defaultData={...ha.defaultData,...yu.identity,position:[0,0,mu.DefaultTargetOffset],...mu.defaultData})(lp||(lp={}));var X1;(e=>{function t(i){return{...ha.defaultData,...L1.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(X1||(X1={}));var Eg;(e=>{function t(r,a,s=0){for(;s<a.length;){let n=r?r[a[s]]:void 0;if(a.length===s+1)return n;if(n)r=n.descendants,s+=1;else return}}e.resolveWithDes=t;function i(r,a,s=0){let n=t(r,a,s);if(n){let o=Object.keys(n);if(o.length===1&&o[0]==="descendants")return}return n}e.resolve=i})(Eg||(Eg={}));var fl;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,a){return{...ha.defaultData,...a,component:r,overrides:new Tr,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let a=yu.fromObject(r.data);return t(r.id,a)}e.fromComponentData=i})(fl||(fl={}));var xu;(e=>{e.defaultData={type:"Page",...ha.defaultData,physics:{...gu.defaultData,fusedBody:!1},...H1.defaultData,camera:lp.defaultData};function t(i){return i.uiScene!==void 0}e.isUIPage=t})(xu||(xu={}));var Y1;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:fu.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:gu.defaultData,states:new Tt,events:new Tt,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...mu.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...ha.defaultData,...Jc.defaultData,geometry:Zc.defaultData("RectangleGeometry"),material:wa.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...ha.defaultData,...Jc.defaultData,geometry:Zc.defaultData("BooleanGeometry"),material:wa.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...ha.defaultData,...Jc.defaultData,geometry:Zc.defaultData("TextGeometry"),material:wa.defaultTwoLayerData("phong","layer1","layer2")}))(Y1||(Y1={}));var lh;(e=>{function t(s,n){let o={name:n};return s.type==="Mesh"?(o.geometry={},"material"in s&&(o.material={layers:new Tr}),"materials"in s&&(o.materials=s.materials.map(l=>({layers:new Tr})))):Mh.is(s.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(s,n){if(n===void 0)return s;let o={...s};return"material"in o&&"material"in n&&n.material&&(o.material=op(o.material,l=>{if(typeof l!="string")for(let[h,c]of Object.entries(n.material.layers)){let u=l.layers.data(h);u&&qr.patch(u,c)}}).data),o.materials&&n.materials&&(o.materials=op(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let c=n.materials[h];if(typeof c!="string")for(let[u,d]of Object.entries(c.layers)){let p=l[h]?.layers?.data(u);p&&qr.patch(p,d)}}}).data),o}function r(s,n){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function c(u,d){for(let[p,f]of Object.entries(d.layers)){let{texture:m,...g}=f;if(m!==void 0&&Object.keys(m).length>0){let v={path:[...u,"layers",p,"texture"],props:m,type:0};l.push(v)}if(Object.keys(g).length>0){let v={path:[...u,"layers",p],props:g,type:0};l.push(v)}}}for(let[u,d]of Object.entries(n))if(u!=="name")if(u==="cloner")l.push(...R1.toOps(d,["cloner"]));else if(u==="pathSnapping")l.push({path:[u],props:{slide:d.slide,offset:d.offset},type:0});else if(u==="material")c(["material"],d);else if(u==="materials")for(let[p,f]of Object.entries(d))c(["materials",p],f);else if(h[u]===0){if(u==="geometry"&&d.extrusion!==void 0){let p={path:[u,"extrusion"],props:d.extrusion,type:0};l.push(p),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let p={path:[u],props:d,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[u]=d;return l}e.toOps=r;function a(s,n){if(n===void 0)return s;let o={...s};if(Object.assign(o,yu.merge(o,n)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:n.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??o.pathSnapping?.offset??0})}),Mh.is(s.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=n;l.orthographic?.zoom!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(o.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(o.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in n&&Object.assign(o,{geometry:N1.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:pl.merge(o.cloner,n.cloner)});else if(s.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:pl.merge(o.cloner,n.cloner)});else if(O1.is(s.type)){let l=n;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=ga.clone(l.color))}return o}e.patch=a})(lh||(lh={}));var Mg;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Mg||(Mg={}));var ml;(e=>e.defaultData={orbitControls:Mg.defaultData,playPage:Gd,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,a=0;return i<5?a=-30:i<10&&(a=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,a],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(ml||(ml={}));var Q1;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Q1||(Q1={}));var K1;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(K1||(K1={}));var hh;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Q1.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:K1.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(hh||(hh={}));var hp;(e=>{function t(r){return r.find(a=>a.data.type==="Page"&&a.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,a,s){r.scene.objects.traverseFrom(a,(n,o)=>{if(o.type==="Instance"){let l=Pg.getComponentData(r,o.component)?.data;l&&s(n,o,l.events)}else s(n,o,o.events)})}e.traverseModuleInstances=i})(hp||(hp={}));var ch;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(a=!0){let s=[],n=Y1.defaultMeshObject;a&&(s.push({fi:-1,data:X1.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:n,children:[]}));let o=new oa;return o.push({fi:1,id:Gd,data:{...xu.defaultData,name:"Scene 1"},children:s}),o}e.defaultData={objects:t(),publish:ml.defaultData,styles:hh.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new oa,publish:ml.defaultData,styles:hh.defaultData()}},e.emptyDataWithPage=function(a=!0){return{objects:t(a),publish:ml.defaultData,styles:hh.defaultData()}},e.emptyData=function(){return{objects:new oa,publish:{...ml.defaultData},styles:hh.defaultData()}};function i(a){return{...e.defaultData,objects:Ln(a,oa.prototype)}}e.withObjs=i;function r(a,s){return i([{id:a,data:s,children:[],fi:0}])}e.withObj=r})(ch||(ch={}));var Hd;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Hd||(Hd={}));var as;(e=>{function t(n){return n.textValue!==void 0}e.isTextValue=t;function i(n){return typeof n=="number"}e.isNumber=i;function r(n){return typeof n=="boolean"}e.isBoolean=r;function a(n){return t(n)?"string":r(n)?"boolean":"number"}e.typeOfVariable=a;function s(n){return e.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(o=>o.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():e.isBoolean(n)?n?"True":"False":e.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}e.getDisplayedValue=s})(as||(as={}));var Z1;(e=>e.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(Z1||(Z1={}));var hE;(e=>e.all=[...Z1.all,"components"])(hE||(hE={}));var cE;(e=>{function t(){return{images:new Vt,videos:new Vt,colors:new Vt,audios:new Vt,particles:new Vt,fonts:new Vt,materials:new Vt,components:new Vt,variables:new Vt}}e.defaultData=t})(cE||(cE={}));var Ch;(e=>{function t(){return{images:new Vt,videos:new Vt,colors:new Vt,audios:new Vt,particles:new Vt,fonts:new Vt,materials:new Vt,components:new Vt,variables:new Vt}}e.defaultData=t})(Ch||(Ch={}));var ws;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ln(n,Vt.prototype)}e.defaultColors=t;function i(){return Ln({},Vt.prototype)}e.defaultImages=i;function r(){return{catelogs:new Vt,materials:new Vt,images:new Vt,videos:new Vt,colors:new Vt,audios:new Vt,particles:new Vt,fonts:new Vt,variables:new Tt,lib:Ch.defaultData()}}e.emptyData=r;function a(n){switch(n){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let o=[0,0,0];return{name:"Time",value:{textValue:o,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:o,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",n)}}e.defaultVariables=a;function s(n,o){if(o.format==="HH:mm:ss"){let l=Math.floor(n/3600),h=Math.floor((n-l*3600)/60),c=Math.round(n-l*3600-h*60);return{textValue:[l,h,c]}}else if(o.format==="mm:ss"){let l=Math.floor(n/60),h=Math.round(n-l*60);return{textValue:[l,h]}}else return o.format==="number"?n=Math.round(n):n=Math.round(n*1e3)/1e3,n}e.getFormattedTimerTime=s})(ws||(ws={}));var Cg;(e=>e.list=["idle","move","jump","run"])(Cg||(Cg={}));var Tg;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new Tt,move:new Tt,jump:new Tt,run:new Tt},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Li.fromHexAndA(3728051,1)}}))(Tg||(Tg={}));function uE(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,a=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let o=2;o<10;o++)a.push(a[1]),s.push(1);let n={...Ao(Pr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:a,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,n)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...Pr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function nl(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function ol(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((a,s)=>{a===void 0&&(r.materials[s]=wa.defaultData(),a=r.materials[s]),typeof a!="string"&&t(a)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=wa.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=wa.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(a=>{a.material&&typeof a.material!="string"&&Object.getPrototypeOf(a.material)!==Tr.prototype&&t(a.material)})})}function Vq(e){Object.assign(e.scene.publish,{orbitControls:{...Mg.defaultData,...Pr(e.scene.publish.orbitControls)}})}function jq(e){Object.assign(e.scene.publish.settings,{video:{...ml.defaultData.settings.video,...Pr(e.scene.publish.settings.video)}})}function Gq(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[a,s]of Object.entries(r))if((E3.includes(a)||typeof s=="boolean")&&delete r[a],a==="texture")for(let[n,o]of Object.entries(s))(kq.includes(n)||typeof o=="boolean")&&delete s[n]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(a=>{let s=a;s.material?t(s.material):s.materials&&s.materials.forEach(n=>{t(n)})})})}function Hq(e){e.scene.publish.withBackground=!0}function Wq(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function qq(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(a=>a+1),r.linear.scale=r.linear.scale.map(a=>a+1))})}function Xq(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function Yq(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let a=Pr(e.scene.objects.data(r));a&&a.type==="Mesh"&&a.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=Pr(i).booleanExclude!==!0)}})}function Qq(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function Kq(e){function t(r){Object.setPrototypeOf(r,Tr.prototype),r.texture&&Object.setPrototypeOf(r.texture,Tr.prototype)}function i(r){Object.setPrototypeOf(r,Tr.prototype);for(let a in r)t(r[a])}e.scene.objects.traverse((r,a)=>{a.states.forEach(s=>{let n=s;if(n.material){let o=Pr(n.material).layers;i(o),n.material.layers=o}if(n.materials)for(let o=0;o<n.materials.length;o++){let l=n.materials[o],h=Pr(l).layers;i(h),l.layers=h}})})}function dE(e){e.layers===void 0&&Object.assign(e,wa.defaultTwoLayerData("lambert"))}function z0(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let a={...Pr(t),colors:i,steps:r};Object.assign(t,a)}})}function Zq(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function pE(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&z0(r)}):"material"in i&&typeof i.material!="string"&&z0(i.material)}),Object.values(e.shared.materials).forEach(t=>z0(t))}function Jq(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function $q(e){e.shared.audios=Ln({},Vt.prototype)}function eX(e){e.shared.videos=Ln({},Vt.prototype)}function tX(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let a={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:a})}})}function iX(e){Object.entries(Pr(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(Pr(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function rX(e){e.scene.publish.settings.web.preload=!1}function fE(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function mE(e){e.layers&&e.layers.forEach(t=>{zq(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function aX(e){e.shared.fonts=Ln({},Vt.prototype)}function sX(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function nX(e){let t=[];e.scene.objects.traverse((i,r)=>{let a=r;if(a.type==="TextFrame"){let s=wa.defaultTwoLayerData("phong"),n=typeof a.color=="string"?e.shared.colors[a.color]:a.color;s.layers[1].data.color={r:n.r,g:n.g,b:n.b},s.layers[1].data.alpha=a.alpha;let o=sX(a.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:a.name,...ha.defaultData,...Jc.defaultData,flatShading:!1,wireframe:!1,geometry:{...Zc.defaultData("TextGeometry"),width:a.width,height:a.height,font:o,depth:0,horizontalAlign:a.horizontalAlign,verticalAlign:a.verticalAlign,fontSize:a.fontSize*1.40625,lineHeight:a.lineHeight/1.40625,letterSpacing:a.letterSpacing-1,text:a.text,textTransform:a.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Pr(a.states),events:Pr(a.events),visible:a.visible,raycastLock:a.raycastLock,position:a.position,rotation:a.rotation,scale:a.scale,hiddenMatrix:a.hiddenMatrix},h=Pr(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function oX(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(a=>{if(t[Number(a.type)])if(Object.assign(a,{type:t[Number(a.type)]}),a.type==="Audio"&&"audioEvent"in a&&(Object.assign(a,{playAudio:a.audioEvent}),delete a.audioEvent),a.type==="GameControl")Object.assign(a,{gameActions:{idle:new Tt,move:new Tt,jump:new Tt}});else{let s=new Tt;Object.assign(a,{actions:s}),(a.type==="MouseDown"||a.type==="MouseUp"||a.type==="KeyDown"||a.type==="KeyUp")&&"url"in a&&s.push({fi:0,id:dt.generateUUID(),data:{type:"Link",url:a.url,delay:0}}),"targets"in a&&(a.targets.forEach((n,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(c,Ao(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(c,{control1:{...n.control1},control2:{...n.control2}});let u={repeat:n.repeat?-1:0,delay:n.delay,delayDirection:n.delayDirection,direction:n.cycle&&n.rewind?"pingpong-rewind":n.cycle?"pingpong":"normal"},d={state:n.state,...u,...c},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Tt({fi:0,id:dt.generateUUID(),data:h},{fi:1,id:dt.generateUUID(),data:d})};s.push({fi:l,id:o,data:p})}),delete a.targets)}})})}function lX(e){e.scene.objects.traverse((t,i)=>{function r(a,s){let n=new Tt,o=[];if(i.events.forEach((l,h,c)=>{if(l.type==="Audio"&&l.trigger===s){let u;o.push(h),l.interaction==="play"?u={...Ao(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")&&(u={...Ao(l,"interaction","delay","object","playAudio"),type:"Audio"}),u&&n.push({fi:c,id:h,data:u})}}),o.forEach(l=>i.events.delete(l)),n.length){let l=i.events.find(h=>h.type===a)?.data;l?"actions"in l&&l.actions.insertBefore(null,n):i.events.insertBefore(null,[{id:dt.generateUUID(),data:{type:a,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function gE(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=qr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function vE(e){nl(e,gE),ol(e,gE)}function hX(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function cX(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function uX(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=wa.defaultTwoLayerData("phong"))})}function dX(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function pX(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function fX(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function mX(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function gX(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function vX(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function yX(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Tg.defaultDataThirdPerson.navmesh)})})}function xX(e){e.scene.styles||(e.scene.styles=hh.defaultData())}function yE(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function bX(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),ol(e,yE),nl(e,yE)}function wX(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Tt})})})}function _X(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function xE(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function SX(e,t){if(t<1&&(ol(e,uE),nl(e,uE),e.schema=1),t<2&&(Vq(e),e.schema=2),t<3&&(Gq(e),e.schema=3),t<4&&(Hq(e),e.schema=4),t<5&&(Wq(e),e.schema=5),t<6&&(qq(e),e.schema=6),t<7&&(Xq(e),e.schema=7),t<8&&(e.schema=8),t<9&&(pE(e),e.schema=9),t<10&&(Zq(e),e.schema=10),t<11&&(Jq(e),e.schema=11),t<12&&(pE(e),e.schema=12),t<13&&($q(e),e.schema=13),t<14&&(tX(e),e.schema=14),t<15&&(iX(e),e.schema=15),t<16&&(rX(e),e.schema=16),t<17&&(ol(e,fE),nl(e,fE),e.schema=17),t<18&&(ol(e,dE),nl(e,dE),e.schema=18),t<19&&(jq(e),e.schema=19),t<20&&(aX(e),nX(e),e.schema=20),t<21&&(oX(e),lX(e),e.schema=21),t<22&&(vE(e),e.schema=22),t<23&&(hX(e),e.schema=23),t<24&&(cX(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(eX(e),t<25&&(e.schema=25)),t<26&&(Yq(e),e.schema=26),t<27&&(Qq(e),e.schema=27),t<28&&(vE(e),e.schema=28),t<29&&(Kq(e),e.schema=29),t<30&&(uX(e),e.schema=30),t<31&&(dX(e),e.schema=31),t<33&&(pX(e),e.schema=33),t<34&&(fX(e),e.schema=34),t<35&&(mX(e),e.schema=35),t<36&&(gX(e),e.schema=36),t<37&&(vX(e),e.schema=37),t<38&&(ol(e,mE),nl(e,mE),e.schema=38),t<39&&(yX(e),e.schema=39),t<40&&(xX(e),e.schema=40),t<41&&(bX(e),e.schema=41),t<42&&(wX(e),e.schema=42),t<43&&(_X(e),e.schema=43),t<99){ol(e,xE),nl(e,xE),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=Uu);let i=Pr(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=Gd,r.insertBefore(null,null,[{id:Gd,data:{...xu.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:Ao(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:Ao(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...vu.defaultData,...Ao(e.scene.environment,"usePhysics","gravity")},camera:Pr(e.scene.ownerCamera)??xu.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==ch.TRASH_CAN_ID&&r.move(Gd,n.fi,n.id);let a=0,s=0;e.shared.penumbraSize&&e.scene.objects.traverse((n,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(a,2)],a+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(s,1)],s+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,gu.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function bE(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function AX(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function EX(e){Array.isArray(Pr(e.events))&&e.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var Ic=180/Math.PI;function wE(e){e.rotation=e.rotation.slice(0,3).map(t=>t*Ic)}function P3(e){wE(e),e.type==="Page"&&wE(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Ic))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Ic),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Ic),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Ic,t.extrusion.twist*=Ic),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(Pr(e.events))&&e.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Repeat")})}function MX(e){e.shared.variables=Ln({},Vt.prototype)}function CX(e){let t=Pr(e.shared.variables);e.shared.variables=Ln(Object.entries(t??{}).map(([i,r],a)=>({fi:a,id:i,data:r})),Tt.prototype)}var po=112;function D3(e,t){t(e.data);for(let i of e.children)D3(i,t)}function TX(e){let t=e.schema??104;t!==po&&t<105&&(D3(e.asset,P3),e.schema=105)}function PX(e){e.shared.particles=Ln({},Vt.prototype),e.shared.lib&&(e.shared.lib.particles=Ch.defaultData().particles)}function DX(e){e.scene.objects.traverse((t,i)=>{i.type==="Particle"&&typeof i.renderMaterial.size=="number"&&Object.assign(i.renderMaterial,{size:[i.renderMaterial.size,i.renderMaterial.size]})})}function RX(e){e.scene.objects.traverse((t,i)=>{i.type==="Page"&&(i.postprocessing.depthOfField.focusDistance=100,i.postprocessing.depthOfField.focalLength=20,i.postprocessing.depthOfField.bokehScale=5)})}function R3(e){let t=e.schema??0;if(t!==po){console.warn("updating from ",t,"to ",po),SX(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=ml.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(ol(e,bE),nl(e,bE),e.schema=101),t<102&&(AX(e),e.schema=102),t<104&&(e.shared.catelogs=new Vt,e.shared.lib=Ch.defaultData(),e.schema=104),t<105&&(MX(e),e.scene.objects.traverse((i,r)=>{P3(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))TX(i);t<106&&(CX(e),e.schema=106),t<107&&(e.shared.lib.variables=Ch.defaultData().variables,e.schema=107),t<109&&(PX(e),e.schema=109),t<110&&(DX(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{EX(r)}),e.schema=111),t<112&&(RX(e),e.schema=112)}}var Pg;(e=>{e.defaultData={schema:po,scene:ch.defaultData,frames:new Vt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Hd.defaultData),shared:{...ws.emptyData(),colors:ws.defaultColors()}},e.emptyDataForImports=function(){let a=ch.emptyDataWithPage();return{schema:po,scene:a,frames:new Vt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Hd.defaultData),shared:{...ws.emptyData(),colors:ws.defaultColors(),images:ws.defaultImages()}}},e.emptyData=function(){return{schema:po,scene:ch.emptyDataWithPage(),frames:new Vt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Hd.defaultData),shared:ws.emptyData()}},e.clipboard2dData=function(){return{schema:po,scene:ch.emptyData(),frames:new Vt,shared:ws.emptyData()}},e.collabHelper={...v1,updateSchema(a){return(a.schema??0)<po?op(a,R3):(a.schema??0)-po}};function t(a){let s=e.collabHelper.updateSchema(a);return typeof s=="number"?s===0?a:null:s.data}e.updateSchemaDirectly=t;function i(a){return{...a,shared:{...a.shared,lib:Ch.defaultData()}}}e.withoutLib=i;function r(a,s){let n=a.scene.objects.get(s);if(n&&n.data.type==="Component")return n;{let o=a.shared.lib.components[s];if(o)return o.asset}}e.getComponentData=r})(Pg||(Pg={}));var J1;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(J1||(J1={}));var _E;(e=>{function t(i){return!0}e.is=t})(_E||(_E={}));var Dg;(e=>{e.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(r,a){return{position:a?.position??r.position,rotation:a?.rotation??r.rotation,scale:a?.scale??r.scale,shear:a?.shear??r.shear}}e.merge=t;function i(r,a){return HP({position:wo.isEqual(r.position,a.position)?void 0:a.position,rotation:r.rotation===a.rotation?void 0:a.rotation,scale:wo.isEqual(r.scale,a.scale)?void 0:a.scale,shear:r.shear&&a.shear&&wo.isEqual(r.shear,a.shear)?void 0:a.shear})}e.diff=i})(Dg||(Dg={}));var $1;(e=>e.defaultData={horizontalConstraint:0,verticalConstraint:0})($1||($1={}));var Rg;(e=>e.defaultData={opacity:1,fill:{color:Li.fromHexAndA(ss,1),enabled:!0},stroke:{color:Li.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Li.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Li.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Rg||(Rg={}));var uh;(e=>{function t(n,o){return{name:o}}e.newEmpty=t;function i(n,o){if(o===void 0)return n;let l={...n},h=["width","height","cornerRadius"];for(let c of h)c in l&&c in o&&o[c]!==void 0&&Object.assign(l,{[c]:o[c]});return l}function r(n,o){if(o===void 0)return n;let l={...n};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}function a(n,o){if(o===void 0)return n;let l={...n};return Object.assign(l,Dg.merge(l,o)),l=i(l,o),l=r(l,o),l}e.patch=a;function s(n,o){let l,h=[];for(let[c,u]of Object.entries(o))c!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},h.push(l)),l.props[c]=u);return h}e.toOps=s})(uh||(uh={}));var cp;(e=>e.defaultData={...Dg.defaultData,...$1.defaultData,states:new Tt,events:new Tt,visible:!0,raycastLock:!1})(cp||(cp={}));var bu;(e=>e.defaultData={...cp.defaultData,...Rg.defaultData})(bu||(bu={}));var Og;(e=>e.defaultData={cornerRadius:[0,0,0,0]})(Og||(Og={}));var ex;(e=>e.defaultData={...bu.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(ex||(ex={}));var up;(e=>e.defaultData={...bu.defaultData,...Og.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(up||(up={}));var tx;(e=>e.defaultData={...bu.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(tx||(tx={}));var ix;(e=>e.defaultData={...bu.defaultData,type:"path2d",path:"",name:"Path"})(ix||(ix={}));var SE;(e=>{function t(i){return i.type==="ellipse2d"||i.type==="rectangle2d"||i.type==="text2d"||i.type==="vector2d"||i.type==="path2d"}e.is=t})(SE||(SE={}));var Lg;(e=>e.defaultData={...cp.defaultData,name:"Group",type:"group2d"})(Lg||(Lg={}));var rx;(e=>e.defaultData=()=>({...cp.defaultData,...Og.defaultData,...Rg.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Li.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Li.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(rx||(rx={}));var yh;(e=>{function t(s){switch(s){case"rectangle2d":return{...up.defaultData};case"ellipse2d":return{...ex.defaultData};case"text2d":return{...tx.defaultData};case"vector2d":return{...up.defaultData};case"path2d":return{...ix.defaultData};case"frame2d":return{...rx.defaultData()};case"group2d":return{...Lg.defaultData}}}e.defaultData=t;function i(s){return"width"in s&&"height"in s?[typeof s.width=="number"?s.width*.5:0,typeof s.height=="number"?s.height*.5:0]:[0,0]}e.getPivot=i;function r(s){return s.type==="rectangle2d"||s.type==="ellipse2d"||s.type==="text2d"||s.type==="frame2d"}e.isResizeable=r;function a(s){return s.type==="rectangle2d"||s.type==="frame2d"}e.hasCorners=a})(yh||(yh={}));var ax;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new oa},e.emptyData=function(){return{type:"scene2d",objects:new oa}}))(ax||(ax={}));function dh(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),a=new Set(Object.keys(e[0].morphAttributes)),s={},n={},o=e[0].morphTargetsRelative,l=new St,h=0;for(let c=0;c<e.length;++c){let u=e[c],d=0;if(i!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() 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 p in u.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(u.attributes[p]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in u.morphAttributes){if(!a.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;n[p]===void 0&&(n[p]=[]),n[p].push(u.morphAttributes[p])}if(t){let p;if(i)p=u.index.count;else if(u.attributes.position!==void 0)p=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,c),h+=p}}if(i){let c=0,u=[];for(let d=0;d<e.length;++d){let p=e[d].index;for(let f=0;f<p.count;++f)u.push(p.getX(f)+c);c+=e[d].attributes.position.count}l.setIndex(u)}for(let c in s){let u=AE(s[c]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,u)}for(let c in n){let u=n[c][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let d=0;d<u;++d){let p=[];for(let m=0;m<n[c].length;++m)p.push(n[c][m][d]);let f=AE(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(f)}}return l}function AE(e){let t,i,r,a=-1,s=0;for(let h=0;h<e.length;++h){let c=e[h];if(t===void 0&&(t=c.array.constructor),t!==c.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=c.itemSize),i!==c.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=c.normalized),r!==c.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(a===-1&&(a=c.gpuType),a!==c.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=c.count*i}let n=new t(s),o=new Ut(n,i,r),l=0;for(let h=0;h<e.length;++h){let c=e[h];if(c.isInterleavedBufferAttribute){let u=l/i;for(let d=0,p=c.count;d<p;d++)for(let f=0;f<i;f++){let m=c.getComponent(d,f);o.setComponent(d+u,f,m)}}else n.set(c.array,l);l+=c.count*i}return a!==void 0&&(o.gpuType=a),o}var OX=Math.pow(2,-24),zf=class{constructor(){}};function An(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function EE(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let a=e[r+3]-e[r];a>i&&(i=a,t=r)}return t}function ME(e,t){t.set(e)}function CE(e,t,i){let r,a;for(let s=0;s<3;s++){let n=s+3;r=e[s],a=t[s],i[s]=r<a?r:a,r=e[n],a=t[n],i[n]=r>a?r:a}}function kf(e,t,i){for(let r=0;r<3;r++){let a=t[e+2*r],s=t[e+2*r+1],n=a-s,o=a+s;n<i[r]&&(i[r]=n),o>i[r+3]&&(i[r+3]=o)}}function dd(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function LX(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,a;i>65535?a=new Uint32Array(new r(4*i)):a=new Uint16Array(new r(2*i)),e.setIndex(new Ut(a,1));for(let s=0;s<i;s++)a[s]=s}}function IX(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let a of e.groups)i.add(a.start),i.add(a.start+a.count);let r=Array.from(i.values()).sort((a,s)=>a-s);for(let a=0;a<r.length-1;a++){let s=r[a],n=r[a+1];t.push({offset:s/3,count:(n-s)/3})}return t}function k0(e,t,i,r,a=null){let s=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0,u=1/0,d=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0,v=a!==null;for(let x=t*6,b=(t+i)*6;x<b;x+=6){let _=e[x+0],M=e[x+1],A=_-M,S=_+M;A<s&&(s=A),S>l&&(l=S),v&&_<u&&(u=_),v&&_>f&&(f=_);let P=e[x+2],L=e[x+3],E=P-L,T=P+L;E<n&&(n=E),T>h&&(h=T),v&&P<d&&(d=P),v&&P>m&&(m=P);let B=e[x+4],V=e[x+5],I=B-V,H=B+V;I<o&&(o=I),H>c&&(c=H),v&&B<p&&(p=B),v&&B>g&&(g=B)}r[0]=s,r[1]=n,r[2]=o,r[3]=l,r[4]=h,r[5]=c,v&&(a[0]=u,a[1]=d,a[2]=p,a[3]=f,a[4]=m,a[5]=g)}function BX(e,t,i,r){let a=1/0,s=1/0,n=1/0,o=-1/0,l=-1/0,h=-1/0;for(let c=t*6,u=(t+i)*6;c<u;c+=6){let d=e[c+0];d<a&&(a=d),d>o&&(o=d);let p=e[c+2];p<s&&(s=p),p>l&&(l=p);let f=e[c+4];f<n&&(n=f),f>h&&(h=f)}r[0]=a,r[1]=s,r[2]=n,r[3]=o,r[4]=l,r[5]=h}function UX(e,t,i,r,a){let s=i,n=i+r-1,o=a.pos,l=a.axis*2;for(;;){for(;s<=n&&t[s*6+l]<o;)s++;for(;s<=n&&t[n*6+l]>=o;)n--;if(s<n){for(let h=0;h<3;h++){let c=e[s*3+h];e[s*3+h]=e[n*3+h],e[n*3+h]=c;let u=t[s*6+h*2+0];t[s*6+h*2+0]=t[n*6+h*2+0],t[n*6+h*2+0]=u;let d=t[s*6+h*2+1];t[s*6+h*2+1]=t[n*6+h*2+1],t[n*6+h*2+1]=d}s++,n--}else return s}}var oo=32,FX=(e,t)=>e.candidate-t.candidate,Yo=new Array(oo).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Vf=new Float32Array(6);function NX(e,t,i,r,a,s){let n=-1,o=0;if(s===0)n=EE(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(s===1)n=EE(e),n!==-1&&(o=zX(i,r,a,n));else if(s===2){let l=dd(e),h=1.25*a,c=r*6,u=(r+a)*6;for(let d=0;d<3;d++){let p=t[d],f=(t[d+3]-p)/oo;if(a<oo/4){let m=[...Yo];m.length=a;let g=0;for(let x=c;x<u;x+=6,g++){let b=m[g];b.candidate=i[x+2*d],b.count=0;let{bounds:_,leftCacheBounds:M,rightCacheBounds:A}=b;for(let S=0;S<3;S++)A[S]=1/0,A[S+3]=-1/0,M[S]=1/0,M[S+3]=-1/0,_[S]=1/0,_[S+3]=-1/0;kf(x,i,_)}m.sort(FX);let v=a;for(let x=0;x<v;x++){let b=m[x];for(;x+1<v&&m[x+1].candidate===b.candidate;)m.splice(x+1,1),v--}for(let x=c;x<u;x+=6){let b=i[x+2*d];for(let _=0;_<v;_++){let M=m[_];b>=M.candidate?kf(x,i,M.rightCacheBounds):(kf(x,i,M.leftCacheBounds),M.count++)}}for(let x=0;x<v;x++){let b=m[x],_=b.count,M=a-b.count,A=b.leftCacheBounds,S=b.rightCacheBounds,P=0;_!==0&&(P=dd(A)/l);let L=0;M!==0&&(L=dd(S)/l);let E=1+1.25*(P*_+L*M);E<h&&(n=d,h=E,o=b.candidate)}}else{for(let v=0;v<oo;v++){let x=Yo[v];x.count=0,x.candidate=p+f+v*f;let b=x.bounds;for(let _=0;_<3;_++)b[_]=1/0,b[_+3]=-1/0}for(let v=c;v<u;v+=6){let x=~~((i[v+2*d]-p)/f);x>=oo&&(x=oo-1);let b=Yo[x];b.count++,kf(v,i,b.bounds)}let m=Yo[oo-1];ME(m.bounds,m.rightCacheBounds);for(let v=oo-2;v>=0;v--){let x=Yo[v],b=Yo[v+1];CE(x.bounds,b.rightCacheBounds,x.rightCacheBounds)}let g=0;for(let v=0;v<oo-1;v++){let x=Yo[v],b=x.count,_=x.bounds,M=Yo[v+1].rightCacheBounds;b!==0&&(g===0?ME(_,Vf):CE(_,Vf,Vf)),g+=b;let A=0,S=0;g!==0&&(A=dd(Vf)/l);let P=a-g;P!==0&&(S=dd(M)/l);let L=1+1.25*(A*g+S*P);L<h&&(n=d,h=L,o=x.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:n,pos:o}}function zX(e,t,i,r){let a=0;for(let s=t,n=t+i;s<n;s++)a+=e[s*6+r*2];return a/i}function kX(e,t){let i=e.attributes.position,r=e.index.array,a=r.length/3,s=new Float32Array(a*6),n=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let c=["getX","getY","getZ"];for(let u=0;u<a;u++){let d=u*3,p=u*6,f,m,g;n?(f=r[d+0],m=r[d+1],g=r[d+2]):(f=r[d+0]*h+l,m=r[d+1]*h+l,g=r[d+2]*h+l);for(let v=0;v<3;v++){let x,b,_;n?(x=i[c[v]](f),b=i[c[v]](m),_=i[c[v]](g)):(x=o[f+v],b=o[m+v],_=o[g+v]);let M=x;b<M&&(M=b),_<M&&(M=_);let A=x;b>A&&(A=b),_>A&&(A=_);let S=(A-M)/2,P=v*2;s[p+P+0]=M+S,s[p+P+1]=S+(Math.abs(M)+S)*OX,M<t[v]&&(t[v]=M),A>t[v+3]&&(t[v+3]=A)}}return s}function VX(e,t){function i(v){d&&d(v/p)}function r(v,x,b,_=null,M=0){if(!f&&M>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),b<=c||M>=l)return i(x+b),v.offset=x,v.count=b,v;let A=NX(v.boundingData,_,n,x,b,u);if(A.axis===-1)return i(x+b),v.offset=x,v.count=b,v;let S=UX(o,n,x,b,A);if(S===x||S===x+b)i(x+b),v.offset=x,v.count=b;else{v.splitAxis=A.axis;let P=new zf,L=x,E=S-x;v.left=P,P.boundingData=new Float32Array(6),k0(n,L,E,P.boundingData,s),r(P,L,E,s,M+1);let T=new zf,B=S,V=b-E;v.right=T,T.boundingData=new Float32Array(6),k0(n,B,V,T.boundingData,s),r(T,B,V,s,M+1)}return v}LX(e,t);let a=new Float32Array(6),s=new Float32Array(6),n=kX(e,a),o=e.index.array,l=t.maxDepth,h=t.verbose,c=t.maxLeafTris,u=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,m=[],g=IX(e);if(g.length===1){let v=g[0],x=new zf;x.boundingData=a,BX(n,v.offset,v.count,s),r(x,v.offset,v.count,s),m.push(x)}else for(let v of g){let x=new zf;x.boundingData=new Float32Array(6),k0(n,v.offset,v.count,x.boundingData,s),r(x,v.offset,v.count,s),m.push(x)}return m}function jX(e,t){let i=VX(e,t),r,a,s,n=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<i.length;c++){let u=i[c],d=l(u),p=new o(32*d);r=new Float32Array(p),a=new Uint32Array(p),s=new Uint16Array(p),h(0,u),n.push(p)}return n;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function h(c,u){let d=c/4,p=c/2,f=!!u.count,m=u.boundingData;for(let g=0;g<6;g++)r[d+g]=m[g];if(f){let g=u.offset,v=u.count;return a[d+6]=g,s[p+14]=v,s[p+15]=65535,c+32}else{let g=u.left,v=u.right,x=u.splitAxis,b;if(b=h(c+32,g),b/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return a[d+6]=b/4,b=h(b,v),a[d+7]=x,b}}}var In=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let a=0,s=e.length;a<s;a++){let n=e[a][t];i=n<i?n:i,r=n>r?n:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let a=0,s=t.length;a<s;a++){let n=t[a],o=e.dot(n);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};In.prototype.setFromBox=function(){let e=new O;return function(t,i){let r=i.min,a=i.max,s=1/0,n=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+a.x*(1-o),e.y=r.y*l+a.y*(1-l),e.z=r.z*h+a.z*(1-h);let c=t.dot(e);s=Math.min(c,s),n=Math.max(c,n)}this.min=s,this.max=n}}();var Pse=function(){let e=new In;return function(t,i){let r=t.points,a=t.satAxes,s=t.satBounds,n=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let c=s[h],u=a[h];if(e.setFromPoints(u,n),c.isSeparated(e))return!1}for(let h=0;h<3;h++){let c=l[h],u=o[h];if(e.setFromPoints(u,r),c.isSeparated(e))return!1}}}(),GX=function(){let e=new O,t=new O,i=new O;return function(r,a,s){let n=r.start,o=e,l=a.start,h=t;i.subVectors(n,l),e.subVectors(r.end,r.start),t.subVectors(a.end,a.start);let c=i.dot(h),u=h.dot(o),d=h.dot(h),p=i.dot(o),f=o.dot(o)*d-u*u,m,g;f!==0?m=(c*u-p*d)/f:m=0,g=(c+m*u)/d,s.x=m,s.y=g}}(),Gb=function(){let e=new ae,t=new O,i=new O;return function(r,a,s,n){GX(r,a,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,s),a.at(l,n);return}else if(o>=0&&o<=1){l<0?a.at(0,n):a.at(1,n),r.closestPointToPoint(n,!0,s);return}else if(l>=0&&l<=1){o<0?r.at(0,s):r.at(1,s),a.closestPointToPoint(s,!0,n);return}else{let h;o<0?h=r.start:h=r.end;let c;l<0?c=a.start:c=a.end;let u=t,d=i;if(r.closestPointToPoint(c,!0,t),a.closestPointToPoint(h,!0,i),u.distanceToSquared(c)<=d.distanceToSquared(h)){s.copy(u),n.copy(c);return}else{s.copy(h),n.copy(d);return}}}}(),HX=function(){let e=new O,t=new O,i=new ts,r=new Es;return function(a,s){let{radius:n,center:o}=a,{a:l,b:h,c}=s;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let u=s.getPlane(i);if(Math.abs(u.distanceToPoint(o))<=n){let d=u.projectPoint(o,t);if(s.containsPoint(d))return!0}return!1}}(),WX=1e-15;function mc(e){return Math.abs(e)<WX}var To=class extends Kr{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new O),this.satBounds=new Array(4).fill().map(()=>new In),this.points=[this.a,this.b,this.c],this.sphere=new Sa,this.plane=new ts,this.needsUpdate=!0}intersectsSphere(e){return HX(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,a=this.satAxes,s=this.satBounds,n=a[0],o=s[0];this.getNormal(n),o.setFromPoints(n,r);let l=a[1],h=s[1];l.subVectors(e,t),h.setFromPoints(l,r);let c=a[2],u=s[2];c.subVectors(t,i),u.setFromPoints(c,r);let d=a[3],p=s[3];d.subVectors(i,e),p.setFromPoints(d,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(n,e),this.needsUpdate=!1}};To.prototype.closestPointToSegment=function(){let e=new O,t=new O,i=new Es;return function(r,a=null,s=null){let{start:n,end:o}=r,l=this.points,h,c=1/0;for(let u=0;u<3;u++){let d=(u+1)%3;i.start.copy(l[u]),i.end.copy(l[d]),Gb(i,r,e,t),h=e.distanceToSquared(t),h<c&&(c=h,a&&a.copy(e),s&&s.copy(t))}return this.closestPointToPoint(n,e),h=n.distanceToSquared(e),h<c&&(c=h,a&&a.copy(e),s&&s.copy(n)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<c&&(c=h,a&&a.copy(e),s&&s.copy(o)),Math.sqrt(c)}}();To.prototype.intersectsTriangle=function(){let e=new To,t=new Array(3),i=new Array(3),r=new In,a=new In,s=new O,n=new O,o=new O,l=new O,h=new Es,c=new Es,u=new Es;return function(d,p=null,f=!1){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(e.copy(d),e.update(),d=e);let m=this.plane,g=d.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){let v=this.satBounds,x=this.satAxes;i[0]=d.a,i[1]=d.b,i[2]=d.c;for(let M=0;M<4;M++){let A=v[M],S=x[M];if(r.setFromPoints(S,i),A.isSeparated(r))return!1}let b=d.satBounds,_=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let M=0;M<4;M++){let A=b[M],S=_[M];if(r.setFromPoints(S,t),A.isSeparated(r))return!1}for(let M=0;M<4;M++){let A=x[M];for(let S=0;S<4;S++){let P=_[S];if(s.crossVectors(A,P),r.setFromPoints(s,t),a.setFromPoints(s,i),r.isSeparated(a))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,x=!1,b=0;for(let V=0;V<3;V++){let I=v[V],H=v[(V+1)%3];h.start.copy(I),h.end.copy(H),h.delta(n);let q=x?c.start:c.end,X=mc(g.distanceToPoint(I));if(mc(g.normal.dot(n))&&X){c.copy(h),b=2;break}if((g.intersectLine(h,q)||X)&&!mc(q.distanceTo(H))){if(b++,x)break;x=!0}}if(b===1&&d.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(b!==2)return!1;let _=d.points,M=!1,A=0;for(let V=0;V<3;V++){let I=_[V],H=_[(V+1)%3];h.start.copy(I),h.end.copy(H),h.delta(o);let q=M?u.start:u.end,X=mc(m.distanceToPoint(I));if(mc(m.normal.dot(o))&&X){u.copy(h),A=2;break}if((m.intersectLine(h,q)||X)&&!mc(q.distanceTo(H))){if(A++,M)break;M=!0}}if(A===1&&this.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(A!==2)return!1;if(c.delta(n),u.delta(o),n.dot(o)<0){let V=u.start;u.start=u.end,u.end=V}let S=c.start.dot(n),P=c.end.dot(n),L=u.start.dot(n),E=u.end.dot(n),T=P<L,B=S<E;return S!==E&&L!==P&&T===B?!1:(p&&(l.subVectors(c.start,u.start),l.dot(n)>0?p.start.copy(c.start):p.start.copy(u.start),l.subVectors(c.end,u.end),l.dot(n)<0?p.end.copy(c.end):p.end.copy(u.end)),!0)}}}();To.prototype.distanceToPoint=function(){let e=new O;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();To.prototype.distanceToTriangle=function(){let e=new O,t=new O,i=["a","b","c"],r=new Es,a=new Es;return function(s,n=null,o=null){let l=n||o?r:null;if(this.intersectsTriangle(s,l))return(n||o)&&(n&&l.getCenter(n),o&&l.getCenter(o)),0;let h=1/0;for(let c=0;c<3;c++){let u,d=i[c],p=s[d];this.closestPointToPoint(p,e),u=p.distanceToSquared(e),u<h&&(h=u,n&&n.copy(e),o&&o.copy(p));let f=this[d];s.closestPointToPoint(f,e),u=f.distanceToSquared(e),u<h&&(h=u,n&&n.copy(f),o&&o.copy(e))}for(let c=0;c<3;c++){let u=i[c],d=i[(c+1)%3];r.set(this[u],this[d]);for(let p=0;p<3;p++){let f=i[p],m=i[(p+1)%3];a.set(s[f],s[m]),Gb(r,a,e,t);let g=e.distanceToSquared(t);g<h&&(h=g,n&&n.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Bn=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new O,this.max=new O,this.matrix=new je,this.invMatrix=new je,this.points=new Array(8).fill().map(()=>new O),this.satAxes=new Array(3).fill().map(()=>new O),this.satBounds=new Array(3).fill().map(()=>new In),this.alignedSatBounds=new Array(3).fill().map(()=>new In),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Bn.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let c=0;c<=1;c++){let u=1*l|2*h|4*c,d=r[u];d.x=l?i.x:t.x,d.y=h?i.y:t.y,d.z=c?i.z:t.z,d.applyMatrix4(e)}let a=this.satBounds,s=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=s[l],c=a[l],u=1<<l,d=r[u];h.subVectors(n,d),c.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Bn.prototype.intersectsBox=function(){let e=new In;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,a=this.satBounds,s=this.satAxes,n=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,n[0].isSeparated(e)||(e.min=i.y,e.max=r.y,n[1].isSeparated(e))||(e.min=i.z,e.max=r.z,n[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=s[o],h=a[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();Bn.prototype.intersectsTriangle=function(){let e=new To,t=new Array(3),i=new In,r=new In,a=new O;return function(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(e.copy(s),e.update(),s=e);let n=this.satBounds,o=this.satAxes;t[0]=s.a,t[1]=s.b,t[2]=s.c;for(let u=0;u<3;u++){let d=n[u],p=o[u];if(i.setFromPoints(p,t),d.isSeparated(i))return!1}let l=s.satBounds,h=s.satAxes,c=this.points;for(let u=0;u<3;u++){let d=l[u],p=h[u];if(i.setFromPoints(p,c),d.isSeparated(i))return!1}for(let u=0;u<3;u++){let d=o[u];for(let p=0;p<4;p++){let f=h[p];if(a.crossVectors(d,f),i.setFromPoints(a,t),r.setFromPoints(a,c),i.isSeparated(r))return!1}}return!0}}();Bn.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();Bn.prototype.distanceToPoint=function(){let e=new O;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Bn.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new Es),i=new Array(12).fill().map(()=>new Es),r=new O,a=new O;return function(s,n=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||l)&&(s.getCenter(a),this.closestPointToPoint(a,r),s.closestPointToPoint(r,a),o&&o.copy(r),l&&l.copy(a)),0;let h=n*n,c=s.min,u=s.max,d=this.points,p=1/0;for(let m=0;m<8;m++){let g=d[m];a.copy(g).clamp(c,u);let v=g.distanceToSquared(a);if(v<p&&(p=v,o&&o.copy(g),l&&l.copy(a),v<h))return Math.sqrt(v)}let f=0;for(let m=0;m<3;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){let x=(m+1)%3,b=(m+2)%3,_=g<<x|v<<b,M=1<<m|g<<x|v<<b,A=d[_],S=d[M];t[f].set(A,S);let P=e[m],L=e[x],E=e[b],T=i[f],B=T.start,V=T.end;B[P]=c[P],B[L]=g?c[L]:u[L],B[E]=v?c[E]:u[L],V[P]=u[P],V[L]=g?c[L]:u[L],V[E]=v?c[E]:u[L],f++}for(let m=0;m<=1;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){a.x=m?u.x:c.x,a.y=g?u.y:c.y,a.z=v?u.z:c.z,this.closestPointToPoint(a,r);let x=a.distanceToSquared(r);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(a),x<h))return Math.sqrt(x)}for(let m=0;m<12;m++){let g=t[m];for(let v=0;v<12;v++){let x=i[v];Gb(g,x,r,a);let b=r.distanceToSquared(a);if(b<p&&(p=b,o&&o.copy(r),l&&l.copy(a),b<h))return Math.sqrt(b)}}return Math.sqrt(p)}}();var gc=new O,vc=new O,yc=new O,jf=new ae,Gf=new ae,Hf=new ae,TE=new O,PE=new O,DE=new O,Wf=new O;function qX(e,t,i,r,a,s){let n;return s===Fr?n=e.intersectTriangle(r,i,t,!0,a):n=e.intersectTriangle(t,i,r,s!==Oa,a),n===null?null:{distance:e.origin.distanceTo(a),point:a.clone()}}function XX(e,t,i,r,a,s,n,o,l){gc.fromBufferAttribute(t,s),vc.fromBufferAttribute(t,n),yc.fromBufferAttribute(t,o);let h=qX(e,gc,vc,yc,Wf,l);if(h){r&&(jf.fromBufferAttribute(r,s),Gf.fromBufferAttribute(r,n),Hf.fromBufferAttribute(r,o),h.uv=Kr.getInterpolation(Wf,gc,vc,yc,jf,Gf,Hf,new ae)),a&&(jf.fromBufferAttribute(a,s),Gf.fromBufferAttribute(a,n),Hf.fromBufferAttribute(a,o),h.uv1=Kr.getInterpolation(Wf,gc,vc,yc,jf,Gf,Hf,new ae)),i&&(TE.fromBufferAttribute(i,s),PE.fromBufferAttribute(i,n),DE.fromBufferAttribute(i,o),h.normal=Kr.getInterpolation(Wf,gc,vc,yc,TE,PE,DE,new O),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let c={a:s,b:n,c:o,normal:new O,materialIndex:0};Kr.getNormal(gc,vc,yc,c.normal),h.face=c,h.faceIndex=s}return h}function O3(e,t,i,r,a){let s=r*3,n=e.index.getX(s),o=e.index.getX(s+1),l=e.index.getX(s+2),{position:h,normal:c,uv:u,uv1:d}=e.attributes,p=XX(i,h,c,u,d,n,o,l,t);return p?(p.faceIndex=r,a&&a.push(p),p):null}function YX(e,t,i,r,a,s){for(let n=r,o=r+a;n<o;n++)O3(e,t,i,n,s)}function QX(e,t,i,r,a){let s=1/0,n=null;for(let o=r,l=r+a;o<l;o++){let h=O3(e,t,i,o);h&&h.distance<s&&(n=h,s=h.distance)}return n}function wn(e,t,i,r){let a=e.a,s=e.b,n=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),a.x=r.getX(o),a.y=r.getY(o),a.z=r.getZ(o),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),n.x=r.getX(h),n.y=r.getY(h),n.z=r.getZ(h)}function RE(e,t,i,r,a,s,n){let o=i.index,l=i.attributes.position;for(let h=e,c=t+e;h<c;h++)if(wn(n,h*3,o,l),n.needsUpdate=!0,r(n,h,a,s))return!0;return!1}var L3=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function ll(e,t){return t[e+15]===65535}function $c(e,t){return t[e+6]}function dp(e,t){return t[e+14]}function pp(e){return e+8}function fp(e,t){return t[e+6]}function KX(e,t){return t[e+7]}var Hc=new sr,Ig=new O,ZX=["x","y","z"];function sx(e,t,i,r,a){let s=e*2,n=Fu,o=Al,l=El;if(ll(s,o)){let h=$c(e,l),c=dp(s,o);YX(t,i,r,h,c,a)}else{let h=pp(e);Bg(h,n,r,Ig)&&sx(h,t,i,r,a);let c=fp(e,l);Bg(c,n,r,Ig)&&sx(c,t,i,r,a)}}function nx(e,t,i,r){let a=e*2,s=Fu,n=Al,o=El;if(ll(a,n)){let l=$c(e,o),h=dp(a,n);return QX(t,i,r,l,h)}else{let l=KX(e,o),h=ZX[l],c=r.direction[h]>=0,u,d;c?(u=pp(e),d=fp(e,o)):(u=fp(e,o),d=pp(e));let p=Bg(u,s,r,Ig)?nx(u,t,i,r):null;if(p){let m=p.point[h];if(c?m<=s[d+l]:m>=s[d+l+3])return p}let f=Bg(d,s,r,Ig)?nx(d,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var JX=function(){let e,t,i=[],r=new L3(()=>new sr);return function(...s){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let n=a(...s);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),n};function a(s,n,o,l,h=null,c=0,u=0){function d(x){let b=x*2,_=Al,M=El;for(;!ll(b,_);)x=pp(x),b=x*2;return $c(x,M)}function p(x){let b=x*2,_=Al,M=El;for(;!ll(b,_);)x=fp(x,M),b=x*2;return $c(x,M)+dp(b,_)}let f=s*2,m=Fu,g=Al,v=El;if(ll(f,g)){let x=$c(s,v),b=dp(f,g);return An(s,m,e),l(x,b,!1,u,c+s,e)}else{let x=pp(s),b=fp(s,v),_=x,M=b,A,S,P,L;if(h&&(P=e,L=t,An(_,m,P),An(M,m,L),A=h(P),S=h(L),S<A)){_=b,M=x;let q=A;A=S,S=q,P=L}P||(P=e,An(_,m,P));let E=ll(_*2,g),T=o(P,E,A,u+1,c+_),B;if(T===2){let q=d(_),X=p(_)-q;B=l(q,X,!0,u+1,c+_,P)}else B=T&&a(_,n,o,l,h,c,u+1);if(B)return!0;L=t,An(M,m,L);let V=ll(M*2,g),I=o(L,V,S,u+1,c+M),H;if(I===2){let q=d(M),X=p(M)-q;H=l(q,X,!0,u+1,c+M,L)}else H=I&&a(M,n,o,l,h,c,u+1);return!!H}}}(),$X=function(){let e=new To,t=new To,i=new je,r=new Bn,a=new Bn;return function s(n,o,l,h,c=null){let u=n*2,d=Fu,p=Al,f=El;if(c===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),c=r),ll(u,p)){let m=o,g=m.index,v=m.attributes.position,x=l.index,b=l.attributes.position,_=$c(n,f),M=dp(u,p);if(i.copy(h).invert(),l.boundsTree)return An(n,d,a),a.matrix.copy(i),a.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:A=>a.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(h),A.b.applyMatrix4(h),A.c.applyMatrix4(h),A.needsUpdate=!0;for(let S=_*3,P=(M+_)*3;S<P;S+=3)if(wn(t,S,g,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=_*3,S=M+_*3;A<S;A+=3){wn(e,A,g,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let P=0,L=x.count;P<L;P+=3)if(wn(t,P,x,b),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let m=n+8,g=f[n+6];return An(m,d,Hc),!!(c.intersectsBox(Hc)&&s(m,o,l,h,c)||(An(g,d,Hc),c.intersectsBox(Hc)&&s(g,o,l,h,c)))}}}();function Bg(e,t,i,r){return An(e,t,Hc),i.intersectBox(Hc,r)}var ox=[],Om,Fu,Al,El;function Rd(e){Om&&ox.push(Om),Om=e,Fu=new Float32Array(e),Al=new Uint16Array(e),El=new Uint32Array(e)}function qf(){Om=null,Fu=null,Al=null,El=null,ox.length&&Rd(ox.pop())}var V0=Symbol("skip tree generation"),j0=new sr,G0=new sr,xc=new je,Xl=new Bn,pd=new Bn,fd=new O,Xf=new O,eY=new O,tY=new O,iY=new O,OE=new sr,hn=new L3(()=>new To),Wd=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Wd.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,a=i.getIndex(),s;return t.cloneBuffers?s={roots:r.map(n=>n.slice()),index:a.array.slice()}:s={roots:r,index:a.array},s}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Wd.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:a}=e,s=new Wd(t,{...i,[V0]:!0});if(s._roots=a,i.setIndex){let n=t.getIndex();if(n===null){let o=new Ut(e.index,1,!1);t.setIndex(o)}else n.array!==r&&(n.array.set(r),n.needsUpdate=!0)}return s}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[V0]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[V0]||(this._roots=jX(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new sr))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,a,s,n,o,l=0,h=this._roots;for(let u=0,d=h.length;u<d;u++)a=h[u],s=new Uint32Array(a),n=new Uint16Array(a),o=new Float32Array(a),c(0,l),l+=a.byteLength;function c(u,d,p=!1){let f=u*2;if(n[f+15]===65535){let m=s[u+6],g=n[f+14],v=1/0,x=1/0,b=1/0,_=-1/0,M=-1/0,A=-1/0;for(let S=3*m,P=3*(m+g);S<P;S++){let L=i[S],E=r.getX(L),T=r.getY(L),B=r.getZ(L);E<v&&(v=E),E>_&&(_=E),T<x&&(x=T),T>M&&(M=T),B<b&&(b=B),B>A&&(A=B)}return o[u+0]!==v||o[u+1]!==x||o[u+2]!==b||o[u+3]!==_||o[u+4]!==M||o[u+5]!==A?(o[u+0]=v,o[u+1]=x,o[u+2]=b,o[u+3]=_,o[u+4]=M,o[u+5]=A,!0):!1}else{let m=u+8,g=s[u+6],v=m+d,x=g+d,b=p,_=!1,M=!1;e?b||(_=e.has(v),M=e.has(x),b=!_&&!M):(_=!0,M=!0);let A=b||_,S=b||M,P=!1;A&&(P=c(m,d,b));let L=!1;S&&(L=c(g,d,b));let E=P||L;if(E)for(let T=0;T<3;T++){let B=m+T,V=g+T,I=o[B],H=o[B+3],q=o[V],X=o[V+3];o[u+T]=I<q?I:q,o[u+T+3]=H>X?H:X}return E}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),a=new Uint16Array(i);s(0);function s(n,o=0){let l=n*2,h=a[l+15]===65535;if(h){let c=r[n+6],u=a[l+14];e(o,h,new Float32Array(i,n*4,6),c,u)}else{let c=n+8,u=r[n+6],d=r[n+7];e(o,h,new Float32Array(i,n*4,6),d)||(s(c,o+1),s(u,o+1))}}}raycast(e,t=Qs){let i=this._roots,r=this.geometry,a=[],s=t.isMaterial,n=Array.isArray(t),o=r.groups,l=s?t.side:t;for(let h=0,c=i.length;h<c;h++){let u=n?t[o[h].materialIndex].side:l,d=a.length;if(Rd(i[h]),sx(0,r,u,e,a),qf(),n){let p=o[h].materialIndex;for(let f=d,m=a.length;f<m;f++)a[f].face.materialIndex=p}}return a}raycastFirst(e,t=Qs){let i=this._roots,r=this.geometry,a=t.isMaterial,s=Array.isArray(t),n=null,o=r.groups,l=a?t.side:t;for(let h=0,c=i.length;h<c;h++){let u=s?t[o[h].materialIndex].side:l;Rd(i[h]);let d=nx(0,r,u,e);qf(),d!=null&&(n==null||d.distance<n.distance)&&(n=d,s&&(d.face.materialIndex=o[h].materialIndex))}return n}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let a of this._roots)if(Rd(a),r=$X(0,i,e,t),qf(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let u=t;t=(d,p,f,m)=>{let g=p*3;return u(d,g,g+1,g+2,f,m)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let a=hn.getPrimitive(),{boundsTraverseOrder:s,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let u=o;o=(d,p,f,m,g)=>u(d,p,f,m,g)?!0:RE(d,p,r,l,f,m,a)}else o||(l?o=(u,d,p,f)=>RE(u,d,r,l,p,f,a):o=(u,d,p)=>p);let h=!1,c=0;for(let u of this._roots){if(Rd(u),h=JX(0,r,n,o,s,c),qf(),h)break;c+=u.byteLength}return hn.releasePrimitive(a),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:a}=i,s=this.geometry.index,n=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;xc.copy(t).invert();let h=hn.getPrimitive(),c=hn.getPrimitive();if(a){let d=function(p,f,m,g,v,x,b,_){for(let M=m,A=m+g;M<A;M++){wn(c,M*3,o,l),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let S=p,P=p+f;S<P;S++)if(wn(h,S*3,s,n),h.needsUpdate=!0,a(h,c,S,M,v,x,b,_))return!0}return!1};if(r){let p=r;r=function(f,m,g,v,x,b,_,M){return p(f,m,g,v,x,b,_,M)?!0:d(f,m,g,v,x,b,_,M)}}else r=d}e.getBoundingBox(G0),G0.applyMatrix4(t);let u=this.shapecast({intersectsBounds:d=>G0.intersectsBox(d),intersectsRange:(d,p,f,m,g,v)=>(j0.copy(v),j0.applyMatrix4(xc),e.shapecast({intersectsBounds:x=>j0.intersectsBox(x),intersectsRange:(x,b,_,M,A)=>r(d,p,x,b,m,g,M,A)}))});return hn.releasePrimitive(h),hn.releasePrimitive(c),u}intersectsBox(e,t){return Xl.set(e.min,e.max,t),Xl.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Xl.intersectsBox(i),intersectsTriangle:i=>Xl.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},a=0,s=1/0){e.boundingBox||e.computeBoundingBox(),Xl.set(e.boundingBox.min,e.boundingBox.max,t),Xl.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,c=e.index,u=hn.getPrimitive(),d=hn.getPrimitive(),p=Xf,f=eY,m=null,g=null;r&&(m=tY,g=iY);let v=1/0,x=null,b=null;return xc.copy(t).invert(),pd.matrix.copy(xc),this.shapecast({boundsTraverseOrder:_=>Xl.distanceToBox(_),intersectsBounds:(_,M,A)=>A<v&&A<s?(M&&(pd.min.copy(_.min),pd.max.copy(_.max),pd.needsUpdate=!0),!0):!1,intersectsRange:(_,M)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>pd.distanceToBox(A),intersectsBounds:(A,S,P)=>P<v&&P<s,intersectsRange:(A,S)=>{for(let P=A*3,L=(A+S)*3;P<L;P+=3){wn(d,P,c,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let E=_*3,T=(_+M)*3;E<T;E+=3){wn(u,E,l,o),u.needsUpdate=!0;let B=u.distanceToTriangle(d,p,m);if(B<v&&(f.copy(p),g&&g.copy(m),v=B,x=E/3,b=P/3),B<a)return!0}}}});{let A=c?c.count:h.count;for(let S=0,P=A;S<P;S+=3){wn(d,S,c,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let L=_*3,E=(_+M)*3;L<E;L+=3){wn(u,L,l,o),u.needsUpdate=!0;let T=u.distanceToTriangle(d,p,m);if(T<v&&(f.copy(p),g&&g.copy(m),v=T,x=L/3,b=S/3),T<a)return!0}}}}}),hn.releasePrimitive(u),hn.releasePrimitive(d),v===1/0?null:(i.point?i.point.copy(f):i.point=f.clone(),i.distance=v,i.faceIndex=x,r&&(r.point?r.point.copy(g):r.point=g.clone(),r.point.applyMatrix4(xc),f.applyMatrix4(xc),r.distance=f.sub(r.point).length(),r.faceIndex=b),i)}closestPointToPoint(e,t={},i=0,r=1/0){let a=i*i,s=r*r,n=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(fd.copy(e).clamp(h.min,h.max),fd.distanceToSquared(e)),intersectsBounds:(h,c,u)=>u<n&&u<s,intersectsTriangle:(h,c)=>{h.closestPointToPoint(e,fd);let u=e.distanceToSquared(fd);return u<n&&(Xf.copy(fd),n=u,o=c),u<a}}),n===1/0)return null;let l=Math.sqrt(n);return t.point?t.point.copy(Xf):t.point=Xf.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{An(0,new Float32Array(t),OE),e.union(OE)}),e}},md=Ro(VB()),rY=.5*(Math.sqrt(3)-1),gd=(3-Math.sqrt(3))/6,aY=1/3,cn=1/6,Dse=(Math.sqrt(5)-1)/4,Rse=(5-Math.sqrt(5))/20,qd=e=>Math.floor(e)|0,LE=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]),H0=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 W0(e=Math.random){let t=I3(e),i=new Float64Array(t).map(a=>LE[a%12*2]),r=new Float64Array(t).map(a=>LE[a%12*2+1]);return function(a,s){let n=0,o=0,l=0,h=(a+s)*rY,c=qd(a+h),u=qd(s+h),d=(c+u)*gd,p=c-d,f=u-d,m=a-p,g=s-f,v,x;m>g?(v=1,x=0):(v=0,x=1);let b=m-v+gd,_=g-x+gd,M=m-1+2*gd,A=g-1+2*gd,S=c&255,P=u&255,L=.5-m*m-g*g;if(L>=0){let B=S+t[P],V=i[B],I=r[B];L*=L,n=L*L*(V*m+I*g)}let E=.5-b*b-_*_;if(E>=0){let B=S+v+t[P+x],V=i[B],I=r[B];E*=E,o=E*E*(V*b+I*_)}let T=.5-M*M-A*A;if(T>=0){let B=S+1+t[P+1],V=i[B],I=r[B];T*=T,l=T*T*(V*M+I*A)}return 70*(n+o+l)}}function sY(e=Math.random){let t=I3(e),i=new Float64Array(t).map(s=>H0[s%12*3]),r=new Float64Array(t).map(s=>H0[s%12*3+1]),a=new Float64Array(t).map(s=>H0[s%12*3+2]);return function(s,n,o){let l,h,c,u,d=(s+n+o)*aY,p=qd(s+d),f=qd(n+d),m=qd(o+d),g=(p+f+m)*cn,v=p-g,x=f-g,b=m-g,_=s-v,M=n-x,A=o-b,S,P,L,E,T,B;_>=M?M>=A?(S=1,P=0,L=0,E=1,T=1,B=0):_>=A?(S=1,P=0,L=0,E=1,T=0,B=1):(S=0,P=0,L=1,E=1,T=0,B=1):M<A?(S=0,P=0,L=1,E=0,T=1,B=1):_<A?(S=0,P=1,L=0,E=0,T=1,B=1):(S=0,P=1,L=0,E=1,T=1,B=0);let V=_-S+cn,I=M-P+cn,H=A-L+cn,q=_-E+2*cn,X=M-T+2*cn,Y=A-B+2*cn,ie=_-1+3*cn,ce=M-1+3*cn,de=A-1+3*cn,ue=p&255,re=f&255,se=m&255,he=.6-_*_-M*M-A*A;if(he<0)l=0;else{let Re=ue+t[re+t[se]];he*=he,l=he*he*(i[Re]*_+r[Re]*M+a[Re]*A)}let _e=.6-V*V-I*I-H*H;if(_e<0)h=0;else{let Re=ue+S+t[re+P+t[se+L]];_e*=_e,h=_e*_e*(i[Re]*V+r[Re]*I+a[Re]*H)}let Ee=.6-q*q-X*X-Y*Y;if(Ee<0)c=0;else{let Re=ue+E+t[re+T+t[se+B]];Ee*=Ee,c=Ee*Ee*(i[Re]*q+r[Re]*X+a[Re]*Y)}let fe=.6-ie*ie-ce*ce-de*de;if(fe<0)u=0;else{let Re=ue+1+t[re+1+t[se+1]];fe*=fe,u=fe*fe*(i[Re]*ie+r[Re]*ce+a[Re]*de)}return 32*(l+h+c+u)}}function I3(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),a=t[i];t[i]=t[r],t[r]=a}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Us=new Kr,nY=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let a=1;Us.a.fromBufferAttribute(e,r),Us.b.fromBufferAttribute(e,r+1),Us.c.fromBufferAttribute(e,r+2),a*=Us.getArea(),t[r/3]=a}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,a=-1;for(;i<=r;){let s=Math.ceil((i+r)/2);if(s===0||t[s-1]<=e&&t[s]>e){a=s;break}else e<t[s]?r=s-1:i=s+1}return a}sampleFace(e,t,i){let r=this.randomFunction(),a=this.randomFunction();return r+a>1&&(r=1-r,a=1-a),Us.a.fromBufferAttribute(this.positionAttribute,e*3),Us.b.fromBufferAttribute(this.positionAttribute,e*3+1),Us.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Us.a,r).addScaledVector(Us.b,a).addScaledVector(Us.c,1-(r+a)),Us.getNormal(i),this}},oY=Ro(cT()),lY=new je,hY=new je,cY=new je,mp;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(mp||(mp={}));var Hb=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new je,this.copyPreviousMatrix=!0,this.hiddenMatrix=new je,this.matrixWorldRigid=new je,this.shearScale=new je,this.shearScaleInv=new je}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Mi&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)mp.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)mp.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:a,q:s}=(0,oY.SVD)(i),n=lY.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=hY.set(a[0][0],a[0][1],a[0][2],0,a[1][0],a[1][1],a[1][2],0,a[2][0],a[2][1],a[2][2],0,0,0,0,1),l=cY.copy(o).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(n,l).copyPosition(this.matrixWorld),s.every(h=>Math.abs(s[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new je().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof je?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,a,s,n){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},uY=class extends Hb(Mi){},dY=e=>e.type==="Mesh",xa=class extends uY{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new xa(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return dY(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}},ih=new O,rh=new O,eu=new je,B3=[new O(-1,1,1),new O(-1,-1,1),new O(1,-1,1),new O(1,1,1),new O(-1,1,-1),new O(-1,-1,-1),new O(1,-1,-1),new O(1,1,-1)],pY=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],fY=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],IE=(e,t,i)=>{e.updateEntityBoxSize(ih,rh),eu.copy(t).multiply(e.matrixWorld),rh.x===0&&rh.y===0&&rh.z===0?i.push(new O(ih.x,ih.y,ih.z).applyMatrix4(eu)):B3.forEach(r=>{i.push(r.clone().multiply(rh).add(ih).applyMatrix4(eu))})},BE=class extends sr{constructor(){super(...arguments),this.matrix=new je,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new je().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){r.push(new O);return}IE(a,t,r)}}):IE(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(eu.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(rh).multiplyScalar(.5),this.getCenter(ih),eu.copy(this.matrix).setPosition(ih),this.vertices=B3.map(e=>e.clone().multiply(rh).applyMatrix4(eu))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=pY.map(([e,t])=>new Es(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new O))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=fY.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},gl={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},mY=class extends HT{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),a=r[r.length-1]/r.length;for(let s=0,n=this.curves;s<n.length;s++){let o=n[s],l=s===0?r[s]:r[s]-r[s-1],h=Math.ceil(e*l/a),c=o.getPoints(h);for(let u=0;u<c.length;u++){let d=c[u];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},lx=.001;function hx(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=lx}function q0(e,t){let i=new O(...e.position),r=new O(...e.controlNext.position),a=new O(...t.controlPrevious.position),s=new O(...t.position);return hx(i,r,s)&&hx(i,a,s)}function U3(e){let t=e.points.map(c=>new O(...c.data.position)),i=[e.points[0]],r=new O(...i[0].data.position);for(let c=0;c<e.points.length-1;c++)hx(r,t[c],t[c+1])||(i.push(e.points[c]),r=t[c]);i.push(e.points[e.points.length-1]);let a=e.isClosed,s=i.length-(a?0:1),n=i.length,o=[];for(let c=0;c<n;c++){let u=i[c].data,d=new O(...u.position),p=new O(...u.controlPrevious.position),f=new O(...u.controlNext.position),m={position:d,baseRoundness:u.roundness,controlPrevious:p,controlNext:f};if(u.roundness===0||!e.isClosed&&(c===0||c===n-1)){o[c]={...m,removedLength:0};continue}let g=a&&c==0?n-1:c-1,v=a&&c==n-1?0:c+1,x=i[g].data,b=i[v].data,_=new O(...x.position),M=new O(...b.position),A=_.clone().sub(d).normalize(),S=M.clone().sub(d).normalize();Object.assign(m,{prevDir:A,nextDir:S});let P=q0(x,u),L=q0(u,b);if(!P||!L)o[c]={...m,removedLength:0};else{let E=A.clone().add(S).normalize(),T=E.clone().cross(A).length()/A.dot(E);o[c]={...m,tan:T,removedLength:u.roundness/T}}}for(let c=0;c<s;c++){let u=c,d=a&&c===n-1?0:c+1,p=o[u],f=o[d];if(p.removedLength!==0||f.removedLength!==0){let m=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let c=0;c<s;c++){let u=c,d=a&&c===n-1?0:c+1,p=o[u],f=o[d],m=null;if(!q0(i[u].data,i[d].data))p.position.distanceTo(f.position)>lx&&(m=new Cm(p.position,p.controlNext,f.controlPrevious,f.position));else{let g=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&g.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),g.distanceTo(v)>lx&&(m=new Cm(g,g.clone().lerp(v,.3),v.clone().lerp(g,.3),v))}l[2*c+1]=m}for(let c=0;c<n;c++){let u=o[c];if(u.removedLength===0){l[2*c]=null;continue}let d=u.position,p=u.prevDir.clone().multiplyScalar(u.removedLength).add(d),f=u.nextDir.clone().multiplyScalar(u.removedLength).add(d),m=u.tan*u.removedLength,g=u.prevDir.clone().add(u.nextDir).normalize(),v=p.clone().lerp(f,.5),x=p.distanceTo(f)/2,b=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(x,2))).add(v),_=g.clone().multiplyScalar(-m).add(b),M=d.distanceTo(_)/d.distanceTo(v),A=u.prevDir.clone().multiplyScalar(M*d.distanceTo(p)).add(d),S=A.clone().lerp(_,2),P=p.clone().lerp(A,4/3),L=f.clone().lerp(S,4/3);l[2*c]=new Cm(p,P,L,f)}let h=new mY;return l.forEach(c=>{c&&h.add(c)}),h}var ui;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(ui||(ui={}));var fo=e=>ui.is(e),gY={type:"completeState",isfromEntity:!0},vY=["x","y","z"],X0=new O,yY=new O().set(0,1,0),Wb=e=>class extends Hb(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new BE,this._recursiveBBox=new BE,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(ui.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(ui.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(ui.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let a of this.data.states)lh.toOps(this.data,a.data).forEach(s=>{let n=fg.replaceProps(s,this.data);this.dataPatched=this.data,this.updateByPatchedOp(n,this.data,i)});if(t!==null){let a=this.data.states.data(t);a&&(this.dataPatched=lh.patch(this.data,a),lh.toOps(this.data,a).forEach(s=>{this.updateByPatchedOp(s,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{fo(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(ui.is(i[r]))return i[r];if(ui.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&ui.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)fo(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{ui.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)fo(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)fo(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)fo(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>fo(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x*dt.RAD2DEG,this.rotation.y*dt.RAD2DEG,this.rotation.z*dt.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return g1(i,t)}getTransformValues(t,i,r){return i[t].map((a,s)=>r?.shared.getVariable(a,[this.uuid,t,vY[s]])??a)}updateTransformState(t,i){let r=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(X0.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(dt.DEG2RAD),this.rotation.setFromVector3(X0),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??fu.identity)),r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)ui.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{ui.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return g1(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,a){let s=this.data;this.data=i;let n=t,o=Fi(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(c=>c===void 0)){let c=this.data;if(c!==void 0){let u=na.zoom(c,t.path.slice(2));if(u)for(let d in t.props)t.props[d]===void 0&&d in u&&(h[d]=u[d])}}n={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:c,...u}=l;l=u}if(t.props.material!==void 0&&"material"in l){let{material:c,...u}=l;l=u}let h=na.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,lh.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Fi(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let c of Object.keys(t.props)){l[l.length-1]=c;let u=r.scene.findInstance([this.uuid,...l]);u&&(u.overrideData=t.props[c],u.updateState(_l.apply(u.component.data,u.overrideData),r))}}else{let c=r.scene.findInstance([this.uuid,...l]);if(c){let u=na.zoom(c.component.data,h);if(t={...t,path:h},t.type===0){let d=t.props;if(u)for(let[p,f]of Object.entries(t.props))f===void 0&&(d===t.props&&(d={...t.props}),d[p]=u[p]);t={...t,props:d}}c.overrideData=Eg.resolve(i.overrides,l),c.updateByOp(t,Zr.applySimple(c.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let c of fl.rootOverrideProps)c in t.props&&(h===void 0&&(h={}),h[c]=t.props[c]);h&&(l={...t,props:h})}else for(let h of fl.rootOverrideProps)if(Fi(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let c=_l.filterOp(h.overrideData,l);c&&h.updateByOp(c,Zr.applySimple(h.data,c),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let c=_l.filterOp(h.overrideData,t);if(c){let u;s===h.data&&t===c?u=i:u=Zr.applySimple(h.data,c),h.updateByOp(c,u,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Mh.is(t.props.type)&&gl.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){gl.changeEntityProptotype(this,i,r);for(let a of this.children)ui.is(a)&&a.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0&&this.updateState(t.props,r),Fi(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Fi(t.path,["cloner"])!==null){let a=Zr.drop(t,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r.scene):(this.setFromClonerState(i.cloner,r),this.expandCloner(r.scene)),this.updateVisible(r.scene)}}updatePathSnapping(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let n=t.find(i);if(!n||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=n.data;if(o.geometry.path.points.length<=1)return;let l=U3(o.geometry.path),h=(r+a)%1;r+a===1&&h===0&&(h=1);let c=l.getPointAt(h);if(c===null)return;let u=this.parent?this.parent?.matrixWorld:new je;n.updateMatrixWorld();let d=new je().multiplyMatrices(u.clone().invert(),n.matrixWorld);c.applyMatrix4(d);let p={position:c.toArray(),rotation:o.rotation};if(s==="tangential"){let f=new je().extractRotation(n.matrixWorld),m=l.getTangentAt(h).applyMatrix4(f).add(c),g=new je().lookAt(c,m,yY),v=X0.setFromEuler(new Qi().setFromRotationMatrix(g)).multiplyScalar(dt.RAD2DEG);p={...p,rotation:v.toArray()}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(gY)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof gl.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new gl.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}},F3=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);i.thetaLength=dt.clamp(i.thetaLength,0,360);let r=i.width/2,a=i.radiusTop??r,s=i.radiusBottom??r;return a===s?(a=r,s=r):a>s?(a=r,s=s*r/a):(a=a*r/s,s=r),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:a,radiusBottom:s})}}static build(e){let{width:t,depth:i,height:r,radialSegments:a,heightSegments:s,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:c,cornerRadius:u,cornerSegments:d,hollow:p}=e.parameters,f;return l===0?(f=new St,f.setAttribute("position",new ut([],3))):u||p?f=new N3(h,c,r,a,s,n,o,l*Math.PI/180,u,u,d,p):f=new hb(h,c,r,a,s,n,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function Qo(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function UE(e){return new ae(e.y,-e.x)}var N3=class extends St{constructor(e,t,i,r,a,s,n,o,l,h,c,u,d=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,a=Math.floor(a)||1,s=s!==void 0?s:!1,n=n!==void 0?n:0,o=o!==void 0?o:Math.PI*2,s&&(l=0,h=0);let p=[],f=[],m=[],g=[],v=0,x=i/2,b=new O,_=new O;d&&e==0&&(e=l),d&&t==0&&(t=h);let M=new ae(e,x),A=new ae(t,-x),S=null,P=null,L=null,E=null,T=M.clone().sub(A),B=0,V=0,I=0;u>0&&(B=Math.min(e,t)*(1-u),V=e-B,I=t-B);let H=M.clone();H.x-=B;let q=Math.PI-T.angle(),X=T.angle(),Y=Math.tan(X/2),ie=Math.tan(q/2),ce=Y+ie,de=u?ce:ie,ue=u?ce:Y;if(l=Math.min(l,(e-V)/de,T.length()/ce),h=Math.min(h,(t-I)/ue,T.length()/ce),l>0){let fe=l/Y;S=M.clone().sub(new ae(fe,l)),u&&(L=S.clone(),L.x-=B-ce*l),M.sub(T.clone().setLength(fe))}if(h>0){let fe=h/ie;P=A.clone().sub(new ae(fe,-h)),A.add(T.clone().setLength(fe)),u&&(E=P.clone(),E.x-=B-ce*h,H.sub(T.clone().setLength(fe)))}T=M.clone().sub(A);let re=T.length()<.5,se=[];for(let fe=0;fe<=r;fe++){let Re=[],Pe=fe/r,te=Pe*o+n,We=new ae(Math.sin(te),Math.cos(te));E&&P?(he(Re,Pe,We,q,h,E,-1,!0),he(Re,Pe,We,X,h,P,-1,!1)):P?(_e(Re,We,P.x,0,-1),he(Re,Pe,We,X,h,P,-1,!1)):s||_e(Re,We,t,I,-1);let Be=UE(T).normalize();if(Qo(Be,We,b),!re)for(let Ue=0;Ue<=a;Ue++){let Ge=Ue/a,tt=T.clone().multiplyScalar(Ge).add(A);Qo(tt,We,_),f.push(_.x,_.y,_.z),m.push(b.x,b.y,b.z),g.push(Pe,.5+_.y/i),Re.push(v++)}if(L&&S?(he(Re,Pe,We,q,l,S,1,!1),he(Re,Pe,We,X,l,L,1,!0)):S?(he(Re,Pe,We,q,l,S,1,!1),_e(Re,We,S.x,0,1)):s||_e(Re,We,e,V,1),u&&!re){let Ue=UE(T).multiplyScalar(-1).normalize();Qo(Ue,We,b);for(let Ge=0;Ge<=a;Ge++){let tt=Ge/a,Fe=T.clone().multiplyScalar(-tt).add(H);Qo(Fe,We,_),f.push(_.x,_.y,_.z),m.push(b.x,b.y,b.z),g.push(Pe,.5+_.y/i),Re.push(v++)}}u&&!s&&Re.push(Re[0]),se.push(Re)}for(let fe=0;fe<se.length-1;fe++)for(let Re=0;Re<se[0].length-1;Re++){if(s&&u&&Re==a)continue;let Pe=se[fe][Re],te=se[fe+1][Re],We=se[fe+1][Re+1],Be=se[fe][Re+1],Ue=f[We*3+0],Ge=f[We*3+2];p.push(Pe,te,Be),(Ue!=0||Ge!=0)&&p.push(te,We,Be)}o<Math.PI*2&&(Ee(-1,se[0],n),Ee(1,se[se.length-1],n+o)),this.setIndex(p),this.setAttribute("position",new ut(f,3)),this.setAttribute("normal",new ut(m,3)),this.setAttribute("uv",new ut(g,2));function he(fe,Re,Pe,te,We,Be,Ue,Ge){for(let tt=0;tt<c+1;tt++){let Fe=tt/c,He=Ue<0?Fe:1-Fe;Ge&&(He-=1),He*=te;let nt=new ae(Math.sin(He),Math.cos(He)*Ue),ht=nt.clone().multiplyScalar(We).add(Be);Qo(ht,Pe,_),f.push(_.x,_.y,_.z),Qo(nt,Pe,b),m.push(b.x,b.y,b.z),g.push(Re,.5+_.y/i),fe.push(v++)}}function _e(fe,Re,Pe,te,We){let Be=new O,Ue=new ae,Ge=[Pe,te];We<0&&Ge.reverse();for(let tt of Ge)Ue.set(tt,x*We),Qo(Ue,Re,Be),f.push(Be.x,Be.y,Be.z),m.push(0,We,0),g.push(.5,.5),fe.push(v++)}function Ee(fe,Re,Pe){let te=new ae(Math.sin(Pe),Math.cos(Pe)),We=new ae(-Math.cos(Pe),Math.sin(Pe)),Be=new O,Ue=fe<0?(Fe,He,nt)=>p.push(Fe,He,nt):(Fe,He,nt)=>p.push(Fe,nt,He),Ge=new ae((e+t+V+I)/4,0);Qo(Ge,te,Be),f.push(Be.x,Be.y,Be.z),m.push(We.x,0,We.y),g.push(.5,.5);let tt=v++;for(let Fe of Re){let He=f.slice(Fe*3,Fe*3+3);f.push(...He),m.push(We.x,0,We.y);let nt=g.slice(Fe*2,Fe*2+2);g.push(...nt),v++}for(let Fe=tt+1;Fe<v-1;Fe++)Ue(tt,Fe,Fe+1);Ue(tt,v-1,tt+1)}}},xY=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=dt.clamp(i.thetaLength,0,360),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:a,heightSegments:s,openEnded:n,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:c,cornerSegments:u}=e.parameters,d;return l===0?(d=new St,d.setAttribute("position",new ut([],3))):h>0||c>0||l<360?d=new N3(0,t/2,r,a,s,n,o,l*Math.PI/180,h,c,u,0,!0):d=new cb(t/2,r,a,s,n),d.scale(1,1,i/t),Object.assign(d,{userData:{...e,type:"ConeGeometry"}})}},bY=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:a,heightSegments:s,depthSegments:n,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o==0?h=new Ks(t,i,r,a,s,n):h=new wY(t,i,r,a,s,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Y0=Math.PI/2,wY=class extends St{constructor(e=1,t=1,i=1,r=1,a=1,s=1,n=0,o=4){super(),this.type="BoxGeometry";let l=this;r=Math.floor(r),a=Math.floor(a),s=Math.floor(s),o=Math.floor(o),n=Math.min(n,e/2,t/2,i/2);let h=[],c=[],u=[],d=[],p=0,f=0;m("z","y","x",-1,-1,i,t,e,s,a,0),m("z","y","x",1,-1,i,t,-e,s,a,1),m("x","z","y",1,1,e,i,t,r,s,2),m("x","z","y",1,-1,e,i,-t,r,s,3),m("x","y","z",1,-1,e,t,i,r,a,4),m("x","y","z",-1,-1,e,t,-i,r,a,5),n>0&&(g("z","y","x",-1,-1,1,i,t,e,s,0),g("z","y","x",1,-1,-1,i,t,e,s,1),g("z","y","x",-1,1,-1,i,t,e,s,1),g("z","y","x",1,1,1,i,t,e,s,0),g("x","y","z",-1,-1,-1,e,t,i,r,0),g("x","y","z",1,-1,1,e,t,i,r,1),g("x","y","z",-1,1,1,e,t,i,r,0),g("x","y","z",1,1,-1,e,t,i,r,1),g("y","x","z",-1,-1,1,t,e,i,a,0),g("y","x","z",1,-1,-1,t,e,i,a,1),g("y","x","z",1,1,1,t,e,i,a,1),g("y","x","z",-1,1,-1,t,e,i,a,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new ut(c,3)),this.setAttribute("normal",new ut(u,3)),this.setAttribute("uv",new ut(d,2));function m(x,b,_,M,A,S,P,L,E,T,B){let V=(S-2*n)/E,I=(P-2*n)/T,H=S/2-n,q=P/2-n,X=L/2,Y=E+1,ie=T+1,ce=0,de=0,ue=new O;for(let re=0;re<ie;re++){let se=re*I-q;for(let he=0;he<Y;he++){let _e=he*V-H;ue[x]=_e*M,ue[b]=se*A,ue[_]=X,c.push(ue.x,ue.y,ue.z),ue[x]=0,ue[b]=0,ue[_]=L>0?1:-1,u.push(ue.x,ue.y,ue.z),d.push(he/E),d.push(1-re/T),ce+=1}}for(let re=0;re<T;re++)for(let se=0;se<E;se++){let he=p+se+Y*re,_e=p+se+Y*(re+1),Ee=p+(se+1)+Y*(re+1),fe=p+(se+1)+Y*re;h.push(he,_e,fe),h.push(_e,Ee,fe),de+=6}l.addGroup(f,de,B),f+=de,p+=ce}function g(x,b,_,M,A,S,P,L,E,T,B){let V=(P-2*n)/T,I=P/2-n,H=L/2-n,q=E/2,X=T+1,Y=0,ie=0,ce=new O,de=new O;for(let ue=0;ue<o+1;ue++){let re=ue/o*Y0,se=Math.sin(re)*n,he=(1-Math.cos(re))*n,_e=Math.sin(re),Ee=Math.cos(re);ce[b]=(H+se)*A,ce[_]=(q-he)*S,de[x]=0,de[b]=_e*Math.sign(ce[b]),de[_]=Ee*Math.sign(ce[_]);for(let fe=0;fe<X;fe++){let Re=fe*V-I;ce[x]=Re*M,c.push(ce.x,ce.y,ce.z),u.push(de.x,de.y,de.z),d.push(fe/T),d.push(0),Y+=1}}for(let ue=0;ue<o;ue++)for(let re=0;re<T;re++){let se=p+re+X*ue,he=p+re+X*(ue+1),_e=p+(re+1)+X*(ue+1),Ee=p+(re+1)+X*ue;h.push(se,he,Ee),h.push(he,_e,Ee),ie+=6}l.addGroup(f,ie,B),f+=ie,p+=Y}function v(x,b,_){let M=new O,A=new O(e/2,t/2,i/2);A.subScalar(n);let S=[],P=x*b*_>0?(E,T,B)=>h.push(E,T,B):(E,T,B)=>h.push(E,B,T);for(let E=0;E<=o;E++){let T=[],B=Y0*(1-E/o),V=Math.cos(B),I=Math.sin(B),H=0;for(let q=0;q<=E;q++){let X=Math.cos(H),Y=Math.sin(H);M.x=V*X,M.y=I,M.z=V*Y;let ie=A.clone().addScaledVector(M,n);c.push(x*ie.x,b*ie.y,_*ie.z),u.push(x*M.x,b*M.y,_*M.z),d.push(0,0),T.push(p++),H+=Y0/E}S.push(T)}let L=S.length-1;for(let E=0;E<L;E++){let T=S[E],B=S[E+1],V=T.length-1;P(T[0],B[1],B[0]);for(let I=1;I<=V;I++)P(T[I-1],T[I],B[I]),P(T[I],B[I+1],B[I])}}}},qb=class extends St{constructor(e=[],t=[],i="",r=1,a=.2,s=4){super(),this.type="PolyhedronGeometryRound";let n=[],o=[],l=[];h(),c(),this.setAttribute("position",new ut(n,3)),this.setAttribute("normal",new ut(l,3)),this.setAttribute("uv",new ut(o,2));return;function h(){a=Math.min(1-1e-5,a),a==0&&(s=0);let u={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new O,p=d.clone(),f=new Kr,m=a*r,g=r-m,v=s+1,x=new O,b=(X,Y)=>x.subVectors(X,Y).normalize(),_=(X,Y)=>Array(X).fill(void 0).map(Y),M=_(e.length/3,(X,Y)=>new O().fromArray(e,Y*3).setLength(r)),A=[],S=1e6;for(let X=0;X<M.length;X++){let Y=M[X],ie=[],ce,de,ue,re=1e10,se=-1;for(;(se=t.indexOf(X,se+1))!=-1;){let fe=se-se%3;ce=t[fe+(se+1)%3],de=t[fe+(se+2)%3],ue=Y.distanceToSquared(M[ce]),re=Math.min(re,ue),ie.push([ce,de,ue])}re+=1e-6;let he=[],_e=0,Ee=ie.length;for(let fe=0;fe<Ee;fe++){[ce,de,ue]=ie[_e];let Re=A[ce]?.includes(X)==!0;ue<=re&&he.push(ce+ +Re*S),_e=ie.findIndex(Pe=>Pe[0]==de)}A.push(he)}let P=[];{let X=0,Y=0,ie,ce,de=u==3;for(let ue=0;ue<=s;ue++){ie=ue*(ue+1)/2,ce=(ue+1)*(ue+2)/2;for(let re=0;re<s-ue;re++)[X,Y]=[ie+re+ue+2,ce+re+ue+3],P.push(ie,ce,...de?[Y,ie]:[X,ce],Y,X),[ie,ce]=[X,Y];P.push(ie,ce,ie+s+2)}}let L=d.clone(),E=d.clone(),T=d.clone(),B=d.clone(),V=d.clone(),I=[],H=_(M.length,()=>_(u,()=>d.clone()));for(let X=0;X<M.length;X++){d.copy(M[X]).normalize(),L.copy(d).multiplyScalar(g);let Y=A[X];for(let he=0;he<Y.length;he++){let _e=Y[he],Ee=Y[(he+1)%u];f.setFromPointsAndIndices(M,X,_e%S,Ee%S),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(L,H[X][he])}let ie=[],ce=[],de=[],ue=new O;s==0&&[...H[X]].reduce((he,_e)=>he.add(_e),ue).multiplyScalar(1/u);for(let he=0;he<u;he++){let _e=[],Ee=(he-1+u)%u,fe=H[X][Ee],Re=H[X][he];d.copy(fe).sub(L),p.copy(Re).sub(L);let Pe=L.angleTo(d),te=d.angleTo(p),We=Math.cos(Pe)*m;s==0?E.copy(ue):E.copy(L).setLength(g+We),ce.push(We);let Be=[E,fe,Re];for(let Ue=0;Ue<2;Ue++){let Ge=Be[Ue],tt=Be[Ue+1];B.subVectors(Ge,L),V.subVectors(tt,L),T.crossVectors(B,V).normalize();for(let Fe=0;Fe<v;Fe++){let He=[Pe,te][Ue]*Fe/v;d.copy(B).applyAxisAngle(T,He).add(L),ie.push(d.clone()),Ue&&(b(d,L),_e.push([Fe==0?Ge:d.clone(),x.clone()]))}Ue&&(b(tt,L),_e.push([tt,x.clone()]))}de.push(_e)}I.push(de);let re=2*v,se=2;for(let he=0;he<u;he++){let _e=re*he,Ee=re*((he+1)%u),fe=[ie[_e]];for(let Pe=1;Pe<v;Pe++){B=ie[_e+Pe],V=ie[Ee+Pe],fe.push(B);for(let te=1,We=Pe-se+1;te<=We;te++)d.lerpVectors(B,V,te/(We+1)),d.sub(L).setLength(ce[he]).add(L),fe.push(d.clone());fe.push(V)}for(let Pe=0;Pe<v;Pe++)fe.push(ie[Pe+v+_e]);fe.push(ie[Ee+v]);let Re=P.map(Pe=>fe[Pe]);n.push(...Re.map(Pe=>[Pe.x,Pe.y,Pe.z]).flat()),l.push(...Re.map(Pe=>(b(Pe,L),[x.x,x.y,x.z])).flat())}}let q=[];for(let X=0;X<A.length;X++)for(let Y=0;Y<u;Y++){let ie=A[X][Y];if(ie<S){let ce=A[ie].findIndex(re=>re%S==X),de=I[X][Y],ue=I[ie][ce];for(let re=0;re<v;re++){let se=de[re],he=ue[v-re],_e=de[re+1],Ee=ue[v-(re+1)];[se,he,_e,_e,he,Ee].forEach(fe=>{n.push(fe[0].x,fe[0].y,fe[0].z),l.push(fe[1].x,fe[1].y,fe[1].z)})}q.push(de[0][0],ue[v][0],de[v][0],ue[0][0])}}for(;q.length;){let X,Y,ie,ce;[X,Y]=q.splice(0,2);let de=[X];for(;X!=Y;)de.push(Y),ie=q.indexOf(Y),ce=ie%2,Y=q.splice(ie-ce,2)[1-ce];x.subVectors(de[0],de[1]).cross(d.subVectors(de[0],de[2])).normalize();let ue=x.dot(de[0])<0;ue&&x.negate();for(let re=1;re<=de.length-2;re++)[de[re+ +ue],de[re+1-+ue],de[0]].forEach(se=>{n.push(se.x,se.y,se.z),l.push(x.x,x.y,x.z)})}}function c(){let u=new O;for(let A=0;A<n.length;A+=3){u.x=n[A+0],u.y=n[A+1],u.z=n[A+2];let S=_(u)/2/Math.PI+.5,P=M(u)/Math.PI+.5;o.push(S,1-P)}let d=new O,p=new O,f=new O,m=new O,g=new ae,v=new ae,x=new ae,b=(A,S,P,L)=>{L<0&&A.x===1&&(o[S]=A.x-1),P.x===0&&P.z===0&&(o[S]=L/2/Math.PI+.5)};for(let A=0,S=0;A<n.length;A+=9,S+=6){d.set(n[A+0],n[A+1],n[A+2]),p.set(n[A+3],n[A+4],n[A+5]),f.set(n[A+6],n[A+7],n[A+8]),g.set(o[S+0],o[S+1]),v.set(o[S+2],o[S+3]),x.set(o[S+4],o[S+5]),m.copy(d).add(p).add(f).divideScalar(3);let P=_(m);b(g,S+0,d,P),b(v,S+2,p,P),b(x,S+4,f,P)}for(let A=0;A<o.length;A+=6){let S=o[A+0],P=o[A+2],L=o[A+4],E=Math.max(S,P,L),T=Math.min(S,P,L);E>.9&&T<.1&&(S<.2&&(o[A+0]+=1),P<.2&&(o[A+2]+=1),L<.2&&(o[A+4]+=1))}function _(A){return Math.atan2(A.z,-A.x)}function M(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(e){return new qb(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},_Y=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:a,corner:s,cornerSides:n}=e.parameters,o=a===0&&s!==0?new z3(t*.5,s,n):new qT(t*.5,a);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},z3=class extends qb{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,a=1/r,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,-a,-r,0,-a,r,0,a,-r,0,a,r,-a,-r,0,-a,r,0,a,-r,0,a,r,0,-r,0,-a,r,0,-a,-r,0,a,r,0,a],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(s,n,o,e,t,i),this.type=o}static fromJSON(e){return new z3(e.radius,e.corner,e.cornerSides)}},vd=1e-12,Xb=class{constructor(e){this.position=new ae,this.startPosition=new ae,this.uuid=dt.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new Xb(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},cx=class extends Xb{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new cx(this.parent).copy(this)}},tu=class extends Xb{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new cx(this),new cx(this))}static create(e,t){let i=new tu(e,new ae(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let a=this.controls[i];this.position.distanceTo(a.position)<=t?a.position.copy(this.position):a.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 tu(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new ae,t=new ae){let[i,r]=this.computeTangents();return i&&r&&(FE(i,e),FE(r,t)),[e,t]}computeTangent(e=new ae){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new ae){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function FE(e,t=new ae){let i=e.length();return t.set(-e.y/i,e.x/i)}var Yb=e=>e,Nu=new ae,dv=new ae,SY=new ae,AY=new ae,EY=new ae,MY=new ae,k3=new O,V3=new O;function CY(e){let t=new ae;t.addVectors(e.v0,Nu.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new ae;return i.addVectors(e.v2,dv.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Ws(e.v0,t,i,e.v2)}function Od(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function TY(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function PY(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function j3(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((a*a+r*r-s*s)/(2*a*r))}function DY(e,t,i){return zE(e,t)&&zE(t,i)&&ux(e.position,t.position,i.position)}function ux(e,t,i){return Nu.copy(t).sub(e).cross(dv.copy(i).sub(e))===0}function RY(e,t,i,r,a){let s=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(e.y-t.y)/s,h=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(t.x-e.x)/s;return r.set(o+l,n+h),a.set(o-l,n-h),[r,a]}function OY(e,t,i){let r=e.distanceTo(i),a=t.distanceTo(i);return r<a?t:e}function LY(e,t,i,r,a,s){let n=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,c=Math.sqrt((n+l)*(n+l)+(o+h)*(o+h)),u;return j3(t,e,i)>Math.PI&&(c*=-1),Od(h,o)?u=(o+h)*(r/c-.5)*8/3/(n-l):u=(n+l)*(r/c-.5)*8/3/(h-o),a.set(t.x-u*o,t.y+u*n),s.set(i.x+u*h,i.y-u*l),[a,s]}function NE(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function zE(e,t){return ux(e.position,e.controls[1].position,t.position)&&ux(e.position,t.controls[0].position,t.position)}function IY(e,t,i,r,a=.5){let s=Nu.subVectors(t,e).multiplyScalar(a).add(e),n=dv.subVectors(i,t).multiplyScalar(a).add(t),o=SY.subVectors(r,i).multiplyScalar(a).add(i),l=s,h=AY.subVectors(n,s).multiplyScalar(a).add(s),c=EY.subVectors(o,n).multiplyScalar(a).add(n),u=o,d=MY.subVectors(c,h).multiplyScalar(a).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,d.x,d.y,c.x,c.y,u.x,u.y,r.x,r.y]}function BY(e,t,i=12,r=!0){let a=V3.set(0,0,0),s,n=0,o=[];for(let l=0;l<t.length;l++){let h=Yb(t[l]),c=Nu,u=xh(h,i);o.push(u);for(let d=0;d<=u;d++)if(h instanceof Ws||h instanceof Ml||h instanceof Pn){if(h.getPoint(d/u,c),a.set(c.x,c.y,0),s!==void 0&&PY(s,a))continue;s===void 0&&(s=k3),s.copy(a),e.setXYZ(n,a.x,a.y,a.z),n++}}return r&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),e}function UY(e,t,i,r=12,a=!0){let s=V3.set(0,0,0),n=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,c=Yb(t[l]),u=Nu,d=xh(c,r);o.push(d);for(let p=0;p<=d;p++)if(c instanceof Ws||c instanceof Ml||c instanceof Pn){if(c.getPoint(p/d,u),s.set(u.x,u.y,0),h?.equals(s))continue;h===void 0?h=k3:(e.setXYZ(n,h.x,h.y,h.z),n++,e.setXYZ(n,s.x,s.y,s.z),n++),h.copy(s)}}return a&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),o}function kE(e,t=12,i=!1){let r=[];for(let a=0,s=e.length;a<s;a++){let n=e[a],o=0;if(i&&n.roundedCurveCorner!==void 0){let l=xh(n.roundedCurveCorner,t)*.5;a>0&&(r[a-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=xh(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=xh(e[0].roundedCurveCorner,t)*.5),r}function xh(e,t=12){return e&&e instanceof Kg?t*2:e&&(e instanceof Pn||e instanceof GT)?1:e&&e instanceof lb?t*e.points.length:t}function FY(e,t,i=12,r=!0){let a,s=0;for(let n=0;n<t.length;n++){let o=Yb(t[n]),l=xh(o,i),h=Nu;for(let c=0;c<=l;c++)if(o instanceof Ws||o instanceof Ml||o instanceof Pn){if(o.getPoint(c/l,h),a!==void 0&&TY(a,h,vd))continue;a===void 0&&(a=dv),a.copy(h),e.push(h.x,h.y),s++}}return Od(e[0],e[e.length-2],vd)&&Od(e[1],e[e.length-1],vd)&&(e.pop(),e.pop()),r&&s>1&&!(Od(e[s-1],e[1],vd)&&Od(e[s-2],e[0],vd))&&(e.push(e[0],e[1]),s++),e}var Q0=new ae,NY=new ae,zY=new ae,kY=new ae,VY=new ae,jY=new ae,ur=class extends $m{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new ts(new O(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=dt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new ur;return r.isClosed=e.isClosed,r.points=e.points.map(a=>tu.create(a.id,a.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(a=>ur.createFromState(a)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let a=0,s=this.shapeHoles.length;a<s;a++){let n=this.shapeHoles[a],o=n.points.length,l=n.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let a=this.shapeHoles[i],s=e-t;if(s<=a.points.length-1)return a.points[s];t+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let a=this.shapeHoles[i],s=a.points.indexOf(e);if(s>=0)return t+s;t+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=Q0.set(e,t);for(let r=0,a=this.points.length;r<a;r++){let s=this.points[r];s.position.multiply(i),s.controls[0].position.multiply(i),s.controls[1].position.multiply(i)}for(let r=0,a=this.shapeHoles.length;r<a;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=dt.generateUUID()){let r;e instanceof ae?r=e:r=new ae(e,t);let a=new tu(i,r);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return BY(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=kE(this.points,e,!1),this.roundedCurveDivisions=kE(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return UY(e,this.curves,t,i,this.autoClose).reduce((r,a)=>r+a,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),FY(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,a=0;t&&this.points[0].roundedCurveCorner!==void 0&&(a=xh(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=r.reduce((n,o)=>n+o,0));for(let n=0,o=r.length;n<o;n++){let l=r[n];if(s<i+l)return[n,(s-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,n=s[e];if(NE(r,a)){let l=r.position.distanceTo(a.position);return r.position.distanceTo(Q0.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=s[l];return(t-o)/n}dispose(){}_applyCurveForPoint(e,t){NE(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let a=this.points[t-1];this._applyCurveForPoint(r,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let a=this.points[i],s=this.points[i-1]??this.points[this.points.length-1],n=this.points[i+1]??this.points[0],o=a.roundness,l=s&&n&&DY(s,a,n);if(!a.controlsMoved()&&o>0&&!l){let h=a.curveBefore,c=a.curveAfter;if(h===void 0||c===void 0)continue;let u=a.roundedCurveBefore,d=a.roundedCurveAfter,p=h.getLength(),f=c.getLength(),m=Math.min(o,p*.499),g=Math.min(o,f*.499),v=Math.min(m,g),x=1-v/p,b=v/f,_=h.getPointAt(x,Q0),M=c.getPointAt(b,NY);this._subSplitCurve(h,u,x,_,void 0),this._subSplitCurve(c,d,b,void 0,M);let A;if(this.useCubicForRoundedCorners){let S=j3(_,a.position,M)/2,P=Math.tan(S)*_.distanceTo(a.position),[L,E]=RY(_,M,P,zY,kY),T=OY(L,E,a.position),[B,V]=LY(T,_,M,P,VY,jY);A=new Ws(_.clone(),B.clone(),V.clone(),M.clone())}else A=new Ml(_.clone(),a.position.clone(),M.clone());a.roundedCurveCorner=A,this.roundedCurves.splice(i+t,0,A),t++}}}}_subSplitCurve(e,t,i,r,a){if(e instanceof Pn)r!==void 0&&t.v2.copy(r),a!==void 0&&t.v1.copy(a);else{let s=e,n=t,o=s.getUtoTmapping(i,0),l=IY(s.v0,s.v1,s.v2,s.v3,o);return r!==void 0&&(n.v0.set(l[0],l[1]),n.v1.set(l[2],l[3]),n.v2.set(l[4],l[5]),n.v3.set(l[6],l[7])),a!==void 0&&(n.v0.set(l[6],l[7]),n.v1.set(l[8],l[9]),n.v2.set(l[10],l[11]),n.v3.set(l[12],l[13])),n}return t}clone(){let e=new ur(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=i*7,a=e.points[r+0],s=e.points[r+1],n=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],c=e.points[r+6],u=new tu(dt.generateUUID(),new ae(a,s));u.controls[0].position.set(n,o),u.controls[1].position.set(l,h),u.roundness=c,this.points.push(u)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new ur;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(a,s)=>{s instanceof Ws&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},r=a=>{let s=[],n,o;for(n=0,o=a.length;n<o;n++)a[n]instanceof Ml&&(a[n]=CY(a[n]));for(n=0,o=a.length;n<o;n++){let c=a[n],u=n>0?a[n-1]:null,d;c instanceof Ws?(d=this.createPoint(c.v0),d.controls[1].position.copy(c.v1)):c instanceof Pn&&(d=this.createPoint(c.v1)),d!==void 0&&(u!==null&&i(d,u),s.push(d))}let l=a[a.length-1],h=!1;return l instanceof Ws?l.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(l.v2),h=!0):l instanceof Pn&&l.v2.equals(s[0].position)&&(h=!0),this.isClosed=h,s};return this.points=r(e.curves),e instanceof $m&&(this.shapeHoles=e.holes.map(a=>{let s=new ur;return s.fromShape(a),s})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},dx=Math.PI*2;function K0({x:e,y:t},i,r,a,s){return{x:e*i+a,y:t*r+s}}function GY(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),a=Math.sin(e),s=Math.cos(e+t),n=Math.sin(e+t);return[{x:r-a*i,y:a+r*i},{x:s+n*i,y:n-s*i},{x:s,y:n}]}function VE(e,t,i,r){let a=e*r-t*i<0?-1:1,s=Math.min(1,Math.max(-1,e*i+t*r));return a*Math.acos(s)}function HY(e,t,i,r,a,s,n,o,l,h){let c=Math.pow(a,2),u=Math.pow(s,2),d=Math.pow(n,2),p=Math.pow(o,2),f=c*u-c*p-u*d;f<0&&(f=0),f/=c*p+u*d,f=Math.sqrt(f)*(l===h?-1:1);let m=f*a/s*o,g=f*-s/a*n,v=m+(e+i)/2,x=g+(t+r)/2,b=(n-m)/a,_=(o-g)/s,M=(-n-m)/a,A=(-o-g)/s,S=VE(1,0,b,_),P=VE(b,_,M,A);return!h&&P>0&&(P-=dx),h&&P<0&&(P+=dx),{centerx:v,centery:x,ang1:S,ang2:P}}function WY({px:e,py:t,cx:i,cy:r,rx:a,ry:s,largeArcFlag:n,sweepFlag:o}){let l=[];if(a===0||s===0)return[];let h=(e-i)/2,c=(t-r)/2;if(h===0&&c===0)return[];a=Math.abs(a),s=Math.abs(s);let u=Math.pow(h,2)/Math.pow(a,2)+Math.pow(c,2)/Math.pow(s,2);u>1&&(a*=Math.sqrt(u),s*=Math.sqrt(u));let d=HY(e,t,i,r,a,s,h,c,n,o),{ang1:p,ang2:f}=d,{centerx:m,centery:g}=d,v=Math.abs(f)/(dx/4);Math.abs(1-v)<1e-7&&(v=1);let x=Math.max(Math.ceil(v),1);f/=x;for(let b=0;b<x;b++)l.push(GY(p,f)),p+=f;return l.map(b=>{let{x:_,y:M}=K0(b[0],a,s,m,g),{x:A,y:S}=K0(b[1],a,s,m,g),{x:P,y:L}=K0(b[2],a,s,m,g);return{x1:_,y1:M,x2:A,y2:S,x:P,y:L}})}var Oi;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Oi||(Oi={}));var Mr;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Mr||(Mr={}));function It(e,t){if(!e)throw t||"Assertion Failed!"}var Ct=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){It(e.vertLeq(t,i)&&e.vertLeq(i,r));var a=i.s-t.s,s=r.s-i.s;return a+s>0?a<s?i.t-t.t+(t.t-r.t)*(a/(a+s)):i.t-r.t+(r.t-t.t)*(s/(a+s)):0},e.edgeSign=function(t,i,r){It(e.vertLeq(t,i)&&e.vertLeq(i,r));var a=i.s-t.s,s=r.s-i.s;return a+s>0?(i.t-r.t)*a+(i.t-t.t)*s:0},e.transEval=function(t,i,r){It(e.transLeq(t,i)&&e.transLeq(i,r));var a=i.t-t.t,s=r.t-i.t;return a+s>0?a<s?i.s-t.s+(t.s-r.s)*(a/(a+s)):i.s-r.s+(r.s-t.s)*(s/(a+s)):0},e.transSign=function(t,i,r){It(e.transLeq(t,i)&&e.transLeq(i,r));var a=i.t-t.t,s=r.t-i.t;return a+s>0?(i.s-r.s)*a+(i.s-t.s)*s:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,a){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+a)/2:i+(a-i)*(t/(t+r)):a+(i-a)*(r/(t+r))},e.intersect=function(t,i,r,a,s){var n,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,a)||(l=r,r=a,a=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=a,a=l),e.vertLeq(r,i)?e.vertLeq(i,a)?(n=e.edgeEval(t,r,i),o=e.edgeEval(r,i,a),n+o<0&&(n=-n,o=-o),s.s=e.interpolate(n,r.s,o,i.s)):(n=e.edgeSign(t,r,i),o=-e.edgeSign(t,a,i),n+o<0&&(n=-n,o=-o),s.s=e.interpolate(n,r.s,o,a.s)):s.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,a)||(l=r,r=a,a=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=a,a=l),e.transLeq(r,i)?e.transLeq(i,a)?(n=e.transEval(t,r,i),o=e.transEval(r,i,a),n+o<0&&(n=-n,o=-o),s.t=e.interpolate(n,r.t,o,i.t)):(n=e.transSign(t,r,i),o=-e.transSign(t,a,i),n+o<0&&(n=-n,o=-o),s.t=e.interpolate(n,r.t,o,a.t)):s.t=(r.t+i.t)/2},e}(),yd=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),Yf=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),Bc=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),jE=function(){function e(){var t=new Bc,i=new yd,r=new Yf(0),a=new Yf(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=a,a.next=a,a.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=a}return e.prototype.makeEdge_=function(t){var i=new Yf(0),r=new Yf(1);t.Sym.side<t.side&&(t=t.Sym);var a=t.Sym.next;return r.next=a,a.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,a=i.Onext;r.Sym.Lnext=i,a.Sym.Lnext=t,t.Onext=a,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var a=t;It(a,"Vertex can't be null!");var s=r.prev;a.prev=s,s.next=a,a.next=r,r.prev=a,a.anEdge=i;var n=i;do n.Org=a,n=n.Onext;while(n!==i)},e.prototype.makeFace_=function(t,i,r){var a=t;It(a,"Face can't be null");var s=r.prev;a.prev=s,s.next=a,a.next=r,r.prev=a,a.anEdge=i,a.trail=null,a.marked=!1,a.inside=r.inside;var n=i;do n.Lface=a,n=n.Lnext;while(n!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,a=r;do a.Org=i,a=a.Onext;while(a!==r);var s=t.prev,n=t.next;n.prev=s,s.next=n},e.prototype.killFace_=function(t,i){var r=t.anEdge,a=r;do a.Lface=i,a=a.Lnext;while(a!==r);var s=t.prev,n=t.next;n.prev=s,s.next=n},e.prototype.makeEdge=function(){var t=new Bc,i=new Bc,r=new yd,a=this.makeEdge_(this.eHead);return this.makeVertex_(t,a,this.vHead),this.makeVertex_(i,a.Sym,this.vHead),this.makeFace_(r,a,this.fHead),a},e.prototype.splice=function(t,i){var r=!1,a=!1;if(t!==i){if(i.Org!==t.Org&&(a=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!a){var s=new Bc;this.makeVertex_(s,i,t.Org),t.Org.anEdge=t}if(!r){var n=new yd;this.makeFace_(n,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var a=new yd;this.makeFace_(a,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var a=new Bc;return this.makeVertex_(a,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,a=this.makeEdge_(t),s=a.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(a,t.Lnext),this.splice_(s,i),a.Org=t.Dst,s.Org=i.Org,a.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!r){var n=new yd;this.makeFace_(n,a,t.Lface)}return a},e.prototype.zapFace=function(t){var i=t.anEdge,r,a,s,n,o;a=i.Lnext;do r=a,a=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=i);n=t.prev,o=t.next,o.prev=n,n.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,a,s,n,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,n=r.Org;a=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(s.Lface),o+l-2<=t&&Ct.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&Ct.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(a=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===n);)r=a;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,a,s,n,o,l,h;for(s=t,s=t;(a=s.next)!==t;s=a){It(a.prev===s),l=a.anEdge;do It(l.Sym!==l),It(l.Sym.Sym===l),It(l.Lnext.Onext.Sym===l),It(l.Onext.Sym.Lnext===l),It(l.Lface===a),l=l.Lnext;while(l!==a.anEdge)}for(It(a.prev===s&&a.anEdge===null),o=i,o=i;(n=o.next)!==i;o=n){It(n.prev===o),l=n.anEdge;do It(l.Sym!==l),It(l.Sym.Sym===l),It(l.Lnext.Onext.Sym===l),It(l.Onext.Sym.Lnext===l),It(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(It(n.prev===o&&n.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)It(l.Sym.next===h.Sym),It(l.Sym!==l),It(l.Sym.Sym===l),It(l.Org!==null),It(l.Dst!==null),It(l.Lnext.Onext.Sym===l),It(l.Onext.Sym.Lnext===l);It(l.Sym.next===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),GE=function(){function e(){this.handle=null}return e}(),HE=function(){function e(){this.key=null,this.node=0}return e}(),qY=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new GE,this.handles[r]=new HE;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,a,s,n;for(a=i[t].handle;;){if(n=t<<1,n<this.size&&this.leq(r[i[n+1].handle].key,r[i[n].handle].key)&&++n,It(n<=this.max),s=i[n].handle,n>this.size||this.leq(r[a].key,r[s].key)){i[t].handle=a,r[a].node=t;break}i[t].handle=s,r[s].node=t,t=n}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,a,s,n;for(a=i[t].handle;;){if(n=t>>1,s=i[n].handle,n===0||this.leq(r[s].key,r[a].key)){i[t].handle=a,r[a].node=t;break}i[t].handle=s,r[s].node=t,t=n}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var a,s;for(s=this.nodes.length,this.nodes.length=this.max+1,a=s;a<this.nodes.length;a++)this.nodes[a]=new GE;for(s=this.handles.length,this.handles.length=this.max+1,a=s;a<this.handles.length;a++)this.handles[a]=new HE}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,a=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),a},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,a;It(t>=1&&t<=this.max&&r[t].key!==null),a=r[t].node,i[a].handle=i[this.size].handle,r[i[a].handle].node=a,--this.size,a<=this.size&&(a<=1||this.leq(r[i[a>>1].handle].key,r[i[a].handle].key)?this.floatDown_(a):this.floatUp_(a)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),Z0=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),WE=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),XY=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new WE,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new WE;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),YY=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var a=t.event,s=i.eUp,n=r.eUp;if(s.Dst===a)return n.Dst===a?Ct.vertLeq(s.Org,n.Org)?Ct.edgeSign(n.Dst,s.Org,n.Org)<=0:Ct.edgeSign(s.Dst,n.Org,s.Org)>=0:Ct.edgeSign(n.Dst,a,n.Org)<=0;if(n.Dst===a)return Ct.edgeSign(s.Dst,a,s.Org)>=0;var o=Ct.edgeEval(s.Dst,a,s.Org),l=Ct.edgeEval(n.Dst,a,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&It(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){It(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,a;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(a=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),a===null)return null;e.fixUpperEdge(t,i,a),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var a=new Z0;return a.eUp=r,a.nodeUp=t.dict.insertBefore(i.nodeUp,a),a.fixUpperEdge=!1,a.sentinel=!1,a.dirty=!1,r.activeRegion=a,a},e.isWindingInside=function(t,i){switch(t.windingRule){case Oi.ODD:return(i&1)!==0;case Oi.NONZERO:return i!==0;case Oi.POSITIVE:return i>0;case Oi.NEGATIVE:return i<0;case Oi.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,a=r.Lface;a.inside=i.inside,a.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var a,s=null,n=i,o=i.eUp;n!==r;){if(n.fixUpperEdge=!1,s=e.regionBelow(n),a=s.eUp,a.Org!=o.Org){if(!s.fixUpperEdge){e.finishRegion(t,n);break}a=t.mesh.connect(o.Lprev,a.Sym),e.fixUpperEdge(t,s,a)}o.Onext!==a&&(t.mesh.splice(a.Oprev,a),t.mesh.splice(o,a)),e.finishRegion(t,n),o=s.eUp,n=s}return o},e.addRightEdges=function(t,i,r,a,s,n){var o,l,h,c,u=!0;h=r;do It(Ct.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==a);for(s===null&&(s=e.regionBelow(i).eUp.Rprev),l=i,c=s;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===c.Org;)h.Onext!==c&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(c.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!u&&e.checkForRightSplice(t,l)&&(e.addWinding(h,c),e.deleteRegion(t,l),t.mesh.delete(c)),u=!1,l=o,c=h;l.dirty=!0,It(l.windingNumber-h.winding===o.windingNumber),n&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var a=Ct.vertL1dist(i,t),s=Ct.vertL1dist(r,t),n=.5*s/(a+s),o=.5*a/(a+s);t.coords[0]+=n*i.coords[0]+o*r.coords[0],t.coords[1]+=n*i.coords[1]+o*r.coords[1],t.coords[2]+=n*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,a,s,n){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,a),e.vertexWeights(i,s,n)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),a=i.eUp,s=r.eUp;if(Ct.vertLeq(a.Org,s.Org)){if(Ct.edgeSign(s.Dst,a.Org,s.Org)>0)return!1;Ct.vertEq(a.Org,s.Org)?a.Org!==s.Org&&(t.pq.delete(a.Org.pqHandle),e.spliceMergeVertices(t,s.Oprev,a)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(a,s.Oprev),i.dirty=r.dirty=!0)}else{if(Ct.edgeSign(a.Dst,s.Org,a.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(a.Sym),t.mesh.splice(s.Oprev,a)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),a=i.eUp,s=r.eUp,n;if(It(!Ct.vertEq(a.Dst,s.Dst)),Ct.vertLeq(a.Dst,s.Dst)){if(Ct.edgeSign(a.Dst,s.Dst,a.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,n=t.mesh.splitEdge(a),t.mesh.splice(s.Sym,n),n.Lface.inside=i.inside}else{if(Ct.edgeSign(s.Dst,a.Dst,s.Org)>0)return!1;i.dirty=r.dirty=!0,n=t.mesh.splitEdge(s),t.mesh.splice(a.Lnext,s.Sym),n.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),a=i.eUp,s=r.eUp,n=a.Org,o=s.Org,l=a.Dst,h=s.Dst,c,u,d=new Bc,p,f;if(It(!Ct.vertEq(h,l)),It(Ct.edgeSign(l,t.event,n)<=0),It(Ct.edgeSign(h,t.event,o)>=0),It(n!==t.event&&o!==t.event),It(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(c=Math.min(n.t,l.t),u=Math.max(o.t,h.t),c>u))return!1;if(Ct.vertLeq(n,o)){if(Ct.edgeSign(h,n,o)>0)return!1}else if(Ct.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),Ct.intersect(l,n,h,o,d),It(Math.min(n.t,l.t)<=d.t),It(d.t<=Math.max(o.t,h.t)),It(Math.min(h.s,l.s)<=d.s),It(d.s<=Math.max(o.s,n.s)),Ct.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),p=Ct.vertLeq(n,o)?n:o,Ct.vertLeq(p,d)&&(d.s=p.s,d.t=p.t),Ct.vertEq(d,n)||Ct.vertEq(d,o)?(e.checkForRightSplice(t,i),!1):!Ct.vertEq(l,t.event)&&Ct.edgeSign(l,t.event,d)>=0||!Ct.vertEq(h,t.event)&&Ct.edgeSign(h,t.event,d)<=0?h===t.event?(t.mesh.splitEdge(a.Sym),t.mesh.splice(s.Sym,a),i=e.topLeftRegion(t,i),a=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,a.Oprev,a,a,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Lnext,s.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=s.Oprev,s=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,s.Onext,a.Rprev,f,!0),!0):(Ct.edgeSign(l,t.event,d)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(a.Sym),a.Org.s=t.event.s,a.Org.t=t.event.t),Ct.edgeSign(h,t.event,d)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(a.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,a),a.Org.s=d.s,a.Org.t=d.t,a.Org.pqHandle=t.pq.insert(a.Org),e.getIntersectData(t,a.Org,n,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),a,s;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,a=i.eUp,s=r.eUp,a.Dst!==s.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(s),r=e.regionBelow(i),s=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(a),i=e.regionAbove(r),a=i.eUp)),a.Org!==s.Org)if(a.Dst!==s.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(a.Dst===t.event||s.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);a.Org===s.Org&&a.Dst===s.Dst&&(e.addWinding(s,a),e.deleteRegion(t,i),t.mesh.delete(a),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var a,s=r.Onext,n=e.regionBelow(i),o=i.eUp,l=n.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Ct.vertEq(o.Org,t.event)&&(t.mesh.splice(s.Oprev,o),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),n),h=!0),Ct.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,n,null),h=!0),h){e.addRightEdges(t,i,r.Onext,s,s,!0);return}Ct.vertLeq(l.Org,o.Org)?a=l.Oprev:a=o,a=t.mesh.connect(r.Lprev,a),e.addRightEdges(t,i,a,a.Onext,a.Onext,!1),a.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var a,s,n,o,l;if(a=i.eUp,Ct.vertEq(a.Org,r)){It(!1),e.spliceMergeVertices(t,a,r.anEdge);return}if(!Ct.vertEq(a.Dst,r)){t.mesh.splitEdge(a.Sym),i.fixUpperEdge&&(t.mesh.delete(a.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,a),e.sweepEvent(t,r);return}It(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,s=o=n.Onext,l.fixUpperEdge&&(It(s!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=s.Oprev),t.mesh.splice(r.anEdge,n),Ct.edgeGoesLeft(s)||(s=null),e.addRightEdges(t,i,n.Onext,o,s,!0)},e.connectLeftVertex=function(t,i){var r,a,s,n,o,l,h=new Z0;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,a=e.regionBelow(r),!!a){if(n=r.eUp,o=a.eUp,Ct.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(s=Ct.vertLeq(o.Dst,n.Dst)?r:a,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(i.anEdge.Sym,n.Lnext);else{var c=t.mesh.connect(o.Dnext,i.anEdge);l=c.Sym}s.fixUpperEdge?e.fixUpperEdge(t,s,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var a=e.topLeftRegion(t,r.activeRegion);It(a!==null);var s=e.regionBelow(a),n=s.eUp,o=e.finishLeftRegions(t,s,null);o.Onext===n?e.connectRightVertex(t,a,o):e.addRightEdges(t,a,o.Onext,n,n,!0)},e.addSentinel=function(t,i,r,a){var s=new Z0,n=t.mesh.makeEdge();n.Org.s=r,n.Org.t=a,n.Dst.s=i,n.Dst.t=a,t.event=n.Dst,s.eUp=n,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},e.initEdgeDict=function(t){t.dict=new XY(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],a=t.bmin[0]-i,s=t.bmax[0]+i,n=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,a,s,n),e.addSentinel(t,a,s,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(It(i.fixUpperEdge),It(++r===1)),It(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,a,s=t.mesh.eHead;for(i=s.next;i!==s;i=r)r=i.next,a=i.Lnext,Ct.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,a,i),t.mesh.delete(i),i=a,a=i.Lnext),a.Lnext===i&&(a!==i&&((a===r||a===r.Sym)&&(r=r.next),t.mesh.delete(a)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,a,s=0;for(a=t.mesh.vHead,r=a.next;r!==a;r=r.next)s++;for(s+=8,i=t.pq=new qY(s,Ct.vertLeq),a=t.mesh.vHead,r=a.next;r!==a;r=r.next)r.pqHandle=i.insert(r);return r!==a?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,a,s;for(r=i.fHead.next;r!==i.fHead;r=a)a=r.next,s=r.anEdge,It(s.Lnext!==s),s.Lnext.Lnext===s&&(e.addWinding(s.Onext,s),t.mesh.delete(s));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,a;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;a=t.pq.min(),!(a===null||!Ct.vertEq(a,r));)a=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,a.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),QY=function(){function e(){this.mesh=new jE,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=Oi.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,a,s,n,o,l=[0,0,0],h=[0,0,0],c=[0,0,0],u=[0,0,0],d=[0,0,0],p=[null,null,null],f=[null,null,null],m=this.mesh.vHead;i=m.next;for(var g=0;g<3;++g)s=i.coords[g],h[g]=s,f[g]=i,l[g]=s,p[g]=i;for(i=m.next;i!==m;i=i.next)for(var v=0;v<3;++v)s=i.coords[v],s<h[v]&&(h[v]=s,f[v]=i),s>l[v]&&(l[v]=s,p[v]=i);var x=0;if(l[1]-h[1]>l[0]-h[0]&&(x=1),l[2]-h[2]>l[x]-h[x]&&(x=2),h[x]>=l[x]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=f[x],a=p[x],c[0]=r.coords[0]-a.coords[0],c[1]=r.coords[1]-a.coords[1],c[2]=r.coords[2]-a.coords[2],i=m.next;i!==m;i=i.next)u[0]=i.coords[0]-a.coords[0],u[1]=i.coords[1]-a.coords[1],u[2]=i.coords[2]-a.coords[2],d[0]=c[1]*u[2]-c[2]*u[1],d[1]=c[2]*u[0]-c[0]*u[2],d[2]=c[0]*u[1]-c[1]*u[0],n=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],n>o&&(o=n,t[0]=d[0],t[1]=d[1],t[2]=d[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,a,s=0,n=t.next;n!==t;n=n.next)if(a=n.anEdge,!(a.winding<=0))do s+=(a.Org.s-a.Dst.s)*(a.Org.t+a.Dst.t),a=a.Lnext;while(a!==n.anEdge);if(s<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,a,s=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),s=!0),r=this.sUnit,a=this.tUnit;var n=this.longAxis_(i);r[n]=0,r[(n+1)%3]=1,r[(n+2)%3]=0,a[n]=0,a[(n+1)%3]=0,a[(n+2)%3]=i[n]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,a);s&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,a;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Ct.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ct.vertLeq(r.Org,r.Dst);r=r.Lnext);a=r.Lprev;for(var s=void 0;r.Lnext!==a;)if(Ct.vertLeq(r.Dst,a.Org)){for(;a.Lnext!==r&&(Ct.edgeGoesLeft(a.Lnext)||Ct.edgeSign(a.Org,a.Dst,a.Lnext.Dst)<=0);)s=t.connect(a.Lnext,a),a=s.Sym;a=a.Lprev}else{for(;a.Lnext!==r&&(Ct.edgeGoesRight(r.Lprev)||Ct.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(a.Lnext===r)throw"Mono region invalid";for(;a.Lnext.Lnext!==r;)s=t.connect(a.Lnext,a),a=s.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var a,s=t.eHead.next;s!==t.eHead;s=a)a=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?i:-i:r?t.delete(s):s.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,a){var s,n=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var h=s.Org;h.n===-1&&(h.n=o,o++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=n,++n}this.elementCount=n,i===Mr.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*a,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var u=h.n*a;this.vertices[u+0]=h.coords[0],this.vertices[u+1]=h.coords[1],a>2&&(this.vertices[u+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var d=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(c.inside){s=c.anEdge,l=0;do{var h=s.Org;this.elements[d++]=h.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1;if(i===Mr.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1}}},e.prototype.outputContours_=function(t,i){var r,a,s=0,n=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){a=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==a);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,c=0;s=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){n=0,a=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,n++,r=r.Lnext;while(r!==a);this.elements[c++]=s,this.elements[c++]=n,s+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new jE),t<2&&(t=2),t>3&&(t=3);for(var r=null,a=0;a<i.length;a+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[a+0],r.Org.coords[1]=i[a+1],t>2?r.Org.coords[2]=i[a+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,a,s,n){if(t===void 0&&(t=Oi.ODD),i===void 0&&(i=Mr.POLYGONS),n===void 0&&(n=!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,a<2&&(a=2),a>3&&(a=3),!this.mesh)return!1;this.projectPolygon_(),YY.computeInterior(this,n);var o=this.mesh;return i===Mr.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===Mr.BOUNDARY_CONTOURS?this.outputContours_(o,a):this.outputPolymesh_(o,i,r,a),!0},e}();function vl(e){var t=e.windingRule,i=t===void 0?Oi.ODD:t,r=e.elementType,a=r===void 0?Mr.POLYGONS:r,s=e.polySize,n=s===void 0?3:s,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,c=h===void 0?[0,0,1]:h,u=e.contours,d=u===void 0?[]:u,p=e.strict,f=p===void 0?!0:p,m=e.debug,g=m===void 0?!1:m;if(!d&&f)throw new Error("Contours can't be empty");if(d){var v=new QY;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var x=0;x<d.length;x++)v.addContour(l||2,d[x]);return v.tesselate(i,a,n,l,c,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var Ose=Oi.ODD,Lse=Oi.NONZERO,Ise=Oi.POSITIVE,Bse=Oi.NEGATIVE,Use=Oi.ABS_GEQ_TWO,Fse=Mr.POLYGONS,Nse=Mr.CONNECTED_POLYGONS,zse=Mr.BOUNDARY_CONTOURS,px=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*px.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,a=0;this.positions=new Float32Array(this.buffer,a*r,3*e),a+=3*e,this.normals=new Float32Array(this.buffer,a*r,3*e),a+=3*e,this.uvs=new Float32Array(this.buffer,a*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let i=e*px.eSize,r=new ArrayBuffer(i),a=Float32Array.BYTES_PER_ELEMENT,s=0,n=new Float32Array(r,s*a,3*e);s+=3*e;let o=new Float32Array(r,s*a,3*e);s+=3*e;let l=new Float32Array(r,s*a,2*e);t?(n.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(n.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=n,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},G3=px;G3.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var KY=Ro(GB()),Qb={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},H3={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},W3={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},J0=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),Kb=class extends St{constructor(e,t,i=0,r=12,a=3,s=Oi.ODD,n=!1){super(),this.forPathBevel=n,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=a;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(L=>{let E=L.extractShapePointsToFlatArray([],r),T=[];for(let B=E.length-1;B>=1;B-=2){let V=E[B-1],I=E[B-0];T.push(V,I)}return T}),h=[],c=[];for(let L=0;L<o.length;L+=2)c.push([o[L],o[L+1]]);h.push(c);for(let L=0;L<l.length;L++){let E=l[L],T=[];for(let B=0;B<E.length;B+=2)T.push([E[B],E[B+1]]);h.push(T)}let u;e.isText?u=new oP().setFromPoints(e.points.map(L=>L.position)).getSize(new ae).length()*.1:h[0].length===0?u=i:u=(0,KY.default)(h).distance,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,u,t/2),this._bevelSegments=Math.floor(a));let d;try{d=vl({windingRule:s,elementType:Mr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{d=Qb}let p;try{p=vl({windingRule:Oi.ODD,elementType:Mr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=H3}if(!d)throw new Error("error generating geometry");let f=d.elementCount;if(p){d.elementCount+=p.elementCount;for(let L=0;L<p.elements.length;L++){let E=p.elements[L],T=L%2===0?d.vertexCount:0;d.elements.push(E+T)}for(let L=0;L<p.vertexIndices.length;L++){let E=p.vertexIndices[L],T=d.vertexCount;d.vertexIndices.push(E+T)}for(let L=0;L<p.vertices.length;L++){let E=p.vertices[L];d.vertices.push(E)}}let m=1/0,g=-1/0,v=1/0,x=-1/0;for(let L=0,E=d.vertexCount;L<E;L++){let T=L*2,B=d.vertices[T+0],V=d.vertices[T+1];B<m&&(m=B),B>g&&(g=B),V<v&&(v=V),V>x&&(x=V)}this._minX=m,this._minY=v,this._width=g-m,this._height=x-v,this._buffer=new G3(this._computeBufferEstimatedSize(d));let b=[],_=[];for(let L=d.elementCount-1;L>=0;L--){let E=L>=f,T=L*2,B=d.elements[T+0],V=d.elements[T+1],I=B+V,H={start:B,count:V,normals:[],continuous:[],concave:[]},q=B,X=I-1,Y=B+1,ie=this._shape.roundedCurves.length;do{let se=q-B,he=d.vertices[X*2+0],_e=d.vertices[X*2+1],Ee=d.vertices[q*2+0],fe=d.vertices[q*2+1],Re=d.vertices[Y*2+0],Pe=d.vertices[Y*2+1],te=Ee-he,We=fe-_e,Be=Math.sqrt(te*te+We*We);te/=Be,We/=Be;let Ue=Ee-Re,Ge=fe-Pe,tt=Math.sqrt(Ue*Ue+Ge*Ge);Ue/=tt,Ge/=tt,H.normals[se*2+0]=-Ge,H.normals[se*2+1]=Ue,H.concave[se]=te*Ge-We*Ue>0;let Fe=d.vertexIndices[q];if(Array.isArray(Fe))H.continuous[se]=!1;else{let[He,nt]=this._shape.getCurveIndexFromVertexId(Fe-1,!0);if(nt>0&&nt<1)H.continuous[se]=!0;else{let ht=nt===1?He+1:He-1;ht=(ht+ie)%ie;let Z=nt===1?0:1,j=this._shape.roundedCurves[He].getTangent(nt),ye=this._shape.roundedCurves[ht].getTangent(Z);H.continuous[se]=j.dot(ye)>.95}}E&&(H.normals[se*2+0]*=-1,H.normals[se*2+1]*=-1),[X,q,Y]=[q,Y,Y+1],Y>=I&&(Y-=V)}while(Y!==B+1);let ce=[];ce.push({bevelI:0,angle:0,size:0,boundary:{vertices:d.vertices.slice(B*2,I*2),vertexCount:V,vertexIndices:new Array(V).fill(!0).map((se,he)=>[he,he]),elements:[0,V],elementCount:1,mesh:null},reverseMap:[],insetPoints:d.vertices.slice(B*2,I*2)});let de=0;for(let se=1;se<=this._bevelSegments;se++){let he=se/this._bevelSegments*Math.PI/2,_e=(1-Math.cos(he))*this._bevel,Ee=[],fe=[],Re=[],Pe=[],te=0;for(let Be=0;Be<V;Be++){let Ue=Be*2,Ge=(Be-1+V)%V*2,tt=d.vertices[H.start*2+Ue+0],Fe=d.vertices[H.start*2+Ue+1],He=-H.normals[Ge+0]*_e,nt=-H.normals[Ge+1]*_e,ht=-H.normals[Ue+0]*_e,Z=-H.normals[Ue+1]*_e;if(H.concave[Be]||!H.concave[Be]&&E){let j=Math.atan2(nt,He),ye=Math.atan2(Z,ht);ye>j&&(ye-=Math.PI*2);let Me=ye-j;if(H.continuous[Be]||E){let Je=j+Me/2,z=Math.cos(Je)*_e,qe=Math.sin(Je)*_e;Ee[2*te+0]=tt+z*(E?-1:1),Ee[2*te+1]=Fe+qe*(E?-1:1),Pe[te]=Be,te++}else{let Je=Math.max(1,Math.floor(r/4*Math.abs(Me)/Math.PI));for(let z=0;z<=Je;z++){let qe=j+Me*(z/Je),ct=Math.cos(qe)*_e,ze=Math.sin(qe)*_e;Ee[2*te+0]=tt+ct,Ee[2*te+1]=Fe+ze,Pe[te]=Be,te++}}}else Ee[2*te+0]=tt+He,Ee[2*te+1]=Fe+nt,Pe[te]=Be,fe[Be]=te,te++,Ee[2*te+0]=tt,Ee[2*te+1]=Fe,Pe[te]=Be,te++,Ee[2*te+0]=tt+ht,Ee[2*te+1]=Fe+Z,Pe[te]=Be,Re[Be]=te,te++}let We=vl({windingRule:Oi.POSITIVE,elementType:Mr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Ee],edgeCreateCallback:Be=>{let Ue=Be.Org.idx,Ge=Pe[Ue],tt=Pe[(Ue+1)%Pe.length];Be.idx=[Ge,tt],Be.Sym.idx=[tt,Ge]},vertexIdCallback:Be=>{let Ue=Be.Lprev.idx;return[Ue?Ue[1]:0,Be.idx?Be.idx[0]:0]}});if(!We)throw console.log("Error"),new Error(`error generating bevel geometry for ${se}'th loop`);if(!We.vertexCount){let Be=(se-1)/this._bevelSegments*Math.PI/2;de=(1-Math.sin(Be))*this._bevel;break}for(let Be=0;Be<We.vertexIndices.length;Be++){let[Ue,Ge]=We.vertexIndices[Be];if(Ue===Ge)continue;let tt=Ge;Ge<Ue&&(tt+=V);for(let Fe=Ue;Fe<tt;Fe++){let He=Fe%V,nt=(Fe+1)%V;if(!H.continuous[He]||!H.continuous[nt]){We.vertexIndices[Be]=[Ue,He],We.vertexIndices.splice(Be+1,0,[nt,Ge]),We.vertices.splice((Be+1)*2,0,We.vertices[Be*2],We.vertices[Be*2+1]);break}}}ce.push({bevelI:se,angle:he,size:_e,boundary:We,reverseMap:Pe,insetPoints:Ee})}let ue=(se,he,_e)=>{let Ee=0,fe=se.boundary.vertexIndices.length;for(;Ee<fe&&_e(se.boundary.vertexIndices[he]);)he=(he+1)%fe,Ee++;return Ee},re=b.length;for(let se=1;se<ce.length;se++){let he=ce[se-1],_e=ce[se],Ee=he.boundary.vertexIndices.length,fe=_e.boundary.vertexIndices.length;if(!Ee||!fe)break;let Re=H.concave.length,Pe=0,te=J0(Pe,V);for(;!he.boundary.vertexIndices.filter(te).length||!_e.boundary.vertexIndices.filter(te).length;)Pe++,te=J0(Pe,V);let We=he.boundary.vertexIndices.findIndex(te),Be=_e.boundary.vertexIndices.findIndex(te);do We=(We+1)%Ee;while(te(he.boundary.vertexIndices[We]));do Be=(Be+1)%fe;while(te(_e.boundary.vertexIndices[Be]));Pe=(Pe+1)%V;let Ue=Pe,Ge=0,tt=this._buildBevelVert(H,he,(We-1+Ee)%Ee,void 0,Ge),Fe=this._buildBevelVert(H,_e,(Be-1+fe)%fe,void 0,Ge),He=tt,nt=Fe,ht,Z,j=!1;do{Ge=(Pe||Re)/Re,te=J0(Pe,V);let ye=ue(he,We,te),Me=ue(_e,Be,te),Je=j;if(j=!1,ye&&!Me){for(let z=0;z<ye;z++)ht=this._buildBevelVert(H,he,(We+z)%Ee,z/(ye-1),Ge),b.push(He.topN,ht.topP,nt.topN),n===!1&&b.push(ht.bottomP,He.bottomN,nt.bottomN),He=ht;j=!0}else if(!ye&&Me)for(let z=0;z<Me;z++)Z=this._buildBevelVert(H,_e,(Be+z)%fe,z/(Me-1),Ge),b.push(nt.topN,He.topP,Z.topP),n===!1&&b.push(He.bottomP,nt.bottomN,Z.bottomP),nt=Z;else if(ye&&Me)if(ht=this._buildBevelVert(H,he,We,0,Ge),Z=this._buildBevelVert(H,_e,Be,0,Ge),Je?(b.push(He.topN,Z.topP,nt.topN),b.push(He.topN,ht.topP,Z.topP),n===!1&&(b.push(Z.bottomP,He.bottomN,nt.bottomN),b.push(Z.bottomP,ht.bottomP,He.bottomN))):(b.push(nt.topN,He.topN,ht.topP),b.push(nt.topN,ht.topP,Z.topP),n===!1&&(b.push(ht.bottomP,He.bottomN,nt.bottomN),b.push(ht.bottomP,nt.bottomN,Z.bottomP))),He=ht,nt=Z,ye===Me)for(let z=1;z<ye;z++)ht=this._buildBevelVert(H,he,(We+z)%Ee,z/(ye-1),Ge),Z=this._buildBevelVert(H,_e,(Be+z)%fe,z/(Me-1),Ge),b.push(He.topN,ht.topP,nt.topN),b.push(nt.topN,ht.topP,Z.topP),n===!1&&(b.push(ht.bottomP,He.bottomN,nt.bottomN),b.push(ht.bottomP,nt.bottomN,Z.bottomP)),He=ht,nt=Z;else if(ye>Me){let z=ye/Me,qe=0;for(let ct=1;ct<ye;ct++)ht=this._buildBevelVert(H,he,(We+ct)%Ee,ct/(ye-1),Ge),b.push(He.topN,ht.topP,nt.topN),n===!1&&b.push(ht.bottomP,He.bottomN,nt.bottomN),He=ht,ct>(qe+1)*z&&(qe++,Z=this._buildBevelVert(H,_e,(Be+qe)%fe,qe/(Me-1),Ge),b.push(nt.topN,ht.topP,Z.topP),n===!1&&b.push(ht.bottomP,nt.bottomN,Z.bottomP),nt=Z)}else{let z=Me/ye,qe=0;for(let ct=1;ct<Me;ct++)Z=this._buildBevelVert(H,_e,(Be+ct)%fe,ct/(Me-1),Ge),b.push(nt.topN,ht.topP,Z.topP),n===!1&&b.push(ht.bottomP,nt.bottomN,Z.bottomP),nt=Z,ct>(qe+1)*z&&(qe++,ht=this._buildBevelVert(H,he,(We+qe)%Ee,qe/(ye-1),Ge),b.push(He.topN,ht.topP,nt.topN),n===!1&&b.push(ht.bottomP,He.bottomN,nt.bottomN),He=ht)}We=(We+ye)%Ee,Be=(Be+Me)%fe,Pe=(Pe+1)%Re}while(Pe!==Ue)}if(n===!1&&this._depth>this._bevel*2&&this._buildWall(ce,H,b),E){let se=[];for(let he=b.length-1;he>=re+2;he-=3){let _e=b[he-2],Ee=b[he-1],fe=b[he-0];se.push(fe,Ee,_e)}b.splice(re,b.length-re,...se)}if(E){let se=[];for(let he=ce[ce.length-1].boundary.vertices.length-1;he>=1;he-=2){let _e=ce[ce.length-1].boundary.vertices[he-1],Ee=ce[ce.length-1].boundary.vertices[he-0];se.push(_e,Ee)}_.push(se)}if(!E){let se=ce[ce.length-1],he;try{he=vl({windingRule:ce.length>1?Oi.POSITIVE:Oi.ODD,elementType:Mr.POLYGONS,vertexSize:2,strict:!0,contours:[se.insetPoints,..._]})}catch{he=W3}if(!he)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<u&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let _e=0;_e<he.elementCount*3;_e+=3){let Ee=this._buildSurfaceVert(he,he.elements[_e+0],de),fe=this._buildSurfaceVert(he,he.elements[_e+1],de),Re=this._buildSurfaceVert(he,he.elements[_e+2],de);b.push(Ee.top,fe.top,Re.top),n===!1&&b.push(Re.bottom,fe.bottom,Ee.bottom)}}this.vertexCache={}}this._buffer.shrink();let M=new Ut(Uint32Array.from(b),1),A=new Ut(this._buffer.positions,3),S=new Ut(this._buffer.normals,3),P=new Ut(this._buffer.uvs,2);A.needsUpdate=!0,S.needsUpdate=!0,P.needsUpdate=!0,M.needsUpdate=!0,this.setAttribute("position",A),this.setAttribute("normal",S),this.setAttribute("uv",P),this.setIndex(M)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let a=0,s=r.boundary.vertexCount;a<s;a++){let n=this._buildBevelVert(t,r,a),o=this._buildBevelVert(t,r,(a+1)%s);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}_buildSurfaceVert(e,t,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let a=e.vertices[t*2+0],s=e.vertices[t*2+1],n=(a-this._minX)/this._width,o=(s-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=l*3,c=l*2,u={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=a,this._buffer.positions[h+1]=s,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[c+0]=n,this._buffer.uvs[c+1]=o,this.forPathBevel===!1&&(this._buffer.positions[h+3]=a,this._buffer.positions[h+4]=s,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[c+2]=n,this._buffer.uvs[c+3]=o),this.vertexCache[r]=u,u}_buildBevelVert(e,t,i,r=1,a){let s=`${t.bevelI}:${i}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[n,o]=t.boundary.vertexIndices[i],l,h,c,u;n!==o?(h=n,l=o,u=!1,c=e.continuous[h]&&e.continuous[l]):(l=n,h=(l-1+e.count)%e.count,u=e.concave[l]&&t.bevelI>0,c=e.continuous[l]||u);let d=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,m=l*2,g=h*2,v=t.boundary.vertices[f+0],x=t.boundary.vertices[f+1],b=(1-p)*this._bevel,_=(v-this._minX)/this._width,M=(x-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(_=a),M=1);let A=e.normals[m+0],S=e.normals[m+1],P=e.normals[g+0],L=e.normals[g+1];if(u){let I=P-A,H=L-S;A=A+I*(1-r),S=S+H*(1-r);let q=Math.sqrt(A*A+S*S);A/=q,S/=q}let E=this.forPathBevel?this._buffer.get(c?1:2):this._buffer.get(c?2:4),T=E*3,B=E*2,V={i,fi:l,topP:E+0,topN:E+0,bottomP:E+1,bottomN:E+1,pathBevelUCoord:a};return this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=x,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[T+0]=A*d,this._buffer.normals[T+1]=S*d,this._buffer.normals[T+2]=p,this._buffer.uvs[B+0]=_,this._buffer.uvs[B+1]=M,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=x,this._buffer.positions[T+5]=b,this._buffer.normals[T+3]=A*d,this._buffer.normals[T+4]=S*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[B+2]=M,this._buffer.uvs[B+3]=_),c||(this.forPathBevel?(E+=1,T+=3,B+=2):(E+=2,T+=6,B+=4),V.topP=E+0,V.bottomP=E+1,this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=x,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[T+0]=P*d,this._buffer.normals[T+1]=L*d,this._buffer.normals[T+2]=p,this._buffer.uvs[B+0]=_,this._buffer.uvs[B+1]=M,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=x,this._buffer.positions[T+5]=b,this._buffer.normals[T+3]=P*d,this._buffer.normals[T+4]=L*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[B+2]=M,this._buffer.uvs[B+3]=_)),this.vertexCache[s]=V,V}clone(){let e=new Kb(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=sv(this.userData),e}},q3=class extends St{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=Oi.ODD,this.elementType=Mr.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Oi.ODD,elementType:Mr.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(d=>d.extractShapePointsToFlatArray([],this._curveSegments)),s,n=!0,o=!0,l,h;for(let d=0,p=r.length/2;d<p;d++){let f=d*2,m=r[f+0],g=r[f+1];if(l!==void 0&&m!==l&&(n=!1),h!==void 0&&g!==h&&(o=!1),l=m,h=g,!n&&!o)break}if(!n&&!o)try{s=vl({contours:[r,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=Qb}let c=s?.vertexCount??1,u=s?.elementCount??1;if(this._positionAttribute=new Ut(new Float32Array(c*3),3),this._normalAttribute=new Ut(new Float32Array(c*3),3),this._uvAttribute=new Ut(new Float32Array(c*2),2),this._indexAttribute=new Ut(new Uint32Array(u*3),1),s){let d=1/0,p=-1/0,f=1/0,m=-1/0;for(let x=0,b=c;x<b;x++){let _=x*2,M=s.vertices[_+0],A=s.vertices[_+1];M<d&&(d=M),M>p&&(p=M),A<f&&(f=A),A>m&&(m=A)}let g=p-d,v=m-f;for(let x=0,b=c;x<b;x++){let _=x*2,M=s.vertices[_+0],A=s.vertices[_+1],S=(M-d)/g,P=(A-f)/v;this._positionAttribute.setXYZ(x,M,A,0),this._normalAttribute.setXYZ(x,0,0,1),this._uvAttribute.setXY(x,S,P)}for(let x=0,b=u;x<b;x++){let _=x*3,M=s.elements[_+0],A=s.elements[_+1],S=s.elements[_+2];this._indexAttribute.setX(_+0,M),this._indexAttribute.setX(_+1,A),this._indexAttribute.setX(_+2,S)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new q3(this._shape,this._curveSegments);return e.userData=sv(this.userData),e}},X3=class extends Kb{constructor(e,t,i=0,r=12,a=3,s=Oi.ODD){super(e,t,i,r,a,s),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let a=0,s=r.boundary.vertexCount;a<s;a++){let n=this._buildBevelVert(t,r,a),o=this._buildBevelVert(t,r,(a+1)%s);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}clone(){let e=new X3(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=sv(this.userData),e}},Bh=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Oi.ODD},e.parameters),r=Math.abs(i.width),a=Math.abs(i.height??i.width),s=Math.abs(i.depth??0),n=e.shape??t?.shape,o=n?.roundness??i.roundness;n!==void 0&&(n instanceof ur?(n.width!==r||n.height!==a)&&n.applySize(r,a):n=new ur(r,a).fromJSON(n),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&n.update());let l=n??new ur(r,a);return{parameters:Object.assign(i,{width:r,height:a,depth:s,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:a,roundness:s,windingRule:n}=e.parameters;e.shape.roundness=s;let o;return t<=0?o=new q3(e.shape,a,{windingRule:n}):o=new X3(e.shape,t,i,a,r,n),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},Y3=Math.PI*2,Zb=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return i.angle=dt.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof ur?e.shape:new ur,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,angle:a,innerRadius:s,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,c=t*.5,u=i*.5,d=ZY(h,c,u,a*Math.PI/180,r,s);h.isClosed=!0,h.update();let p;return a===0?(p=new St,p.setAttribute("position",new ut([],3))):p=Bh.create({shape:h,parameters:{subdivisions:d,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}}),Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function ZY(e,t,i,r,a,s){if(r>=Y3)return a>30||a%4===0?($Y(e,t,i,s),Math.round(a/4)):qE(e,r,a,t,i,s);r=Math.max(r,.001);let n={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=WY({px:n.x,py:n.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return a>30||a%h.length===0?JY(e,n.x,n.y,h,a,t,i,s):qE(e,r,a,t,i,s)}function JY(e,t,i,r,a,s,n,o){let l=Math.round(a/r.length);e.addPoint(iu(t,i));for(let h=0,c=r.length;h<c;h++){let u=r[h],d=e.points[h],p=iu(u.x,u.y);d.controls[1].position.set(u.x1,u.y1),p.controls[0].position.set(u.x2,u.y2),e.addPoint(p)}return o>0?Q3(e,s,n,o):e.addPoint(iu(0,0)),l}function qE(e,t,i,r,a,s){let n=-t/i;for(let o=0;o<=i;o++){let l=n*o,h=Math.sin(l)*r,c=Math.cos(l)*a;e.addPoint(iu(h,c))}return t<Y3?s>0?Q3(e,r,a,s):e.addPoint(iu(0,0)):(e.removePoint(e.points[e.points.length-1]),s>0&&K3(e,r,a,s)),1}function $Y(e,t,i,r=0,a=0,s=0){let n=.5522847498,o=t*n,l=i*n;e.addPoint(Qf(a-t,s,a-t,s-l,a-t,s+l)),e.addPoint(Qf(a,s+i,a-o,s+i,a+o,s+i)),e.addPoint(Qf(a+t,s,a+t,s+l,a+t,s-l)),e.addPoint(Qf(a,s-i,a+o,s-i,a-o,s-i)),r>0&&K3(e,t,i,r)}function iu(e,t){return new tu(dt.generateUUID(),new ae(e,t))}function Qf(e,t,i,r,a,s){let n=iu(e,t);return n.controls[0].position.set(i,r),n.controls[1].position.set(a,s),n}function Q3(e,t,i,r){Z3(e,t,i,r).forEach(a=>e.addPoint(a))}function K3(e,t,i,r){let a=Z3(e,t,i,r),s=new ur;a.forEach(n=>s.addPoint(n)),s.isClosed=!0,e.shapeHoles.push(s)}function Z3(e,t,i,r){let a=r*t/100,s=a*(Math.abs(i)/Math.abs(t)),n=new ae(a/t,s/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=dt.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(n);let h=l.controls[0].position.clone().multiply(n),c=l.controls[1].position.clone().multiply(n);l.controls[0].position.copy(c),l.controls[1].position.copy(h)}),o}var eQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),a=Math.abs(i.height??r),s=Math.abs(i.depth??r),n=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(i,{width:r,height:a,depth:s,radius:n,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:a,revolutions:s,segments:n,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:c,cornerSegments:u}=e.parameters,d=new J3(!1,t,i,r,a,s,n,o,l,h,c,u);return Object.assign(d,{userData:{...e,type:"HelixGeometry"}})}},$0=new Yc([0,0,0],1),J3=class extends St{constructor(e=!0,t=1,i=1,r=1,a=1,s=1,n=1,o=1,l=1,h=1,c=1,u=1){if(super(),s===0)return;let d=e&&s===1;d&&(u=0),c>100&&(c=100),c===0&&(u=0);let p=()=>new O,f=new O,m=p(),g=p(),v=p(),x,b,_,M,A,S,P,L,E=p(),T=p(),B=p(),V=p(),I=p(),H=p(),q=p(),X=p(),Y=i-2*o+.001,ie=Y/s,ce=Math.ceil(n*s),de=ce+1,ue=Y/ce,re=-Y/2,se=h+1,he=2*Math.PI/h,_e=Math.PI/2/u,Ee=.01,fe=Math.min((1-c/100)*o,o-Ee),Re=o-fe,Pe=0,te=2,We=u*te+te,Be=se*We/te,Ue=Be+se*de,Ge=Math.max(0,se*(de+We)),[tt,Fe,He]=[3,3,2].map(Qe=>Array(Ge*Qe).fill(0)),nt=[],ht=a-o;function Z(Qe,Ze){let Zt=Math.PI/2;S=Ze*ue,L=2*Math.PI*(S%ie)/ie+Zt,S+=re,P=Math.sin(L)*ht,A=Math.cos(L)*ht,e?Qe.set(A,P,S):Qe.set(A,S,P)}Z(f,-1e-10),Z(m,0),E.copy(f),Z(f,1);let j=f.distanceTo(m),ye=d?0:Re+fe,Me=j*ce+2*ye,Je=fe,z=Me-ye;for(let Qe=0;Qe<=ce;Qe++){Z(g,Qe),X.subVectors(g,E).normalize(),E.copy(g),H.copy(g).setComponent(+e+1,0).normalize(),q.crossVectors(X,H).normalize();let Ze=Qe===0,Zt=Qe===ce,Ot=Ze?3*Math.PI/2:_e,Pt=Ze?Je:z,At=Ze?se:Ue,bt=Ze?0:Ge-se,mt=X.clone().multiplyScalar(Ze?-Re:Re).add(g),gi=X.clone().multiplyScalar(Ze?-1:1).normalize();for(let Jt=0;Jt<se;Jt++){let pe=Jt*he;if(T.addVectors(f.copy(H).multiplyScalar(o*Math.cos(pe)),m.copy(q).multiplyScalar(o*Math.sin(pe))),B.copy(T).normalize(),Ze||Zt){d||(Pe=bt+Jt,[0,1,2].forEach(et=>{tt[Pe*3+et]=mt.getComponent(et),Fe[Pe*3+et]=gi.getComponent(et)}),He[Pe*2]=+Zt,He[Pe*2+1]=Jt/h),m.copy(B).multiplyScalar(fe),v.addVectors(g,m);for(let et=0;et<u;et++){let Se=et*_e+Ot;V.addVectors(f.copy(X).multiplyScalar(Re*Math.sin(Se)),m.copy(B).multiplyScalar(Re*Math.cos(Se))),I.copy(V).normalize(),m.addVectors(v,V),V.normalize(),Pe=At+et*se+Jt,[0,1,2].forEach(rt=>{tt[Pe*3+rt]=m.getComponent(rt),Fe[Pe*3+rt]=I.getComponent(rt)});let Ke=+Ze+Math.sin(Se);He[Pe*2]=(Pt+Re*Ke)/Me,He[Pe*2+1]=Jt/h}}m.addVectors(g,T),Pe=Be+Qe*se+Jt,[0,1,2].forEach(et=>{tt[Pe*3+et]=m.getComponent(et),Fe[Pe*3+et]=B.getComponent(et)}),He[Pe*2]=(ye+Qe*j)/Me,He[Pe*2+1]=Jt/h}}let qe=de+2*u+te,ct=1,[ze,at]=[+d,qe-1];for(let Qe=ze;Qe<=at-1;Qe++){let Ze=d&&Qe===at-1;for(let Zt=0;Zt<se-1;Zt++)x=Qe*se+Zt,b=x+1,_=(Ze?Zt:x)+se,M=(Ze?Zt+1:b)+se,Qe===0?nt.push(b,M,_):Qe===qe-2?nt.push(x,b,_):nt.push(x,b,_,b,M,_)}this.setIndex(nt),this.setAttribute("position",new ut(tt,3)),this.setAttribute("normal",new ut(Fe,3)),this.setAttribute("uv",new ut(He,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),a,s,n,o,l=6*(t-1)*e.radialSegments,h=t,c=h===t;for(let u=0;u<e.radialSegments;u++)a=h*i+u,s=a+1,n=(c?u:a)+i,o=(c?u+1:s)+i,r[l++]=a,r[l++]=s,r[l++]=n,r[l++]=s,r[l++]=o,r[l++]=n;return r.length=l,$0.array=r,$0.count=r.length,$0}},tQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:a,corner:s,cornerSides:n}=e.parameters,o=a===0&&s!==0?new $3(t*.5,s,n):new ZT(t*.5,a);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},$3=class extends qb{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,a=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],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],n="IcosahedronGeometry";super(a,s,n,e,t,i),this.type=n}static fromJSON(e){return new $3(e.radius,e.corner,e.cornerSides)}},iQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,a=new $m;a.moveTo(t[0].x,t[0].y),a.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new WT(a.extractPoints(r).shape,i);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...e,type:"LatheGeometry"}})}},un=new je,ey=new Mi,Kf=new O,Ug=class extends ua{constructor(){super(),this.uuid=dt.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new Ht().getNormalMatrix(e);for(let i=0,r=this.vertices.length;i<r;i++)this.vertices[i].applyMatrix4(e);for(let i=0,r=this.faces.length;i<r;i++){let a=this.faces[i];a.normal.applyMatrix3(t).normalize();for(let s=0,n=a.vertexNormals.length;s<n;s++)a.vertexNormals[s].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return un.makeRotationX(e),this.applyMatrix4(un),this}rotateY(e){return un.makeRotationY(e),this.applyMatrix4(un),this}rotateZ(e){return un.makeRotationZ(e),this.applyMatrix4(un),this}translate(e,t,i){return un.makeTranslation(e,t,i),this.applyMatrix4(un),this}scale(e,t,i){return un.makeScale(e,t,i),this.applyMatrix4(un),this}lookAt(e){return ey.lookAt(e),ey.updateMatrix(),this.applyMatrix4(ey.matrix),this}fromBufferGeometry(e){let t=this,i=e.index!==null?e.index:void 0,r=e.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let a=r.position,s=r.normal,n=r.color,o=r.uv,l=r.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let u=0;u<a.count;u++)t.vertices.push(new O().fromBufferAttribute(a,u)),n!==void 0&&t.colors.push(new _t().fromBufferAttribute(n,u));function h(u,d,p,f){let m=n===void 0?[]:[t.colors[u].clone(),t.colors[d].clone(),t.colors[p].clone()],g=s===void 0?[]:[new O().fromBufferAttribute(s,u),new O().fromBufferAttribute(s,d),new O().fromBufferAttribute(s,p)],v=new fx(u,d,p,g,m,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new ae().fromBufferAttribute(o,u),new ae().fromBufferAttribute(o,d),new ae().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new ae().fromBufferAttribute(l,u),new ae().fromBufferAttribute(l,d),new ae().fromBufferAttribute(l,p)])}let c=e.groups;if(c.length>0)for(let u=0;u<c.length;u++){let d=c[u],p=d.start,f=d.count;for(let m=p,g=p+f;m<g;m+=3)i!==void 0?h(i.getX(m),i.getX(m+1),i.getX(m+2),d.materialIndex):h(m,m+1,m+2,d.materialIndex)}else if(i!==void 0)for(let u=0;u<i.count;u+=3)h(i.getX(u),i.getX(u+1),i.getX(u+2));else for(let u=0;u<a.count;u+=3)h(u,u+1,u+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Kf).negate(),this.translate(Kf.x,Kf.y,Kf.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new je;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let e=new O,t=new O;for(let i=0,r=this.faces.length;i<r;i++){let a=this.faces[i],s=this.vertices[a.a],n=this.vertices[a.b],o=this.vertices[a.c];e.subVectors(o,n),t.subVectors(s,n),e.cross(t),e.normalize(),a.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let i=0,r=this.vertices.length;i<r;i++)t[i]=new O;if(e){let i=new O,r=new O;for(let a=0,s=this.faces.length;a<s;a++){let n=this.faces[a],o=this.vertices[n.a],l=this.vertices[n.b],h=this.vertices[n.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[n.a].add(i),t[n.b].add(i),t[n.c].add(i)}}else{this.computeFaceNormals();for(let i=0,r=this.faces.length;i<r;i++){let a=this.faces[i];t[a.a].add(a.normal),t[a.b].add(a.normal),t[a.c].add(a.normal)}}for(let i=0,r=this.vertices.length;i<r;i++)t[i].normalize();for(let i=0,r=this.faces.length;i<r;i++){let a=this.faces[i],s=a.vertexNormals;s.length===3?(s[0].copy(t[a.a]),s[1].copy(t[a.b]),s[2].copy(t[a.c])):(s[0]=t[a.a].clone(),s[1]=t[a.b].clone(),s[2]=t[a.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let i=this.faces[e],r=i.vertexNormals;r.length===3?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let a=0,s=r.vertexNormals.length;a<s;a++)r.__originalVertexNormals[a]?r.__originalVertexNormals[a].copy(r.vertexNormals[a]):r.__originalVertexNormals[a]=r.vertexNormals[a].clone()}let e=new Ug;e.faces=this.faces;for(let t=0,i=this.morphTargets.length;t<i;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let a=this.morphNormals[t].faceNormals,s=this.morphNormals[t].vertexNormals;for(let n=0,o=this.faces.length;n<o;n++){let l=new O,h={a:new O,b:new O,c:new O};a.push(l),s.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let a=0,s=this.faces.length;a<s;a++){let n=this.faces[a],o=r.faceNormals[a],l=r.vertexNormals[a];o.copy(n.normal),l.a.copy(n.vertexNormals[0]),l.b.copy(n.vertexNormals[1]),l.c.copy(n.vertexNormals[2])}}for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new sr),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Sa),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,i=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let r,a=this.vertices.length,s=this.vertices,n=e.vertices,o=this.faces,l=e.faces,h=this.colors,c=e.colors;t!==void 0&&(r=new Ht().getNormalMatrix(t));for(let u=0,d=n.length;u<d;u++){let p=n[u].clone();t!==void 0&&p.applyMatrix4(t),s.push(p)}for(let u=0,d=c.length;u<d;u++)h.push(c[u].clone());for(let u=0,d=l.length;u<d;u++){let p=l[u],f,m,g=p.vertexNormals,v=p.vertexColors,x=new fx(p.a+a,p.b+a,p.c+a);x.normal.copy(p.normal),r!==void 0&&x.normal.applyMatrix3(r).normalize();for(let b=0,_=g.length;b<_;b++)f=g[b].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),x.vertexNormals.push(f);x.color.copy(p.color);for(let b=0,_=v.length;b<_;b++)m=v[b],x.vertexColors.push(m.clone());x.materialIndex=p.materialIndex+i,o.push(x)}for(let u=0,d=e.faceVertexUvs.length;u<d;u++){let p=e.faceVertexUvs[u];this.faceVertexUvs[u]===void 0&&(this.faceVertexUvs[u]=[]);for(let f=0,m=p.length;f<m;f++){let g=p[f],v=[];for(let x=0,b=g.length;x<b;x++)v.push(g[x].clone());this.faceVertexUvs[u].push(v)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},i=[],r=[],a=Math.pow(10,e);for(let o=0,l=this.vertices.length;o<l;o++){let h=this.vertices[o],c=Math.round(h.x*a)+"_"+Math.round(h.y*a)+"_"+Math.round(h.z*a);t[c]===void 0?(t[c]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[c]]}let s=[];for(let o=0,l=this.faces.length;o<l;o++){let h=this.faces[o];h.a=r[h.a],h.b=r[h.b],h.c=r[h.c];let c=[h.a,h.b,h.c];for(let u=0;u<3;u++)if(c[u]===c[(u+1)%3]){s.push(o);break}}for(let o=s.length-1;o>=0;o--){let l=s[o];this.faces.splice(l,1);for(let h=0,c=this.faceVertexUvs.length;h<c;h++)this.faceVertexUvs[h].splice(l,1)}let n=this.vertices.length-i.length;return this.vertices=i,n}setFromPoints(e){this.vertices=[];for(let t=0,i=e.length;t<i;t++){let r=e[t];this.vertices.push(new O(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let o=0;o<t;o++)e[o]._id=o;function i(o,l){return o.materialIndex-l.materialIndex}e.sort(i);let r=this.faceVertexUvs[0],a=this.faceVertexUvs[1],s,n;r&&r.length===t&&(s=[]),a&&a.length===t&&(n=[]);for(let o=0;o<t;o++){let l=e[o]._id;s&&s.push(r[l]),n&&n.push(a[l])}s&&(this.faceVertexUvs[0]=s),n&&(this.faceVertexUvs[1]=n)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let f in p)p[f]!==void 0&&(e[f]=p[f]);return e}let t=[];for(let p=0;p<this.vertices.length;p++){let f=this.vertices[p];t.push(f.x,f.y,f.z)}let i=[],r=[],a={},s=[],n={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],m=!0,g=!1,v=this.faceVertexUvs[0][p]!==void 0,x=f.normal.length()>0,b=f.vertexNormals.length>0,_=f.color.r!==1||f.color.g!==1||f.color.b!==1,M=f.vertexColors.length>0,A=0;if(A=h(A,0,0),A=h(A,1,m),A=h(A,2,g),A=h(A,3,v),A=h(A,4,x),A=h(A,5,b),A=h(A,6,_),A=h(A,7,M),i.push(A),i.push(f.a,f.b,f.c),i.push(f.materialIndex),v){let S=this.faceVertexUvs[0][p];i.push(d(S[0]),d(S[1]),d(S[2]))}if(x&&i.push(c(f.normal)),b){let S=f.vertexNormals;i.push(c(S[0]),c(S[1]),c(S[2]))}if(_&&i.push(u(f.color)),M){let S=f.vertexColors;i.push(u(S[0]),u(S[1]),u(S[2]))}}function h(p,f,m){return m?p|1<<f:p&~(1<<f)}function c(p){let f=p.x.toString()+p.y.toString()+p.z.toString();return a[f]!==void 0||(a[f]=r.length/3,r.push(p.x,p.y,p.z)),a[f]}function u(p){let f=p.r.toString()+p.g.toString()+p.b.toString();return n[f]!==void 0||(n[f]=s.length,s.push(p.getHex())),n[f]}function d(p){let f=p.x.toString()+p.y.toString();return l[f]!==void 0||(l[f]=o.length/2,o.push(p.x,p.y)),l[f]}return e.data={},e.data.vertices=t,e.data.normals=r,s.length>0&&(e.data.colors=s),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new Ug().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let u=0,d=t.length;u<d;u++)this.vertices.push(t[u].clone());let i=e.colors;for(let u=0,d=i.length;u<d;u++)this.colors.push(i[u].clone());let r=e.faces;for(let u=0,d=r.length;u<d;u++)this.faces.push(r[u].clone());for(let u=0,d=e.faceVertexUvs.length;u<d;u++){let p=e.faceVertexUvs[u];this.faceVertexUvs[u]===void 0&&(this.faceVertexUvs[u]=[]);for(let f=0,m=p.length;f<m;f++){let g=p[f],v=[];for(let x=0,b=g.length;x<b;x++){let _=g[x];v.push(_.clone())}this.faceVertexUvs[u].push(v)}}let a=e.morphTargets;for(let u=0,d=a.length;u<d;u++){let p={};if(p.name=a[u].name,a[u].vertices!==void 0){p.vertices=[];for(let f=0,m=a[u].vertices.length;f<m;f++)p.vertices.push(a[u].vertices[f].clone())}if(a[u].normals!==void 0){p.normals=[];for(let f=0,m=a[u].normals.length;f<m;f++)p.normals.push(a[u].normals[f].clone())}this.morphTargets.push(p)}let s=e.morphNormals;for(let u=0,d=s.length;u<d;u++){let p={};if(s[u].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,m=s[u].vertexNormals.length;f<m;f++){let g=s[u].vertexNormals[f],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),p.vertexNormals.push(v)}}if(s[u].faceNormals!==void 0){p.faceNormals=[];for(let f=0,m=s[u].faceNormals.length;f<m;f++)p.faceNormals.push(s[u].faceNormals[f].clone())}this.morphNormals.push(p)}let n=e.skinWeights;for(let u=0,d=n.length;u<d;u++)this.skinWeights.push(n[u].clone());let o=e.skinIndices;for(let u=0,d=o.length;u<d;u++)this.skinIndices.push(o[u].clone());let l=e.lineDistances;for(let u=0,d=l.length;u<d;u++)this.lineDistances.push(l[u]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new rQ().fromGeometry(this),t=new St,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",Zf.call(new Ut(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",Zf.call(new Ut(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",XE.call(new Ut(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",YE.call(new Ut(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",YE.call(new Ut(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let a=[],s=e.morphTargets[r];for(let n=0,o=s.length;n<o;n++){let l=s[n],h=new ut(l.data.length*3,3);h.name=l.name,a.push(Zf.call(h,l.data))}t.morphAttributes[r]=a}if(e.skinIndices.length>0){let r=new ut(e.skinIndices.length*4,4);t.setAttribute("skinIndex",QE.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new ut(e.skinWeights.length*4,4);t.setAttribute("skinWeight",QE.call(r,e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new St,i=e.geometry;if(e.isPoints||e.isLine){let r=new ut(i.vertices.length*3,3),a=new ut(i.colors.length*3,3);if(t.setAttribute("position",Zf.call(r,i.vertices)),t.setAttribute("color",XE.call(a,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let s=new ut(i.lineDistances.length,1);t.setAttribute("lineDistance",aQ.call(s,i.lineDistances))}i.boundingSphere!==null&&(t.boundingSphere=i.boundingSphere.clone()),i.boundingBox!==null&&(t.boundingBox=i.boundingBox.clone())}else e.isMesh&&(t=i.toBufferGeometry());return t}};Ug.prototype.isGeometry=!0;var rQ=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],i,r,a,s=e.faces;for(r=0;r<s.length;r++){let n=s[r];n.materialIndex!==a&&(a=n.materialIndex,i!==void 0&&(i.count=r*3-i.start,t.push(i)),i={start:r*3,materialIndex:a})}i!==void 0&&(i.count=r*3-i.start,t.push(i)),this.groups=t}fromGeometry(e){let t=e.faces,i=e.vertices,r=e.faceVertexUvs,a=r[0]&&r[0].length>0,s=r[1]&&r[1].length>0,n=e.morphTargets,o=n.length,l;if(o>0){l=[];for(let g=0;g<o;g++)l[g]={name:n[g].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,c=h.length,u;if(c>0){u=[];for(let g=0;g<c;g++)u[g]={name:h[g].name,data:[]};this.morphTargets.normal=u}let d=e.skinIndices,p=e.skinWeights,f=d.length===i.length,m=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<t.length;g++){let v=t[g];this.vertices.push(i[v.a],i[v.b],i[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let _=v.normal;this.normals.push(_,_,_)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let _=v.color;this.colors.push(_,_,_)}if(a===!0){let _=r[0][g];_!==void 0?this.uvs.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new ae,new ae,new ae))}if(s===!0){let _=r[1][g];_!==void 0?this.uvs2.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new ae,new ae,new ae))}for(let _=0;_<o;_++){let M=n[_].vertices;l[_].data.push(M[v.a],M[v.b],M[v.c])}for(let _=0;_<c;_++){let M=h[_].vertexNormals[g];u[_].data.push(M.a,M.b,M.c)}f&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),m&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},fx=class{constructor(e,t,i,r,a,s=0){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new O,this.vertexNormals=Array.isArray(r)?r:[],this.color=a&&a.isColor?a:new _t,this.vertexColors=Array.isArray(a)?a:[],this.materialIndex=s}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};function aQ(e){return this.array.set(e),this}function XE(e){let t=this.array,i=0;for(let r=0,a=e.length;r<a;r++){let s=e[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),s=new _t),t[i++]=s.r,t[i++]=s.g,t[i++]=s.b}return this}function YE(e){let t=this.array,i=0;for(let r=0,a=e.length;r<a;r++){let s=e[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),s=new ae),t[i++]=s.x,t[i++]=s.y}return this}function Zf(e){let t=this.array,i=0;for(let r=0,a=e.length;r<a;r++){let s=e[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),s=new O),t[i++]=s.x,t[i++]=s.y,t[i++]=s.z}return this}function QE(e){let t=this.array,i=0;for(let r=0,a=e.length;r<a;r++){let s=e[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),s=new Nt),t[i++]=s.x,t[i++]=s.y,t[i++]=s.z,t[i++]=s.w}return this}var sQ=["a","b","c"];function nQ(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function ty(e,t,i){let r=Math.min(e,t),a=Math.max(e,t),s=r+"_"+a;return i.get(s)}function iy(e,t,i,r,a,s){let n=Math.min(e,t),o=Math.max(e,t),l=n+"_"+o,h;if(r.has(l))h=r.get(l);else{let c=i[n],u=i[o];h={a:c,b:u,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(a),s[e].edges.push(h),s[t].edges.push(h)}function oQ(e,t,i,r){let a,s,n;for(a=0,s=e.length;a<s;a++)i[a]={edges:[]};for(a=0,s=t.length;a<s;a++)n=t[a],iy(n.a,n.b,e,r,n,i),iy(n.b,n.c,e,r,n,i),iy(n.c,n.a,e,r,n,i)}function Jf(e,t,i,r,a){e.push(new fx(t,i,r,void 0,void 0,a))}function bc(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function $f(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var lQ=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof St?e=new Ug().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new O,i,r,a,s,n,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],c=h!==void 0&&h.length>0,u=[],d=new Map;oQ(o,l,u,d);let p=[],f,m,g,v,x,b,_;for(let Ee of Array.from(d.keys())){for(m=d.get(Ee),g=new O,x=3/8,b=1/8,_=m.faces.length,_!=2&&(x=.5,b=0,_!=1),g.addVectors(m.a,m.b).multiplyScalar(x),t.set(0,0,0),s=0;s<_;s++){for(v=m.faces[s],n=0;n<3&&(f=o[nQ(v,sQ[n])],!(f!==m.a&&f!==m.b));n++);f&&t.add(f)}t.multiplyScalar(b),g.add(t),m.newEdge=p.length,p.push(g)}let M,A,S,P,L,E,T,B=[];for(r=0,a=o.length;r<a;r++){for(E=o[r],L=u[r].edges,i=L.length,i==3?M=3/16:i>3&&(M=3/(8*i)),A=1-i*Number(M),S=M,i<=2&&(i==2?(A=3/4,S=1/8):i==1||i==0),T=E.clone().multiplyScalar(A),t.set(0,0,0),s=0;s<i;s++)P=L[s],f=P.a!==E?P.a:P.b,t.add(f);t.multiplyScalar(Number(S)),T.add(t),B.push(T)}let V=B.concat(p),I=B.length,H,q,X,Y=[],ie=[],ce,de,ue,re,se=new ae,he=new ae,_e=new ae;for(r=0,a=l.length;r<a;r++)v=l[r],H=Number(ty(v.a,v.b,d).newEdge)+I,q=Number(ty(v.b,v.c,d).newEdge)+I,X=Number(ty(v.c,v.a,d).newEdge)+I,Jf(Y,H,q,X,v.materialIndex),Jf(Y,v.a,H,X,v.materialIndex),Jf(Y,v.b,q,H,v.materialIndex),Jf(Y,v.c,X,q,v.materialIndex),c&&(ce=h[r],de=ce[0],ue=ce[1],re=ce[2],se.set(bc(de.x,ue.x),bc(de.y,ue.y)),he.set(bc(ue.x,re.x),bc(ue.y,re.y)),_e.set(bc(de.x,re.x),bc(de.y,re.y)),$f(ie,se,he,_e),$f(ie,de,se,_e),$f(ie,ue,he,se),$f(ie,re,_e,he));e.vertices=V,e.faces=Y,c&&(e.faceVertexUvs[0]=ie)}},Lr=new O,hQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new St().copy(new Ks(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Lr),r={width:Lr.x,height:Lr.y,depth:Lr.z,subdivisions:0}):r=t.parameters;let a={...r,...e.parameters};return{parameters:{width:Math.abs(a.width),height:Math.abs(a.height),depth:Math.abs(a.depth),subdivisions:Math.abs(a.subdivisions)},geometry:i}}static build(e){let{width:t,height:i,depth:r,subdivisions:a}=e.parameters,s=e.geometry??new St().copy(new Ks(100,100,100)),n=s.userData.parameters;n===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Lr)):Lr.set(n.width,n.height,n.depth),(t!==Lr.x||i!==Lr.y||r!==Lr.z)&&s.scale(Lr.x===0?1:t/Lr.x,Lr.y===0?1:i/Lr.y,Lr.z===0?1:r/Lr.z);let o=s.originalGeometry;try{a>0?(o===void 0||n?.subdivisions!==a)&&(o===void 0&&(o=s),s=new lQ(a).modify(o).toBufferGeometry()):(o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return o!==void 0&&Object.assign(s,{originalGeometry:o}),delete e.geometry,Object.assign(s,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new sP(i).load(e,r=>{let a=this.normalizeInputs({geometry:r});r.boundingBox.getSize(Lr);let s=100/Lr.x;Object.assign(a.parameters,{width:100,height:Lr.y*s,depth:Lr.z*s}),t(this.build(a))})}},eD=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof ur?e.shape:new ur,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:a,depth:s,extrudeBevelSize:n,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,c=i*.5,u=0,d=0,p=2*Math.PI/r;for(let m=0;m<r;m++){let g=p*m,v=u+Math.sin(g)*h,x=d+Math.cos(g)*c;l.addPoint(l.createPoint(v,x))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=a;l.roundness=a,l.update();let f=Bh.create({shape:l,parameters:{roundness:a,depth:s,extrudeBevelSize:n,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},cQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,radialSegments:a,heightSegments:s,openEnded:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=new dQ(t*.5,i,a,s,n,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function xd(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function ry(e,t,i,r,a,s){let n=t.clone().sub(e),o=i.clone().sub(e),l=n.angleTo(o);if(n.normalize(),o.normalize(),r===a){let h=n.add(o).normalize();s.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=n.angleTo(o);s.copy(e),s.addScaledVector(n,a/Math.sin(h)),s.addScaledVector(o,r/Math.sin(h))}}function uQ(e,t,i){let r=e.clone().sub(t),a=i.clone().sub(t);return r.projectOnVector(a),r.add(t)}var dQ=class extends St{constructor(e=.5,t=1,i=4,r=1,a=!1,s=0,n=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),n=Math.floor(n);let o=[],l=[],h=[],c=[],u=0,d=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),m=2*Math.PI/i,g=(i-2)*Math.PI/i,v=Math.PI-g,x=new O(0,-d,0),b=new O(0,d,0),_=new ae(e,-d),M=new ae(f,-d),A=new ae(0,b.y).sub(M),S=new ae(0,b.y).sub(_),P=new ae(A.y,-A.x).normalize(),L=new ae(S.y,-S.x).normalize(),E=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-A.angle())/2)-1e-8;s=Math.min(s,E);let T;{let Y=new O(P.x,P.y,0),ie=new O(Math.cos(m)*Y.x,Y.y,Math.sin(m)*Y.x);T=Y.angleTo(ie)}let B=s/Math.tan((Math.PI-A.angle())/2),V=s/Math.tan((Math.PI-T)/2),I=new O;if(!a){l.push(x.x,x.y,x.z),h.push(0,-1,0),c.push(0,0);let Y=u++,ie=[],ce=_.clone(),de=B/Math.cos(Math.PI/i);ce.x-=de;for(let ue=0;ue<i;ue++){let re=ue/i*Math.PI*2+p,se=new ae(Math.sin(re),Math.cos(re));xd(ce,se,I),l.push(I.x,I.y,I.z),h.push(0,-1,0),c.push(0,0),ie.push(u++)}for(let ue=0;ue<ie.length;ue++)o.push(ie[ue],Y,ie[(ue+1)%ie.length])}let H=[];{let Y=new O,ie=new O,ce=new O,de=new O,ue=new O,re=new O;for(let se=0;se<i;se++){let he=se/i*Math.PI*2+p,_e=(se+.5)/i*Math.PI*2+p,Ee=(se+1)/i*Math.PI*2+p,fe=new ae(Math.sin(he),Math.cos(he)),Re=new ae(Math.sin(_e),Math.cos(_e)),Pe=new ae(Math.sin(Ee),Math.cos(Ee));xd(_,fe,ie),xd(_,Pe,ce),xd(P,Re,Y),ry(b,ie,ce,V,V,de),l.push(de.x,de.y,de.z),ry(ie,b,ce,V,B,ue),l.push(ue.x,ue.y,ue.z),ry(ce,ie,b,B,V,re),l.push(re.x,re.y,re.z),h.push(Y.x,Y.y,Y.z),h.push(Y.x,Y.y,Y.z),h.push(Y.x,Y.y,Y.z),c.push(0,0),c.push(0,0),c.push(0,0);let te=u++,We=u++,Be=u++;if(o.push(te,We,Be),s>0){{let tt=ie.clone().add(ce).multiplyScalar(.5),Fe=b.clone().sub(tt).normalize(),He=x.clone().sub(tt).normalize().add(Fe).normalize().multiplyScalar(-1),nt=re.clone().sub(ue);q(tt,nt,He,A.angle())}let Ue,Ge;{let tt=new O;xd(L,Pe,tt);let Fe=re.clone().add(de).multiplyScalar(.5);Fe=uQ(Fe,ce,b);let He=re.clone().sub(de);[Ue,Ge]=q(Fe,He,tt,T,de.y)}{let tt=Ue,Fe=tt.clone().setY(0).normalize(),He=new O(0,-1,0),nt=Fe.clone().cross(He);X(tt,Fe,He,nt)}H.concat(Ge);{let tt=A.angle(),Fe=Math.PI-tt,He=b.clone();He.y-=s/Math.sin(tt-Math.PI/2);let nt=new O,ht=[];for(let j=0;j<n;j++){let ye=[],Me=Math.PI/2-Fe*j/n,Je=Math.cos(Me),z=Math.sin(Me),qe=_e;for(let ct=0;ct<=j;ct++){let ze=Math.cos(qe),at=Math.sin(qe);Y.x=Je*at,Y.y=z,Y.z=Je*ze,nt.copy(He).addScaledVector(Y,s),l.push(nt.x,nt.y,nt.z),h.push(Y.x,Y.y,Y.z),c.push(0,0),ye.push(u++),qe+=Math.PI*2/j/i}ht.push(ye)}Ge.reverse(),ht.push(Ge);let Z=ht.length-1;for(let j=0;j<Z;j++){let ye=ht[j],Me=ht[j+1],Je=ye.length-1;o.push(Me[1],ye[0],Me[0]);for(let z=1;z<=Je;z++)o.push(ye[z],ye[z-1],Me[z]),o.push(Me[z+1],ye[z],Me[z])}}}}}this.setIndex(o),this.setAttribute("position",new ut(l,3)),this.setAttribute("normal",new ut(h,3)),this.setAttribute("uv",new ut(c,2));function q(Y,ie,ce,de,ue){let re=-de/2,se=(Math.PI-de)/2,he=ie.clone().normalize().cross(ce);Y.addScaledVector(ce,-s/Math.sin(se));let _e=new O,Ee=new O,fe=1,Re=u,Pe=[];for(let te=0;te<=n;te++){let We=re+te/n*de;Ee.set(0,0,0),Ee.addScaledVector(he,Math.sin(We)),Ee.addScaledVector(ce,Math.cos(We));for(let Be=0;Be<=fe;Be++){let Ue=Be/fe-.5;if(_e.copy(Y),_e.addScaledVector(ie,Ue),_e.addScaledVector(Ee,s),ue!=null){let Ge=Math.max(0,_e.y-ue);_e.addScaledVector(ie,-Ge/ie.y)}l.push(_e.x,_e.y,_e.z),h.push(Ee.x,Ee.y,Ee.z),c.push(0,0),Be===0&&Pe.push(u),u++}}for(let te=0;te<n;te++)for(let We=0;We<fe;We++){let Be=Re+We+(fe+1)*te,Ue=Be+(fe+1),Ge=Ue+1,tt=Be+1;o.push(Be,Ue,tt),o.push(Ue,Ge,tt)}return[Y.clone().addScaledVector(ie,.5),Pe]}function X(Y,ie,ce,de){let ue=Math.PI/2,re=S.angle()-ue,se=[],he=new O,_e=new O;for(let fe=0;fe<=n;fe++){let Re=[],Pe=fe/n;for(let te=0;te<=fe;te++){let We=((fe?te/fe:0)-.5)*v,Be=Math.cos(We),Ue=Math.sin(We),Ge=Math.atan(Math.tan(re)*Be),tt=(ue+Ge)*Pe,Fe=Math.cos(tt),He=Math.sin(tt);he.set(0,0,0),he.addScaledVector(ie,He*Be),he.addScaledVector(ce,Fe),he.addScaledVector(de,He*Ue),_e.copy(Y).addScaledVector(he,s),l.push(_e.x,_e.y,_e.z),h.push(he.x,he.y,he.z),c.push(0,0),Re.push(u++)}se.push(Re)}let Ee=se.length-1;for(let fe=0;fe<Ee;fe++){let Re=se[fe],Pe=se[fe+1],te=Re.length-1;o.push(Re[0],Pe[1],Pe[0]);for(let We=1;We<=te;We++)o.push(Re[We-1],Re[We],Pe[We]),o.push(Re[We],Pe[We+1],Pe[We])}}}},Jb=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof ur?e.shape:new ur,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(e){let t=e.shape,{width:i,height:r,cornerRadius:a,cornerType:s,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},c={x:-h.x,y:-h.y},u={x:h.x,y:h.y};function d(_,M,A){return M>i&&A>r?Math.min(_*i/M,_*r/A):M>i?_*i/M:A>r?_*r/A:_}let p=[];p[0]=a[0]===0?0:d(a[0],a[0]+a[3],a[0]+a[1]),p[1]=a[1]===0?0:d(a[1],a[1]+a[2],a[1]+a[0]),p[2]=a[2]===0?0:d(a[2],a[2]+a[1],a[2]+a[3]),p[3]=a[3]===0?0:d(a[3],a[3]+a[0],a[3]+a[2]);let f=c.x,m=u.x,g=u.y,v=c.y;t.addPoint(t.createPoint(f,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let x=!0;for(let _=0,M=t.points.length;_<M;_++)t.points[_].roundness=p[_],_>0&&p[_]!==p[_-1]&&(x=!1);x&&(t.roundness=p[0]),t.useCubicForRoundedCorners=s!==1,t.update();let b=Bh.create({shape:t,parameters:{depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...e,type:"RectangleGeometry"}})}},pQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},e.parameters);return i.thetaLength=dt.clamp(i.thetaLength,0,180),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t=100,height:i=t,depth:r=t,widthSegments:a=64,heightSegments:s=64,phiStart:n,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,c;return h===0?(c=new St,c.setAttribute("position",new ut([],3))):c=new Qc(.5*t,a,s,n,o,l,h*dt.DEG2RAD),c.scale(1,i/t,r/t),Object.assign(c,{userData:{...e,type:"SphereGeometry"}})}},fQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:a=8}=e.parameters,s=new Pl(t,i,r,a);return s.scale(1,1,1),Object.assign(s,{userData:{...e,type:"PlaneGeometry"}})}},mQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:a,cornerRadius:s,cornerSegments:n}=e.parameters,o=new gQ(t,i,r,a,s,n);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},gQ=class extends St{constructor(e=1,t=1,i=1,r=90,a=10,s=24){super(),this.type="BackdropGeometry";let n=[],o=[],l=[],h=.001;a==0&&(s=1),s=Math.max(1,Math.floor(s)),a=Math.min(a,100),r=Math.min(180-h,r),r*=Math.PI/180;let c=[],u=Math.PI/2,d=(Ee=0,fe=0,Re=0)=>new O(Ee,fe,Re),p=d(),f=d(),[m,g,v]=[t/2,e/2,i/2],x=-g,b=+g,[_,M,A]=[d(x,-m,+v),d(x,-m,-v),d(x,+m,-v)],S=(Ee,fe=!1)=>Math.sin(Ee-Math.PI/(1+ +fe)),P=(Ee,fe=!1)=>Math.cos(Ee-Math.PI/(1+ +fe));A.y=Math.sin(r)*t-m;let L=Math.cos(r)*t-v,E=_.z-h;r<=u?(A.z=Math.min(L,E),A.z==E&&(A.y-=(L-E)/Math.tan(u-r))):M.z=Math.min(M.z-L-v,_.z-h),p.subVectors(_,M),f.subVectors(A,M);let T=Math.min(p.length(),f.length())*a/100,B=T*Math.tan(r/2),V=T/Math.cos(r/2),I=p.clone().normalize().add(f.normalize()).setLength(V).add(M);p.set(0,S(r,!0),P(r,!0)),c.push([A,p.clone()]);let H=(Math.PI-r)/s;for(let Ee=0;Ee<=s;Ee++){let fe=u+r+Ee*H;p.set(0,Math.sin(fe)*B,Math.cos(fe)*B),p.add(I),f.set(0,S(fe),P(fe)),c.push([p.clone(),f.clone()])}c.push([_,d(0,1,0)]);let q=Math.sin(H/2)*B*2,X=c.length-1,Y=c[0][0].distanceTo(c[1][0]),ie=c[X-1][0].distanceTo(c[X][0]),ce=Y+q*s+ie;c[0].push(1);for(let Ee=0;Ee<=s;Ee++)c[Ee+1].push(1-(Y+Ee*q)/ce);c[X].push(0);let[de,ue,re]=c[0],se,he,_e;for(let Ee=1;Ee<c.length;Ee++)[se,he,_e]=c[Ee],n.push(x,de.y,de.z,x,se.y,se.z,b,de.y,de.z,b,de.y,de.z,x,se.y,se.z,b,se.y,se.z),o.push(0,ue.y,ue.z,0,he.y,he.z,0,ue.y,ue.z,0,ue.y,ue.z,0,he.y,he.z,0,he.y,he.z),l.push(0,re,0,_e,1,re,1,re,0,_e,1,_e),[de,ue,re]=[se,he,_e];this.setAttribute("position",new ut(n,3)),this.setAttribute("normal",new ut(o,3)),this.setAttribute("uv",new ut(l,2))}},tD=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof ur?e.shape:new ur,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:a,cornerRadius:s,angle:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,c=e.shape,u=t*.5,d=i*.5,p=0,f=0,m=n*Math.PI/360/a,g=Math.PI/2*3*-1,v=u*r/100,x=d*r/100;if(a===3&&r===50){m=2*Math.PI/a;for(let _=0;_<a;_++){let M=m*_,A=p+Math.sin(M)*u,S=f+Math.cos(M)*d;c.addPoint(c.createPoint(A,S))}}else for(let _=0;_<a;_++){let M=p+Math.cos(g)*u,A=f+Math.sin(g)*d;c.addPoint(c.createPoint(M,A)),g+=m,M=p+Math.cos(g)*v,A=f+Math.sin(g)*x,_<=a,c.addPoint(c.createPoint(M,A)),g+=m}c.isClosed=!0;for(let _=0,M=c.points.length;_<M;_++)c.points[_].roundness=s;c.roundness=s,c.update();let b=Bh.create({shape:c,parameters:{roundness:s,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(b,{userData:{...e,type:"StarGeometry"}})}},vQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i}=e.parameters,r=new Pl(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},yQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),a=Math.abs(i.height??i.width),s=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:a,depth:s})}}static build(e){let{width:t,height:i,depth:r,radialSegments:a,tubularSegments:s,arc:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=xQ(t,i,r,t*.5,n,s,0,0,a,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function xQ(e,t,i,r,a,s,n,o,l,h,c){[t,i]=[i,t],n=t/2;let u=dt.clamp(a/360,0,1);if(u===0){let d=new St;return d.setAttribute("position",new ut([],3)),d}return u===1&&(h=0),new J3(!0,e,t,i,r,u,s,n,o,l,h,c)}var bQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??i.width*.125})}}static build(e){let{width:t,tube:i,tubularSegments:r,radialSegments:a,p:s,q:n}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new $T(o,i,r,a,s,n);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},wQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof ur?e.shape:new ur,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t=100,height:i,cornerRadius:r,depth:a,extrudeBevelSize:s,extrudeBevelSegments:n,isRect:o}=e.parameters,l=e.shape,h=t*.5,c=i*.5;o?(l.addPoint(l.createPoint(-h,c)),l.addPoint(l.createPoint(h,-c)),l.addPoint(l.createPoint(-h,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(h,-c)),l.addPoint(l.createPoint(-h,-c))),l.isClosed=!0;for(let d=0,p=l.points.length;d<p;d++)l.points[d].roundness=r;l.roundness=r,l.update();let u=Bh.create({shape:l,parameters:{roundness:r,depth:a,extrudeBevelSize:s,extrudeBevelSegments:n}});return Object.assign(u,{userData:{...e,type:"TriangleGeometry"}})}};function _Q(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}var SQ=class{add(e,t,i){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(r){this[r]=this[r]||[],t&&this[r][i?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(i){i.call(t&&t.context?t.context:t,t)})}},AQ=class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(t=>{if(typeof t!="object"||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");this.registered[t.name]||(t.init(this.jsep),this.registered[t.name]=t)})}},Ie=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+Ie.version}static addUnaryOp(e){return Ie.max_unop_len=Math.max(e.length,Ie.max_unop_len),Ie.unary_ops[e]=1,Ie}static addBinaryOp(e,t,i){return Ie.max_binop_len=Math.max(e.length,Ie.max_binop_len),Ie.binary_ops[e]=t,i?Ie.right_associative.add(e):Ie.right_associative.delete(e),Ie}static addIdentifierChar(e){return Ie.additional_identifier_chars.add(e),Ie}static addLiteral(e,t){return Ie.literals[e]=t,Ie}static removeUnaryOp(e){return delete Ie.unary_ops[e],e.length===Ie.max_unop_len&&(Ie.max_unop_len=Ie.getMaxKeyLen(Ie.unary_ops)),Ie}static removeAllUnaryOps(){return Ie.unary_ops={},Ie.max_unop_len=0,Ie}static removeIdentifierChar(e){return Ie.additional_identifier_chars.delete(e),Ie}static removeBinaryOp(e){return delete Ie.binary_ops[e],e.length===Ie.max_binop_len&&(Ie.max_binop_len=Ie.getMaxKeyLen(Ie.binary_ops)),Ie.right_associative.delete(e),Ie}static removeAllBinaryOps(){return Ie.binary_ops={},Ie.max_binop_len=0,Ie}static removeLiteral(e){return delete Ie.literals[e],Ie}static removeAllLiterals(){return Ie.literals={},Ie}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new Ie(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(t=>t.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return Ie.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!Ie.binary_ops[String.fromCharCode(e)]||Ie.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return Ie.isIdentifierStart(e)||Ie.isDecimalDigit(e)}throwError(e){let t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(Ie.hooks[e]){let i={context:this,node:t};return Ie.hooks.run(e,i),i.node}return t}searchHook(e){if(Ie.hooks[e]){let t={context:this};return Ie.hooks[e].find(function(i){return i.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===Ie.SPACE_CODE||e===Ie.TAB_CODE||e===Ie.LF_CODE||e===Ie.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=e.length===1?e[0]:{type:Ie.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],i,r;for(;this.index<this.expr.length;)if(i=this.code,i===Ie.SEMCOL_CODE||i===Ie.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(i===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,Ie.max_binop_len),t=e.length;for(;t>0;){if(Ie.binary_ops.hasOwnProperty(e)&&(!Ie.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!Ie.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,i,r,a,s,n,o,l;if(s=this.gobbleToken(),!s||(t=this.gobbleBinaryOp(),!t))return s;for(a={value:t,prec:Ie.binaryPrecedence(t),right_a:Ie.right_associative.has(t)},n=this.gobbleToken(),n||this.throwError("Expected expression after "+t),r=[s,a,n];t=this.gobbleBinaryOp();){if(i=Ie.binaryPrecedence(t),i===0){this.index-=t.length;break}a={value:t,prec:i,right_a:Ie.right_associative.has(t)},l=t;let h=c=>a.right_a&&c.right_a?i>c.prec:i<=c.prec;for(;r.length>2&&h(r[r.length-2]);)n=r.pop(),t=r.pop().value,s=r.pop(),e={type:Ie.BINARY_EXP,operator:t,left:s,right:n},r.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),r.push(a,e)}for(o=r.length-1,e=r[o];o>1;)e={type:Ie.BINARY_EXP,operator:r[o-1].value,left:r[o-2],right:e},o-=2;return e}gobbleToken(){let e,t,i,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(e=this.code,Ie.isDecimalDigit(e)||e===Ie.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===Ie.SQUOTE_CODE||e===Ie.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===Ie.OBRACK_CODE)r=this.gobbleArray();else{for(t=this.expr.substr(this.index,Ie.max_unop_len),i=t.length;i>0;){if(Ie.unary_ops.hasOwnProperty(t)&&(!Ie.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!Ie.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=i;let a=this.gobbleToken();return a||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:Ie.UNARY_EXP,operator:t,argument:a,prefix:!0})}t=t.substr(0,--i)}Ie.isIdentifierStart(e)?(r=this.gobbleIdentifier(),Ie.literals.hasOwnProperty(r.name)?r={type:Ie.LITERAL,value:Ie.literals[r.name],raw:r.name}:r.name===Ie.this_str&&(r={type:Ie.THIS_EXP})):e===Ie.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===Ie.PERIOD_CODE||t===Ie.OBRACK_CODE||t===Ie.OPAREN_CODE||t===Ie.QUMARK_CODE;){let i;if(t===Ie.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==Ie.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===Ie.OBRACK_CODE?(e={type:Ie.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},this.gobbleSpaces(),t=this.code,t!==Ie.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===Ie.OPAREN_CODE?e={type:Ie.CALL_EXP,arguments:this.gobbleArguments(Ie.CPAREN_CODE),callee:e}:(t===Ie.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),e={type:Ie.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),i&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,i;for(;Ie.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===Ie.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);Ie.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(t=this.char,t==="e"||t==="E"){for(e+=this.expr.charAt(this.index++),t=this.char,(t==="+"||t==="-")&&(e+=this.expr.charAt(this.index++));Ie.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);Ie.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return i=this.code,Ie.isIdentifierStart(i)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(i===Ie.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===Ie.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:Ie.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,i=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let a=this.expr.charAt(this.index++);if(a===i){r=!0;break}else if(a==="\\")switch(a=this.expr.charAt(this.index++),a){case"n":e+=`
3836
+ }`,m5=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){let r=new Ki,a=e.properties.get(r);a.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}render(e,t){if(this.texture!==null){if(this.mesh===null){let i=t.cameras[0].viewport,r=new vi({extensions:{fragDepth:!0},vertexShader:p5,fragmentShader:f5,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new xr(new Pl(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}},g5=class extends ua{constructor(e,t){super();let i=this,r=null,a=1,s=null,n="local-floor",o=1,l=null,h=null,c=null,u=null,d=null,p=null,f=new m5,m=t.getContextAttributes(),g=null,v=null,x=[],b=[],_=new ae,M=null,A=new va;A.layers.enable(1),A.viewport=new Nt;let S=new va;S.layers.enable(2),S.viewport=new Nt;let P=[A,S],L=new u5;L.layers.enable(1),L.layers.enable(2);let E=null,T=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(re){let se=x[re];return se===void 0&&(se=new S0,x[re]=se),se.getTargetRaySpace()},this.getControllerGrip=function(re){let se=x[re];return se===void 0&&(se=new S0,x[re]=se),se.getGripSpace()},this.getHand=function(re){let se=x[re];return se===void 0&&(se=new S0,x[re]=se),se.getHandSpace()};function B(re){let se=b.indexOf(re.inputSource);if(se===-1)return;let he=x[se];he!==void 0&&(he.update(re.inputSource,re.frame,l||s),he.dispatchEvent({type:re.type,data:re.inputSource}))}function V(){r.removeEventListener("select",B),r.removeEventListener("selectstart",B),r.removeEventListener("selectend",B),r.removeEventListener("squeeze",B),r.removeEventListener("squeezestart",B),r.removeEventListener("squeezeend",B),r.removeEventListener("end",V),r.removeEventListener("inputsourceschange",I);for(let re=0;re<x.length;re++){let se=b[re];se!==null&&(b[re]=null,x[re].disconnect(se))}E=null,T=null,f.reset(),e.setRenderTarget(g),d=null,u=null,c=null,r=null,v=null,ue.stop(),i.isPresenting=!1,e.setPixelRatio(M),e.setSize(_.width,_.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(re){a=re,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(re){n=re,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(re){l=re},this.getBaseLayer=function(){return u!==null?u:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(re){if(r=re,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",B),r.addEventListener("selectstart",B),r.addEventListener("selectend",B),r.addEventListener("squeeze",B),r.addEventListener("squeezestart",B),r.addEventListener("squeezeend",B),r.addEventListener("end",V),r.addEventListener("inputsourceschange",I),m.xrCompatible!==!0&&await t.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(_),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let se={antialias:r.renderState.layers===void 0?m.antialias:!0,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:a};d=new XRWebGLLayer(r,t,se),r.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),v=new _i(d.framebufferWidth,d.framebufferHeight,{format:Qr,type:la,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let se=null,he=null,_e=null;m.depth&&(_e=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=m.stencil?Sh:gh,he=m.stencil?wl:En);let Ee={colorFormat:t.RGBA8,depthFormat:_e,scaleFactor:a};c=new XRWebGLBinding(r,t),u=c.createProjectionLayer(Ee),r.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),v=new _i(u.textureWidth,u.textureHeight,{format:Qr,type:la,depthTexture:new Ah(u.textureWidth,u.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0});let fe=e.properties.get(v);fe.__ignoreDepthValues=u.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await r.requestReferenceSpace(n),ue.setContext(r),ue.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function I(re){for(let se=0;se<re.removed.length;se++){let he=re.removed[se],_e=b.indexOf(he);_e>=0&&(b[_e]=null,x[_e].disconnect(he))}for(let se=0;se<re.added.length;se++){let he=re.added[se],_e=b.indexOf(he);if(_e===-1){for(let fe=0;fe<x.length;fe++)if(fe>=b.length){b.push(he),_e=fe;break}else if(b[fe]===null){b[fe]=he,_e=fe;break}if(_e===-1)break}let Ee=x[_e];Ee&&Ee.connect(he)}}let H=new O,q=new O;function X(re,se,he){H.setFromMatrixPosition(se.matrixWorld),q.setFromMatrixPosition(he.matrixWorld);let _e=H.distanceTo(q),Ee=se.projectionMatrix.elements,fe=he.projectionMatrix.elements,Re=Ee[14]/(Ee[10]-1),Pe=Ee[14]/(Ee[10]+1),te=(Ee[9]+1)/Ee[5],We=(Ee[9]-1)/Ee[5],Be=(Ee[8]-1)/Ee[0],Ue=(fe[8]+1)/fe[0],Ge=Re*Be,tt=Re*Ue,Fe=_e/(-Be+Ue),He=Fe*-Be;se.matrixWorld.decompose(re.position,re.quaternion,re.scale),re.translateX(He),re.translateZ(Fe),re.matrixWorld.compose(re.position,re.quaternion,re.scale),re.matrixWorldInverse.copy(re.matrixWorld).invert();let nt=Re+Fe,ht=Pe+Fe,Z=Ge-He,j=tt+(_e-He),ye=te*Pe/ht*nt,Me=We*Pe/ht*nt;re.projectionMatrix.makePerspective(Z,j,ye,Me,nt,ht),re.projectionMatrixInverse.copy(re.projectionMatrix).invert()}function Y(re,se){se===null?re.matrixWorld.copy(re.matrix):re.matrixWorld.multiplyMatrices(se.matrixWorld,re.matrix),re.matrixWorldInverse.copy(re.matrixWorld).invert()}this.updateCamera=function(re){if(r===null)return;f.texture!==null&&(re.near=f.depthNear,re.far=f.depthFar),L.near=S.near=A.near=re.near,L.far=S.far=A.far=re.far,(E!==L.near||T!==L.far)&&(r.updateRenderState({depthNear:L.near,depthFar:L.far}),E=L.near,T=L.far,A.near=E,A.far=T,S.near=E,S.far=T,A.updateProjectionMatrix(),S.updateProjectionMatrix(),re.updateProjectionMatrix());let se=re.parent,he=L.cameras;Y(L,se);for(let _e=0;_e<he.length;_e++)Y(he[_e],se);he.length===2?X(L,A,S):L.projectionMatrix.copy(A.projectionMatrix),ie(re,L,se)};function ie(re,se,he){he===null?re.matrix.copy(se.matrixWorld):(re.matrix.copy(he.matrixWorld),re.matrix.invert(),re.matrix.multiply(se.matrixWorld)),re.matrix.decompose(re.position,re.quaternion,re.scale),re.updateMatrixWorld(!0),re.projectionMatrix.copy(se.projectionMatrix),re.projectionMatrixInverse.copy(se.projectionMatrixInverse),re.isPerspectiveCamera&&(re.fov=hu*2*Math.atan(1/re.projectionMatrix.elements[5]),re.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(u===null&&d===null))return o},this.setFoveation=function(re){o=re,u!==null&&(u.fixedFoveation=re),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=re)},this.hasDepthSensing=function(){return f.texture!==null};let ce=null;function de(re,se){if(h=se.getViewerPose(l||s),p=se,h!==null){let he=h.views;d!==null&&(e.setRenderTargetFramebuffer(v,d.framebuffer),e.setRenderTarget(v));let _e=!1;he.length!==L.cameras.length&&(L.cameras.length=0,_e=!0);for(let fe=0;fe<he.length;fe++){let Re=he[fe],Pe=null;if(d!==null)Pe=d.getViewport(Re);else{let We=c.getViewSubImage(u,Re);Pe=We.viewport,fe===0&&(e.setRenderTargetTextures(v,We.colorTexture,u.ignoreDepthValues?void 0:We.depthStencilTexture),e.setRenderTarget(v))}let te=P[fe];te===void 0&&(te=new va,te.layers.enable(fe),te.viewport=new Nt,P[fe]=te),te.matrix.fromArray(Re.transform.matrix),te.matrix.decompose(te.position,te.quaternion,te.scale),te.projectionMatrix.fromArray(Re.projectionMatrix),te.projectionMatrixInverse.copy(te.projectionMatrix).invert(),te.viewport.set(Pe.x,Pe.y,Pe.width,Pe.height),fe===0&&(L.matrix.copy(te.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),_e===!0&&L.cameras.push(te)}let Ee=r.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")){let fe=c.getDepthInformation(he[0]);fe&&fe.isValid&&fe.texture&&f.init(e,fe,r.renderState)}}for(let he=0;he<x.length;he++){let _e=b[he],Ee=x[he];_e!==null&&Ee!==void 0&&Ee.update(_e,se,l||s)}f.render(e,L),ce&&ce(re,se),se.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:se}),p=null}let ue=new LT;ue.setAnimationLoop(de),this.setAnimationLoop=function(re){ce=re},this.dispose=function(){}}},Wl=new Qi,v5=new je;function y5(e,t){function i(g,v){g.matrixAutoUpdate===!0&&g.updateMatrix(),v.value.copy(g.matrix)}function r(g,v){v.color.getRGB(g.fogColor.value,OT(e)),v.isFog?(g.fogNear.value=v.near,g.fogFar.value=v.far):v.isFogExp2&&(g.fogDensity.value=v.density)}function a(g,v,x,b,_){v.isMeshBasicMaterial||v.isMeshLambertMaterial?s(g,v):v.isMeshToonMaterial?(s(g,v),u(g,v)):v.isMeshPhongMaterial?(s(g,v),c(g,v)):v.isMeshStandardMaterial?(s(g,v),d(g,v),v.isMeshPhysicalMaterial&&p(g,v,_)):v.isMeshMatcapMaterial?(s(g,v),f(g,v)):v.isMeshDepthMaterial?s(g,v):v.isMeshDistanceMaterial?(s(g,v),m(g,v)):v.isMeshNormalMaterial?s(g,v):v.isLineBasicMaterial?(n(g,v),v.isLineDashedMaterial&&o(g,v)):v.isPointsMaterial?l(g,v,x,b):v.isSpriteMaterial?h(g,v):v.isShadowMaterial?(g.color.value.copy(v.color),g.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(g,v){g.opacity.value=v.opacity,v.color&&g.diffuse.value.copy(v.color),v.emissive&&g.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(g.map.value=v.map,i(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,i(v.alphaMap,g.alphaMapTransform)),v.bumpMap&&(g.bumpMap.value=v.bumpMap,i(v.bumpMap,g.bumpMapTransform),g.bumpScale.value=v.bumpScale,v.side===Fr&&(g.bumpScale.value*=-1)),v.normalMap&&(g.normalMap.value=v.normalMap,i(v.normalMap,g.normalMapTransform),g.normalScale.value.copy(v.normalScale),v.side===Fr&&g.normalScale.value.negate()),v.displacementMap&&(g.displacementMap.value=v.displacementMap,i(v.displacementMap,g.displacementMapTransform),g.displacementScale.value=v.displacementScale,g.displacementBias.value=v.displacementBias),v.emissiveMap&&(g.emissiveMap.value=v.emissiveMap,i(v.emissiveMap,g.emissiveMapTransform)),v.specularMap&&(g.specularMap.value=v.specularMap,i(v.specularMap,g.specularMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest);let x=t.get(v),b=x.envMap,_=x.envMapRotation;if(b&&(g.envMap.value=b,Wl.copy(_),Wl.x*=-1,Wl.y*=-1,Wl.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Wl.y*=-1,Wl.z*=-1),g.envMapRotation.value.setFromMatrix4(v5.makeRotationFromEuler(Wl)),g.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=v.reflectivity,g.ior.value=v.ior,g.refractionRatio.value=v.refractionRatio),v.lightMap){g.lightMap.value=v.lightMap;let M=e._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=v.lightMapIntensity*M,i(v.lightMap,g.lightMapTransform)}v.aoMap&&(g.aoMap.value=v.aoMap,g.aoMapIntensity.value=v.aoMapIntensity,i(v.aoMap,g.aoMapTransform))}function n(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,v.map&&(g.map.value=v.map,i(v.map,g.mapTransform))}function o(g,v){g.dashSize.value=v.dashSize,g.totalSize.value=v.dashSize+v.gapSize,g.scale.value=v.scale}function l(g,v,x,b){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.size.value=v.size*x,g.scale.value=b*.5,v.map&&(g.map.value=v.map,i(v.map,g.uvTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,i(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function h(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.rotation.value=v.rotation,v.map&&(g.map.value=v.map,i(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,i(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function c(g,v){g.specular.value.copy(v.specular),g.shininess.value=Math.max(v.shininess,1e-4)}function u(g,v){v.gradientMap&&(g.gradientMap.value=v.gradientMap)}function d(g,v){g.metalness.value=v.metalness,v.metalnessMap&&(g.metalnessMap.value=v.metalnessMap,i(v.metalnessMap,g.metalnessMapTransform)),g.roughness.value=v.roughness,v.roughnessMap&&(g.roughnessMap.value=v.roughnessMap,i(v.roughnessMap,g.roughnessMapTransform)),t.get(v).envMap&&(g.envMapIntensity.value=v.envMapIntensity)}function p(g,v,x){g.ior.value=v.ior,v.sheen>0&&(g.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),g.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(g.sheenColorMap.value=v.sheenColorMap,i(v.sheenColorMap,g.sheenColorMapTransform)),v.sheenRoughnessMap&&(g.sheenRoughnessMap.value=v.sheenRoughnessMap,i(v.sheenRoughnessMap,g.sheenRoughnessMapTransform))),v.clearcoat>0&&(g.clearcoat.value=v.clearcoat,g.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(g.clearcoatMap.value=v.clearcoatMap,i(v.clearcoatMap,g.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,i(v.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(g.clearcoatNormalMap.value=v.clearcoatNormalMap,i(v.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Fr&&g.clearcoatNormalScale.value.negate())),v.iridescence>0&&(g.iridescence.value=v.iridescence,g.iridescenceIOR.value=v.iridescenceIOR,g.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(g.iridescenceMap.value=v.iridescenceMap,i(v.iridescenceMap,g.iridescenceMapTransform)),v.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=v.iridescenceThicknessMap,i(v.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),v.transmission>0&&(g.transmission.value=v.transmission,g.transmissionSamplerMap.value=x.texture,g.transmissionSamplerSize.value.set(x.width,x.height),v.transmissionMap&&(g.transmissionMap.value=v.transmissionMap,i(v.transmissionMap,g.transmissionMapTransform)),g.thickness.value=v.thickness,v.thicknessMap&&(g.thicknessMap.value=v.thicknessMap,i(v.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=v.attenuationDistance,g.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(g.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(g.anisotropyMap.value=v.anisotropyMap,i(v.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=v.specularIntensity,g.specularColor.value.copy(v.specularColor),v.specularColorMap&&(g.specularColorMap.value=v.specularColorMap,i(v.specularColorMap,g.specularColorMapTransform)),v.specularIntensityMap&&(g.specularIntensityMap.value=v.specularIntensityMap,i(v.specularIntensityMap,g.specularIntensityMapTransform))}function f(g,v){v.matcap&&(g.matcap.value=v.matcap)}function m(g,v){let x=t.get(v).light;g.referencePosition.value.setFromMatrixPosition(x.matrixWorld),g.nearDistance.value=x.shadow.camera.near,g.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:a}}function x5(e,t,i,r){let a={},s={},n=[],o=i.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(x,b){let _=b.program;r.uniformBlockBinding(x,_)}function h(x,b){let _=a[x.id];_===void 0&&(f(x),_=c(x),a[x.id]=_,x.addEventListener("dispose",g));let M=b.program;r.updateUBOMapping(x,M);let A=t.render.frame;s[x.id]!==A&&(d(x),s[x.id]=A)}function c(x){let b=u();x.__bindingPointIndex=b;let _=e.createBuffer(),M=x.__size,A=x.usage;return e.bindBuffer(e.UNIFORM_BUFFER,_),e.bufferData(e.UNIFORM_BUFFER,M,A),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,b,_),_}function u(){for(let x=0;x<o;x++)if(n.indexOf(x)===-1)return n.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){let b=a[x.id],_=x.uniforms,M=x.__cache;e.bindBuffer(e.UNIFORM_BUFFER,b);for(let A=0,S=_.length;A<S;A++){let P=Array.isArray(_[A])?_[A]:[_[A]];for(let L=0,E=P.length;L<E;L++){let T=P[L];if(p(T,A,L,M)===!0){let B=T.__offset,V=Array.isArray(T.value)?T.value:[T.value],I=0;for(let H=0;H<V.length;H++){let q=V[H],X=m(q);typeof q=="number"||typeof q=="boolean"?(T.__data[0]=q,e.bufferSubData(e.UNIFORM_BUFFER,B+I,T.__data)):q.isMatrix3?(T.__data[0]=q.elements[0],T.__data[1]=q.elements[1],T.__data[2]=q.elements[2],T.__data[3]=0,T.__data[4]=q.elements[3],T.__data[5]=q.elements[4],T.__data[6]=q.elements[5],T.__data[7]=0,T.__data[8]=q.elements[6],T.__data[9]=q.elements[7],T.__data[10]=q.elements[8],T.__data[11]=0):(q.toArray(T.__data,I),I+=X.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,B,T.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}function p(x,b,_,M){let A=x.value,S=b+"_"+_;if(M[S]===void 0)return typeof A=="number"||typeof A=="boolean"?M[S]=A:M[S]=A.clone(),!0;{let P=M[S];if(typeof A=="number"||typeof A=="boolean"){if(P!==A)return M[S]=A,!0}else if(P.equals(A)===!1)return P.copy(A),!0}return!1}function f(x){let b=x.uniforms,_=0,M=16;for(let S=0,P=b.length;S<P;S++){let L=Array.isArray(b[S])?b[S]:[b[S]];for(let E=0,T=L.length;E<T;E++){let B=L[E],V=Array.isArray(B.value)?B.value:[B.value];for(let I=0,H=V.length;I<H;I++){let q=V[I],X=m(q),Y=_%M;Y!==0&&M-Y<X.boundary&&(_+=M-Y),B.__data=new Float32Array(X.storage/Float32Array.BYTES_PER_ELEMENT),B.__offset=_,_+=X.storage}}}let A=_%M;return A>0&&(_+=M-A),x.__size=_,x.__cache={},this}function m(x){let b={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(b.boundary=4,b.storage=4):x.isVector2?(b.boundary=8,b.storage=8):x.isVector3||x.isColor?(b.boundary=16,b.storage=12):x.isVector4?(b.boundary=16,b.storage=16):x.isMatrix3?(b.boundary=48,b.storage=48):x.isMatrix4?(b.boundary=64,b.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),b}function g(x){let b=x.target;b.removeEventListener("dispose",g);let _=n.indexOf(b.__bindingPointIndex);n.splice(_,1),e.deleteBuffer(a[b.id]),delete a[b.id],delete s[b.id]}function v(){for(let x in a)e.deleteBuffer(a[x]);n=[],a={},s={}}return{bind:l,update:h,dispose:v}}var kT=class{constructor(e={}){let{canvas:t=oU(),context:i=null,depth:r=!0,stencil:a=!0,alpha:s=!1,antialias:n=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:c=!1}=e;this.isWebGLRenderer=!0;let u;i!==null?u=i.getContextAttributes().alpha:u=s;let d=new Uint32Array(4),p=new Int32Array(4),f=null,m=null,g=[],v=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=wi,this._useLegacyLights=!1,this.toneMapping=bl,this.toneMappingExposure=1;let x=this,b=!1,_=0,M=0,A=null,S=-1,P=null,L=new Nt,E=new Nt,T=null,B=new _t(0),V=0,I=t.width,H=t.height,q=1,X=null,Y=null,ie=new Nt(0,0,I,H),ce=new Nt(0,0,I,H),de=!1,ue=new rb,re=!1,se=!1,he=null,_e=new je,Ee=new ae,fe=new O,Re={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Pe(){return A===null?q:1}let te=i;function We(Q,xe){for(let Ce=0;Ce<Q.length;Ce++){let De=Q[Ce],Ae=t.getContext(De,xe);if(Ae!==null)return Ae}return null}try{let Q={alpha:!0,depth:r,stencil:a,antialias:n,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:c};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Su}`),t.addEventListener("webglcontextlost",gi,!1),t.addEventListener("webglcontextrestored",Jt,!1),t.addEventListener("webglcontextcreationerror",pe,!1),te===null){let xe=["webgl2","webgl","experimental-webgl"];if(x.isWebGL1Renderer===!0&&xe.shift(),te=We(xe,Q),te===null)throw We(xe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&te instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),te.getShaderPrecisionFormat===void 0&&(te.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Q){throw console.error("THREE.WebGLRenderer: "+Q.message),Q}let Be,Ue,Ge,tt,Fe,He,nt,ht,Z,j,ye,Me,Je,z,qe,ct,ze,at,Qe,Ze,Zt,Ot,Pt,At;function bt(){Be=new Mz(te),Ue=new bz(te,Be,e),Be.init(Ue),Ot=new c5(te,Be,Ue),Ge=new l5(te,Be,Ue),tt=new Pz(te),Fe=new Qk,He=new h5(te,Be,Ge,Fe,Ue,Ot,tt),nt=new _z(x),ht=new Ez(x),Z=new BU(te,Ue),Pt=new yz(te,Be,Z,Ue),j=new Cz(te,Z,tt,Pt),ye=new Lz(te,j,Z,tt),Qe=new Oz(te,Ue,He),ct=new wz(Fe),Me=new Yk(x,nt,ht,Be,Ue,Pt,ct),Je=new y5(x,Fe),z=new Zk,qe=new r5(Be,Ue),at=new vz(x,nt,ht,Ge,ye,u,o),ze=new o5(x,ye,Ue),At=new x5(te,tt,Ue,Ge),Ze=new xz(te,Be,tt,Ue),Zt=new Tz(te,Be,tt,Ue),tt.programs=Me.programs,x.capabilities=Ue,x.extensions=Be,x.properties=Fe,x.renderLists=z,x.shadowMap=ze,x.state=Ge,x.info=tt}bt();let mt=new g5(x,te);this.xr=mt,this.getContext=function(){return te},this.getContextAttributes=function(){return te.getContextAttributes()},this.forceContextLoss=function(){let Q=Be.get("WEBGL_lose_context");Q&&Q.loseContext()},this.forceContextRestore=function(){let Q=Be.get("WEBGL_lose_context");Q&&Q.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(Q){Q!==void 0&&(q=Q,this.setSize(I,H,!1))},this.getSize=function(Q){return Q.set(I,H)},this.setSize=function(Q,xe,Ce=!0){if(mt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}I=Q,H=xe,t.width=Math.floor(Q*q),t.height=Math.floor(xe*q),Ce===!0&&(t.style.width=Q+"px",t.style.height=xe+"px"),this.setViewport(0,0,Q,xe)},this.getDrawingBufferSize=function(Q){return Q.set(I*q,H*q).floor()},this.setDrawingBufferSize=function(Q,xe,Ce){I=Q,H=xe,q=Ce,t.width=Math.floor(Q*Ce),t.height=Math.floor(xe*Ce),this.setViewport(0,0,Q,xe)},this.getCurrentViewport=function(Q){return Q.copy(L)},this.getViewport=function(Q){return Q.copy(ie)},this.setViewport=function(Q,xe,Ce,De){Q.isVector4?ie.set(Q.x,Q.y,Q.z,Q.w):ie.set(Q,xe,Ce,De),Ge.viewport(L.copy(ie).multiplyScalar(q).round())},this.getScissor=function(Q){return Q.copy(ce)},this.setScissor=function(Q,xe,Ce,De){Q.isVector4?ce.set(Q.x,Q.y,Q.z,Q.w):ce.set(Q,xe,Ce,De),Ge.scissor(E.copy(ce).multiplyScalar(q).round())},this.getScissorTest=function(){return de},this.setScissorTest=function(Q){Ge.setScissorTest(de=Q)},this.setOpaqueSort=function(Q){X=Q},this.setTransparentSort=function(Q){Y=Q},this.getClearColor=function(Q){return Q.copy(at.getClearColor())},this.setClearColor=function(){at.setClearColor.apply(at,arguments)},this.getClearAlpha=function(){return at.getClearAlpha()},this.setClearAlpha=function(){at.setClearAlpha.apply(at,arguments)},this.clear=function(Q=!0,xe=!0,Ce=!0){let De=0;if(Q){let Ae=!1;if(A!==null){let it=A.texture.format;Ae=it===Kx||it===xT||it===yT}if(Ae){let it=A.texture.type,Mt=it===la||it===En||it===Qx||it===wl||it===mT||it===gT,yt=at.getClearColor(),Et=at.getClearAlpha(),$t=yt.r,wt=yt.g,jt=yt.b;Mt?(d[0]=$t,d[1]=wt,d[2]=jt,d[3]=Et,te.clearBufferuiv(te.COLOR,0,d)):(p[0]=$t,p[1]=wt,p[2]=jt,p[3]=Et,te.clearBufferiv(te.COLOR,0,p))}else De|=te.COLOR_BUFFER_BIT}xe&&(De|=te.DEPTH_BUFFER_BIT),Ce&&(De|=te.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),te.clear(De)},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",gi,!1),t.removeEventListener("webglcontextrestored",Jt,!1),t.removeEventListener("webglcontextcreationerror",pe,!1),z.dispose(),qe.dispose(),Fe.dispose(),nt.dispose(),ht.dispose(),ye.dispose(),Pt.dispose(),At.dispose(),Me.dispose(),mt.dispose(),mt.removeEventListener("sessionstart",Zi),mt.removeEventListener("sessionend",_r),he&&(he.dispose(),he=null),oi.stop()};function gi(Q){Q.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function Jt(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;let Q=tt.autoReset,xe=ze.enabled,Ce=ze.autoUpdate,De=ze.needsUpdate,Ae=ze.type;bt(),tt.autoReset=Q,ze.enabled=xe,ze.autoUpdate=Ce,ze.needsUpdate=De,ze.type=Ae}function pe(Q){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Q.statusMessage)}function et(Q){let xe=Q.target;xe.removeEventListener("dispose",et),Se(xe)}function Se(Q){Ke(Q),Fe.remove(Q)}function Ke(Q){let xe=Fe.get(Q).programs;xe!==void 0&&(xe.forEach(function(Ce){Me.releaseProgram(Ce)}),Q.isShaderMaterial&&Me.releaseShaderCache(Q))}this.renderBufferDirect=function(Q,xe,Ce,De,Ae,it){xe===null&&(xe=Re);let Mt=Ae.isMesh&&Ae.matrixWorld.determinant()<0,yt=qu(Q,xe,Ce,De,Ae);Ge.setMaterial(De,Mt);let Et=Ce.index,$t=1;if(De.wireframe===!0){if(Et=j.getWireframeAttribute(Ce),Et===void 0)return;$t=2}let wt=Ce.drawRange,jt=Ce.attributes.position,Gi=wt.start*$t,Xi=(wt.start+wt.count)*$t;it!==null&&(Gi=Math.max(Gi,it.start*$t),Xi=Math.min(Xi,(it.start+it.count)*$t)),Et!==null?(Gi=Math.max(Gi,0),Xi=Math.min(Xi,Et.count)):jt!=null&&(Gi=Math.max(Gi,0),Xi=Math.min(Xi,jt.count));let Ft=Xi-Gi;if(Ft<0||Ft===1/0)return;Pt.setup(Ae,De,yt,Ce,Et);let Yi,Ni=Ze;if(Et!==null&&(Yi=Z.get(Et),Ni=Zt,Ni.setIndex(Yi)),Ae.isMesh)De.wireframe===!0?(Ge.setLineWidth(De.wireframeLinewidth*Pe()),Ni.setMode(te.LINES)):Ni.setMode(te.TRIANGLES);else if(Ae.isLine){let Qt=De.linewidth;Qt===void 0&&(Qt=1),Ge.setLineWidth(Qt*Pe()),Ae.isLineSegments?Ni.setMode(te.LINES):Ae.isLineLoop?Ni.setMode(te.LINE_LOOP):Ni.setMode(te.LINE_STRIP)}else Ae.isPoints?Ni.setMode(te.POINTS):Ae.isSprite&&Ni.setMode(te.TRIANGLES);if(Ae.isBatchedMesh)Ni.renderMultiDraw(Ae._multiDrawStarts,Ae._multiDrawCounts,Ae._multiDrawCount);else if(Ae.isInstancedMesh)Ni.renderInstances(Gi,Ft,Ae.count);else if(Ce.isInstancedBufferGeometry){let Qt=Ce._maxInstanceCount!==void 0?Ce._maxInstanceCount:1/0,Bo=Math.min(Ce.instanceCount,Qt);Ni.renderInstances(Gi,Ft,Bo)}else Ni.render(Gi,Ft)};function rt(Q,xe,Ce){Q.transparent===!0&&Q.side===Oa&&Q.forceSinglePass===!1?(Q.side=Fr,Q.needsUpdate=!0,Vn(Q,xe,Ce),Q.side=Qs,Q.needsUpdate=!0,Vn(Q,xe,Ce),Q.side=Oa):Vn(Q,xe,Ce)}this.compile=function(Q,xe,Ce=null){Ce===null&&(Ce=Q),m=qe.get(Ce),m.init(),v.push(m),Ce.traverseVisible(function(Ae){Ae.isLight&&Ae.layers.test(xe.layers)&&(m.pushLight(Ae),Ae.castShadow&&m.pushShadow(Ae))}),Q!==Ce&&Q.traverseVisible(function(Ae){Ae.isLight&&Ae.layers.test(xe.layers)&&(m.pushLight(Ae),Ae.castShadow&&m.pushShadow(Ae))}),m.setupLights(x._useLegacyLights);let De=new Set;return Q.traverse(function(Ae){let it=Ae.material;if(it)if(Array.isArray(it))for(let Mt=0;Mt<it.length;Mt++){let yt=it[Mt];rt(yt,Ce,Ae),De.add(yt)}else rt(it,Ce,Ae),De.add(it)}),v.pop(),m=null,De},this.compileAsync=function(Q,xe,Ce=null){let De=this.compile(Q,xe,Ce);return new Promise(Ae=>{function it(){if(De.forEach(function(Mt){Fe.get(Mt).currentProgram.isReady()&&De.delete(Mt)}),De.size===0){Ae(Q);return}setTimeout(it,10)}Be.get("KHR_parallel_shader_compile")!==null?it():setTimeout(it,10)})};let ni=null;function hi(Q){ni&&ni(Q)}function Zi(){oi.stop()}function _r(){oi.start()}let oi=new LT;oi.setAnimationLoop(hi),typeof self<"u"&&oi.setContext(self),this.setAnimationLoop=function(Q){ni=Q,mt.setAnimationLoop(Q),Q===null?oi.stop():oi.start()},mt.addEventListener("sessionstart",Zi),mt.addEventListener("sessionend",_r),this.render=function(Q,xe){if(xe!==void 0&&xe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;Q.matrixWorldAutoUpdate===!0&&Q.updateMatrixWorld(),xe.parent===null&&xe.matrixWorldAutoUpdate===!0&&xe.updateMatrixWorld(),mt.enabled===!0&&mt.isPresenting===!0&&(mt.cameraAutoUpdate===!0&&mt.updateCamera(xe),xe=mt.getCamera()),Q.isScene===!0&&Q.onBeforeRender(x,Q,xe,A),m=qe.get(Q,v.length),m.init(),v.push(m),_e.multiplyMatrices(xe.projectionMatrix,xe.matrixWorldInverse),ue.setFromProjectionMatrix(_e),se=this.localClippingEnabled,re=ct.init(this.clippingPlanes,se),f=z.get(Q,g.length),f.init(),g.push(f),da(Q,xe,0,x.sortObjects),f.finish(),x.sortObjects===!0&&f.sort(X,Y),this.info.render.frame++,re===!0&&ct.beginShadows();let Ce=m.state.shadowsArray;if(ze.render(Ce,Q,xe),re===!0&&ct.endShadows(),this.info.autoReset===!0&&this.info.reset(),(mt.enabled===!1||mt.isPresenting===!1||mt.hasDepthSensing()===!1)&&at.render(f,Q),m.setupLights(x._useLegacyLights),xe.isArrayCamera){let De=xe.cameras;for(let Ae=0,it=De.length;Ae<it;Ae++){let Mt=De[Ae];Va(f,Q,Mt,Mt.viewport)}}else Va(f,Q,xe);A!==null&&(He.updateMultisampleRenderTarget(A),He.updateRenderTargetMipmap(A)),Q.isScene===!0&&Q.onAfterRender(x,Q,xe),Pt.resetDefaultState(),S=-1,P=null,v.pop(),v.length>0?m=v[v.length-1]:m=null,g.pop(),g.length>0?f=g[g.length-1]:f=null};function da(Q,xe,Ce,De){if(Q.visible===!1)return;if(Q.layers.test(xe.layers)){if(Q.isGroup)Ce=Q.renderOrder;else if(Q.isLOD)Q.autoUpdate===!0&&Q.update(xe);else if(Q.isLight)m.pushLight(Q),Q.castShadow&&m.pushShadow(Q);else if(Q.isSprite){if(!Q.frustumCulled||ue.intersectsSprite(Q)){De&&fe.setFromMatrixPosition(Q.matrixWorld).applyMatrix4(_e);let it=ye.update(Q),Mt=Q.material;Mt.visible&&f.push(Q,it,Mt,Ce,fe.z,null)}}else if((Q.isMesh||Q.isLine||Q.isPoints)&&(!Q.frustumCulled||ue.intersectsObject(Q))){let it=ye.update(Q),Mt=Q.material;if(De&&(Q.boundingSphere!==void 0?(Q.boundingSphere===null&&Q.computeBoundingSphere(),fe.copy(Q.boundingSphere.center)):(it.boundingSphere===null&&it.computeBoundingSphere(),fe.copy(it.boundingSphere.center)),fe.applyMatrix4(Q.matrixWorld).applyMatrix4(_e)),Array.isArray(Mt)){let yt=it.groups;for(let Et=0,$t=yt.length;Et<$t;Et++){let wt=yt[Et],jt=Mt[wt.materialIndex];jt&&jt.visible&&f.push(Q,it,jt,Ce,fe.z,wt)}}else Mt.visible&&f.push(Q,it,Mt,Ce,fe.z,null)}}let Ae=Q.children;for(let it=0,Mt=Ae.length;it<Mt;it++)da(Ae[it],xe,Ce,De)}function Va(Q,xe,Ce,De){let Ae=Q.opaque,it=Q.transmissive,Mt=Q.transparent;m.setupLightsView(Ce),re===!0&&ct.setGlobalState(x.clippingPlanes,Ce),it.length>0&&Il(Ae,it,xe,Ce),De&&Ge.viewport(L.copy(De)),Ae.length>0&&kn(Ae,xe,Ce),it.length>0&&kn(it,xe,Ce),Mt.length>0&&kn(Mt,xe,Ce),Ge.buffers.depth.setTest(!0),Ge.buffers.depth.setMask(!0),Ge.buffers.color.setMask(!0),Ge.setPolygonOffset(!1)}function Il(Q,xe,Ce,De){if((Ce.isScene===!0?Ce.overrideMaterial:null)!==null)return;let Ae=Ue.isWebGL2;he===null&&(he=new _i(1,1,{generateMipmaps:!0,type:Be.has("EXT_color_buffer_half_float")?_h:la,minFilter:cl,samples:Ae?4:0})),x.getDrawingBufferSize(Ee),Ae?he.setSize(Ee.x,Ee.y):he.setSize(Km(Ee.x),Km(Ee.y));let it=x.getRenderTarget();x.setRenderTarget(he),x.getClearColor(B),V=x.getClearAlpha(),V<1&&x.setClearColor(16777215,.5),x.clear();let Mt=x.toneMapping;x.toneMapping=bl,kn(Q,Ce,De),He.updateMultisampleRenderTarget(he),He.updateRenderTargetMipmap(he);let yt=!1;for(let Et=0,$t=xe.length;Et<$t;Et++){let wt=xe[Et],jt=wt.object,Gi=wt.geometry,Xi=wt.material,Ft=wt.group;if(Xi.side===Oa&&jt.layers.test(De.layers)){let Yi=Xi.side;Xi.side=Fr,Xi.needsUpdate=!0,Vh(jt,Ce,De,Gi,Xi,Ft),Xi.side=Yi,Xi.needsUpdate=!0,yt=!0}}yt===!0&&(He.updateMultisampleRenderTarget(he),He.updateRenderTargetMipmap(he)),x.setRenderTarget(it),x.setClearColor(B,V),x.toneMapping=Mt}function kn(Q,xe,Ce){let De=xe.isScene===!0?xe.overrideMaterial:null;for(let Ae=0,it=Q.length;Ae<it;Ae++){let Mt=Q[Ae],yt=Mt.object,Et=Mt.geometry,$t=De===null?Mt.material:De,wt=Mt.group;yt.layers.test(Ce.layers)&&Vh(yt,xe,Ce,Et,$t,wt)}}function Vh(Q,xe,Ce,De,Ae,it){Q.onBeforeRender(x,xe,Ce,De,Ae,it),Q.modelViewMatrix.multiplyMatrices(Ce.matrixWorldInverse,Q.matrixWorld),Q.normalMatrix.getNormalMatrix(Q.modelViewMatrix),Ae.onBeforeRender(x,xe,Ce,De,Q,it),Ae.transparent===!0&&Ae.side===Oa&&Ae.forceSinglePass===!1?(Ae.side=Fr,Ae.needsUpdate=!0,x.renderBufferDirect(Ce,xe,De,Ae,Q,it),Ae.side=Qs,Ae.needsUpdate=!0,x.renderBufferDirect(Ce,xe,De,Ae,Q,it),Ae.side=Oa):x.renderBufferDirect(Ce,xe,De,Ae,Q,it),Q.onAfterRender(x,xe,Ce,De,Ae,it)}function Vn(Q,xe,Ce){xe.isScene!==!0&&(xe=Re);let De=Fe.get(Q),Ae=m.state.lights,it=m.state.shadowsArray,Mt=Ae.state.version,yt=Me.getParameters(Q,Ae.state,it,xe,Ce),Et=Me.getProgramCacheKey(yt),$t=De.programs;De.environment=Q.isMeshStandardMaterial?xe.environment:null,De.fog=xe.fog,De.envMap=(Q.isMeshStandardMaterial?ht:nt).get(Q.envMap||De.environment),De.envMapRotation=De.environment!==null&&Q.envMap===null?xe.environmentRotation:Q.envMapRotation,$t===void 0&&(Q.addEventListener("dispose",et),$t=new Map,De.programs=$t);let wt=$t.get(Et);if(wt!==void 0){if(De.currentProgram===wt&&De.lightsStateVersion===Mt)return Bl(Q,yt),wt}else yt.uniforms=Me.getUniforms(Q),Q.onBuild(Ce,yt,x),Q.onBeforeCompile(yt,x),wt=Me.acquireProgram(yt,Et),$t.set(Et,wt),De.uniforms=yt.uniforms;let jt=De.uniforms;return(!Q.isShaderMaterial&&!Q.isRawShaderMaterial||Q.clipping===!0)&&(jt.clippingPlanes=ct.uniform),Bl(Q,yt),De.needsLights=jh(Q),De.lightsStateVersion=Mt,De.needsLights&&(jt.ambientLightColor.value=Ae.state.ambient,jt.lightProbe.value=Ae.state.probe,jt.directionalLights.value=Ae.state.directional,jt.directionalLightShadows.value=Ae.state.directionalShadow,jt.spotLights.value=Ae.state.spot,jt.spotLightShadows.value=Ae.state.spotShadow,jt.rectAreaLights.value=Ae.state.rectArea,jt.ltc_1.value=Ae.state.rectAreaLTC1,jt.ltc_2.value=Ae.state.rectAreaLTC2,jt.pointLights.value=Ae.state.point,jt.pointLightShadows.value=Ae.state.pointShadow,jt.hemisphereLights.value=Ae.state.hemi,jt.directionalShadowMap.value=Ae.state.directionalShadowMap,jt.directionalShadowMatrix.value=Ae.state.directionalShadowMatrix,jt.spotShadowMap.value=Ae.state.spotShadowMap,jt.spotLightMatrix.value=Ae.state.spotLightMatrix,jt.spotLightMap.value=Ae.state.spotLightMap,jt.pointShadowMap.value=Ae.state.pointShadowMap,jt.pointShadowMatrix.value=Ae.state.pointShadowMatrix),De.currentProgram=wt,De.uniformsList=null,wt}function Aa(Q){if(Q.uniformsList===null){let xe=Q.currentProgram.getUniforms();Q.uniformsList=Mm.seqWithValue(xe.seq,Q.uniforms)}return Q.uniformsList}function Bl(Q,xe){let Ce=Fe.get(Q);Ce.outputColorSpace=xe.outputColorSpace,Ce.batching=xe.batching,Ce.instancing=xe.instancing,Ce.instancingColor=xe.instancingColor,Ce.instancingMorph=xe.instancingMorph,Ce.skinning=xe.skinning,Ce.morphTargets=xe.morphTargets,Ce.morphNormals=xe.morphNormals,Ce.morphColors=xe.morphColors,Ce.morphTargetsCount=xe.morphTargetsCount,Ce.numClippingPlanes=xe.numClippingPlanes,Ce.numIntersection=xe.numClipIntersection,Ce.vertexAlphas=xe.vertexAlphas,Ce.vertexTangents=xe.vertexTangents,Ce.toneMapping=xe.toneMapping}function qu(Q,xe,Ce,De,Ae){xe.isScene!==!0&&(xe=Re),He.resetTextureUnits();let it=xe.fog,Mt=De.isMeshStandardMaterial?xe.environment:null,yt=A===null?x.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:Cs,Et=(De.isMeshStandardMaterial?ht:nt).get(De.envMap||Mt),$t=De.vertexColors===!0&&!!Ce.attributes.color&&Ce.attributes.color.itemSize===4,wt=!!Ce.attributes.tangent&&(!!De.normalMap||De.anisotropy>0),jt=!!Ce.morphAttributes.position,Gi=!!Ce.morphAttributes.normal,Xi=!!Ce.morphAttributes.color,Ft=bl;De.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(Ft=x.toneMapping);let Yi=Ce.morphAttributes.position||Ce.morphAttributes.normal||Ce.morphAttributes.color,Ni=Yi!==void 0?Yi.length:0,Qt=Fe.get(De),Bo=m.state.lights;if(re===!0&&(se===!0||Q!==P)){let G=Q===P&&De.id===S;ct.setState(De,Q,G)}let jn=!1;De.version===Qt.__version?(Qt.needsLights&&Qt.lightsStateVersion!==Bo.state.version||Qt.outputColorSpace!==yt||Ae.isBatchedMesh&&Qt.batching===!1||!Ae.isBatchedMesh&&Qt.batching===!0||Ae.isInstancedMesh&&Qt.instancing===!1||!Ae.isInstancedMesh&&Qt.instancing===!0||Ae.isSkinnedMesh&&Qt.skinning===!1||!Ae.isSkinnedMesh&&Qt.skinning===!0||Ae.isInstancedMesh&&Qt.instancingColor===!0&&Ae.instanceColor===null||Ae.isInstancedMesh&&Qt.instancingColor===!1&&Ae.instanceColor!==null||Ae.isInstancedMesh&&Qt.instancingMorph===!0&&Ae.morphTexture===null||Ae.isInstancedMesh&&Qt.instancingMorph===!1&&Ae.morphTexture!==null||Qt.envMap!==Et||De.fog===!0&&Qt.fog!==it||Qt.numClippingPlanes!==void 0&&(Qt.numClippingPlanes!==ct.numPlanes||Qt.numIntersection!==ct.numIntersection)||Qt.vertexAlphas!==$t||Qt.vertexTangents!==wt||Qt.morphTargets!==jt||Qt.morphNormals!==Gi||Qt.morphColors!==Xi||Qt.toneMapping!==Ft||Ue.isWebGL2===!0&&Qt.morphTargetsCount!==Ni)&&(jn=!0):(jn=!0,Qt.__version=De.version);let ia=Qt.currentProgram;jn===!0&&(ia=Vn(De,xe,Ae));let ii=!1,Gn=!1,tn=!1,zi=ia.getUniforms(),Dr=Qt.uniforms;if(Ge.useProgram(ia.program)&&(ii=!0,Gn=!0,tn=!0),De.id!==S&&(S=De.id,Gn=!0),ii||P!==Q){zi.setValue(te,"projectionMatrix",Q.projectionMatrix),zi.setValue(te,"viewMatrix",Q.matrixWorldInverse);let G=zi.map.cameraPosition;G!==void 0&&G.setValue(te,fe.setFromMatrixPosition(Q.matrixWorld)),Ue.logarithmicDepthBuffer&&zi.setValue(te,"logDepthBufFC",2/(Math.log(Q.far+1)/Math.LN2)),(De.isMeshPhongMaterial||De.isMeshToonMaterial||De.isMeshLambertMaterial||De.isMeshBasicMaterial||De.isMeshStandardMaterial||De.isShaderMaterial)&&zi.setValue(te,"isOrthographic",Q.isOrthographicCamera===!0),P!==Q&&(P=Q,Gn=!0,tn=!0)}if(Ae.isSkinnedMesh){zi.setOptional(te,Ae,"bindMatrix"),zi.setOptional(te,Ae,"bindMatrixInverse");let G=Ae.skeleton;G&&(Ue.floatVertexTextures?(G.boneTexture===null&&G.computeBoneTexture(),zi.setValue(te,"boneTexture",G.boneTexture,He)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Ae.isBatchedMesh&&(zi.setOptional(te,Ae,"batchingTexture"),zi.setValue(te,"batchingTexture",Ae._matricesTexture,He));let F=Ce.morphAttributes;if((F.position!==void 0||F.normal!==void 0||F.color!==void 0&&Ue.isWebGL2===!0)&&Qe.update(Ae,Ce,ia),(Gn||Qt.receiveShadow!==Ae.receiveShadow)&&(Qt.receiveShadow=Ae.receiveShadow,zi.setValue(te,"receiveShadow",Ae.receiveShadow)),De.isMeshGouraudMaterial&&De.envMap!==null&&(Dr.envMap.value=Et,Dr.flipEnvMap.value=Et.isCubeTexture&&Et.isRenderTargetTexture===!1?-1:1),Gn&&(zi.setValue(te,"toneMappingExposure",x.toneMappingExposure),Qt.needsLights&&nr(Dr,tn),it&&De.fog===!0&&Je.refreshFogUniforms(Dr,it),Je.refreshMaterialUniforms(Dr,De,q,H,he),Mm.upload(te,Aa(Qt),Dr,He)),De.isShaderMaterial&&De.uniformsNeedUpdate===!0&&(Mm.upload(te,Aa(Qt),Dr,He),De.uniformsNeedUpdate=!1),De.isSpriteMaterial&&zi.setValue(te,"center",Ae.center),zi.setValue(te,"modelViewMatrix",Ae.modelViewMatrix),zi.setValue(te,"normalMatrix",Ae.normalMatrix),zi.setValue(te,"modelMatrix",Ae.matrixWorld),Ae.previousModelViewMatrix&&zi.setValue(te,"previousModelViewMatrix",Ae.previousModelViewMatrix),Q.previousProjectionMatrix&&zi.setValue(te,"previousProjectionMatrix",Q.previousProjectionMatrix),De.isShaderMaterial||De.isRawShaderMaterial){let G=De.uniformsGroups;for(let oe=0,K=G.length;oe<K;oe++)if(Ue.isWebGL2){let ve=G[oe];At.update(ve,ia),At.bind(ve,ia)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return ia}function nr(Q,xe){Q.ambientLightColor.needsUpdate=xe,Q.lightProbe.needsUpdate=xe,Q.directionalLights.needsUpdate=xe,Q.directionalLightShadows.needsUpdate=xe,Q.pointLights.needsUpdate=xe,Q.pointLightShadows.needsUpdate=xe,Q.spotLights.needsUpdate=xe,Q.spotLightShadows.needsUpdate=xe,Q.rectAreaLights.needsUpdate=xe,Q.hemisphereLights.needsUpdate=xe}function jh(Q){return Q.isMeshLambertMaterial||Q.isMeshToonMaterial||Q.isMeshPhongMaterial||Q.isMeshStandardMaterial||Q.isShadowMaterial||Q.isShaderMaterial&&Q.lights===!0}this.getActiveCubeFace=function(){return _},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(Q,xe,Ce){Fe.get(Q.texture).__webglTexture=xe,Fe.get(Q.depthTexture).__webglTexture=Ce;let De=Fe.get(Q);De.__hasExternalTextures=!0,De.__autoAllocateDepthBuffer=Ce===void 0,De.__autoAllocateDepthBuffer||Be.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),De.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(Q,xe){let Ce=Fe.get(Q);Ce.__webglFramebuffer=xe,Ce.__useDefaultFramebuffer=xe===void 0},this.setRenderTarget=function(Q,xe=0,Ce=0){A=Q,_=xe,M=Ce;let De=!0,Ae=null,it=!1,Mt=!1;if(Q){let yt=Fe.get(Q);yt.__useDefaultFramebuffer!==void 0?(Ge.bindFramebuffer(te.FRAMEBUFFER,null),De=!1):yt.__webglFramebuffer===void 0?He.setupRenderTarget(Q):yt.__hasExternalTextures&&He.rebindTextures(Q,Fe.get(Q.texture).__webglTexture,Fe.get(Q.depthTexture).__webglTexture);let Et=Q.texture;(Et.isData3DTexture||Et.isDataArrayTexture||Et.isCompressedArrayTexture)&&(Mt=!0);let $t=Fe.get(Q).__webglFramebuffer;Q.isWebGLCubeRenderTarget?(Array.isArray($t[xe])?Ae=$t[xe][Ce]:Ae=$t[xe],it=!0):Ue.isWebGL2&&Q.samples>0&&He.useMultisampledRTT(Q)===!1?Ae=Fe.get(Q).__webglMultisampledFramebuffer:Array.isArray($t)?Ae=$t[Ce]:Ae=$t,L.copy(Q.viewport),E.copy(Q.scissor),T=Q.scissorTest}else L.copy(ie).multiplyScalar(q).floor(),E.copy(ce).multiplyScalar(q).floor(),T=de;if(Ge.bindFramebuffer(te.FRAMEBUFFER,Ae)&&Ue.drawBuffers&&De&&Ge.drawBuffers(Q,Ae),Ge.viewport(L),Ge.scissor(E),Ge.setScissorTest(T),it){let yt=Fe.get(Q.texture);te.framebufferTexture2D(te.FRAMEBUFFER,te.COLOR_ATTACHMENT0,te.TEXTURE_CUBE_MAP_POSITIVE_X+xe,yt.__webglTexture,Ce)}else if(Mt){let yt=Fe.get(Q.texture),Et=xe||0;te.framebufferTextureLayer(te.FRAMEBUFFER,te.COLOR_ATTACHMENT0,yt.__webglTexture,Ce||0,Et)}S=-1},this.readRenderTargetPixels=function(Q,xe,Ce,De,Ae,it,Mt){if(!(Q&&Q.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let yt=Fe.get(Q).__webglFramebuffer;if(Q.isWebGLCubeRenderTarget&&Mt!==void 0&&(yt=yt[Mt]),yt){Ge.bindFramebuffer(te.FRAMEBUFFER,yt);try{let Et=Q.texture,$t=Et.format,wt=Et.type;if($t!==Qr&&Ot.convert($t)!==te.getParameter(te.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let jt=wt===_h&&(Be.has("EXT_color_buffer_half_float")||Ue.isWebGL2&&Be.has("EXT_color_buffer_float"));if(wt!==la&&Ot.convert(wt)!==te.getParameter(te.IMPLEMENTATION_COLOR_READ_TYPE)&&!(wt===ir&&(Ue.isWebGL2||Be.has("OES_texture_float")||Be.has("WEBGL_color_buffer_float")))&&!jt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}xe>=0&&xe<=Q.width-De&&Ce>=0&&Ce<=Q.height-Ae&&te.readPixels(xe,Ce,De,Ae,Ot.convert($t),Ot.convert(wt),it)}finally{let Et=A!==null?Fe.get(A).__webglFramebuffer:null;Ge.bindFramebuffer(te.FRAMEBUFFER,Et)}}},this.copyFramebufferToTexture=function(Q,xe,Ce=0){let De=Math.pow(2,-Ce),Ae=Math.floor(xe.image.width*De),it=Math.floor(xe.image.height*De);He.setTexture2D(xe,0),te.copyTexSubImage2D(te.TEXTURE_2D,Ce,0,0,Q.x,Q.y,Ae,it),Ge.unbindTexture()},this.copyTextureToTexture=function(Q,xe,Ce,De=0){let Ae=xe.image.width,it=xe.image.height,Mt=Ot.convert(Ce.format),yt=Ot.convert(Ce.type);He.setTexture2D(Ce,0),te.pixelStorei(te.UNPACK_FLIP_Y_WEBGL,Ce.flipY),te.pixelStorei(te.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ce.premultiplyAlpha),te.pixelStorei(te.UNPACK_ALIGNMENT,Ce.unpackAlignment),xe.isDataTexture?te.texSubImage2D(te.TEXTURE_2D,De,Q.x,Q.y,Ae,it,Mt,yt,xe.image.data):xe.isCompressedTexture?te.compressedTexSubImage2D(te.TEXTURE_2D,De,Q.x,Q.y,xe.mipmaps[0].width,xe.mipmaps[0].height,Mt,xe.mipmaps[0].data):te.texSubImage2D(te.TEXTURE_2D,De,Q.x,Q.y,Mt,yt,xe.image),De===0&&Ce.generateMipmaps&&te.generateMipmap(te.TEXTURE_2D),Ge.unbindTexture()},this.copyTextureToTexture3D=function(Q,xe,Ce,De,Ae=0){if(x.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let it=Math.round(Q.max.x-Q.min.x),Mt=Math.round(Q.max.y-Q.min.y),yt=Q.max.z-Q.min.z+1,Et=Ot.convert(De.format),$t=Ot.convert(De.type),wt;if(De.isData3DTexture)He.setTexture3D(De,0),wt=te.TEXTURE_3D;else if(De.isDataArrayTexture||De.isCompressedArrayTexture)He.setTexture2DArray(De,0),wt=te.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}te.pixelStorei(te.UNPACK_FLIP_Y_WEBGL,De.flipY),te.pixelStorei(te.UNPACK_PREMULTIPLY_ALPHA_WEBGL,De.premultiplyAlpha),te.pixelStorei(te.UNPACK_ALIGNMENT,De.unpackAlignment);let jt=te.getParameter(te.UNPACK_ROW_LENGTH),Gi=te.getParameter(te.UNPACK_IMAGE_HEIGHT),Xi=te.getParameter(te.UNPACK_SKIP_PIXELS),Ft=te.getParameter(te.UNPACK_SKIP_ROWS),Yi=te.getParameter(te.UNPACK_SKIP_IMAGES),Ni=Ce.isCompressedTexture?Ce.mipmaps[Ae]:Ce.image;te.pixelStorei(te.UNPACK_ROW_LENGTH,Ni.width),te.pixelStorei(te.UNPACK_IMAGE_HEIGHT,Ni.height),te.pixelStorei(te.UNPACK_SKIP_PIXELS,Q.min.x),te.pixelStorei(te.UNPACK_SKIP_ROWS,Q.min.y),te.pixelStorei(te.UNPACK_SKIP_IMAGES,Q.min.z),Ce.isDataTexture||Ce.isData3DTexture?te.texSubImage3D(wt,Ae,xe.x,xe.y,xe.z,it,Mt,yt,Et,$t,Ni.data):De.isCompressedArrayTexture?te.compressedTexSubImage3D(wt,Ae,xe.x,xe.y,xe.z,it,Mt,yt,Et,Ni.data):te.texSubImage3D(wt,Ae,xe.x,xe.y,xe.z,it,Mt,yt,Et,$t,Ni),te.pixelStorei(te.UNPACK_ROW_LENGTH,jt),te.pixelStorei(te.UNPACK_IMAGE_HEIGHT,Gi),te.pixelStorei(te.UNPACK_SKIP_PIXELS,Xi),te.pixelStorei(te.UNPACK_SKIP_ROWS,Ft),te.pixelStorei(te.UNPACK_SKIP_IMAGES,Yi),Ae===0&&De.generateMipmaps&&te.generateMipmap(wt),Ge.unbindTexture()},this.initTexture=function(Q){Q.isCubeTexture?He.setTextureCube(Q,0):Q.isData3DTexture?He.setTexture3D(Q,0):Q.isDataArrayTexture||Q.isCompressedArrayTexture?He.setTexture2DArray(Q,0):He.setTexture2D(Q,0),Ge.unbindTexture()},this.resetState=function(){_=0,M=0,A=null,Ge.reset(),Pt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return bo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===$x?"display-p3":"srgb",t.unpackColorSpace=Di.workingColorSpace===Yg?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}},b5=class extends kT{};b5.prototype.isWebGL1Renderer=!0;var VT=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new _t(e),this.near=t,this.far=i}clone(){return new VT(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},So=class extends Mi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Qi,this.environmentRotation=new Qi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentRotation=this.environmentRotation.toArray(),t}},w5=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=$y,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=As()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return MT("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,a=this.stride;r<a;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=As()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=As()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ca=new O,r1=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ca.fromBufferAttribute(this,t),Ca.applyMatrix4(e),this.setXYZ(t,Ca.x,Ca.y,Ca.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ca.fromBufferAttribute(this,t),Ca.applyNormalMatrix(e),this.setXYZ(t,Ca.x,Ca.y,Ca.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ca.fromBufferAttribute(this,t),Ca.transformDirection(e),this.setXYZ(t,Ca.x,Ca.y,Ca.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Gs(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Pi(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=Pi(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Pi(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Pi(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Pi(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Gs(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Gs(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Gs(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Gs(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array),r=Pi(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,a){return e=e*this.data.stride+this.offset,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array),r=Pi(r,this.array),a=Pi(a,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=a,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[r+a])}return new Ut(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new r1(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[r+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},jT=class extends Mi{constructor(){super(),this.isBone=!0,this.type="Bone"}},is=class extends Ki{constructor(e=null,t=1,i=1,r,a,s,n,o,l=bi,h=bi,c,u){super(null,s,n,o,l,h,r,a,c,u),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},b2=new je,_5=new je,nb=class{constructor(e=[],t=[]){this.uuid=As(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new je)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new je;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let a=0,s=e.length;a<s;a++){let n=e[a]?e[a].matrixWorld:_5;b2.multiplyMatrices(n,t[a]),b2.toArray(i,a*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new nb(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new is(t,e,e,Qr,ir);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let a=e.bones[i],s=t[a];s===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",a),s=new jT),this.bones.push(s),this.boneInverses.push(new je().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,a=t.length;r<a;r++){let s=t[r];e.bones.push(s.uuid);let n=i[r];e.boneInverses.push(n.toArray())}return e}},Jd=class extends Ut{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},pc=new je,w2=new je,_f=[],_2=new sr,S5=new je,nd=new xr,od=new Sa,A5=class extends xr{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Jd(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,S5)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new sr),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,pc),_2.copy(e.boundingBox).applyMatrix4(pc),this.boundingBox.union(_2)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Sa),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,pc),od.copy(e.boundingSphere).applyMatrix4(pc),this.boundingSphere.union(od)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,a=i.length+1,s=e*a+1;for(let n=0;n<i.length;n++)i[n]=r[s+n]}raycast(e,t){let i=this.matrixWorld,r=this.count;if(nd.geometry=this.geometry,nd.material=this.material,nd.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),od.copy(this.boundingSphere),od.applyMatrix4(i),e.ray.intersectsSphere(od)!==!1))for(let a=0;a<r;a++){this.getMatrixAt(a,pc),w2.multiplyMatrices(i,pc),nd.matrixWorld=w2,nd.raycast(e,_f);for(let s=0,n=_f.length;s<n;s++){let o=_f[s];o.instanceId=a,o.object=this,t.push(o)}_f.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Jd(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new is(new Float32Array(r*this.count),r,this.count,vT,ir));let a=this.morphTexture.source.data.data,s=0;for(let l=0;l<i.length;l++)s+=i[l];let n=this.geometry.morphTargetsRelative?1:1-s,o=r*e;a[o]=n,a.set(i,o+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}},Dl=class extends bp{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new _t(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},S2=new O,A2=new O,E2=new je,A0=new Au,Sf=new Sa,Zm=class extends Mi{constructor(e=new St,t=new Dl){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,a=t.count;r<a;r++)S2.fromBufferAttribute(t,r-1),A2.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=S2.distanceTo(A2);e.setAttribute("lineDistance",new ut(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,a=e.params.Line.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Sf.copy(i.boundingSphere),Sf.applyMatrix4(r),Sf.radius+=a,e.ray.intersectsSphere(Sf)===!1)return;E2.copy(r).invert(),A0.copy(e.ray).applyMatrix4(E2);let n=a/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,l=new O,h=new O,c=new O,u=new O,d=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let m=Math.max(0,s.start),g=Math.min(p.count,s.start+s.count);for(let v=m,x=g-1;v<x;v+=d){let b=p.getX(v),_=p.getX(v+1);if(l.fromBufferAttribute(f,b),h.fromBufferAttribute(f,_),A0.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);let M=e.ray.origin.distanceTo(u);M<e.near||M>e.far||t.push({distance:M,point:c.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let m=Math.max(0,s.start),g=Math.min(f.count,s.start+s.count);for(let v=m,x=g-1;v<x;v+=d){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),A0.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);let b=e.ray.origin.distanceTo(u);b<e.near||b>e.far||t.push({distance:b,point:c.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){let s=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=r}}}}},M2=new O,C2=new O,wp=class extends Zm{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,a=t.count;r<a;r+=2)M2.fromBufferAttribute(t,r),C2.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+M2.distanceTo(C2);e.setAttribute("lineDistance",new ut(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},E5=class extends Ki{constructor(e,t,i,r,a,s,n,o,l){super(e,t,i,r,a,s,n,o,l),this.isVideoTexture=!0,this.minFilter=s!==void 0?s:Wt,this.magFilter=a!==void 0?a:Wt,this.generateMipmaps=!1;let h=this;function c(){h.needsUpdate=!0,e.requestVideoFrameCallback(c)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(c)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},M5=class extends Ki{constructor(e,t,i,r,a,s,n,o,l){super(e,t,i,r,a,s,n,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Fn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),a=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),a+=i.distanceTo(r),t.push(a),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,a=i.length,s;t?s=t:s=e*i[a-1];let n=0,o=a-1,l;for(;n<=o;)if(r=Math.floor(n+(o-n)/2),l=i[r]-s,l<0)n=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===s)return r/(a-1);let h=i[r],c=i[r+1]-h,u=(s-h)/c;return(r+u)/(a-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let a=this.getPoint(i),s=this.getPoint(r),n=t||(a.isVector2?new ae:new O);return n.copy(s).sub(a).normalize(),n}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new O,r=[],a=[],s=[],n=new O,o=new je;for(let d=0;d<=e;d++){let p=d/e;r[d]=this.getTangentAt(p,new O)}a[0]=new O,s[0]=new O;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),c=Math.abs(r[0].y),u=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),u<=l&&i.set(0,0,1),n.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],n),s[0].crossVectors(r[0],a[0]);for(let d=1;d<=e;d++){if(a[d]=a[d-1].clone(),s[d]=s[d-1].clone(),n.crossVectors(r[d-1],r[d]),n.length()>Number.EPSILON){n.normalize();let p=Math.acos(yr(r[d-1].dot(r[d]),-1,1));a[d].applyMatrix4(o.makeRotationAxis(n,p))}s[d].crossVectors(r[d],a[d])}if(t===!0){let d=Math.acos(yr(a[0].dot(a[e]),-1,1));d/=e,r[0].dot(n.crossVectors(a[0],a[e]))>0&&(d=-d);for(let p=1;p<=e;p++)a[p].applyMatrix4(o.makeRotationAxis(r[p],d*p)),s[p].crossVectors(r[p],a[p])}return{tangents:r,normals:a,binormals:s}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Kg=class extends Fn{constructor(e=0,t=0,i=1,r=1,a=0,s=Math.PI*2,n=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=a,this.aEndAngle=s,this.aClockwise=n,this.aRotation=o}getPoint(e,t=new ae){let i=t,r=Math.PI*2,a=this.aEndAngle-this.aStartAngle,s=Math.abs(a)<Number.EPSILON;for(;a<0;)a+=r;for(;a>r;)a-=r;a<Number.EPSILON&&(s?a=0:a=r),this.aClockwise===!0&&!s&&(a===r?a=-r:a=a-r);let n=this.aStartAngle+e*a,o=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);if(this.aRotation!==0){let h=Math.cos(this.aRotation),c=Math.sin(this.aRotation),u=o-this.aX,d=l-this.aY;o=u*h-d*c+this.aX,l=u*c+d*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},C5=class extends Kg{constructor(e,t,i,r,a,s){super(e,t,i,i,r,a,s),this.isArcCurve=!0,this.type="ArcCurve"}};function ob(){let e=0,t=0,i=0,r=0;function a(s,n,o,l){e=s,t=o,i=-3*s+3*n-2*o-l,r=2*s-2*n+o+l}return{initCatmullRom:function(s,n,o,l,h){a(n,o,h*(o-s),h*(l-n))},initNonuniformCatmullRom:function(s,n,o,l,h,c,u){let d=(n-s)/h-(o-s)/(h+c)+(o-n)/c,p=(o-n)/c-(l-n)/(c+u)+(l-o)/u;d*=c,p*=c,a(n,o,d,p)},calc:function(s){let n=s*s,o=n*s;return e+t*s+i*n+r*o}}}var Af=new O,E0=new ob,M0=new ob,C0=new ob,T5=class extends Fn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new O){let i=t,r=this.points,a=r.length,s=(a-(this.closed?0:1))*e,n=Math.floor(s),o=s-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/a)+1)*a:o===0&&n===a-1&&(n=a-2,o=1);let l,h;this.closed||n>0?l=r[(n-1)%a]:(Af.subVectors(r[0],r[1]).add(r[0]),l=Af);let c=r[n%a],u=r[(n+1)%a];if(this.closed||n+2<a?h=r[(n+2)%a]:(Af.subVectors(r[a-1],r[a-2]).add(r[a-1]),h=Af),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(c),d),f=Math.pow(c.distanceToSquared(u),d),m=Math.pow(u.distanceToSquared(h),d);f<1e-4&&(f=1),p<1e-4&&(p=f),m<1e-4&&(m=f),E0.initNonuniformCatmullRom(l.x,c.x,u.x,h.x,p,f,m),M0.initNonuniformCatmullRom(l.y,c.y,u.y,h.y,p,f,m),C0.initNonuniformCatmullRom(l.z,c.z,u.z,h.z,p,f,m)}else this.curveType==="catmullrom"&&(E0.initCatmullRom(l.x,c.x,u.x,h.x,this.tension),M0.initCatmullRom(l.y,c.y,u.y,h.y,this.tension),C0.initCatmullRom(l.z,c.z,u.z,h.z,this.tension));return i.set(E0.calc(o),M0.calc(o),C0.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new O().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function T2(e,t,i,r,a){let s=(r-t)*.5,n=(a-i)*.5,o=e*e,l=e*o;return(2*i-2*r+s+n)*l+(-3*i+3*r-2*s-n)*o+s*e+i}function P5(e,t){let i=1-e;return i*i*t}function D5(e,t){return 2*(1-e)*e*t}function R5(e,t){return e*e*t}function kd(e,t,i,r){return P5(e,t)+D5(e,i)+R5(e,r)}function O5(e,t){let i=1-e;return i*i*i*t}function L5(e,t){let i=1-e;return 3*i*i*e*t}function I5(e,t){return 3*(1-e)*e*e*t}function B5(e,t){return e*e*e*t}function Vd(e,t,i,r,a){return O5(e,t)+L5(e,i)+I5(e,r)+B5(e,a)}var Ws=class extends Fn{constructor(e=new ae,t=new ae,i=new ae,r=new ae){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new ae){let i=t,r=this.v0,a=this.v1,s=this.v2,n=this.v3;return i.set(Vd(e,r.x,a.x,s.x,n.x),Vd(e,r.y,a.y,s.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Cm=class extends Fn{constructor(e=new O,t=new O,i=new O,r=new O){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new O){let i=t,r=this.v0,a=this.v1,s=this.v2,n=this.v3;return i.set(Vd(e,r.x,a.x,s.x,n.x),Vd(e,r.y,a.y,s.y,n.y),Vd(e,r.z,a.z,s.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Pn=class extends Fn{constructor(e=new ae,t=new ae){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ae){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ae){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},GT=class extends Fn{constructor(e=new O,t=new O){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new O){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new O){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Ml=class extends Fn{constructor(e=new ae,t=new ae,i=new ae){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new ae){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(kd(e,r.x,a.x,s.x),kd(e,r.y,a.y,s.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},U5=class extends Fn{constructor(e=new O,t=new O,i=new O){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new O){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(kd(e,r.x,a.x,s.x),kd(e,r.y,a.y,s.y),kd(e,r.z,a.z,s.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},lb=class extends Fn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ae){let i=t,r=this.points,a=(r.length-1)*e,s=Math.floor(a),n=a-s,o=r[s===0?s:s-1],l=r[s],h=r[s>r.length-2?r.length-1:s+1],c=r[s>r.length-3?r.length-1:s+2];return i.set(T2(n,o.x,l.x,h.x,c.x),T2(n,o.y,l.y,h.y,c.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new ae().fromArray(r))}return this}},P2=Object.freeze({__proto__:null,ArcCurve:C5,CatmullRomCurve3:T5,CubicBezierCurve:Ws,CubicBezierCurve3:Cm,EllipseCurve:Kg,LineCurve:Pn,LineCurve3:GT,QuadraticBezierCurve:Ml,QuadraticBezierCurve3:U5,SplineCurve:lb}),HT=class extends Fn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new P2[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),a=0;for(;a<r.length;){if(r[a]>=i){let s=r[a]-i,n=this.curves[a],o=n.getLength(),l=o===0?0:1-s/o;return n.getPointAt(l,t)}a++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,a=this.curves;r<a.length;r++){let s=a[r],n=s.isEllipseCurve?e*2:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,o=s.getPoints(n);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new P2[r.type]().fromJSON(r))}return this}},Jm=class extends HT{constructor(e){super(),this.type="Path",this.currentPoint=new ae,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new Pn(this.currentPoint.clone(),new ae(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let a=new Ml(this.currentPoint.clone(),new ae(e,t),new ae(i,r));return this.curves.push(a),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,a,s){let n=new Ws(this.currentPoint.clone(),new ae(e,t),new ae(i,r),new ae(a,s));return this.curves.push(n),this.currentPoint.set(a,s),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new lb(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,a,s){let n=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+n,t+o,i,r,a,s),this}absarc(e,t,i,r,a,s){return this.absellipse(e,t,i,i,r,a,s),this}ellipse(e,t,i,r,a,s,n,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,a,s,n,o),this}absellipse(e,t,i,r,a,s,n,o){let l=new Kg(e,t,i,r,a,s,n,o);if(this.curves.length>0){let c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},WT=class extends St{constructor(e=[new ae(0,-.5),new ae(.5,0),new ae(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=yr(r,0,Math.PI*2);let a=[],s=[],n=[],o=[],l=[],h=1/t,c=new O,u=new ae,d=new O,p=new O,f=new O,m=0,g=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=g*1,d.y=-m,d.z=g*0,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=g*1,d.y=-m,d.z=g*0,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let v=0;v<=t;v++){let x=i+v*h*r,b=Math.sin(x),_=Math.cos(x);for(let M=0;M<=e.length-1;M++){c.x=e[M].x*b,c.y=e[M].y,c.z=e[M].x*_,s.push(c.x,c.y,c.z),u.x=v/t,u.y=M/(e.length-1),n.push(u.x,u.y);let A=o[3*M+0]*b,S=o[3*M+1],P=o[3*M+0]*_;l.push(A,S,P)}}for(let v=0;v<t;v++)for(let x=0;x<e.length-1;x++){let b=x+v*e.length,_=b,M=b+e.length,A=b+e.length+1,S=b+1;a.push(_,M,S),a.push(A,S,M)}this.setIndex(a),this.setAttribute("position",new ut(s,3)),this.setAttribute("uv",new ut(n,2)),this.setAttribute("normal",new ut(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new WT(e.points,e.segments,e.phiStart,e.phiLength)}},hb=class extends St{constructor(e=1,t=1,i=1,r=32,a=1,s=!1,n=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:a,openEnded:s,thetaStart:n,thetaLength:o};let l=this;r=Math.floor(r),a=Math.floor(a);let h=[],c=[],u=[],d=[],p=0,f=[],m=i/2,g=0;v(),s===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new ut(c,3)),this.setAttribute("normal",new ut(u,3)),this.setAttribute("uv",new ut(d,2));function v(){let b=new O,_=new O,M=0,A=(t-e)/i;for(let S=0;S<=a;S++){let P=[],L=S/a,E=L*(t-e)+e;for(let T=0;T<=r;T++){let B=T/r,V=B*o+n,I=Math.sin(V),H=Math.cos(V);_.x=E*I,_.y=-L*i+m,_.z=E*H,c.push(_.x,_.y,_.z),b.set(I,A,H).normalize(),u.push(b.x,b.y,b.z),d.push(B,1-L),P.push(p++)}f.push(P)}for(let S=0;S<r;S++)for(let P=0;P<a;P++){let L=f[P][S],E=f[P+1][S],T=f[P+1][S+1],B=f[P][S+1];h.push(L,E,B),h.push(E,T,B),M+=6}l.addGroup(g,M,0),g+=M}function x(b){let _=p,M=new ae,A=new O,S=0,P=b===!0?e:t,L=b===!0?1:-1;for(let T=1;T<=r;T++)c.push(0,m*L,0),u.push(0,L,0),d.push(.5,.5),p++;let E=p;for(let T=0;T<=r;T++){let B=T/r*o+n,V=Math.cos(B),I=Math.sin(B);A.x=P*I,A.y=m*L,A.z=P*V,c.push(A.x,A.y,A.z),u.push(0,L,0),M.x=V*.5+.5,M.y=I*.5*L+.5,d.push(M.x,M.y),p++}for(let T=0;T<r;T++){let B=_+T,V=E+T;b===!0?h.push(V,V+1,B):h.push(V+1,V,B),S+=3}l.addGroup(g,S,b===!0?1:2),g+=S}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new hb(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},cb=class extends hb{constructor(e=1,t=1,i=32,r=1,a=!1,s=0,n=Math.PI*2){super(0,e,t,i,r,a,s,n),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:n}}static fromJSON(e){return new cb(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},ub=class extends St{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let a=[],s=[];n(r),l(i),h(),this.setAttribute("position",new ut(a,3)),this.setAttribute("normal",new ut(a.slice(),3)),this.setAttribute("uv",new ut(s,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function n(v){let x=new O,b=new O,_=new O;for(let M=0;M<t.length;M+=3)d(t[M+0],x),d(t[M+1],b),d(t[M+2],_),o(x,b,_,v)}function o(v,x,b,_){let M=_+1,A=[];for(let S=0;S<=M;S++){A[S]=[];let P=v.clone().lerp(b,S/M),L=x.clone().lerp(b,S/M),E=M-S;for(let T=0;T<=E;T++)T===0&&S===M?A[S][T]=P:A[S][T]=P.clone().lerp(L,T/E)}for(let S=0;S<M;S++)for(let P=0;P<2*(M-S)-1;P++){let L=Math.floor(P/2);P%2===0?(u(A[S][L+1]),u(A[S+1][L]),u(A[S][L])):(u(A[S][L+1]),u(A[S+1][L+1]),u(A[S+1][L]))}}function l(v){let x=new O;for(let b=0;b<a.length;b+=3)x.x=a[b+0],x.y=a[b+1],x.z=a[b+2],x.normalize().multiplyScalar(v),a[b+0]=x.x,a[b+1]=x.y,a[b+2]=x.z}function h(){let v=new O;for(let x=0;x<a.length;x+=3){v.x=a[x+0],v.y=a[x+1],v.z=a[x+2];let b=m(v)/2/Math.PI+.5,_=g(v)/Math.PI+.5;s.push(b,1-_)}p(),c()}function c(){for(let v=0;v<s.length;v+=6){let x=s[v+0],b=s[v+2],_=s[v+4],M=Math.max(x,b,_),A=Math.min(x,b,_);M>.9&&A<.1&&(x<.2&&(s[v+0]+=1),b<.2&&(s[v+2]+=1),_<.2&&(s[v+4]+=1))}}function u(v){a.push(v.x,v.y,v.z)}function d(v,x){let b=v*3;x.x=e[b+0],x.y=e[b+1],x.z=e[b+2]}function p(){let v=new O,x=new O,b=new O,_=new O,M=new ae,A=new ae,S=new ae;for(let P=0,L=0;P<a.length;P+=9,L+=6){v.set(a[P+0],a[P+1],a[P+2]),x.set(a[P+3],a[P+4],a[P+5]),b.set(a[P+6],a[P+7],a[P+8]),M.set(s[L+0],s[L+1]),A.set(s[L+2],s[L+3]),S.set(s[L+4],s[L+5]),_.copy(v).add(x).add(b).divideScalar(3);let E=m(_);f(M,L+0,v,E),f(A,L+2,x,E),f(S,L+4,b,E)}}function f(v,x,b,_){_<0&&v.x===1&&(s[x]=v.x-1),b.x===0&&b.z===0&&(s[x]=_/2/Math.PI+.5)}function m(v){return Math.atan2(v.z,-v.x)}function g(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ub(e.vertices,e.indices,e.radius,e.details)}},qT=class extends ub{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],s=[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(a,s,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new qT(e.radius,e.detail)}},$m=class extends Jm{constructor(e){super(e),this.uuid=As(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Jm().fromJSON(r))}return this}},F5={triangulate:function(e,t,i=2){let r=t&&t.length,a=r?t[0]*i:e.length,s=XT(e,0,a,i,!0),n=[];if(!s||s.next===s.prev)return n;let o,l,h,c,u,d,p;if(r&&(s=j5(e,t,s,i)),e.length>80*i){o=h=e[0],l=c=e[1];for(let f=i;f<a;f+=i)u=e[f],d=e[f+1],u<o&&(o=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);p=Math.max(h-o,c-l),p=p!==0?32767/p:0}return $d(s,n,i,o,l,p,0),n}};function XT(e,t,i,r,a){let s,n;if(a===$5(e,t,i,r)>0)for(s=t;s<i;s+=r)n=D2(s,e[s],e[s+1],n);else for(s=i-r;s>=t;s-=r)n=D2(s,e[s],e[s+1],n);return n&&Zg(n,n.next)&&(tp(n),n=n.next),n}function Eh(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(Zg(i,i.next)||rr(i.prev,i,i.next)===0)){if(tp(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function $d(e,t,i,r,a,s,n){if(!e)return;!n&&s&&X5(e,r,a,s);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,s?z5(e,r,a,s):N5(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),tp(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=k5(Eh(e),t,i),$d(e,t,i,r,a,s,2)):n===2&&V5(e,t,i,r,a,s):$d(Eh(e),t,i,r,a,s,1);break}}}function N5(e){let t=e.prev,i=e,r=e.next;if(rr(t,i,r)>=0)return!1;let a=t.x,s=i.x,n=r.x,o=t.y,l=i.y,h=r.y,c=a<s?a<n?a:n:s<n?s:n,u=o<l?o<h?o:h:l<h?l:h,d=a>s?a>n?a:n:s>n?s:n,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&Gc(a,o,s,l,n,h,f.x,f.y)&&rr(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function z5(e,t,i,r){let a=e.prev,s=e,n=e.next;if(rr(a,s,n)>=0)return!1;let o=a.x,l=s.x,h=n.x,c=a.y,u=s.y,d=n.y,p=o<l?o<h?o:h:l<h?l:h,f=c<u?c<d?c:d:u<d?u:d,m=o>l?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=a1(p,f,t,i,r),x=a1(m,g,t,i,r),b=e.prevZ,_=e.nextZ;for(;b&&b.z>=v&&_&&_.z<=x;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==a&&b!==n&&Gc(o,c,l,u,h,d,b.x,b.y)&&rr(b.prev,b,b.next)>=0||(b=b.prevZ,_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==a&&_!==n&&Gc(o,c,l,u,h,d,_.x,_.y)&&rr(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;b&&b.z>=v;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==a&&b!==n&&Gc(o,c,l,u,h,d,b.x,b.y)&&rr(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==a&&_!==n&&Gc(o,c,l,u,h,d,_.x,_.y)&&rr(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function k5(e,t,i){let r=e;do{let a=r.prev,s=r.next.next;!Zg(a,s)&&YT(a,r,r.next,s)&&ep(a,s)&&ep(s,a)&&(t.push(a.i/i|0),t.push(r.i/i|0),t.push(s.i/i|0),tp(r),tp(r.next),r=e=s),r=r.next}while(r!==e);return Eh(r)}function V5(e,t,i,r,a,s){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&K5(n,o)){let l=QT(n,o);n=Eh(n,n.next),l=Eh(l,l.next),$d(n,t,i,r,a,s,0),$d(l,t,i,r,a,s,0);return}o=o.next}n=n.next}while(n!==e)}function j5(e,t,i,r){let a=[],s,n,o,l,h;for(s=0,n=t.length;s<n;s++)o=t[s]*r,l=s<n-1?t[s+1]*r:e.length,h=XT(e,o,l,r,!1),h===h.next&&(h.steiner=!0),a.push(Q5(h));for(a.sort(G5),s=0;s<a.length;s++)i=H5(a[s],i);return i}function G5(e,t){return e.x-t.x}function H5(e,t){let i=W5(e,t);if(!i)return t;let r=QT(i,e);return Eh(r,r.next),Eh(i,i.next)}function W5(e,t){let i=t,r=-1/0,a,s=e.x,n=e.y;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){let d=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(d<=s&&d>r&&(r=d,a=i.x<i.next.x?i:i.next,d===s))return a}i=i.next}while(i!==t);if(!a)return null;let o=a,l=a.x,h=a.y,c=1/0,u;i=a;do s>=i.x&&i.x>=l&&s!==i.x&&Gc(n<h?s:r,n,l,h,n<h?r:s,n,i.x,i.y)&&(u=Math.abs(n-i.y)/(s-i.x),ep(i,e)&&(u<c||u===c&&(i.x>a.x||i.x===a.x&&q5(a,i)))&&(a=i,c=u)),i=i.next;while(i!==o);return a}function q5(e,t){return rr(e.prev,e,t.prev)<0&&rr(t.next,e,e.next)<0}function X5(e,t,i,r){let a=e;do a.z===0&&(a.z=a1(a.x,a.y,t,i,r)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==e);a.prevZ.nextZ=null,a.prevZ=null,Y5(a)}function Y5(e){let t,i,r,a,s,n,o,l,h=1;do{for(i=e,e=null,s=null,n=0;i;){for(n++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(a=i,i=i.nextZ,o--):(a=r,r=r.nextZ,l--),s?s.nextZ=a:e=a,a.prevZ=s,s=a;i=r}s.nextZ=null,h*=2}while(n>1);return e}function a1(e,t,i,r,a){return e=(e-i)*a|0,t=(t-r)*a|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Q5(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function Gc(e,t,i,r,a,s,n,o){return(a-n)*(t-o)>=(e-n)*(s-o)&&(e-n)*(r-o)>=(i-n)*(t-o)&&(i-n)*(s-o)>=(a-n)*(r-o)}function K5(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Z5(e,t)&&(ep(e,t)&&ep(t,e)&&J5(e,t)&&(rr(e.prev,e,t.prev)||rr(e,t.prev,t))||Zg(e,t)&&rr(e.prev,e,e.next)>0&&rr(t.prev,t,t.next)>0)}function rr(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Zg(e,t){return e.x===t.x&&e.y===t.y}function YT(e,t,i,r){let a=Mf(rr(e,t,i)),s=Mf(rr(e,t,r)),n=Mf(rr(i,r,e)),o=Mf(rr(i,r,t));return!!(a!==s&&n!==o||a===0&&Ef(e,i,t)||s===0&&Ef(e,r,t)||n===0&&Ef(i,e,r)||o===0&&Ef(i,t,r))}function Ef(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Mf(e){return e>0?1:e<0?-1:0}function Z5(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&YT(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function ep(e,t){return rr(e.prev,e,e.next)<0?rr(e,t,e.next)>=0&&rr(e,e.prev,t)>=0:rr(e,t,e.prev)<0||rr(e,e.next,t)<0}function J5(e,t){let i=e,r=!1,a=(e.x+t.x)/2,s=(e.y+t.y)/2;do i.y>s!=i.next.y>s&&i.next.y!==i.y&&a<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function QT(e,t){let i=new s1(e.i,e.x,e.y),r=new s1(t.i,t.x,t.y),a=e.next,s=t.prev;return e.next=t,t.prev=e,i.next=a,a.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function D2(e,t,i,r){let a=new s1(e,t,i);return r?(a.next=r.next,a.prev=r,r.next.prev=a,r.next=a):(a.prev=a,a.next=a),a}function tp(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function s1(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function $5(e,t,i,r){let a=0;for(let s=t,n=i-r;s<i;s+=r)a+=(e[n]-e[s])*(e[s+1]+e[n+1]),n=s;return a}var KT=class{static area(e){let t=e.length,i=0;for(let r=t-1,a=0;a<t;r=a++)i+=e[r].x*e[a].y-e[a].x*e[r].y;return i*.5}static isClockWise(e){return KT.area(e)<0}static triangulateShape(e,t){let i=[],r=[],a=[];R2(e),O2(i,e);let s=e.length;t.forEach(R2);for(let o=0;o<t.length;o++)r.push(s),s+=t[o].length,O2(i,t[o]);let n=F5.triangulate(i,r);for(let o=0;o<n.length;o+=3)a.push(n.slice(o,o+3));return a}};function R2(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function O2(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var ZT=class extends ub{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,a,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ZT(e.radius,e.detail)}},Qc=class extends St{constructor(e=1,t=32,i=16,r=0,a=Math.PI*2,s=0,n=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:a,thetaStart:s,thetaLength:n},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(s+n,Math.PI),l=0,h=[],c=new O,u=new O,d=[],p=[],f=[],m=[];for(let g=0;g<=i;g++){let v=[],x=g/i,b=0;g===0&&s===0?b=.5/t:g===i&&o===Math.PI&&(b=-.5/t);for(let _=0;_<=t;_++){let M=_/t;c.x=-e*Math.cos(r+M*a)*Math.sin(s+x*n),c.y=e*Math.cos(s+x*n),c.z=e*Math.sin(r+M*a)*Math.sin(s+x*n),p.push(c.x,c.y,c.z),u.copy(c).normalize(),f.push(u.x,u.y,u.z),m.push(M+b,1-x),v.push(l++)}h.push(v)}for(let g=0;g<i;g++)for(let v=0;v<t;v++){let x=h[g][v+1],b=h[g][v],_=h[g+1][v],M=h[g+1][v+1];(g!==0||s>0)&&d.push(x,b,M),(g!==i-1||o<Math.PI)&&d.push(b,_,M)}this.setIndex(d),this.setAttribute("position",new ut(p,3)),this.setAttribute("normal",new ut(f,3)),this.setAttribute("uv",new ut(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qc(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},JT=class extends St{constructor(e=1,t=.4,i=12,r=48,a=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:a},i=Math.floor(i),r=Math.floor(r);let s=[],n=[],o=[],l=[],h=new O,c=new O,u=new O;for(let d=0;d<=i;d++)for(let p=0;p<=r;p++){let f=p/r*a,m=d/i*Math.PI*2;c.x=(e+t*Math.cos(m))*Math.cos(f),c.y=(e+t*Math.cos(m))*Math.sin(f),c.z=t*Math.sin(m),n.push(c.x,c.y,c.z),h.x=e*Math.cos(f),h.y=e*Math.sin(f),u.subVectors(c,h).normalize(),o.push(u.x,u.y,u.z),l.push(p/r),l.push(d/i)}for(let d=1;d<=i;d++)for(let p=1;p<=r;p++){let f=(r+1)*d+p-1,m=(r+1)*(d-1)+p-1,g=(r+1)*(d-1)+p,v=(r+1)*d+p;s.push(f,m,v),s.push(m,g,v)}this.setIndex(s),this.setAttribute("position",new ut(n,3)),this.setAttribute("normal",new ut(o,3)),this.setAttribute("uv",new ut(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new JT(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},$T=class extends St{constructor(e=1,t=.4,i=64,r=8,a=2,s=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:a,q:s},i=Math.floor(i),r=Math.floor(r);let n=[],o=[],l=[],h=[],c=new O,u=new O,d=new O,p=new O,f=new O,m=new O,g=new O;for(let x=0;x<=i;++x){let b=x/i*a*Math.PI*2;v(b,a,s,e,d),v(b+.01,a,s,e,p),m.subVectors(p,d),g.addVectors(p,d),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let _=0;_<=r;++_){let M=_/r*Math.PI*2,A=-t*Math.cos(M),S=t*Math.sin(M);c.x=d.x+(A*g.x+S*f.x),c.y=d.y+(A*g.y+S*f.y),c.z=d.z+(A*g.z+S*f.z),o.push(c.x,c.y,c.z),u.subVectors(c,d).normalize(),l.push(u.x,u.y,u.z),h.push(x/i),h.push(_/r)}}for(let x=1;x<=i;x++)for(let b=1;b<=r;b++){let _=(r+1)*(x-1)+(b-1),M=(r+1)*x+(b-1),A=(r+1)*x+b,S=(r+1)*(x-1)+b;n.push(_,M,S),n.push(M,A,S)}this.setIndex(n),this.setAttribute("position",new ut(o,3)),this.setAttribute("normal",new ut(l,3)),this.setAttribute("uv",new ut(h,2));function v(x,b,_,M,A){let S=Math.cos(x),P=Math.sin(x),L=_/b*x,E=Math.cos(L);A.x=M*(2+E)*.5*S,A.y=M*(2+E)*P*.5,A.z=M*Math.sin(L)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $T(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function Cf(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function e6(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function t6(e){function t(a,s){return e[a]-e[s]}let i=e.length,r=new Array(i);for(let a=0;a!==i;++a)r[a]=a;return r.sort(t),r}function L2(e,t,i){let r=e.length,a=new e.constructor(r);for(let s=0,n=0;n!==r;++s){let o=i[s]*t;for(let l=0;l!==t;++l)a[n++]=e[o+l]}return a}function eP(e,t,i,r){let a=1,s=e[0];for(;s!==void 0&&s[r]===void 0;)s=e[a++];if(s===void 0)return;let n=s[r];if(n!==void 0)if(Array.isArray(n))do n=s[r],n!==void 0&&(t.push(s.time),i.push.apply(i,n)),s=e[a++];while(s!==void 0);else if(n.toArray!==void 0)do n=s[r],n!==void 0&&(t.push(s.time),n.toArray(i,i.length)),s=e[a++];while(s!==void 0);else do n=s[r],n!==void 0&&(t.push(s.time),i.push(n)),s=e[a++];while(s!==void 0)}var Jg=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],a=t[i-1];e:{t:{let s;i:{r:if(!(e<r)){for(let n=i+2;;){if(r===void 0){if(e<a)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===n)break;if(a=r,r=t[++i],e<r)break t}s=t.length;break i}if(!(e>=a)){let n=t[1];e<n&&(i=2,a=n);for(let o=i-2;;){if(a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=a,a=t[--i-1],e>=a)break t}s=i,i=0;break i}break e}for(;i<s;){let n=i+s>>>1;e<t[n]?s=n:i=n+1}if(r=t[i],a=t[i-1],a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,a,r)}return this.interpolate_(i,a,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r;for(let s=0;s!==r;++s)t[s]=i[a+s];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},i6=class extends Jg{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:zc,endingEnd:zc}}intervalChanged_(e,t,i){let r=this.parameterPositions,a=e-2,s=e+1,n=r[a],o=r[s];if(n===void 0)switch(this.getSettings_().endingStart){case kc:a=e,n=2*t-i;break;case Wm:a=r.length-2,n=t+r[a]-r[a+1];break;default:a=e,n=i}if(o===void 0)switch(this.getSettings_().endingEnd){case kc:s=e,o=2*i-t;break;case Wm:s=1,o=i+r[1]-r[0];break;default:s=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-n),this._weightNext=l/(o-i),this._offsetPrev=a*h,this._offsetNext=s*h}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=this._offsetPrev,c=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-t)/(r-t),f=p*p,m=f*p,g=-u*m+2*u*f-u*p,v=(1+u)*m+(-1.5-2*u)*f+(-.5+u)*p+1,x=(-1-d)*m+(1.5+d)*f+.5*p,b=d*m-d*f;for(let _=0;_!==n;++_)a[_]=g*s[h+_]+v*s[l+_]+x*s[o+_]+b*s[c+_];return a}},tP=class extends Jg{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=(i-t)/(r-t),c=1-h;for(let u=0;u!==n;++u)a[u]=s[l+u]*c+s[o+u]*h;return a}},r6=class extends Jg{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Nn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Cf(t,this.TimeBufferType),this.values=Cf(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Cf(e.times,Array),values:Cf(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new r6(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new tP(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new i6(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Gm:t=this.InterpolantFactoryMethodDiscrete;break;case Hm:t=this.InterpolantFactoryMethodLinear;break;case Jv:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Gm;case this.InterpolantFactoryMethodLinear:return Hm;case this.InterpolantFactoryMethodSmooth:return Jv}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,a=0,s=r-1;for(;a!==r&&i[a]<e;)++a;for(;s!==-1&&i[s]>t;)--s;if(++s,a!==0||s!==r){a>=s&&(s=Math.max(s,1),a=s-1);let n=this.getValueSize();this.times=i.slice(a,s),this.values=this.values.slice(a*n,s*n)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,a=i.length;a===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let n=0;n!==a;n++){let o=i[n];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,o),e=!1;break}if(s!==null&&s>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,o,s),e=!1;break}s=o}if(r!==void 0&&e6(r))for(let n=0,o=r.length;n!==o;++n){let l=r[n];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Jv,a=e.length-1,s=1;for(let n=1;n<a;++n){let o=!1,l=e[n],h=e[n+1];if(l!==h&&(n!==1||l!==e[0]))if(r)o=!0;else{let c=n*i,u=c-i,d=c+i;for(let p=0;p!==i;++p){let f=t[c+p];if(f!==t[u+p]||f!==t[d+p]){o=!0;break}}}if(o){if(n!==s){e[s]=e[n];let c=n*i,u=s*i;for(let d=0;d!==i;++d)t[u+d]=t[c+d]}++s}}if(a>0){e[s]=e[a];for(let n=a*i,o=s*i,l=0;l!==i;++l)t[o+l]=t[n+l];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=t.slice(0,s*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Nn.prototype.TimeBufferType=Float32Array;Nn.prototype.ValueBufferType=Float32Array;Nn.prototype.DefaultInterpolation=Hm;var Cu=class extends Nn{};Cu.prototype.ValueTypeName="bool";Cu.prototype.ValueBufferType=Array;Cu.prototype.DefaultInterpolation=Gm;Cu.prototype.InterpolantFactoryMethodLinear=void 0;Cu.prototype.InterpolantFactoryMethodSmooth=void 0;var iP=class extends Nn{};iP.prototype.ValueTypeName="color";var eg=class extends Nn{};eg.prototype.ValueTypeName="number";var a6=class extends Jg{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=(i-t)/(r-t),l=e*n;for(let h=l+n;l!==h;l+=4)zt.slerpFlat(a,0,s,l-n,s,l,o);return a}},_p=class extends Nn{InterpolantFactoryMethodLinear(e){return new a6(this.times,this.values,this.getValueSize(),e)}};_p.prototype.ValueTypeName="quaternion";_p.prototype.DefaultInterpolation=Hm;_p.prototype.InterpolantFactoryMethodSmooth=void 0;var Tu=class extends Nn{};Tu.prototype.ValueTypeName="string";Tu.prototype.ValueBufferType=Array;Tu.prototype.DefaultInterpolation=Gm;Tu.prototype.InterpolantFactoryMethodLinear=void 0;Tu.prototype.InterpolantFactoryMethodSmooth=void 0;var tg=class extends Nn{};tg.prototype.ValueTypeName="vector";var n1=class{constructor(e,t=-1,i,r=Jx){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=As(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let s=0,n=i.length;s!==n;++s)t.push(n6(i[s]).scale(r));let a=new this(e.name,e.duration,t,e.blendMode);return a.uuid=e.uuid,a}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let a=0,s=i.length;a!==s;++a)t.push(Nn.toJSON(i[a]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let a=t.length,s=[];for(let n=0;n<a;n++){let o=[],l=[];o.push((n+a-1)%a,n,(n+1)%a),l.push(0,1,0);let h=t6(o);o=L2(o,1,h),l=L2(l,1,h),!r&&o[0]===0&&(o.push(a),l.push(l[0])),s.push(new eg(".morphTargetInfluences["+t[n].name+"]",o,l).scale(1/i))}return new this(e,-1,s)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},a=/^([\w-]*?)([\d]+)$/;for(let n=0,o=e.length;n<o;n++){let l=e[n],h=l.name.match(a);if(h&&h.length>1){let c=h[1],u=r[c];u||(r[c]=u=[]),u.push(l)}}let s=[];for(let n in r)s.push(this.CreateFromMorphTargetSequence(n,r[n],t,i));return s}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,c,u,d,p){if(u.length!==0){let f=[],m=[];eP(u,f,m,d),f.length!==0&&p.push(new h(c,f,m))}},r=[],a=e.name||"default",s=e.fps||30,n=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let c=l[h].keys;if(!(!c||c.length===0))if(c[0].morphTargets){let u={},d;for(d=0;d<c.length;d++)if(c[d].morphTargets)for(let p=0;p<c[d].morphTargets.length;p++)u[c[d].morphTargets[p]]=-1;for(let p in u){let f=[],m=[];for(let g=0;g!==c[d].morphTargets.length;++g){let v=c[d];f.push(v.time),m.push(v.morphTarget===p?1:0)}r.push(new eg(".morphTargetInfluence["+p+"]",f,m))}o=u.length*s}else{let u=".bones["+t[h].name+"]";i(tg,u+".position",c,"pos",r),i(_p,u+".quaternion",c,"rot",r),i(tg,u+".scale",c,"scl",r)}}return r.length===0?null:new this(a,o,r,n)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let a=this.tracks[i];t=Math.max(t,a.times[a.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function s6(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return eg;case"vector":case"vector2":case"vector3":case"vector4":return tg;case"color":return iP;case"quaternion":return _p;case"bool":case"boolean":return Cu;case"string":return Tu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function n6(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=s6(e.type);if(e.times===void 0){let i=[],r=[];eP(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var ig={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},rP=class{constructor(e,t,i){let r=this,a=!1,s=0,n=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){n++,a===!1&&r.onStart!==void 0&&r.onStart(h,s,n),a=!0},this.itemEnd=function(h){s++,r.onProgress!==void 0&&r.onProgress(h,s,n),s===n&&(a=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,c){return l.push(h,c),this},this.removeHandler=function(h){let c=l.indexOf(h);return c!==-1&&l.splice(c,2),this},this.getHandler=function(h){for(let c=0,u=l.length;c<u;c+=2){let d=l[c],p=l[c+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}},o6=new rP,Pu=class{constructor(e){this.manager=e!==void 0?e:o6,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,a){i.load(e,r,t,a)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};Pu.DEFAULT_MATERIAL_NAME="__DEFAULT";var eo={},l6=class extends Error{constructor(e,t){super(e),this.response=t}},o1=class extends Pu{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let a=ig.get(e);if(a!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(a),this.manager.itemEnd(e)},0),a;if(eo[e]!==void 0){eo[e].push({onLoad:t,onProgress:i,onError:r});return}eo[e]=[],eo[e].push({onLoad:t,onProgress:i,onError:r});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),n=this.mimeType,o=this.responseType;fetch(s).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=eo[e],c=l.body.getReader(),u=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=u?parseInt(u):0,p=d!==0,f=0,m=new ReadableStream({start(g){v();function v(){c.read().then(({done:x,value:b})=>{if(x)g.close();else{f+=b.byteLength;let _=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:d});for(let M=0,A=h.length;M<A;M++){let S=h[M];S.onProgress&&S.onProgress(_)}g.enqueue(b),v()}})}}});return new Response(m)}else throw new l6(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,n));case"json":return l.json();default:if(n===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(n),c=h&&h[1]?h[1].toLowerCase():void 0,u=new TextDecoder(c);return l.arrayBuffer().then(d=>u.decode(d))}}}).then(l=>{ig.add(e,l);let h=eo[e];delete eo[e];for(let c=0,u=h.length;c<u;c++){let d=h[c];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=eo[e];if(h===void 0)throw this.manager.itemError(e),l;delete eo[e];for(let c=0,u=h.length;c<u;c++){let d=h[c];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},h6=class extends Pu{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let a=this,s=ig.get(e);if(s!==void 0)return a.manager.itemStart(e),setTimeout(function(){t&&t(s),a.manager.itemEnd(e)},0),s;let n=Zd("img");function o(){h(),ig.add(e,this),t&&t(this),a.manager.itemEnd(e)}function l(c){h(),r&&r(c),a.manager.itemError(e),a.manager.itemEnd(e)}function h(){n.removeEventListener("load",o,!1),n.removeEventListener("error",l,!1)}return n.addEventListener("load",o,!1),n.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(n.crossOrigin=this.crossOrigin),a.manager.itemStart(e),n.src=e,n}},c6=class extends Pu{constructor(e){super(e)}load(e,t,i,r){let a=new Ki,s=new h6(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(n){a.image=n,a.needsUpdate=!0,t!==void 0&&t(a)},i,r),a}},Sp=class extends Mi{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new _t(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},u6=class extends Sp{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Mi.DEFAULT_UP),this.updateMatrix(),this.groundColor=new _t(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},T0=new je,I2=new O,B2=new O,db=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ae(512,512),this.map=null,this.mapPass=null,this.matrix=new je,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new rb,this._frameExtents=new ae(1,1),this._viewportCount=1,this._viewports=[new Nt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;I2.setFromMatrixPosition(e.matrixWorld),t.position.copy(I2),B2.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(B2),t.updateMatrixWorld(),T0.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(T0),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(T0)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},d6=class extends db{constructor(){super(new va(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=hu*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,a=e.distance||t.far;(i!==t.fov||r!==t.aspect||a!==t.far)&&(t.fov=i,t.aspect=r,t.far=a,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},p6=class extends Sp{constructor(e,t,i=0,r=Math.PI/3,a=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Mi.DEFAULT_UP),this.updateMatrix(),this.target=new Mi,this.distance=i,this.angle=r,this.penumbra=a,this.decay=s,this.map=null,this.shadow=new d6}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},U2=new je,ld=new O,P0=new O,f6=class extends db{constructor(){super(new va(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ae(4,2),this._viewportCount=6,this._viewports=[new Nt(2,1,1,1),new Nt(0,1,1,1),new Nt(3,1,1,1),new Nt(1,1,1,1),new Nt(3,0,1,1),new Nt(1,0,1,1)],this._cubeDirections=[new O(1,0,0),new O(-1,0,0),new O(0,0,1),new O(0,0,-1),new O(0,1,0),new O(0,-1,0)],this._cubeUps=[new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,1,0),new O(0,0,1),new O(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,a=e.distance||i.far;a!==i.far&&(i.far=a,i.updateProjectionMatrix()),ld.setFromMatrixPosition(e.matrixWorld),i.position.copy(ld),P0.copy(i.position),P0.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(P0),i.updateMatrixWorld(),r.makeTranslation(-ld.x,-ld.y,-ld.z),U2.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(U2)}},m6=class extends Sp{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new f6}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},g6=class extends db{constructor(){super(new ab(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},v6=class extends Sp{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Mi.DEFAULT_UP),this.updateMatrix(),this.target=new Mi,this.shadow=new g6}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},aP=class extends St{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},sP=class extends Pu{constructor(e){super(e)}load(e,t,i,r){let a=this,s=new o1(a.manager);s.setPath(a.path),s.setRequestHeader(a.requestHeader),s.setWithCredentials(a.withCredentials),s.load(e,function(n){try{t(a.parse(JSON.parse(n)))}catch(o){r?r(o):console.error(o),a.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(u,d){if(t[d]!==void 0)return t[d];let p=u.interleavedBuffers[d],f=a(u,p.buffer),m=$p(p.type,f),g=new w5(m,p.stride);return g.uuid=p.uuid,t[d]=g,g}function a(u,d){if(i[d]!==void 0)return i[d];let p=u.arrayBuffers[d],f=new Uint32Array(p).buffer;return i[d]=f,f}let s=e.isInstancedBufferGeometry?new aP:new St,n=e.data.index;if(n!==void 0){let u=$p(n.type,n.array);s.setIndex(new Ut(u,1))}let o=e.data.attributes;for(let u in o){let d=o[u],p;if(d.isInterleavedBufferAttribute){let f=r(e.data,d.data);p=new r1(f,d.itemSize,d.offset,d.normalized)}else{let f=$p(d.type,d.array),m=d.isInstancedBufferAttribute?Jd:Ut;p=new m(f,d.itemSize,d.normalized)}d.name!==void 0&&(p.name=d.name),d.usage!==void 0&&p.setUsage(d.usage),s.setAttribute(u,p)}let l=e.data.morphAttributes;if(l)for(let u in l){let d=l[u],p=[];for(let f=0,m=d.length;f<m;f++){let g=d[f],v;if(g.isInterleavedBufferAttribute){let x=r(e.data,g.data);v=new r1(x,g.itemSize,g.offset,g.normalized)}else{let x=$p(g.type,g.array);v=new Ut(x,g.itemSize,g.normalized)}g.name!==void 0&&(v.name=g.name),p.push(v)}s.morphAttributes[u]=p}e.data.morphTargetsRelative&&(s.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let u=0,d=h.length;u!==d;++u){let p=h[u];s.addGroup(p.start,p.count,p.materialIndex)}let c=e.data.boundingSphere;if(c!==void 0){let u=new O;c.center!==void 0&&u.fromArray(c.center),s.boundingSphere=new Sa(u,c.radius)}return e.name&&(s.name=e.name),e.userData&&(s.userData=e.userData),s}},y6=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=F2(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=F2();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function F2(){return(typeof performance>"u"?Date:performance).now()}var x6=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,a,s;switch(t){case"quaternion":r=this._slerp,a=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,a=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,a=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=a,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,a=e*r+r,s=this.cumulativeWeight;if(s===0){for(let n=0;n!==r;++n)i[a+n]=i[n];s=t}else{s+=t;let n=t/s;this._mixBufferRegion(i,a,0,n,r)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,a=this.cumulativeWeight,s=this.cumulativeWeightAdditive,n=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,a<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-a,t)}s>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){n.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let a=i,s=r;a!==s;++a)t[a]=t[r+a%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,a){if(r>=.5)for(let s=0;s!==a;++s)e[t+s]=e[i+s]}_slerp(e,t,i,r){zt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,a){let s=this._workIndex*a;zt.multiplyQuaternionsFlat(e,s,e,t,e,i),zt.slerpFlat(e,t,e,t,e,s,r)}_lerp(e,t,i,r,a){let s=1-r;for(let n=0;n!==a;++n){let o=t+n;e[o]=e[o]*s+e[i+n]*r}}_lerpAdditive(e,t,i,r,a){for(let s=0;s!==a;++s){let n=t+s;e[n]=e[n]+e[i+s]*r}}},pb="\\[\\]\\.:\\/",b6=new RegExp("["+pb+"]","g"),fb="[^"+pb+"]",w6="[^"+pb.replace("\\.","")+"]",_6=/((?:WC+[\/:])*)/.source.replace("WC",fb),S6=/(WCOD+)?/.source.replace("WCOD",w6),A6=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",fb),E6=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",fb),M6=new RegExp("^"+_6+S6+A6+E6+"$"),C6=["material","materials","bones","map"],T6=class{constructor(e,t,i){let r=i||Bi.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,a=i.length;r!==a;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Bi=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Bi.parseTrackName(t),this.node=Bi.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Bi.Composite(e,t,i):new Bi(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(b6,"")}static parseTrackName(e){let t=M6.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let a=i.nodeName.substring(r+1);C6.indexOf(a)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=a)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(a){for(let s=0;s<a.length;s++){let n=a[s];if(n.name===t||n.uuid===t)return n;let o=i(n.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,a=t.propertyIndex;if(e||(e=Bi.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let s=e[r];if(s===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let n=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?n=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(n=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(a!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[a]!==void 0&&(a=e.morphTargetDictionary[a])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=a}else s.fromArray!==void 0&&s.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][n]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Bi.Composite=T6;Bi.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Bi.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Bi.prototype.GetterByBindingType=[Bi.prototype._getValue_direct,Bi.prototype._getValue_array,Bi.prototype._getValue_arrayElement,Bi.prototype._getValue_toArray];Bi.prototype.SetterByBindingTypeAndVersioning=[[Bi.prototype._setValue_direct,Bi.prototype._setValue_direct_setNeedsUpdate,Bi.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Bi.prototype._setValue_array,Bi.prototype._setValue_array_setNeedsUpdate,Bi.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Bi.prototype._setValue_arrayElement,Bi.prototype._setValue_arrayElement_setNeedsUpdate,Bi.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Bi.prototype._setValue_fromArray,Bi.prototype._setValue_fromArray_setNeedsUpdate,Bi.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var P6=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let a=t.tracks,s=a.length,n=new Array(s),o={endingStart:zc,endingEnd:zc};for(let l=0;l!==s;++l){let h=a[l].createInterpolant(null);n[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=n,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=_T,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,a=e._clip.duration,s=a/r,n=r/a;e.warp(1,s,t),this.warp(n,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,a=r.time,s=this.timeScale,n=this._timeScaleInterpolant;n===null&&(n=r._lendControlInterpolant(),this._timeScaleInterpolant=n);let o=n.parameterPositions,l=n.sampleValues;return o[0]=a,o[1]=a+i,l[0]=e/s,l[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let a=this._startTime;if(a!==null){let o=(e-a)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let s=this._updateTime(t),n=this._updateWeight(e);if(n>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case B4:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(s),l[h].accumulateAdditive(n);break;case Jx:default:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(s),l[h].accumulate(r,n)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,a=this._loopCount,s=i===Zx;if(e===0)return a===-1?r:s&&(a&1)===1?t-r:r;if(i===wT){a===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(a===-1&&(e>=0?(a=0,this._setEndings(!0,this.repetitions===0,s)):this._setEndings(this.repetitions===0,!0,s)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,a+=Math.abs(n);let o=this.repetitions-a;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,s)}else this._setEndings(!1,!1,s);this._loopCount=a,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(s&&(a&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=kc,r.endingEnd=kc):(e?r.endingStart=this.zeroSlopeAtStart?kc:zc:r.endingStart=Wm,t?r.endingEnd=this.zeroSlopeAtEnd?kc:zc:r.endingEnd=Wm)}_scheduleFading(e,t,i){let r=this._mixer,a=r.time,s=this._weightInterpolant;s===null&&(s=r._lendControlInterpolant(),this._weightInterpolant=s);let n=s.parameterPositions,o=s.sampleValues;return n[0]=a,o[0]=t,n[1]=a+e,o[1]=i,this}},D6=new Float32Array(1),R6=class extends ua{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,a=r.length,s=e._propertyBindings,n=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let c=0;c!==a;++c){let u=r[c],d=u.name,p=h[d];if(p!==void 0)++p.referenceCount,s[c]=p;else{if(p=s[c],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,d));continue}let f=t&&t._propertyBindings[c].binding.parsedPath;p=new x6(Bi.create(i,d,f),u.ValueTypeName,u.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,d),s[c]=p}n[c].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,a=this._actionsByClip[r];this._bindAction(e,a&&a.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let a=t[i];a.useCount++===0&&(this._lendBinding(a),a.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let a=t[i];--a.useCount===0&&(a.restoreOriginalState(),this._takeBackBinding(a))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,a=this._actionsByClip,s=a[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,a[t]=s;else{let n=s.knownActions;e._byClipCacheIndex=n.length,n.push(e)}e._cacheIndex=r.length,r.push(e),s.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let a=e._clip.uuid,s=this._actionsByClip,n=s[a],o=n.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let c=n.actionByRoot,u=(e._localRoot||this._root).uuid;delete c[u],o.length===0&&delete s[a],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let a=t[i];--a.referenceCount===0&&this._removeInactiveBinding(a)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,a=this._bindings,s=r[t];s===void 0&&(s={},r[t]=s),s[i]=e,e._cacheIndex=a.length,a.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,a=i.path,s=this._bindingsByRootAndName,n=s[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete n[a],Object.keys(n).length===0&&delete s[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new tP(new Float32Array(2),new Float32Array(2),1,D6),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,a=t[r];e.__cacheIndex=r,t[r]=e,a.__cacheIndex=i,t[i]=a}clipAction(e,t,i){let r=t||this._root,a=r.uuid,s=typeof e=="string"?n1.findByName(r,e):e,n=s!==null?s.uuid:e,o=this._actionsByClip[n],l=null;if(i===void 0&&(s!==null?i=s.blendMode:i=Jx),o!==void 0){let c=o.actionByRoot[a];if(c!==void 0&&c.blendMode===i)return c;l=o.knownActions[0],s===null&&(s=l._clip)}if(s===null)return null;let h=new P6(this,s,t,i);return this._bindAction(h,l),this._addInactiveAction(h,n,a),h}existingAction(e,t){let i=t||this._root,r=i.uuid,a=typeof e=="string"?n1.findByName(i,e):e,s=a?a.uuid:e,n=this._actionsByClip[s];return n!==void 0&&n.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,a=Math.sign(e),s=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,a,s);let n=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)n[l].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,a=r[i];if(a!==void 0){let s=a.knownActions;for(let n=0,o=s.length;n!==o;++n){let l=s[n];this._deactivateAction(l);let h=l._cacheIndex,c=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,c._cacheIndex=h,t[h]=c,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let s in i){let n=i[s].actionByRoot,o=n[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,a=r[t];if(a!==void 0)for(let s in a){let n=a[s];n.restoreOriginalState(),this._removeInactiveBinding(n)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},Ve=class{constructor(e){this.value=e}clone(){return new Ve(this.value.clone===void 0?this.value:this.value.clone())}},N2=new je,nP=class{constructor(e,t,i=0,r=1/0){this.ray=new Au(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new tb,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return N2.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(N2),this}intersectObject(e,t=!0,i=[]){return l1(e,this,i,t),i.sort(z2),i}intersectObjects(e,t=!0,i=[]){for(let r=0,a=e.length;r<a;r++)l1(e[r],this,i,t);return i.sort(z2),i}};function z2(e,t){return e.distance-t.distance}function l1(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let a=e.children;for(let s=0,n=a.length;s<n;s++)l1(a[s],t,i,!0)}}var k2=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(yr(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},V2=new ae,oP=class{constructor(e=new ae(1/0,1/0),t=new ae(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=V2.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,V2).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},j2=new O,Tf=new O,Es=class{constructor(e=new O,t=new O){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){j2.subVectors(e,this.start),Tf.subVectors(this.end,this.start);let i=Tf.dot(Tf),r=Tf.dot(j2)/i;return t&&(r=yr(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},G2=new O,O6=class extends Mi{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new St,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let s=0,n=1,o=32;s<o;s++,n++){let l=s/o*Math.PI*2,h=n/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new ut(r,3));let a=new Dl({fog:!1,toneMapped:!1});this.cone=new wp(i,a),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),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),G2.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(G2),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},L6=class extends xr{constructor(e,t,i){let r=new Qc(t,4,2),a=new Dh({wireframe:!0,fog:!1,toneMapped:!1});super(r,a),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},H2=new O,Pf=new O,W2=new O,I6=class extends Mi{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new St;r.setAttribute("position",new ut([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let a=new Dl({fog:!1,toneMapped:!1});this.lightPlane=new Zm(r,a),this.add(this.lightPlane),r=new St,r.setAttribute("position",new ut([0,0,0,0,0,1],3)),this.targetLine=new Zm(r,a),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),H2.setFromMatrixPosition(this.light.matrixWorld),Pf.setFromMatrixPosition(this.light.target.matrixWorld),W2.subVectors(Pf,H2),this.lightPlane.lookAt(Pf),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(Pf),this.targetLine.scale.z=W2.length()}},Df=new O,lr=new Rh,rg=class extends wp{constructor(e){let t=new St,i=new Dl({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],a=[],s={};n("n1","n2"),n("n2","n4"),n("n4","n3"),n("n3","n1"),n("f1","f2"),n("f2","f4"),n("f4","f3"),n("f3","f1"),n("n1","f1"),n("n2","f2"),n("n3","f3"),n("n4","f4"),n("p","n1"),n("p","n2"),n("p","n3"),n("p","n4"),n("u1","u2"),n("u2","u3"),n("u3","u1"),n("c","t"),n("p","c"),n("cn1","cn2"),n("cn3","cn4"),n("cf1","cf2"),n("cf3","cf4");function n(p,f){o(p),o(f)}function o(p){r.push(0,0,0),a.push(0,0,0),s[p]===void 0&&(s[p]=[]),s[p].push(r.length/3-1)}t.setAttribute("position",new ut(r,3)),t.setAttribute("color",new ut(a,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();let l=new _t(16755200),h=new _t(16711680),c=new _t(43775),u=new _t(16777215),d=new _t(3355443);this.setColors(l,h,c,u,d)}setColors(e,t,i,r,a){let s=this.geometry.getAttribute("color");s.setXYZ(0,e.r,e.g,e.b),s.setXYZ(1,e.r,e.g,e.b),s.setXYZ(2,e.r,e.g,e.b),s.setXYZ(3,e.r,e.g,e.b),s.setXYZ(4,e.r,e.g,e.b),s.setXYZ(5,e.r,e.g,e.b),s.setXYZ(6,e.r,e.g,e.b),s.setXYZ(7,e.r,e.g,e.b),s.setXYZ(8,e.r,e.g,e.b),s.setXYZ(9,e.r,e.g,e.b),s.setXYZ(10,e.r,e.g,e.b),s.setXYZ(11,e.r,e.g,e.b),s.setXYZ(12,e.r,e.g,e.b),s.setXYZ(13,e.r,e.g,e.b),s.setXYZ(14,e.r,e.g,e.b),s.setXYZ(15,e.r,e.g,e.b),s.setXYZ(16,e.r,e.g,e.b),s.setXYZ(17,e.r,e.g,e.b),s.setXYZ(18,e.r,e.g,e.b),s.setXYZ(19,e.r,e.g,e.b),s.setXYZ(20,e.r,e.g,e.b),s.setXYZ(21,e.r,e.g,e.b),s.setXYZ(22,e.r,e.g,e.b),s.setXYZ(23,e.r,e.g,e.b),s.setXYZ(24,t.r,t.g,t.b),s.setXYZ(25,t.r,t.g,t.b),s.setXYZ(26,t.r,t.g,t.b),s.setXYZ(27,t.r,t.g,t.b),s.setXYZ(28,t.r,t.g,t.b),s.setXYZ(29,t.r,t.g,t.b),s.setXYZ(30,t.r,t.g,t.b),s.setXYZ(31,t.r,t.g,t.b),s.setXYZ(32,i.r,i.g,i.b),s.setXYZ(33,i.r,i.g,i.b),s.setXYZ(34,i.r,i.g,i.b),s.setXYZ(35,i.r,i.g,i.b),s.setXYZ(36,i.r,i.g,i.b),s.setXYZ(37,i.r,i.g,i.b),s.setXYZ(38,r.r,r.g,r.b),s.setXYZ(39,r.r,r.g,r.b),s.setXYZ(40,a.r,a.g,a.b),s.setXYZ(41,a.r,a.g,a.b),s.setXYZ(42,a.r,a.g,a.b),s.setXYZ(43,a.r,a.g,a.b),s.setXYZ(44,a.r,a.g,a.b),s.setXYZ(45,a.r,a.g,a.b),s.setXYZ(46,a.r,a.g,a.b),s.setXYZ(47,a.r,a.g,a.b),s.setXYZ(48,a.r,a.g,a.b),s.setXYZ(49,a.r,a.g,a.b),s.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;lr.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),mr("c",t,e,lr,0,0,-1),mr("t",t,e,lr,0,0,1),mr("n1",t,e,lr,-i,-r,-1),mr("n2",t,e,lr,i,-r,-1),mr("n3",t,e,lr,-i,r,-1),mr("n4",t,e,lr,i,r,-1),mr("f1",t,e,lr,-i,-r,1),mr("f2",t,e,lr,i,-r,1),mr("f3",t,e,lr,-i,r,1),mr("f4",t,e,lr,i,r,1),mr("u1",t,e,lr,i*.7,r*1.1,-1),mr("u2",t,e,lr,-i*.7,r*1.1,-1),mr("u3",t,e,lr,0,r*2,-1),mr("cf1",t,e,lr,-i,0,1),mr("cf2",t,e,lr,i,0,1),mr("cf3",t,e,lr,0,-r,1),mr("cf4",t,e,lr,0,r,1),mr("cn1",t,e,lr,-i,0,-1),mr("cn2",t,e,lr,i,0,-1),mr("cn3",t,e,lr,0,-r,-1),mr("cn4",t,e,lr,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function mr(e,t,i,r,a,s,n){Df.set(a,s,n).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,c=o.length;h<c;h++)l.setXYZ(o[h],Df.x,Df.y,Df.z)}}var ag=class extends wp{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],a=new St;a.setIndex(new Ut(i,1)),a.setAttribute("position",new ut(r,3)),super(a,new Dl({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},B6=class extends wp{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new St;r.setAttribute("position",new ut(t,3)),r.setAttribute("color",new ut(i,3));let a=new Dl({vertexColors:!0,toneMapped:!1});super(r,a),this.type="AxesHelper"}setColors(e,t,i){let r=new _t,a=this.geometry.attributes.color.array;return r.set(e),r.toArray(a,0),r.toArray(a,3),r.set(t),r.toArray(a,6),r.toArray(a,9),r.set(i),r.toArray(a,12),r.toArray(a,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:Su}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Su);var hd=".",mb=Symbol("target"),lP=Symbol("unsubscribe");function h1(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function U6(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var _n=Array.isArray;function gb(e){return typeof e=="symbol"}var F6={after:(e,t)=>_n(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>_n(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=hd),gb(t)?e+t.toString():e+t):e,initial:e=>{if(_n(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(hd);return t===-1?"":e.slice(0,t)},last:e=>{if(_n(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(hd);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(_n(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(hd);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(hd,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},xs=F6;function N6(e){return typeof e=="object"&&typeof e.next=="function"}function z6(e,t,i,r,a){let s=e.next;if(t.name==="entries")e.next=function(){let n=s.call(this);return n.done===!1&&(n.value[0]=a(n.value[0],t,n.value[0],r),n.value[1]=a(n.value[1],t,n.value[0],r)),n};else if(t.name==="values"){let n=i[mb].keys();e.next=function(){let o=s.call(this);return o.done===!1&&(o.value=a(o.value,t,n.next().value,r)),o}}else e.next=function(){let n=s.call(this);return n.done===!1&&(n.value=a(n.value,t,n.value,r)),n};return e}function q2(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&gb(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var k6=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let a=e[r],s=a||e;this._pathCache.set(s,t);let n=this._proxyCache.get(s);return n===void 0&&(n=a===void 0?new Proxy(e,i):e,this._proxyCache.set(s,n)),n}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,xs.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,a){if(!this._equals(a,i)||!(t in e)){let s=this._getOwnPropertyDescriptor(e,t);return s!==void 0&&"set"in s?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function c1(e){return toString.call(e)==="[object Object]"}function Rf(){return!0}function fc(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var hP=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),V6=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),cP={push:Rf,pop:Rf,shift:Rf,unshift:Rf,copyWithin:fc,reverse:fc,sort:fc,splice:fc,flat:fc,fill:fc},j6=new Set([...hP,...V6,...Object.keys(cP)]);function Of(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var uP=["keys","values","entries"],dP=new Set(["has","toString"]),pP={add:Of,clear:Of,delete:Of,forEach:Of},G6=new Set([...dP,...Object.keys(pP),...uP]);function Lf(e,t){if(e.size!==t.size)return!0;let i;for(let[r,a]of e)if(i=t.get(r),i!==a||i===void 0&&!t.has(r))return!0;return!1}var H6=new Set([...dP,"get"]),fP={set:Lf,clear:Lf,delete:Lf,forEach:Lf},W6=new Set([...H6,...Object.keys(fP),...uP]),Cl=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return hP.has(e)}_shallowClone(e){let t=e;if(c1(e))t={...e};else if(_n(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(_n(r)?this._onIsChanged=cP[t]:r instanceof Set?this._onIsChanged=pP[t]:r instanceof Map&&(this._onIsChanged=fP[t]),r):i}update(e,t,i){let r=xs.after(e,this._path);if(t!=="length"){let a=this.clone;xs.walk(r,s=>{a&&a[s]&&(this._clonedCache.has(a[s])||(a[s]=this._shallowClone(a[s])),a=a[s])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),a&&a[t]&&(a[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],xs.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},X2=class extends Cl{static isHandledMethod(e){return j6.has(e)}},q6=class extends Cl{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},Y2=class extends Cl{static isHandledMethod(e){return G6.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},Q2=class extends Cl{static isHandledMethod(e){return W6.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},X6=class extends Cl{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},Y6=class extends Cl{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},Lc=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return c1(e)||_n(e)||h1(e)}static isHandledMethod(e,t){return c1(e)?Cl.isHandledMethod(t):_n(e)?X2.isHandledMethod(t):e instanceof Set?Y2.isHandledMethod(t):e instanceof Map?Q2.isHandledMethod(t):h1(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=Cl;_n(e)?r=X2:e instanceof Date?r=q6:e instanceof Set?r=Y2:e instanceof Map?r=Q2:e instanceof WeakSet?r=X6:e instanceof WeakMap&&(r=Y6),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,a=Lc.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(a,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},Q6={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},vb=(e,t,i={})=>{i={...Q6,...i};let r=Symbol("ProxyTarget"),{equals:a,isShallow:s,ignoreDetached:n,details:o}=i,l=new k6(a),h=typeof i.onValidate=="function",c=new Lc(h),u=(x,b,_,M,A)=>!h||c.isCloning||i.onValidate(xs.concat(l.getPath(x),b),_,M,A)===!0,d=(x,b,_,M)=>{!q2(l,i,b)&&!(n&&l.isDetached(x,e))&&p(l.getPath(x),b,_,M)},p=(x,b,_,M,A)=>{c.isCloning?c.update(x,b,M):t(xs.concat(x,b),_,M,A)},f=x=>x&&(x[r]||x),m=(x,b,_,M)=>U6(x)||_==="constructor"||s&&!Lc.isHandledMethod(b,_)||q2(l,i,_)||l.isGetInvariant(b,_)||n&&l.isDetached(b,e)?x:(M===void 0&&(M=l.getPath(b)),l.getProxy(x,xs.concat(M,_),g,r)),g={get(x,b,_){if(gb(b)){if(b===r||b===mb)return x;if(b===lP&&!l.isUnsubscribed&&l.getPath(x).length===0)return l.unsubscribe(),x}let M=h1(x)?Reflect.get(x,b):Reflect.get(x,b,_);return m(M,x,b)},set(x,b,_,M){_=f(_);let A=x[r]||x,S=A[b];if(a(S,_)&&b in x)return!0;let P=u(x,b,_,S);return P&&l.setProperty(A,b,_,M,S)?(d(x,b,x[b],S),!0):!P},defineProperty(x,b,_){if(!l.isSameDescriptor(_,x,b)){let M=x[b];u(x,b,_.value,M)&&l.defineProperty(x,b,_,M)&&d(x,b,_.value,M)}return!0},deleteProperty(x,b){if(!Reflect.has(x,b))return!0;let _=Reflect.get(x,b),M=u(x,b,void 0,_);return M&&l.deleteProperty(x,b,_)?(d(x,b,void 0,_),!0):!M},apply(x,b,_){let M=b[r]||b;if(l.isUnsubscribed)return Reflect.apply(x,M,_);if((o===!1||o!==!0&&!o.includes(x.name))&&Lc.isHandledType(M)){let A=xs.initial(l.getPath(x)),S=Lc.isHandledMethod(M,x.name);c.start(M,A,_);let P=Reflect.apply(x,c.preferredThisArg(x,b,M),S?_.map(T=>f(T)):_),L=c.isChanged(M,a),E=c.stop();if(Lc.isHandledType(P)&&S&&(b instanceof Map&&x.name==="get"&&(A=xs.concat(A,_[0])),P=l.getProxy(P,A,g)),L){let T={name:x.name,args:_,result:P},B=c.isCloning?xs.initial(A):A,V=c.isCloning?xs.last(A):"";u(xs.get(e,B),V,M,E,T)?p(B,V,M,E,T):c.undo(M)}return(b instanceof Map||b instanceof Set)&&N6(P)?z6(P,x,b,A,m):P}return Reflect.apply(x,b,_)}},v=l.getProxy(e,i.pathAsArray?[]:"",g);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};vb.target=e=>e&&e[mb]||e;vb.unsubscribe=e=>e[lP]||e;var K2=vb,K6=typeof global=="object"&&global&&global.Object===Object&&global,mP=K6,Z6=typeof self=="object"&&self&&self.Object===Object&&self,J6=mP||Z6||Function("return this")(),Js=J6,$6=Js.Symbol,Ts=$6,gP=Object.prototype,eV=gP.hasOwnProperty,tV=gP.toString,cd=Ts?Ts.toStringTag:void 0;function iV(e){var t=eV.call(e,cd),i=e[cd];try{e[cd]=void 0;var r=!0}catch{}var a=tV.call(e);return r&&(t?e[cd]=i:delete e[cd]),a}var rV=iV,aV=Object.prototype,sV=aV.toString;function nV(e){return sV.call(e)}var oV=nV,lV="[object Null]",hV="[object Undefined]",Z2=Ts?Ts.toStringTag:void 0;function cV(e){return e==null?e===void 0?hV:lV:Z2&&Z2 in Object(e)?rV(e):oV(e)}var Oh=cV;function uV(e){return e!=null&&typeof e=="object"}var Co=uV,dV="[object Symbol]";function pV(e){return typeof e=="symbol"||Co(e)&&Oh(e)==dV}var $g=pV;function fV(e,t){for(var i=-1,r=e==null?0:e.length,a=Array(r);++i<r;)a[i]=t(e[i],i,e);return a}var vP=fV,mV=Array.isArray,On=mV,gV=1/0,J2=Ts?Ts.prototype:void 0,$2=J2?J2.toString:void 0;function yP(e){if(typeof e=="string")return e;if(On(e))return vP(e,yP)+"";if($g(e))return $2?$2.call(e):"";var t=e+"";return t=="0"&&1/e==-gV?"-0":t}var vV=yP,yV=/\s/;function xV(e){for(var t=e.length;t--&&yV.test(e.charAt(t)););return t}var bV=xV,wV=/^\s+/;function _V(e){return e&&e.slice(0,bV(e)+1).replace(wV,"")}var SV=_V;function AV(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Zs=AV,eA=0/0,EV=/^[-+]0x[0-9a-f]+$/i,MV=/^0b[01]+$/i,CV=/^0o[0-7]+$/i,TV=parseInt;function PV(e){if(typeof e=="number")return e;if($g(e))return eA;if(Zs(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Zs(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=SV(e);var i=MV.test(e);return i||CV.test(e)?TV(e.slice(2),i?2:8):EV.test(e)?eA:+e}var tA=PV;function DV(e){return e}var RV=DV,OV="[object AsyncFunction]",LV="[object Function]",IV="[object GeneratorFunction]",BV="[object Proxy]";function UV(e){if(!Zs(e))return!1;var t=Oh(e);return t==LV||t==IV||t==OV||t==BV}var xP=UV,FV=Js["__core-js_shared__"],D0=FV,iA=function(){var e=/[^.]+$/.exec(D0&&D0.keys&&D0.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function NV(e){return!!iA&&iA in e}var zV=NV,kV=Function.prototype,VV=kV.toString;function jV(e){if(e!=null){try{return VV.call(e)}catch{}try{return e+""}catch{}}return""}var Lh=jV,GV=/[\\^$.*+?()[\]{}|]/g,HV=/^\[object .+?Constructor\]$/,WV=Function.prototype,qV=Object.prototype,XV=WV.toString,YV=qV.hasOwnProperty,QV=RegExp("^"+XV.call(YV).replace(GV,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function KV(e){if(!Zs(e)||zV(e))return!1;var t=xP(e)?QV:HV;return t.test(Lh(e))}var ZV=KV;function JV(e,t){return e?.[t]}var $V=JV;function e8(e,t){var i=$V(e,t);return ZV(i)?i:void 0}var Ih=e8,t8=Ih(Js,"WeakMap"),u1=t8,rA=Object.create,i8=function(){function e(){}return function(t){if(!Zs(t))return{};if(rA)return rA(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),r8=i8;function a8(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var s8=a8;function n8(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var o8=n8,l8=800,h8=16,c8=Date.now;function u8(e){var t=0,i=0;return function(){var r=c8(),a=h8-(r-i);if(i=r,a>0){if(++t>=l8)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var d8=u8;function p8(e){return function(){return e}}var f8=p8,m8=function(){try{var e=Ih(Object,"defineProperty");return e({},"",{}),e}catch{}}(),sg=m8,g8=sg?function(e,t){return sg(e,"toString",{configurable:!0,enumerable:!1,value:f8(t),writable:!0})}:RV,v8=g8,y8=d8(v8),x8=y8;function b8(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var w8=b8,_8=9007199254740991,S8=/^(?:0|[1-9]\d*)$/;function A8(e,t){var i=typeof e;return t=t??_8,!!t&&(i=="number"||i!="symbol"&&S8.test(e))&&e>-1&&e%1==0&&e<t}var yb=A8;function E8(e,t,i){t=="__proto__"&&sg?sg(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var bP=E8;function M8(e,t){return e===t||e!==e&&t!==t}var xb=M8,C8=Object.prototype,T8=C8.hasOwnProperty;function P8(e,t,i){var r=e[t];(!(T8.call(e,t)&&xb(r,i))||i===void 0&&!(t in e))&&bP(e,t,i)}var bb=P8;function D8(e,t,i,r){var a=!i;i||(i={});for(var s=-1,n=t.length;++s<n;){var o=t[s],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),a?bP(i,o,l):bb(i,o,l)}return i}var Ap=D8,aA=Math.max;function R8(e,t,i){return t=aA(t===void 0?e.length-1:t,0),function(){for(var r=arguments,a=-1,s=aA(r.length-t,0),n=Array(s);++a<s;)n[a]=r[t+a];a=-1;for(var o=Array(t+1);++a<t;)o[a]=r[a];return o[t]=i(n),s8(e,this,o)}}var O8=R8,L8=9007199254740991;function I8(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=L8}var wb=I8;function B8(e){return e!=null&&wb(e.length)&&!xP(e)}var wP=B8,U8=Object.prototype;function F8(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||U8;return e===i}var _b=F8;function N8(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var z8=N8,k8="[object Arguments]";function V8(e){return Co(e)&&Oh(e)==k8}var sA=V8,_P=Object.prototype,j8=_P.hasOwnProperty,G8=_P.propertyIsEnumerable,H8=sA(function(){return arguments}())?sA:function(e){return Co(e)&&j8.call(e,"callee")&&!G8.call(e,"callee")},Sb=H8;function W8(){return!1}var q8=W8,SP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,nA=SP&&typeof module=="object"&&module&&!module.nodeType&&module,X8=nA&&nA.exports===SP,oA=X8?Js.Buffer:void 0,Y8=oA?oA.isBuffer:void 0,Q8=Y8||q8,ng=Q8,K8="[object Arguments]",Z8="[object Array]",J8="[object Boolean]",$8="[object Date]",ej="[object Error]",tj="[object Function]",ij="[object Map]",rj="[object Number]",aj="[object Object]",sj="[object RegExp]",nj="[object Set]",oj="[object String]",lj="[object WeakMap]",hj="[object ArrayBuffer]",cj="[object DataView]",uj="[object Float32Array]",dj="[object Float64Array]",pj="[object Int8Array]",fj="[object Int16Array]",mj="[object Int32Array]",gj="[object Uint8Array]",vj="[object Uint8ClampedArray]",yj="[object Uint16Array]",xj="[object Uint32Array]",Wi={};Wi[uj]=Wi[dj]=Wi[pj]=Wi[fj]=Wi[mj]=Wi[gj]=Wi[vj]=Wi[yj]=Wi[xj]=!0;Wi[K8]=Wi[Z8]=Wi[hj]=Wi[J8]=Wi[cj]=Wi[$8]=Wi[ej]=Wi[tj]=Wi[ij]=Wi[rj]=Wi[aj]=Wi[sj]=Wi[nj]=Wi[oj]=Wi[lj]=!1;function bj(e){return Co(e)&&wb(e.length)&&!!Wi[Oh(e)]}var wj=bj;function _j(e){return function(t){return e(t)}}var Ab=_j,AP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,jd=AP&&typeof module=="object"&&module&&!module.nodeType&&module,Sj=jd&&jd.exports===AP,R0=Sj&&mP.process,Aj=function(){try{var e=jd&&jd.require&&jd.require("util").types;return e||R0&&R0.binding&&R0.binding("util")}catch{}}(),uu=Aj,lA=uu&&uu.isTypedArray,Ej=lA?Ab(lA):wj,EP=Ej,Mj=Object.prototype,Cj=Mj.hasOwnProperty;function Tj(e,t){var i=On(e),r=!i&&Sb(e),a=!i&&!r&&ng(e),s=!i&&!r&&!a&&EP(e),n=i||r||a||s,o=n?z8(e.length,String):[],l=o.length;for(var h in e)(t||Cj.call(e,h))&&!(n&&(h=="length"||a&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||yb(h,l)))&&o.push(h);return o}var MP=Tj;function Pj(e,t){return function(i){return e(t(i))}}var CP=Pj,Dj=CP(Object.keys,Object),Rj=Dj,Oj=Object.prototype,Lj=Oj.hasOwnProperty;function Ij(e){if(!_b(e))return Rj(e);var t=[];for(var i in Object(e))Lj.call(e,i)&&i!="constructor"&&t.push(i);return t}var Bj=Ij;function Uj(e){return wP(e)?MP(e):Bj(e)}var Eb=Uj;function Fj(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var Nj=Fj,zj=Object.prototype,kj=zj.hasOwnProperty;function Vj(e){if(!Zs(e))return Nj(e);var t=_b(e),i=[];for(var r in e)r=="constructor"&&(t||!kj.call(e,r))||i.push(r);return i}var jj=Vj;function Gj(e){return wP(e)?MP(e,!0):jj(e)}var oh=Gj,Hj=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Wj=/^\w*$/;function qj(e,t){if(On(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||$g(e)?!0:Wj.test(e)||!Hj.test(e)||t!=null&&e in Object(t)}var Xj=qj,Yj=Ih(Object,"create"),ip=Yj;function Qj(){this.__data__=ip?ip(null):{},this.size=0}var Kj=Qj;function Zj(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Jj=Zj,$j="__lodash_hash_undefined__",eG=Object.prototype,tG=eG.hasOwnProperty;function iG(e){var t=this.__data__;if(ip){var i=t[e];return i===$j?void 0:i}return tG.call(t,e)?t[e]:void 0}var rG=iG,aG=Object.prototype,sG=aG.hasOwnProperty;function nG(e){var t=this.__data__;return ip?t[e]!==void 0:sG.call(t,e)}var oG=nG,lG="__lodash_hash_undefined__";function hG(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=ip&&t===void 0?lG:t,this}var cG=hG;function Du(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Du.prototype.clear=Kj;Du.prototype.delete=Jj;Du.prototype.get=rG;Du.prototype.has=oG;Du.prototype.set=cG;var hA=Du;function uG(){this.__data__=[],this.size=0}var dG=uG;function pG(e,t){for(var i=e.length;i--;)if(xb(e[i][0],t))return i;return-1}var ev=pG,fG=Array.prototype,mG=fG.splice;function gG(e){var t=this.__data__,i=ev(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():mG.call(t,i,1),--this.size,!0}var vG=gG;function yG(e){var t=this.__data__,i=ev(t,e);return i<0?void 0:t[i][1]}var xG=yG;function bG(e){return ev(this.__data__,e)>-1}var wG=bG;function _G(e,t){var i=this.__data__,r=ev(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var SG=_G;function Ru(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Ru.prototype.clear=dG;Ru.prototype.delete=vG;Ru.prototype.get=xG;Ru.prototype.has=wG;Ru.prototype.set=SG;var tv=Ru,AG=Ih(Js,"Map"),rp=AG;function EG(){this.size=0,this.__data__={hash:new hA,map:new(rp||tv),string:new hA}}var MG=EG;function CG(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var TG=CG;function PG(e,t){var i=e.__data__;return TG(t)?i[typeof t=="string"?"string":"hash"]:i.map}var iv=PG;function DG(e){var t=iv(this,e).delete(e);return this.size-=t?1:0,t}var RG=DG;function OG(e){return iv(this,e).get(e)}var LG=OG;function IG(e){return iv(this,e).has(e)}var BG=IG;function UG(e,t){var i=iv(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var FG=UG;function Ou(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Ou.prototype.clear=MG;Ou.prototype.delete=RG;Ou.prototype.get=LG;Ou.prototype.has=BG;Ou.prototype.set=FG;var rv=Ou,NG="Expected a function";function Mb(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(NG);var i=function(){var r=arguments,a=t?t.apply(this,r):r[0],s=i.cache;if(s.has(a))return s.get(a);var n=e.apply(this,r);return i.cache=s.set(a,n)||s,n};return i.cache=new(Mb.Cache||rv),i}Mb.Cache=rv;var zG=Mb,kG=500;function VG(e){var t=zG(e,function(r){return i.size===kG&&i.clear(),r}),i=t.cache;return t}var jG=VG,GG=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,HG=/\\(\\)?/g,WG=jG(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(GG,function(i,r,a,s){t.push(a?s.replace(HG,"$1"):r||i)}),t}),qG=WG;function XG(e){return e==null?"":vV(e)}var YG=XG;function QG(e,t){return On(e)?e:Xj(e,t)?[e]:qG(YG(e))}var Lu=QG,KG=1/0;function ZG(e){if(typeof e=="string"||$g(e))return e;var t=e+"";return t=="0"&&1/e==-KG?"-0":t}var av=ZG;function JG(e,t){t=Lu(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[av(t[i++])];return i&&i==r?e:void 0}var TP=JG;function $G(e,t){for(var i=-1,r=t.length,a=e.length;++i<r;)e[a+i]=t[i];return e}var Cb=$G,cA=Ts?Ts.isConcatSpreadable:void 0;function eH(e){return On(e)||Sb(e)||!!(cA&&e&&e[cA])}var tH=eH;function PP(e,t,i,r,a){var s=-1,n=e.length;for(i||(i=tH),a||(a=[]);++s<n;){var o=e[s];t>0&&i(o)?t>1?PP(o,t-1,i,r,a):Cb(a,o):r||(a[a.length]=o)}return a}var iH=PP;function rH(e){var t=e==null?0:e.length;return t?iH(e,1):[]}var aH=rH;function sH(e){return x8(O8(e,void 0,aH),e+"")}var DP=sH,nH=CP(Object.getPrototypeOf,Object),Tb=nH,oH="[object Object]",lH=Function.prototype,hH=Object.prototype,RP=lH.toString,cH=hH.hasOwnProperty,uH=RP.call(Object);function dH(e){if(!Co(e)||Oh(e)!=oH)return!1;var t=Tb(e);if(t===null)return!0;var i=cH.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&RP.call(i)==uH}var pH=dH;function fH(e,t,i){var r=-1,a=e.length;t<0&&(t=-t>a?0:a+t),i=i>a?a:i,i<0&&(i+=a),a=t>i?0:i-t>>>0,t>>>=0;for(var s=Array(a);++r<a;)s[r]=e[r+t];return s}var mH=fH;function gH(){this.__data__=new tv,this.size=0}var vH=gH;function yH(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var xH=yH;function bH(e){return this.__data__.get(e)}var wH=bH;function _H(e){return this.__data__.has(e)}var SH=_H,AH=200;function EH(e,t){var i=this.__data__;if(i instanceof tv){var r=i.__data__;if(!rp||r.length<AH-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new rv(r)}return i.set(e,t),this.size=i.size,this}var MH=EH;function Iu(e){var t=this.__data__=new tv(e);this.size=t.size}Iu.prototype.clear=vH;Iu.prototype.delete=xH;Iu.prototype.get=wH;Iu.prototype.has=SH;Iu.prototype.set=MH;var Tm=Iu;function CH(e,t){return e&&Ap(t,Eb(t),e)}var TH=CH;function PH(e,t){return e&&Ap(t,oh(t),e)}var DH=PH,OP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,uA=OP&&typeof module=="object"&&module&&!module.nodeType&&module,RH=uA&&uA.exports===OP,dA=RH?Js.Buffer:void 0,pA=dA?dA.allocUnsafe:void 0;function OH(e,t){if(t)return e.slice();var i=e.length,r=pA?pA(i):new e.constructor(i);return e.copy(r),r}var LH=OH;function IH(e,t){for(var i=-1,r=e==null?0:e.length,a=0,s=[];++i<r;){var n=e[i];t(n,i,e)&&(s[a++]=n)}return s}var BH=IH;function UH(){return[]}var LP=UH,FH=Object.prototype,NH=FH.propertyIsEnumerable,fA=Object.getOwnPropertySymbols,zH=fA?function(e){return e==null?[]:(e=Object(e),BH(fA(e),function(t){return NH.call(e,t)}))}:LP,Pb=zH;function kH(e,t){return Ap(e,Pb(e),t)}var VH=kH,jH=Object.getOwnPropertySymbols,GH=jH?function(e){for(var t=[];e;)Cb(t,Pb(e)),e=Tb(e);return t}:LP,IP=GH;function HH(e,t){return Ap(e,IP(e),t)}var WH=HH;function qH(e,t,i){var r=t(e);return On(e)?r:Cb(r,i(e))}var BP=qH;function XH(e){return BP(e,Eb,Pb)}var d1=XH;function YH(e){return BP(e,oh,IP)}var UP=YH,QH=Ih(Js,"DataView"),p1=QH,KH=Ih(Js,"Promise"),f1=KH,ZH=Ih(Js,"Set"),m1=ZH,mA="[object Map]",JH="[object Object]",gA="[object Promise]",vA="[object Set]",yA="[object WeakMap]",xA="[object DataView]",$H=Lh(p1),eW=Lh(rp),tW=Lh(f1),iW=Lh(m1),rW=Lh(u1),Zl=Oh;(p1&&Zl(new p1(new ArrayBuffer(1)))!=xA||rp&&Zl(new rp)!=mA||f1&&Zl(f1.resolve())!=gA||m1&&Zl(new m1)!=vA||u1&&Zl(new u1)!=yA)&&(Zl=function(e){var t=Oh(e),i=t==JH?e.constructor:void 0,r=i?Lh(i):"";if(r)switch(r){case $H:return xA;case eW:return mA;case tW:return gA;case iW:return vA;case rW:return yA}return t});var ap=Zl,aW=Object.prototype,sW=aW.hasOwnProperty;function nW(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&sW.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var oW=nW,lW=Js.Uint8Array,og=lW;function hW(e){var t=new e.constructor(e.byteLength);return new og(t).set(new og(e)),t}var Db=hW;function cW(e,t){var i=t?Db(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var uW=cW,dW=/\w*$/;function pW(e){var t=new e.constructor(e.source,dW.exec(e));return t.lastIndex=e.lastIndex,t}var fW=pW,bA=Ts?Ts.prototype:void 0,wA=bA?bA.valueOf:void 0;function mW(e){return wA?Object(wA.call(e)):{}}var gW=mW;function vW(e,t){var i=t?Db(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var yW=vW,xW="[object Boolean]",bW="[object Date]",wW="[object Map]",_W="[object Number]",SW="[object RegExp]",AW="[object Set]",EW="[object String]",MW="[object Symbol]",CW="[object ArrayBuffer]",TW="[object DataView]",PW="[object Float32Array]",DW="[object Float64Array]",RW="[object Int8Array]",OW="[object Int16Array]",LW="[object Int32Array]",IW="[object Uint8Array]",BW="[object Uint8ClampedArray]",UW="[object Uint16Array]",FW="[object Uint32Array]";function NW(e,t,i){var r=e.constructor;switch(t){case CW:return Db(e);case xW:case bW:return new r(+e);case TW:return uW(e,i);case PW:case DW:case RW:case OW:case LW:case IW:case BW:case UW:case FW:return yW(e,i);case wW:return new r;case _W:case EW:return new r(e);case SW:return fW(e);case AW:return new r;case MW:return gW(e)}}var zW=NW;function kW(e){return typeof e.constructor=="function"&&!_b(e)?r8(Tb(e)):{}}var VW=kW,jW="[object Map]";function GW(e){return Co(e)&&ap(e)==jW}var HW=GW,_A=uu&&uu.isMap,WW=_A?Ab(_A):HW,qW=WW,XW="[object Set]";function YW(e){return Co(e)&&ap(e)==XW}var QW=YW,SA=uu&&uu.isSet,KW=SA?Ab(SA):QW,ZW=KW,JW=1,$W=2,e9=4,FP="[object Arguments]",t9="[object Array]",i9="[object Boolean]",r9="[object Date]",a9="[object Error]",NP="[object Function]",s9="[object GeneratorFunction]",n9="[object Map]",o9="[object Number]",zP="[object Object]",l9="[object RegExp]",h9="[object Set]",c9="[object String]",u9="[object Symbol]",d9="[object WeakMap]",p9="[object ArrayBuffer]",f9="[object DataView]",m9="[object Float32Array]",g9="[object Float64Array]",v9="[object Int8Array]",y9="[object Int16Array]",x9="[object Int32Array]",b9="[object Uint8Array]",w9="[object Uint8ClampedArray]",_9="[object Uint16Array]",S9="[object Uint32Array]",Vi={};Vi[FP]=Vi[t9]=Vi[p9]=Vi[f9]=Vi[i9]=Vi[r9]=Vi[m9]=Vi[g9]=Vi[v9]=Vi[y9]=Vi[x9]=Vi[n9]=Vi[o9]=Vi[zP]=Vi[l9]=Vi[h9]=Vi[c9]=Vi[u9]=Vi[b9]=Vi[w9]=Vi[_9]=Vi[S9]=!0;Vi[a9]=Vi[NP]=Vi[d9]=!1;function Pm(e,t,i,r,a,s){var n,o=t&JW,l=t&$W,h=t&e9;if(i&&(n=a?i(e,r,a,s):i(e)),n!==void 0)return n;if(!Zs(e))return e;var c=On(e);if(c){if(n=oW(e),!o)return o8(e,n)}else{var u=ap(e),d=u==NP||u==s9;if(ng(e))return LH(e,o);if(u==zP||u==FP||d&&!a){if(n=l||d?{}:VW(e),!o)return l?WH(e,DH(n,e)):VH(e,TH(n,e))}else{if(!Vi[u])return a?e:{};n=zW(e,u,o)}}s||(s=new Tm);var p=s.get(e);if(p)return p;s.set(e,n),ZW(e)?e.forEach(function(g){n.add(Pm(g,t,i,g,e,s))}):qW(e)&&e.forEach(function(g,v){n.set(v,Pm(g,t,i,v,e,s))});var f=h?l?UP:d1:l?oh:Eb,m=c?void 0:f(e);return w8(m||e,function(g,v){m&&(v=g,g=e[v]),bb(n,v,Pm(g,t,i,v,e,s))}),n}var kP=Pm,A9=1,E9=4;function M9(e){return kP(e,A9|E9)}var sv=M9,C9="__lodash_hash_undefined__";function T9(e){return this.__data__.set(e,C9),this}var P9=T9;function D9(e){return this.__data__.has(e)}var R9=D9;function lg(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new rv;++t<i;)this.add(e[t])}lg.prototype.add=lg.prototype.push=P9;lg.prototype.has=R9;var O9=lg;function L9(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var I9=L9;function B9(e,t){return e.has(t)}var U9=B9,F9=1,N9=2;function z9(e,t,i,r,a,s){var n=i&F9,o=e.length,l=t.length;if(o!=l&&!(n&&l>o))return!1;var h=s.get(e),c=s.get(t);if(h&&c)return h==t&&c==e;var u=-1,d=!0,p=i&N9?new O9:void 0;for(s.set(e,t),s.set(t,e);++u<o;){var f=e[u],m=t[u];if(r)var g=n?r(m,f,u,t,e,s):r(f,m,u,e,t,s);if(g!==void 0){if(g)continue;d=!1;break}if(p){if(!I9(t,function(v,x){if(!U9(p,x)&&(f===v||a(f,v,i,r,s)))return p.push(x)})){d=!1;break}}else if(!(f===m||a(f,m,i,r,s))){d=!1;break}}return s.delete(e),s.delete(t),d}var VP=z9;function k9(e){var t=-1,i=Array(e.size);return e.forEach(function(r,a){i[++t]=[a,r]}),i}var V9=k9;function j9(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var G9=j9,H9=1,W9=2,q9="[object Boolean]",X9="[object Date]",Y9="[object Error]",Q9="[object Map]",K9="[object Number]",Z9="[object RegExp]",J9="[object Set]",$9="[object String]",e7="[object Symbol]",t7="[object ArrayBuffer]",i7="[object DataView]",AA=Ts?Ts.prototype:void 0,O0=AA?AA.valueOf:void 0;function r7(e,t,i,r,a,s,n){switch(i){case i7:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case t7:return!(e.byteLength!=t.byteLength||!s(new og(e),new og(t)));case q9:case X9:case K9:return xb(+e,+t);case Y9:return e.name==t.name&&e.message==t.message;case Z9:case $9:return e==t+"";case Q9:var o=V9;case J9:var l=r&H9;if(o||(o=G9),e.size!=t.size&&!l)return!1;var h=n.get(e);if(h)return h==t;r|=W9,n.set(e,t);var c=VP(o(e),o(t),r,a,s,n);return n.delete(e),c;case e7:if(O0)return O0.call(e)==O0.call(t)}return!1}var a7=r7,s7=1,n7=Object.prototype,o7=n7.hasOwnProperty;function l7(e,t,i,r,a,s){var n=i&s7,o=d1(e),l=o.length,h=d1(t),c=h.length;if(l!=c&&!n)return!1;for(var u=l;u--;){var d=o[u];if(!(n?d in t:o7.call(t,d)))return!1}var p=s.get(e),f=s.get(t);if(p&&f)return p==t&&f==e;var m=!0;s.set(e,t),s.set(t,e);for(var g=n;++u<l;){d=o[u];var v=e[d],x=t[d];if(r)var b=n?r(x,v,d,t,e,s):r(v,x,d,e,t,s);if(!(b===void 0?v===x||a(v,x,i,r,s):b)){m=!1;break}g||(g=d=="constructor")}if(m&&!g){var _=e.constructor,M=t.constructor;_!=M&&"constructor"in e&&"constructor"in t&&!(typeof _=="function"&&_ instanceof _&&typeof M=="function"&&M instanceof M)&&(m=!1)}return s.delete(e),s.delete(t),m}var h7=l7,c7=1,EA="[object Arguments]",MA="[object Array]",If="[object Object]",u7=Object.prototype,CA=u7.hasOwnProperty;function d7(e,t,i,r,a,s){var n=On(e),o=On(t),l=n?MA:ap(e),h=o?MA:ap(t);l=l==EA?If:l,h=h==EA?If:h;var c=l==If,u=h==If,d=l==h;if(d&&ng(e)){if(!ng(t))return!1;n=!0,c=!1}if(d&&!c)return s||(s=new Tm),n||EP(e)?VP(e,t,i,r,a,s):a7(e,t,l,i,r,a,s);if(!(i&c7)){var p=c&&CA.call(e,"__wrapped__"),f=u&&CA.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,g=f?t.value():t;return s||(s=new Tm),a(m,g,i,r,s)}}return d?(s||(s=new Tm),h7(e,t,i,r,a,s)):!1}var p7=d7;function jP(e,t,i,r,a){return e===t?!0:e==null||t==null||!Co(e)&&!Co(t)?e!==e&&t!==t:p7(e,t,i,r,jP,a)}var f7=jP;function m7(e,t){return e!=null&&t in Object(e)}var g7=m7;function v7(e,t,i){t=Lu(t,e);for(var r=-1,a=t.length,s=!1;++r<a;){var n=av(t[r]);if(!(s=e!=null&&i(e,n)))break;e=e[n]}return s||++r!=a?s:(a=e==null?0:e.length,!!a&&wb(a)&&yb(n,a)&&(On(e)||Sb(e)))}var y7=v7;function x7(e,t){return e!=null&&y7(e,t,g7)}var b7=x7,w7=function(){return Js.Date.now()},L0=w7,_7="Expected a function",S7=Math.max,A7=Math.min;function E7(e,t,i){var r,a,s,n,o,l,h=0,c=!1,u=!1,d=!0;if(typeof e!="function")throw new TypeError(_7);t=tA(t)||0,Zs(i)&&(c=!!i.leading,u="maxWait"in i,s=u?S7(tA(i.maxWait)||0,t):s,d="trailing"in i?!!i.trailing:d);function p(A){var S=r,P=a;return r=a=void 0,h=A,n=e.apply(P,S),n}function f(A){return h=A,o=setTimeout(v,t),c?p(A):n}function m(A){var S=A-l,P=A-h,L=t-S;return u?A7(L,s-P):L}function g(A){var S=A-l,P=A-h;return l===void 0||S>=t||S<0||u&&P>=s}function v(){var A=L0();if(g(A))return x(A);o=setTimeout(v,m(A))}function x(A){return o=void 0,d&&r?p(A):(r=a=void 0,n)}function b(){o!==void 0&&clearTimeout(o),h=0,r=l=a=o=void 0}function _(){return o===void 0?n:x(L0())}function M(){var A=L0(),S=g(A);if(r=arguments,a=this,l=A,S){if(o===void 0)return f(l);if(u)return clearTimeout(o),o=setTimeout(v,t),p(l)}return o===void 0&&(o=setTimeout(v,t)),n}return M.cancel=b,M.flush=_,M}var Rb=E7;function M7(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var C7=M7;function T7(e,t){return t.length<2?e:TP(e,mH(t,0,-1))}var P7=T7;function D7(e,t){return f7(e,t)}var GP=D7;function R7(e,t){return t=Lu(t,e),e=P7(e,t),e==null||delete e[av(C7(t))]}var O7=R7;function L7(e){return pH(e)?void 0:e}var I7=L7,B7=1,U7=2,F7=4,N7=DP(function(e,t){var i={};if(e==null)return i;var r=!1;t=vP(t,function(s){return s=Lu(s,e),r||(r=s.length>1),s}),Ap(e,UP(e),i),r&&(i=kP(i,B7|U7|F7,I7));for(var a=t.length;a--;)O7(i,t[a]);return i}),g1=N7;function z7(e,t,i,r){if(!Zs(e))return e;t=Lu(t,e);for(var a=-1,s=t.length,n=s-1,o=e;o!=null&&++a<s;){var l=av(t[a]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(a!=n){var c=o[l];h=r?r(c,l,o):void 0,h===void 0&&(h=Zs(c)?c:yb(t[a+1])?[]:{})}bb(o,l,h),o=o[l]}return e}var k7=z7;function V7(e,t,i){for(var r=-1,a=t.length,s={};++r<a;){var n=t[r],o=TP(e,n);i(o,n)&&k7(s,Lu(n,e),o)}return s}var j7=V7;function G7(e,t){return j7(e,t,function(i,r){return b7(e,r)})}var H7=G7,W7=DP(function(e,t){return e==null?{}:H7(e,t)}),Ao=W7,q7="Expected a function";function X7(e,t,i){var r=!0,a=!0;if(typeof e!="function")throw new TypeError(q7);return Zs(i)&&(r="leading"in i?!!i.leading:r,a="trailing"in i?!!i.trailing:a),Rb(e,t,{leading:r,maxWait:t,trailing:a})}var Y7=X7;function HP(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Ln(e,t){return Object.setPrototypeOf(e,t),e}var Q7=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),K7=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),Z7=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||nv&&"ontouchend"in document,J7=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,$7=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,eq=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},tq=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},iq=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},rq=Q7(),yse=rq?iq():void 0,nv=K7(),Ob=Z7(),aq=J7(),rs=$7(),TA=eq(),PA=Number(tq());function WP(e){return Array.isArray(e)?e:[e]}function qP(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function Bf(e){return nv?e.metaKey:e.ctrlKey}function sq(e){return e.wheelDeltaY===0||e.deltaY===0?nv&&e.shiftKey&&Math.abs(e.wheelDeltaX)>=120?!1:e.wheelDeltaX?e.wheelDeltaX===-3*e.deltaX||e.wheelDeltaX===-3*window.devicePixelRatio*e.deltaX:e.deltaMode===0:e.wheelDeltaY?e.wheelDeltaY===-3*e.deltaY||e.wheelDeltaY===-3*window.devicePixelRatio*e.deltaY:e.deltaMode===0}var Lt=[],hg={},Dd={},Dm={};function XP(e){Lt.includes(e)||Lt.push(e)}function Kc(e){delete hg[e.pointerId];for(let t=0;t<Lt.length;t++)if(Lt[t].pointerId===e.pointerId){Lt.splice(t,1);break}}function nq(){Lt.splice(0,Lt.length)}function cg(e){if(e.pointerType!=="touch")return;let t=hg[e.pointerId];t===void 0&&(t={x:0,y:0},hg[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function I0(e){let t=e.pointerId===Lt[0].pointerId?Lt[1]:Lt[0];return hg[t.pointerId]}function YP(e){Dd[e.key]=!0,Dm[e.key]=Dm[e.key]===void 0?1:Dm[e.key]+1}function QP(e){if(nv&&Dd.Meta)for(let t in Dd)Dd[t]=!1;else Dd[e.key]=!1;Dm={}}function oq(e){e.addEventListener("pointerdown",XP,!0),e.addEventListener("pointerdown",cg,!0),e.addEventListener("pointermove",cg,!0),e.addEventListener("pointerup",Kc,!0),e.addEventListener("pointercancel",Kc,!0),e.addEventListener("pointerleave",Kc,!0),window.addEventListener("keydown",YP,!0),window.addEventListener("keyup",QP,!0)}function lq(e){e.removeEventListener("pointerdown",XP,!0),e.removeEventListener("pointerdown",cg,!0),e.removeEventListener("pointermove",cg,!0),e.removeEventListener("pointerup",Kc,!0),e.removeEventListener("pointercancel",Kc,!0),e.removeEventListener("pointerleave",Kc,!0),window.removeEventListener("keydown",YP,!0),window.removeEventListener("keyup",QP,!0)}var KP,hq=new Promise(e=>{KP=e}),Uf;function cq(){if(Uf)return Uf;async function e(){let t="https://unpkg.com/@splinetool/navmesh-wasm@1.0.85/build",i=import("./navmesh.js"),[r,a]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),s=r.default,n=await s({wasmBinary:a});KP(n)}return Uf=e(),Uf}var ZP,uq=new Promise(e=>{ZP=e}),Ff;function dq(){if(Ff)return Ff;async function e(){let t=await import("./physics.js");await t.init(),ZP(t)}return Ff=e(),Ff}var Vt=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,Vt.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:a,data:s}=e,n={...t,[a]:s};return Object.setPrototypeOf(n,Vt.prototype),{data:n,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let a={...t};return Object.setPrototypeOf(a,Vt.prototype),delete a[i],{data:a,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function Lb(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&Lb(r)}return Object.freeze(e)}function pq(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var JP=class extends Error{};function B0(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function ul(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let s=e;e=t,t=s}let r=[],a=1/(i+1);for(let s=0;s<i;s++){let n=e+(t-e)*(s+.75+Math.random()*.5)*a;r.push(n)}return r}function Ib(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function fq(){return typeof process<"u"}function $P(e,t){for(let i of e)t(i.id,i.data)!==!0&&$P(i.children,t)}function e3(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)e3(i,t)}var oa=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,oa.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Lb(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&e3(i,t)}}traverse(e){$P(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),a=r.findIndex(n=>n.id===e);if(a<0)throw new Error("not expected");let s=r[a];return r=[...r],r[a]={...s,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let s=r,n=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===n);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:s}}Object.setPrototypeOf(r,oa.prototype);let a=r;return a.fillCaches(),a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:a,children:s}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let n=t,o=this.childrenArray(n),l={fi:i,id:r,data:a,children:s};return o=[...o,l],o.sort((h,c)=>h.fi-c.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(n,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),a=r.findIndex(n=>n.id===t);e.localIndex=a,r=[...r];let s=r.splice(a,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...s,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let u=t;for(;u!==null;){if(u===void 0)throw new Error;if(u===r)throw new JP("cyclic tree");u=this.parent(u)}}let a=this.parent(r);if(a===void 0)return null;let s=a,n=this.childrenArray(a),o=n.findIndex(u=>u.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(a,n);a=t,n=h.childrenArray(a);let c=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((u,d)=>u.fi-d.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(a,n),{data:h,actual:e,reverse:{type:9,parent:s,fi:c,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(a=>a.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(a=>a.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>pq(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),a=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...a,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return ul(0,i,i);{let a=r[0].fi;return ul(a-i,a,i)}}else{let a=this.get(t);if(a===void 0||this.parent(t)!==e)throw new Error("illegal args");let s=r.find(n=>n.fi>a.fi);if(s===void 0){let n=r[r.length-1].fi;return ul(n,n+i,i)}else return ul(a.fi,s.fi,i)}}},ug;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let a=r.props,s={},n=[...i],o=!1;if(a)for(let l of Object.keys(a)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");s[l]=n[h],n[h]=a[l],o=!0}return o?{data:n,actual:r,reverse:{type:0,props:s}}:null}else{let a=r.props,s={},n={...i},o=!1;if(a)for(let l of Object.keys(a)){s[l]=n[l];let h=a[l];h===void 0?delete n[l]:n[l]=h,o=!0}return o?{data:n,actual:r,reverse:{type:0,props:s}}:null}}e.runOp=t})(ug||(ug={}));var Tt=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Tt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Lb(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(s=>s.id===e);if(r<0)throw new Error("not expected");let a=i[r];return i=[...i],i[r]={...a,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,Tt.prototype);let t=e;return fq()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,a=this,s={fi:t,id:i,data:r};return a=[...a,s],a.sort((n,o)=>n.fi-o.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(s=>s.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let a=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let a=r.findIndex(o=>o.id===i);if(a===-1)return null;let s=r[a].fi,n={...r[a],fi:t};return r[a]=n,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(n),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:s,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return ul(0,t,t);{let r=i[0].fi;return ul(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let a=i.find(s=>s.fi>r.fi);if(a===void 0){let s=i[i.length-1].fi;return ul(s,s+t,t)}else return ul(r.fi,a.fi,t)}}};function du(e){return e&&typeof e=="object"&&e instanceof Tr}var Tr=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,a={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!du(i))return null;r+=1}i=i?B0(i):new Tr;for(let[o,l]of Object.entries(e.props)){let h=i[o];a[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=B0(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=B0(o);l[e.path[r-1]]=i,i=l}else{let l=new Tr;l[e.path[r-1]]=i,i=l}}r-=1}let s=Object.setPrototypeOf(i,Tr.prototype),n={...e,props:a};return{data:s,actual:e,reverse:n}}},_l;(e=>{function t(a,s){return sp(a,s)??a}e.apply=t;function i(a,s){return Ub(a,s)}e.merge=i;function r(a,s){let n=0,o=s.path,l=a;for(;n<o.length&&l!==void 0;){if(l=na.zoomOnce(l,o[n]),l===void 0)return s;if(!du(l))return;n+=1}if(l===void 0)return s;if(du(l))if(s.type===0){let h={...s.props};for(let c of Object.keys(l))delete h[c];return{...s,props:h}}else if(s.type===1||s.type===4||s.type===7){let h=Bb([s],l);return h?(console.log(h),h):s}else return s}e.filterOp=r})(_l||(_l={}));function Bb(e,t){if(t===void 0)return;let i=!1,r=e.map(a=>{let s=a.id,n=sp(a.data,t[s]);if(i=i||n!==void 0,n===void 0&&(n=a.data),a.children){let o=Bb(a.children,t);return o!==void 0?i=!0:o=a.children,{...a,id:s,data:n,children:o}}else return{...a,id:s,data:n}});if(i)return r}function mq(e,t){if(t===void 0)return;let i=!1,r=e.map(a=>{let s=a.id,n=sp(a.data,t[s]);return i=i||n!==void 0,n===void 0&&(n=a.data),{...a,id:s,data:n}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function sp(e,t){if(!du(t))return t;if(e instanceof oa){let i=Bb(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof Tt)return mq(e,t);if(Array.isArray(e)){let i=!1,r=e.map((a,s)=>{let n=sp(a,t[s]);return i=i||n!==void 0,n===void 0&&(n=a),n});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof Tr)return Ub(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[a,s]of Object.entries(e)){let n=sp(s,t[a]);r=r||n!==void 0,n===void 0&&(n=s),i[a]=n}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function Ub(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!du(t))return t;if(!du(e))return _l.apply(e,t);let i=new Set;for(let a of Object.keys(e))i.add(a);for(let a of Object.keys(t))i.add(a);let r=new Tr;for(let a of i){let s=Ub(e===void 0?void 0:e[a],t===void 0?void 0:t[a]);r[a]=s}return r}function gq(e,t){let i={cur:[],result:[],len:0};return e=np(e,t,i)??e,[e,i.result]}function dg(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function pg(e){e&&(e.len-=1)}function vq(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function t3(e,t,i){let r=!1,a=e.map(s=>{let n=s.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=np(s.data,t,dg(i,n));pg(i),r=r||l!==void 0,l===void 0&&(l=s.data);let h=t3(s.children,t,i);return h!==void 0?r=!0:h=s.children,{...s,id:n,data:l,children:h}});if(r)return a}function yq(e,t,i){let r=!1,a=e.map(s=>{let n=s.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=np(s.data,t,dg(i,n));return pg(i),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:n,data:l}});if(r)return Object.setPrototypeOf(a,Object.getPrototypeOf(e)),a}function np(e,t,i){if(e instanceof oa){let r=t3(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof Tt)return yq(e,t,i);if(Array.isArray(e)){let r=!1,a=e.map((s,n)=>{let o=np(s,t,dg(i,n));return pg(i),r=r||o!==void 0,o===void 0&&(o=s),o});return r?(Object.setPrototypeOf(a,Object.getPrototypeOf(e)),a):void 0}else if(e&&typeof e=="object"&&!Ib(e)){let r={},a=!1;for(let[s,n]of Object.entries(e))if(s!=="name"){let o=t[s];if(typeof o=="string"){if(i!==null)throw new Error("not supported");a=!0,s=o}let l=np(n,t,dg(i,s));pg(i),a=a||l!==void 0,l===void 0&&(l=n),r[s]=l}else r[s]=n;return a?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&vq(i),r}else return}}var fg;(e=>{function t(i,r){let a=na.zoom(r,i.path);if(typeof a=="object"){let s={};for(let n of Object.keys(i.props))s[n]=a[n];return{...i,props:s}}else return{...i,props:{}}}e.replaceProps=t})(fg||(fg={}));var Zr;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let c=h.path;for(var u=[];;){let d;if(l instanceof Tr&&h.type===0&&(d=l.runOp({...h,path:c.slice(u.length)}),d===null&&(d=void 0)),d===void 0&&u.length===c.length&&(l instanceof oa||l instanceof Tt||l instanceof Vt?d=l.runOp(h):d=ug.runOp(l,h)),d!==void 0)if(d!==null){let m=d.data;for(let g=u.length-1;g>=0;g--){let v=c[g],x=u[g];if(x instanceof oa){if(typeof v=="number")throw new Error("illegal arg");m=x.modifyById(v,m)}else if(x instanceof Tt){if(typeof v=="number")throw new Error("illegal arg");m=x.modifyById(v,m)}else if(x instanceof Vt){if(typeof v=="number")throw new Error("illegal arg");m=x.modifyById(v,m)}else if(x instanceof Tr){let b={...x,[v]:m};m=Object.setPrototypeOf(b,Tr.prototype)}else if(typeof x=="object")if(Array.isArray(x)){if(typeof v=="string"&&(v=parseInt(v),isNaN(v)))throw new Error("Invalid path");let b=m;m=[...x],m[v]=b}else m={...x,[v]:m};else return null}return{data:m,actual:{...d.actual,path:c},reverse:{...d.reverse,path:c}}}else return null;let p=c[u.length],f;if(l instanceof oa){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof Tt){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else l!==null&&(f=l[p]);if(f!==void 0)u.push(l),l=f;else return null}}e.apply=r;function a(l,h){for(let c=0;c<l.length&&c<h.length;c++)if(l[c]!==h[c])return!0;return!1}e.pathDisjoint=a;function s(l,h){if(l.length!==h.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==h[c])return!1;return!0}e.pathEq=s;function n(l,h){return a(l.path,h.path)}e.commutative=n;function o(l,h){return l.type===0&&h.type===0&&s(l.path,h.path)?Object.keys(l.props).every(c=>h.props[c]!==void 0):!1}e.subsumed=o})(Zr||(Zr={}));var v1;(e=>{function t(){return[]}e.empty=t;function i(h,c){let u=[];for(let d of h){let[p,...f]=d.path;p===c&&u.push({...d,path:f})}return u}e.removePrefix=i;function r(h,c){return h.map(u=>({...u,path:[c,...u.path]}))}e.addPrefix=r;function a(h,c){return[...h,...c]}e.concat=a;function s(h,c){return[...h.filter(u=>!c.some(d=>Zr.subsumed(u,d))),...c]}e.compress=s;function n(h,c){return h.every(u=>c.every(d=>Zr.commutative(u,d)))}e.commutative=n;function o(h,c){for(let u of c){let d=l(h,u);d!==null&&(h=d.data)}return h}e.applyAll=o;function l(h,c){var u=h;let d=[],p=[];for(let f of c)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let m,g,v;if(f.type===3?(m=na.zoom(u,[...f.path,f.id]),v=Zr.apply(u,{...f,type:2})):(m=na.zoom(u,[...f.path,f.id,"value"]),v=Zr.apply(u,f)),v!==null){u=v.data;let[x,b]=gq(u,{[f.id]:m});u=x;for(let _=0;_<b.length;_++){let M=b[_],A=M.pop();if(typeof A=="number"){let S=[A];for(let L=_+1;L<b.length;L++){let E=b[L],T=E[E.length-1];if(typeof T=="number"&&na.equal(M,E.slice(0,E.length-1)))S.push(T),b.splice(L,1);else break}let P=na.zoom(u,M);g=P.map((L,E)=>S.includes(E)?f.id:L),m=P,A=M.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let S=m,P=na.zoom(u,M.slice(0,M.length-2)),L=P.layers.map(E=>E.id===M[M.length-1]?{...E,data:{...E.data,[A]:S}}:E);Object.setPrototypeOf(L,Object.getPrototypeOf(P.layers)),P.layers=L}g=f.id}d.push({type:0,path:M,props:{[A]:m}}),p.push({type:0,path:M,props:{[A]:g}})}p.push(v.reverse),d.push(v.actual)}}else{let m=Zr.apply(u,f);m!==null&&(d.push(m.actual),u=m.data,p.push(m.reverse))}}catch(m){if(m instanceof JP)return null;throw m}return{data:u,actual:d,reverse:p.reverse()}}e.apply=l})(v1||(v1={}));var i3=Symbol(),xq=Symbol(),ov=Symbol(),Ep=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let a=i;for(;!(r instanceof a3);){let s=r._path,n=r._current;if(s!==""&&a.splice(0,0,s),r=r._parent,r===null)return;r.update(s,n)}r.push(a,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[ov];i&&i(),delete this._children[e]}}}},bq=class extends Ep{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,ug.runOp(this._current,e),e.path)}},wq=class extends Ep{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,Vt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},r3={get(e,t){if(t===ov)return()=>{e._parent=null};if(t===i3)return e._current;if(t===xq)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let a=r===void 0?void 0:r[t];if(a!==void 0)return a;let s=i[t],n=lv(e,t,s);return n!==s?(r===void 0&&(r={},e._children=r),r[t]=n,n):s},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},_q={...r3,set(e,t,i){let r={type:0,props:{[t]:Pr(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},Sq={...r3,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},Fb=class extends Ep{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[ov]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let a=t.get(e)?.data,s=lv(this,e,a);return s!==a?(i===void 0&&(i={},this._children=i),i[e]=s,s):a}add(e,t,i,r,a){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:a})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.add(e,r[a],s.id,s.data,s.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.add(e,r[a],s.id,s.data,s.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.move(e,r[a],s)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let a=0;a<i.length;a++){let s=i[a];this.move(e,r[a],s)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Nb=class extends Ep{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[ov]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,a=this._current[i].fi;e(this.data(this._current[i].id),r,a)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let a=t.get(e)?.data,s=lv(this,e,a);return s!==a?(i===void 0&&(i={},this._children=i),i[e]=s,s):a}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.add(i[r],a.id,a.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.add(i[r],a.id,a.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.move(i[r],a)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let a=t[r];this.move(i[r],a)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function U0(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&na.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var a3=class extends Ep{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){U0(this.ts,t,e),U0(this.actual,i,e),U0(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function lv(e,t,i){return i instanceof oa?new Fb(e,t,i):i instanceof Tt?new Nb(e,t,i):i instanceof Vt?new Proxy(new wq(e,t,i),Sq):i!==null&&typeof i=="object"?Ib(i)?i:new Proxy(new bq(e,t,i),_q):i}function s3(e){let t=new a3(e);return[lv(t,"",e),t]}function op(e,t){let[i,r]=s3(e);return t(i),r.result()}function Pr(e){return e instanceof Fb||e instanceof Nb?e._current:e!==null&&typeof e=="object"?e[i3]:e}var na;(e=>{function t(s,n){if(n.length===s.length)for(var o=0;o<s.length;){if(s[o]!==n[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(s,n,o){let l=a(o,s);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...n};return Object.keys(l).forEach(c=>{delete h[c]}),h}else return n}e.removeOverridden=i;function r(s,n){if((s instanceof oa||s instanceof Fb)&&typeof n=="string"||(s instanceof Tt||s instanceof Nb)&&typeof n=="string")return s.data(n);if(typeof n=="number"&&Array.isArray(s)||typeof n=="string"&&typeof s=="object"&&s!==null)return s[n]}e.zoomOnce=r;function a(s,n,o=0){for(;o<n.length&&s!==void 0;)s=r(s,n[o]),o+=1;return s}e.zoom=a})(na||(na={}));function Aq(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function Fi(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var n3=class{},DA=class extends n3{constructor(e){super(),this.id=e}},RA=class extends n3{constructor(e){super(),this.data=e}},y1;try{y1=new TextDecoder}catch{}var ft,Sl,we=0,o3=[],x1=o3,b1=0,qa={},yi,dl,bs=0,Sn=0,es,Eo,Ua=[],Ei,OA={useRecords:!1,mapsAsObjects:!0},l3=class{},h3=new l3;h3.name="MessagePack 0xC1";var pu=!1,mg=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(ft)return m3(()=>(_1(),this?this.unpack(e,t):mg.prototype.unpack.call(OA,e,t)));Sl=t>-1?t:e.length,we=0,b1=0,Sn=0,dl=null,x1=o3,es=null,ft=e;try{Ei=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw ft=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof mg){if(qa=this,this.structures)return yi=this.structures,Nf();(!yi||yi.length>0)&&(yi=[])}else qa=OA,(!yi||yi.length>0)&&(yi=[]);return Nf()}unpackMultiple(e,t){let i,r=0;try{pu=!0;let a=e.length,s=this?this.unpack(e,a):cv.unpack(e,a);if(t){for(t(s);we<a;)if(r=we,t(Nf())===!1)return}else{for(i=[s];we<a;)r=we,i.push(Nf());return i}}catch(a){throw a.lastPosition=r,a.values=i,a}finally{pu=!1,_1()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let a=e[i];a&&(a.isShared=!0,i>=32&&(a.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],a=t[i];a&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=a)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Nf(){try{if(!qa.trusted&&!pu){let t=yi.sharedLength||0;t<yi.length&&(yi.length=t)}let e=cr();if(we==Sl)yi.restoreStructures&&LA(),yi=null,ft=null,Eo&&(Eo=null);else if(we>Sl){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!pu)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw yi.restoreStructures&&LA(),_1(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function LA(){for(let e in yi.restoreStructures)yi[e]=yi.restoreStructures[e];yi.restoreStructures=null}function cr(){let e=ft[we++];if(e<160)if(e<128){if(e<64)return e;{let t=yi[e&63]||qa.getStructures&&c3()[e&63];return t?(t.read||(t.read=zb(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,qa.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[d3()]=cr();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(cr(),cr());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=cr();return t}else if(e<192){let t=e-160;if(Sn>=we)return dl.slice(we-bs,(we+=t)-bs);if(Sn==0&&Sl<140){let i=t<16?kb(t):u3(t);if(i!=null)return i}return w1(t)}else{let t;switch(e){case 192:return null;case 193:return es?(t=cr(),t>0?es[1].slice(es.position1,es.position1+=t):es[0].slice(es.position0,es.position0-=t)):h3;case 194:return!1;case 195:return!0;case 196:return F0(ft[we++]);case 197:return t=Ei.getUint16(we),we+=2,F0(t);case 198:return t=Ei.getUint32(we),we+=4,F0(t);case 199:return ql(ft[we++]);case 200:return t=Ei.getUint16(we),we+=2,ql(t);case 201:return t=Ei.getUint32(we),we+=4,ql(t);case 202:if(t=Ei.getFloat32(we),qa.useFloat32>2){let i=Vb[(ft[we]&127)<<1|ft[we+1]>>7];return we+=4,(i*t+(t>0?.5:-.5)>>0)/i}return we+=4,t;case 203:return t=Ei.getFloat64(we),we+=8,t;case 204:return ft[we++];case 205:return t=Ei.getUint16(we),we+=2,t;case 206:return t=Ei.getUint32(we),we+=4,t;case 207:return qa.int64AsNumber?(t=Ei.getUint32(we)*4294967296,t+=Ei.getUint32(we+4)):t=Ei.getBigUint64(we),we+=8,t;case 208:return Ei.getInt8(we++);case 209:return t=Ei.getInt16(we),we+=2,t;case 210:return t=Ei.getInt32(we),we+=4,t;case 211:return qa.int64AsNumber?(t=Ei.getInt32(we)*4294967296,t+=Ei.getUint32(we+4)):t=Ei.getBigInt64(we),we+=8,t;case 212:if(t=ft[we++],t==114)return NA(ft[we++]&63);{let i=Ua[t];if(i)return i.read?(we++,i.read(cr())):i.noBuffer?(we++,i()):i(ft.subarray(we,++we));throw new Error("Unknown extension "+t)}case 213:return t=ft[we],t==114?(we++,NA(ft[we++]&63,ft[we++])):ql(2);case 214:return ql(4);case 215:return ql(8);case 216:return ql(16);case 217:return t=ft[we++],Sn>=we?dl.slice(we-bs,(we+=t)-bs):Mq(t);case 218:return t=Ei.getUint16(we),we+=2,Sn>=we?dl.slice(we-bs,(we+=t)-bs):Cq(t);case 219:return t=Ei.getUint32(we),we+=4,Sn>=we?dl.slice(we-bs,(we+=t)-bs):Tq(t);case 220:return t=Ei.getUint16(we),we+=2,BA(t);case 221:return t=Ei.getUint32(we),we+=4,BA(t);case 222:return t=Ei.getUint16(we),we+=2,UA(t);case 223:return t=Ei.getUint32(we),we+=4,UA(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var Eq=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function zb(e,t){function i(){if(i.count++>2){let a=e.read=new Function("r","return function(){return {"+e.map(s=>Eq.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(cr);return e.highByte===0&&(e.read=IA(t,e.read)),a()}let r={};for(let a=0,s=e.length;a<s;a++){let n=e[a];r[n]=cr()}return r}return i.count=0,e.highByte===0?IA(t,i):i}var IA=(e,t)=>function(){let i=ft[we++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),a=yi[r]||c3()[r];if(!a)throw new Error("Record id is not defined for "+r);return a.read||(a.read=zb(a,e)),a.read()};function c3(){let e=m3(()=>(ft=null,qa.getStructures()));return yi=qa._mergeStructures(e,yi)}var w1=hv,Mq=hv,Cq=hv,Tq=hv;function hv(e){let t;if(e<16&&(t=kb(e)))return t;if(e>64&&y1)return y1.decode(ft.subarray(we,we+=e));let i=we+e,r=[];for(t="";we<i;){let a=ft[we++];if((a&128)===0)r.push(a);else if((a&224)===192){let s=ft[we++]&63;r.push((a&31)<<6|s)}else if((a&240)===224){let s=ft[we++]&63,n=ft[we++]&63;r.push((a&31)<<12|s<<6|n)}else if((a&248)===240){let s=ft[we++]&63,n=ft[we++]&63,o=ft[we++]&63,l=(a&7)<<18|s<<12|n<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(a);r.length>=4096&&(t+=Wr.apply(String,r),r.length=0)}return r.length>0&&(t+=Wr.apply(String,r)),t}function BA(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=cr();return t}function UA(e){if(qa.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[d3()]=cr();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(cr(),cr());return t}}var Wr=String.fromCharCode;function u3(e){let t=we,i=new Array(e);for(let r=0;r<e;r++){let a=ft[we++];if((a&128)>0){we=t;return}i[r]=a}return Wr.apply(String,i)}function kb(e){if(e<4)if(e<2){if(e===0)return"";{let t=ft[we++];if((t&128)>1){we-=1;return}return Wr(t)}}else{let t=ft[we++],i=ft[we++];if((t&128)>0||(i&128)>0){we-=2;return}if(e<3)return Wr(t,i);let r=ft[we++];if((r&128)>0){we-=3;return}return Wr(t,i,r)}else{let t=ft[we++],i=ft[we++],r=ft[we++],a=ft[we++];if((t&128)>0||(i&128)>0||(r&128)>0||(a&128)>0){we-=4;return}if(e<6){if(e===4)return Wr(t,i,r,a);{let s=ft[we++];if((s&128)>0){we-=5;return}return Wr(t,i,r,a,s)}}else if(e<8){let s=ft[we++],n=ft[we++];if((s&128)>0||(n&128)>0){we-=6;return}if(e<7)return Wr(t,i,r,a,s,n);let o=ft[we++];if((o&128)>0){we-=7;return}return Wr(t,i,r,a,s,n,o)}else{let s=ft[we++],n=ft[we++],o=ft[we++],l=ft[we++];if((s&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){we-=8;return}if(e<10){if(e===8)return Wr(t,i,r,a,s,n,o,l);{let h=ft[we++];if((h&128)>0){we-=9;return}return Wr(t,i,r,a,s,n,o,l,h)}}else if(e<12){let h=ft[we++],c=ft[we++];if((h&128)>0||(c&128)>0){we-=10;return}if(e<11)return Wr(t,i,r,a,s,n,o,l,h,c);let u=ft[we++];if((u&128)>0){we-=11;return}return Wr(t,i,r,a,s,n,o,l,h,c,u)}else{let h=ft[we++],c=ft[we++],u=ft[we++],d=ft[we++];if((h&128)>0||(c&128)>0||(u&128)>0||(d&128)>0){we-=12;return}if(e<14){if(e===12)return Wr(t,i,r,a,s,n,o,l,h,c,u,d);{let p=ft[we++];if((p&128)>0){we-=13;return}return Wr(t,i,r,a,s,n,o,l,h,c,u,d,p)}}else{let p=ft[we++],f=ft[we++];if((p&128)>0||(f&128)>0){we-=14;return}if(e<15)return Wr(t,i,r,a,s,n,o,l,h,c,u,d,p,f);let m=ft[we++];if((m&128)>0){we-=15;return}return Wr(t,i,r,a,s,n,o,l,h,c,u,d,p,f,m)}}}}}function F0(e){return qa.copyBuffers?Uint8Array.prototype.slice.call(ft,we,we+=e):ft.subarray(we,we+=e)}function ql(e){let t=ft[we++];if(Ua[t])return Ua[t](ft.subarray(we,we+=e));throw new Error("Unknown extension type "+t)}var FA=new Array(4096);function d3(){let e=ft[we++];if(e>=160&&e<192){if(e=e-160,Sn>=we)return dl.slice(we-bs,(we+=e)-bs);if(!(Sn==0&&Sl<180))return w1(e)}else return we--,cr();let t=(e<<5^(e>1?Ei.getUint16(we):e>0?ft[we]:0))&4095,i=FA[t],r=we,a=we+e-3,s,n=0;if(i&&i.bytes==e){for(;r<a;){if(s=Ei.getUint32(r),s!=i[n++]){r=1879048192;break}r+=4}for(a+=3;r<a;)if(s=ft[r++],s!=i[n++]){r=1879048192;break}if(r===a)return we=r,i.string;a-=3,r=we}for(i=[],FA[t]=i,i.bytes=e;r<a;)s=Ei.getUint32(r),i.push(s),r+=4;for(a+=3;r<a;)s=ft[r++],i.push(s);let o=e<16?kb(e):u3(e);return o!=null?i.string=o:i.string=w1(e)}var NA=(e,t)=>{var i=cr();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let a=yi[e];return a&&a.isShared&&((yi.restoreStructures||(yi.restoreStructures=[]))[e]=a),yi[e]=i,i.read=zb(i,r),i.read()},p3=typeof self=="object"?self:global;Ua[0]=()=>{};Ua[0].noBuffer=!0;Ua[101]=()=>{let e=cr();return(p3[e[0]]||Error)(e[1])};Ua[105]=e=>{let t=Ei.getUint32(we-4);Eo||(Eo=new Map);let i=ft[we],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let a={target:r};Eo.set(t,a);let s=cr();return a.used?Object.assign(r,s):(a.target=s,s)};Ua[112]=e=>{let t=Ei.getUint32(we-4),i=Eo.get(t);return i.used=!0,i.target};Ua[115]=()=>new Set(cr());var f3=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Ua[116]=e=>{let t=e[0],i=f3[t];if(!i)throw new Error("Could not find typed array for code "+t);return new p3[i](Uint8Array.prototype.slice.call(e,1).buffer)};Ua[120]=()=>{let e=cr();return new RegExp(e[0],e[1])};Ua[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=we;we+=t-4,es=[cr(),cr()],es.position0=0,es.position1=0;let r=we;we=i;try{return cr()}finally{we=r}};Ua[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function m3(e){let t=Sl,i=we,r=b1,a=bs,s=Sn,n=dl,o=x1,l=Eo,h=es,c=new Uint8Array(ft.slice(0,Sl)),u=yi,d=yi.slice(0,yi.length),p=qa,f=pu,m=e();return Sl=t,we=i,b1=r,bs=a,Sn=s,dl=n,x1=o,Eo=l,es=h,ft=c,pu=f,yi=u,yi.splice(0,yi.length,...d),qa=p,Ei=new DataView(ft.buffer,ft.byteOffset,ft.byteLength),m}function _1(){ft=null,Eo=null,yi=null}function Pq(e){e.unpack?Ua[e.type]=e.unpack:Ua[e.type]=e}var Vb=new Array(147);for(let e=0;e<256;e++)Vb[e]=+("1e"+Math.floor(45.15-e*.30103));var cv=new mg({useRecords:!1}),xse=cv.unpack,bse=cv.unpackMultiple,wse=cv.unpack,Dq={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Rq=new Float32Array(1),_se=new Uint8Array(Rq.buffer,0,4),Rm;try{Rm=new TextEncoder}catch{}var gg,jb,uv=typeof Buffer<"u",N0=uv?Buffer.allocUnsafeSlow:Uint8Array,g3=uv?Buffer:Uint8Array,zA=uv?4294967296:2144337920,Ne,gr,Te=0,on,ln=null,Oq=/[\u0080-\uFFFF]/,ud=Symbol("record-id"),v3=class extends mg{constructor(e){super(e),this.offset=0;let t,i,r,a,s,n,o=0,l=g3.prototype.utf8Write?function(S,P,L){return Ne.utf8Write(S,P,L)}:Rm&&Rm.encodeInto?function(S,P){return Rm.encodeInto(S,Ne.subarray(P)).written}:!1,h=this;e||(e={});let c=e&&e.sequential,u=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=u?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=u?32:64),c&&!e.saveStructures&&(this.structures=[]);let f=d>32||p+d>64,m=d+64,g=d+p+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,b=0;this.pack=this.encode=function(S,P){if(Ne||(Ne=new N0(8192),gr=new DataView(Ne.buffer,0,8192),Te=0),on=Ne.length-10,on-Te<2048?(Ne=new N0(Ne.length),gr=new DataView(Ne.buffer,0,Ne.length),on=Ne.length-10,Te=0):Te=Te+7&2147483640,i=Te,n=h.structuredClone?new Map:null,h.bundleStrings?(ln=["",""],Ne[Te++]=214,Ne[Te++]=98,ln.position=Te-i,Te+=4):ln=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let L=r.sharedLength||0;if(L>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let E=0;E<L;E++){let T=r[E];if(!T)continue;let B,V=r.transitions;for(let I=0,H=T.length;I<H;I++){let q=T[I];B=V[q],B||(B=V[q]=Object.create(null)),V=B}V[ud]=E+64}o=L}c||(r.nextId=L+64)}a&&(a=!1),s=r||[];try{if(_(S),ln){gr.setUint32(ln.position+i,Te-ln.position-i);let L=ln;ln=null,_(L[0]),_(L[1])}if(h.offset=Te,n&&n.idsToInsert){Te+=n.idsToInsert.length*6,Te>on&&A(Te),h.offset=Te;let L=Iq(Ne.subarray(i,Te),n.idsToInsert);return n=null,L}return P&Bq?(Ne.start=i,Ne.end=Te,Ne):Ne.subarray(i,Te)}finally{if(r){if(b<10&&b++,x>1e4)r.transitions=null,b=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!c){for(let L=0,E=v.length;L<E;L++)v[L][ud]=0;v=[]}if(a&&h.saveStructures){let L=r.sharedLength||d;r.length>L&&(r=r.slice(0,L));let E=Ne.subarray(i,Te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(S)):(o=L,E)}}P&Uq&&(Te=i)}};let _=S=>{Te>on&&(Ne=A(Te));var P=typeof S,L;if(P==="string"){let E=S.length;if(ln&&E>=8&&E<4096){let V=Oq.test(S);ln[V?0:1]+=S,Ne[Te++]=193,_(V?-E:E);return}let T;E<32?T=1:E<256?T=2:E<65536?T=3:T=5;let B=E*3;if(Te+B>on&&(Ne=A(Te+B)),E<64||!l){let V,I,H,q=Te+T;for(V=0;V<E;V++)I=S.charCodeAt(V),I<128?Ne[q++]=I:I<2048?(Ne[q++]=I>>6|192,Ne[q++]=I&63|128):(I&64512)===55296&&((H=S.charCodeAt(V+1))&64512)===56320?(I=65536+((I&1023)<<10)+(H&1023),V++,Ne[q++]=I>>18|240,Ne[q++]=I>>12&63|128,Ne[q++]=I>>6&63|128,Ne[q++]=I&63|128):(Ne[q++]=I>>12|224,Ne[q++]=I>>6&63|128,Ne[q++]=I&63|128);L=q-Te-T}else L=l(S,Te+T,B);L<32?Ne[Te++]=160|L:L<256?(T<2&&Ne.copyWithin(Te+2,Te+1,Te+1+L),Ne[Te++]=217,Ne[Te++]=L):L<65536?(T<3&&Ne.copyWithin(Te+3,Te+2,Te+2+L),Ne[Te++]=218,Ne[Te++]=L>>8,Ne[Te++]=L&255):(T<5&&Ne.copyWithin(Te+5,Te+3,Te+3+L),Ne[Te++]=219,gr.setUint32(Te,L),Te+=4),Te+=L}else if(P==="number")if(S>>>0===S)S<64?Ne[Te++]=S:S<256?(Ne[Te++]=204,Ne[Te++]=S):S<65536?(Ne[Te++]=205,Ne[Te++]=S>>8,Ne[Te++]=S&255):(Ne[Te++]=206,gr.setUint32(Te,S),Te+=4);else if(S>>0===S)S>=-32?Ne[Te++]=256+S:S>=-128?(Ne[Te++]=208,Ne[Te++]=S+256):S>=-32768?(Ne[Te++]=209,gr.setInt16(Te,S),Te+=2):(Ne[Te++]=210,gr.setInt32(Te,S),Te+=4);else{let E;if((E=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){Ne[Te++]=202,gr.setFloat32(Te,S);let T;if(E<4||(T=S*Vb[(Ne[Te]&127)<<1|Ne[Te+1]>>7])>>0===T){Te+=4;return}else Te--}Ne[Te++]=203,gr.setFloat64(Te,S),Te+=8}else if(P==="object")if(!S)Ne[Te++]=192;else{if(n){let T=n.get(S);if(T){if(!T.id){let B=n.idsToInsert||(n.idsToInsert=[]);T.id=B.push(T)}Ne[Te++]=214,Ne[Te++]=112,gr.setUint32(Te,T.id),Te+=4;return}else n.set(S,{offset:Te-i})}let E=S.constructor;if(E===Object)M(S,!0);else if(E===Array){L=S.length,L<16?Ne[Te++]=144|L:L<65536?(Ne[Te++]=220,Ne[Te++]=L>>8,Ne[Te++]=L&255):(Ne[Te++]=221,gr.setUint32(Te,L),Te+=4);for(let T=0;T<L;T++)_(S[T])}else if(E===Map){L=S.size,L<16?Ne[Te++]=128|L:L<65536?(Ne[Te++]=222,Ne[Te++]=L>>8,Ne[Te++]=L&255):(Ne[Te++]=223,gr.setUint32(Te,L),Te+=4);for(let[T,B]of S)_(T),_(B)}else{for(let T=0,B=gg.length;T<B;T++){let V=jb[T];if(S instanceof V){let I=gg[T];if(I.write){I.type&&(Ne[Te++]=212,Ne[Te++]=I.type,Ne[Te++]=0),_(I.write.call(this,S));return}let H=Ne,q=gr,X=Te;Ne=null;let Y;try{Y=I.pack.call(this,S,ie=>(Ne=H,H=null,Te+=ie,Te>on&&A(Te),{target:Ne,targetView:gr,position:Te-ie}),_)}finally{H&&(Ne=H,gr=q,Te=X,on=Ne.length-10)}Y&&(Y.length+Te>on&&A(Y.length+Te),Te=Lq(Y,Ne,Te,I.type));return}}M(S,!S.hasOwnProperty)}}else if(P==="boolean")Ne[Te++]=S?195:194;else if(P==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))Ne[Te++]=211,gr.setBigInt64(Te,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)Ne[Te++]=207,gr.setBigUint64(Te,S);else if(this.largeBigIntToFloat)Ne[Te++]=203,gr.setFloat64(Te,Number(S));else throw new RangeError(S+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");Te+=8}else if(P==="undefined")this.encodeUndefinedAsNil?Ne[Te++]=192:(Ne[Te++]=212,Ne[Te++]=0,Ne[Te++]=0);else if(P==="function")_(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+P)},M=this.useRecords===!1?this.variableMapSize?S=>{let P=Object.keys(S),L=P.length;L<16?Ne[Te++]=128|L:L<65536?(Ne[Te++]=222,Ne[Te++]=L>>8,Ne[Te++]=L&255):(Ne[Te++]=223,gr.setUint32(Te,L),Te+=4);let E;for(let T=0;T<L;T++)_(E=P[T]),_(S[E])}:(S,P)=>{Ne[Te++]=222;let L=Te-i;Te+=2;let E=0;for(let T in S)(P||S.hasOwnProperty(T))&&(_(T),_(S[T]),E++);Ne[L+++i]=E>>8,Ne[L+i]=E&255}:S=>{let P=Object.keys(S),L,E=s.transitions||(s.transitions=Object.create(null)),T=0;for(let V=0,I=P.length;V<I;V++){let H=P[V];L=E[H],L||(L=E[H]=Object.create(null),T++),E=L}let B=E[ud];if(B)B>=96&&f?(Ne[Te++]=((B-=96)&31)+96,Ne[Te++]=B>>5):Ne[Te++]=B;else{B=s.nextId,B||(B=64),B<m&&this.shouldShareStructure&&!this.shouldShareStructure(P)?(B=s.nextOwnId,B<g||(B=m),s.nextOwnId=B+1):(B>=g&&(B=m),s.nextId=B+1);let V=P.highByte=B>=96&&f?B-96>>5:-1;E[ud]=B,s[B-64]=P,B<m?(P.isShared=!0,s.sharedLength=B-63,a=!0,V>=0?(Ne[Te++]=(B&31)+96,Ne[Te++]=V):Ne[Te++]=B):(V>=0?(Ne[Te++]=213,Ne[Te++]=114,Ne[Te++]=(B&31)+96,Ne[Te++]=V):(Ne[Te++]=212,Ne[Te++]=114,Ne[Te++]=B),T&&(x+=b*T),v.length>=p&&(v.shift()[ud]=0),v.push(E),_(P))}for(let V=0,I=P.length;V<I;V++)_(S[P[V]])},A=S=>{let P;if(S>16777216){if(S-i>zA)throw new Error("Packed buffer would be larger than maximum buffer size");P=Math.min(zA,Math.round(Math.max((S-i)*(S>67108864?1.25:2),4194304)/4096)*4096)}else P=(Math.max(S-i<<2,Ne.length-1)>>12)+1<<12;let L=new N0(P);return gr=new DataView(L.buffer,0,P),Ne.copy?Ne.copy(L,0,i,S):L.set(Ne.slice(i,S)),Te-=i,i=0,on=L.length-10,Ne=L}}useBuffer(e){Ne=e,gr=new DataView(Ne.buffer,Ne.byteOffset,Ne.byteLength),Te=0}};jb=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,l3];gg=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:a,targetView:s,position:n}=t(6);a[n++]=214,a[n++]=255,s.setUint32(n,r)}else if(r>0&&r<17179869184){let{target:a,targetView:s,position:n}=t(10);a[n++]=215,a[n++]=255,s.setUint32(n,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(n+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:a,targetView:s,position:n}=t(3);a[n++]=212,a[n++]=255,a[n++]=255}else{let{target:a,targetView:s,position:n}=t(15);a[n++]=199,a[n++]=12,a[n++]=255,s.setUint32(n,e.getMilliseconds()*1e6),s.setBigInt64(n+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:a,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(a[s++]=212,a[s++]=115,a[s++]=0),i(r)}},{pack(e,t,i){let{target:r,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(r[a++]=212,r[a++]=101,r[a++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(r[a++]=212,r[a++]=120,r[a++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?kA(e,16,t):VA(uv?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==g3&&this.structuredClone?kA(e,f3.indexOf(i.name),t):VA(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function kA(e,t,i,r){let a=e.byteLength;if(a+1<256){var{target:s,position:n}=i(4+a);s[n++]=199,s[n++]=a+1}else if(a+1<65536){var{target:s,position:n}=i(5+a);s[n++]=200,s[n++]=a+1>>8,s[n++]=a+1&255}else{var{target:s,position:n,targetView:o}=i(7+a);s[n++]=201,o.setUint32(n,a+1),n+=4}s[n++]=116,s[n++]=t,s.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n)}function VA(e,t){let i=e.byteLength;var r,a;if(i<256){var{target:r,position:a}=t(i+2);r[a++]=196,r[a++]=i}else if(i<65536){var{target:r,position:a}=t(i+3);r[a++]=197,r[a++]=i>>8,r[a++]=i&255}else{var{target:r,position:a,targetView:s}=t(i+5);r[a++]=198,s.setUint32(a,i),a+=4}r.set(e,a)}function Lq(e,t,i,r){let a=e.length;switch(a){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:a<256?(t[i++]=199,t[i++]=a):a<65536?(t[i++]=200,t[i++]=a>>8,t[i++]=a&255):(t[i++]=201,t[i++]=a>>24,t[i++]=a>>16&255,t[i++]=a>>8&255,t[i++]=a&255)}return t[i++]=r,t.set(e,i),i+=a,i}function Iq(e,t){let i,r=t.length*6,a=e.length-r;for(t.sort((s,n)=>s.offset>n.offset?1:-1);i=t.pop();){let s=i.offset,n=i.id;e.copyWithin(s+r,s,a),r-=6;let o=s+r;e[o++]=214,e[o++]=105,e[o++]=n>>24,e[o++]=n>>16&255,e[o++]=n>>8&255,e[o++]=n&255,a=s}return e}function Bu(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");jb.unshift(e.Class),gg.unshift(e)}Pq(e)}var y3=new v3({useRecords:!1}),Sse=y3.pack,Ase=y3.pack,{NEVER:Ese,ALWAYS:Mse,DECIMAL_ROUND:Cse,DECIMAL_FIT:Tse}=Dq,Bq=512,Uq=1024,jA=new v3({structuredClone:!0});Bu({Class:Vt.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Vt.prototype),e}});Bu({Class:Tt.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,Tt.prototype),e}});Bu({Class:oa.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,oa.prototype),e}});Bu({Class:DA.prototype.constructor,type:4,write(e){return e.id},read(e){return new DA(e)}});Bu({Class:RA.prototype.constructor,type:5,write(e){return e.data},read(e){return new RA(e)}});Bu({Class:Tr.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Tr.prototype),e}});function Fq(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function S1(e){if(Ib(e))return e;if(Array.isArray(e))return e.map(S1);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=S1(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var A1;(e=>{function t(a){return jA.pack(a)}e.serialize=t;function i(a){return jA.unpack(a)}e.deserialize=i;function r(a){return Fq(t(S1(a))).toString()}e.checksum=r})(A1||(A1={}));var GA;(e=>{function t(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=t;function i(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=i})(GA||(GA={}));var ja={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional"],MouseHover:["Transition","Animation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],Scroll:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional"],Start:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],Conditional:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MousePress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional"],GameControl:["Transition","Animation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],VariableChange:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"]},HA;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,runMode:"Once",actions:new Tt}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new Tt}}e.defaultData=i})(HA||(HA={}));var vg;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(vg||(vg={}));var E1;(e=>{function t(a){return{type:"Comparison",operator:"==",lOperand:vg.propertyDefaultData(a),rOperand:{...vg.valueDefaultData}}}e.comparisonDefaultData=t;function i(a){return{type:"Distance",toObject:a??null,fromObject:a??null,distance:200}}e.distanceDefaultData=i;function r(a,s){return{type:"State",object:a??null,state:s??null}}e.stateDefaultData=r})(E1||(E1={}));var WA;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new Tt,outActions:new Tt,condition:E1.distanceDefaultData(r)}}e.defaultData=i})(WA||(WA={}));var qA;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new Tt,drop:new Tt}})(qA||(qA={}));var M1;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new Tt})(M1||(M1={}));var C1;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(C1||(C1={}));var XA;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new Tt}}e.defaultData=i})(XA||(XA={}));var YA;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Tt}}e.defaultData=i})(YA||(YA={}));var QA;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new Tt}}e.defaultData=i})(QA||(QA={}));var KA;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new Tt}}e.defaultData=i})(KA||(KA={}));var ZA;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,a){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new Tt,triggerZone:"box",position:a.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(ZA||(ZA={}));var T1;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(n){return n.type==="Resize"}e.is=t;function i(n){return typeof n=="string"?n:"custom"}e.sizeToDevice=i;function r(n){return typeof n=="string"?[...e.defaultSizes[n]]:[...n]}e.deviceToSize=r;function a(){let n={size:"mobile",operator:"<",actions:new Tt},o={size:"tablet",operator:"<",actions:new Tt},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new Tt},h=new Tt;return h.push({id:dt.generateUUID(),fi:0,data:n},{id:dt.generateUUID(),fi:1,data:o},{id:dt.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:h}}e.defaultData=a;function s(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new Tt}}e.defaultBreakpointData=s})(T1||(T1={}));var P1;(e=>{e.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}e.is=t;function i(){return{disabled:!1,type:"VariableChange",actions:new Tt,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(P1||(P1={}));var Uu="personal camera",Gd="a218fcc3-276b-49b9-b485-49037fd14f5f",Nq=2960946,ss=5526619,wo;(e=>{function t(f,m){return f[0]===m[0]&&f[1]===m[1]}e.isEqual=t;function i(f,m,g){return[f[0]+(m[0]-f[0])*g,f[1]+(m[1]-f[1])*g]}e.lerp=i;function r(f,m){return[f[0]+m[0],f[1]+m[1]]}e.add=r;function a(f,m){return[f[0]-m[0],f[1]-m[1]]}e.sub=a;function s(f,m){return[f[0]*m[0],f[1]*m[1]]}e.multiply=s;function n(f,m){return[f[0]/m[0],f[1]/m[1]]}e.divide=n;function o(f,m){return Math.pow(m[0]-f[0],2)+Math.pow(m[1]-f[1],2)}e.distanceSquared=o;function l(f,m){return Math.sqrt(o(f,m))}e.distance=l;function h(f,m){return f[0]*m[0]+f[1]*m[1]}e.dot=h;function c(f,m){return[f[0]*m,f[1]*m]}e.scalarMultiply=c;function u(f,m,g){let v=e.sub(m,f),x=e.sub(g,f),b=e.dot(v,x)/e.dot(v,v),_=e.scalarMultiply(v,b);return e.add(f,_)}e.projectionOnto=u;function d(f,m,g){return l(f,u(f,m,g))}e.projectionOntoDistance=d;function p(f,m){return[(f[0]+m[0])*.5,(f[1]+m[1])*.5]}e.center=p})(wo||(wo={}));var vh;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function a(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=a;function s(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=s;function n(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=n;function o(l,h,c){return[l[0]+(h[0]-l[0])*c,l[1]+(h[1]-l[1])*c,l[2]+(h[2]-l[2])*c]}e.lerp=o})(vh||(vh={}));var yg;(e=>{function t(r,a){return r[0]===a[0]&&r[1]===a[1]&&r[2]===a[2]&&r[3]===a[3]}e.isEqual=t;function i(r,a,s){return[r[0]+(a[0]-r[0])*s,r[1]+(a[1]-r[1])*s,r[2]+(a[2]-r[2])*s,r[3]+(a[3]-r[3])*s]}e.lerp=i})(yg||(yg={}));var fu;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(a,s){for(let n=0;n<16;n++)if(a[n]!==s[n])return!1;return!0}e.isEqual=t;function i(a){return a??e.identity}e.simplify=i;function r(a,s){let n=s.slice(0);for(var o=0,l=s.length;o<l;o+=3){let h=a[3]*s[o]+a[7]*s[o+1]+a[11]*s[o+2]+a[15];n[o]=(a[0]*s[o]+a[4]*s[o+1]+a[8]*s[o+2]+a[12])/h,n[o+1]=(a[1]*s[o]+a[5]*s[o+1]+a[9]*s[o+2]+a[13])/h,n[o+2]=(a[2]*s[o]+a[6]*s[o+1]+a[10]*s[o+2]+a[14])/h}return n}e.applyMatrix4=r})(fu||(fu={}));var ga;(e=>{function t(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}e.toRgb255a1=i;function r(h){return{r:h.r,g:h.g,b:h.b}}e.clone=r;function a(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}e.fromHex=a;function s(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}e.toHex=s;function n(h,c){return h.r===c.r&&h.g===c.g&&h.b===c.b}e.equals=n;function o(h,c){return h.r.toFixed(2)===c.r.toFixed(2)&&h.g.toFixed(2)===c.g.toFixed(2)&&h.b.toFixed(2)===c.b.toFixed(2)}e.equalsFixed=o;function l(h,c,u){return{r:h.r+(c.r-h.r)*u,g:h.g+(c.g-h.g)*u,b:h.b+(c.b-h.b)*u}}e.lerp=l})(ga||(ga={}));var Li;(e=>{e.white={...ga.white,a:1},e.transparent={...ga.white,a:0};function t(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}e.from0to1=t;function i(l,h){return{...ga.fromHex(l),a:h}}e.fromHexAndA=i;function r(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}e.toRgb255a1=r;function a(l,h){return ga.equals(l,h)&&l.a===h.a}e.equals=a;function s(l,h){return ga.equalsFixed(l,h)&&l.a.toFixed(2)===h.a.toFixed(2)}e.equalsFixed=s;function n(l,h,c){return{r:l.r+(h.r-l.r)*c,g:l.g+(h.g-l.g)*c,b:l.b+(h.b-l.b)*c,a:l.a+(h.a-l.a)*c}}e.lerp=n;function o({r:l,g:h,b:c,a:u}=e.white){return`rgba(${l*255}, ${h*255}, ${c*255}, ${u})`}e.toStyle=o})(Li||(Li={}));var D1;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(D1||(D1={}));var JA;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(JA||(JA={}));var $A;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})($A||($A={}));var rl;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(rl||(rl={}));function eE(e){return typeof e=="string"&&e.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!1}var Mh;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Mh||(Mh={}));var mu;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective?.zoom??1:i.orthographic?.zoom??1}e.getZoom=t})(mu||(mu={}));var pl;(e=>{function t(r,a=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*a,0,0]},grid:{count:[2,2,2],size:r.map(s=>s*(1+a)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(r,a){let s={...r};if(x3.forEach(n=>{Object.assign(s,{[n]:a[n]??r[n]})}),s.radial={...r.radial},a.radial){let n=r.radial,o=a.radial;b3.forEach(l=>{Object.assign(s.radial,{[l]:o[l]??n[l]})})}if(s.linear={...r.linear},a.linear){let n=r.linear,o=a.linear;w3.forEach(l=>{Object.assign(s.linear,{[l]:o[l]??n[l]})})}if(s.grid={...r.grid},a.grid){let n=r.grid,o=a.grid;_3.forEach(l=>{Object.assign(s.grid,{[l]:o[l]??n[l]})})}if(s.toObject={...r.toObject},a.toObject){let n=r.toObject,o=a.toObject;S3.forEach(l=>{Object.assign(s.toObject,{[l]:o[l]??n[l]})})}if(s.randomnessObject={...r.randomnessObject},a.randomnessObject){let n=r.randomnessObject,o=a.randomnessObject;A3.forEach(l=>{Object.assign(s.randomnessObject,{[l]:o[l]??n[l]})})}return s}e.merge=i})(pl||(pl={}));var R1;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,a){let s=[];r.count!==void 0&&s.push({type:0,path:a,props:{count:r.count}});for(let n of t){let o=r[n];o&&Object.keys(o).length>0&&s.push({type:0,path:[...a,n],props:o})}return s}e.toOps=i})(R1||(R1={}));var x3=["count"],b3=["radius","start","end","position","scale","rotation"],w3=["position","scale","rotation"],_3=["count","size"],S3=["count","position","scale","rotation"],A3=["strength","scale","rotation","position","movement","seed","freqScale"],O1;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(O1||(O1={}));var L1;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:Li.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Li.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Li.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(L1||(L1={}));var xg;(e=>(e.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},e.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},e.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:e.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...e.defaultCollisionData}))(xg||(xg={}));var gu;(e=>e.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(gu||(gu={}));var I1;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(I1||(I1={}));var B1;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})(B1||(B1={}));var U1;(e=>e.defaultData={...B1.defaultData,...I1.defaultData})(U1||(U1={}));var tE;(e=>{function t(i,r){let a=[];if("material"in i){let s=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;s&&a.push(s)}else if("materials"in i)for(let s of i.materials){let n=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;n&&a.push(n)}return a}e.getMaterialData=t})(tE||(tE={}));var bg;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(bg||(bg={}));var iE;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="particle"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(iE||(iE={}));function zq(e){return e.type!=="displace"}var rE;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(rE||(rE={}));var E3=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],kq=["wrapping","image","video","name","minFilter"],qr;(e=>{function t(s,n){let{texture:o,...l}=n;if(Object.assign(s,l),o){let h=s.texture;h&&Object.assign(h,o)}}e.patch=t;function i(s,n){return s==="light"&&n?r(n):a(s)}e.defaultData=i;function r(s){let n={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...n,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...n,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...n,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...n,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function a(s){let n={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...n,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"video":return{...n,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:bg.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"color":return{...n,type:"color",color:ga.fromHex(ss)};case"depth":return{...n,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...n,type:"normal",cnormal:[1,1,1]};case"gradient":return{...n,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...n,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...ga.fromHex(6710886),a:1},colorB:{...ga.fromHex(6710886),a:1},colorC:{...ga.fromHex(16777215),a:1},colorD:{...ga.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...n,type:"fresnel",color:Li.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...n,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...n,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Li.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...n,type:"outline",outlineColor:Li.fromHexAndA(0,1),contourColor:Li.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{...n,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008}};case"transmission":return{...n,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...n,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...ga.fromHex(0),a:1},colorB:{...ga.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(qr||(qr={}));var wa;(e=>{function t(c){return!c.layers.some(u=>u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")}e.isMergable=t;function i(c){let u="";return c.layers.forEach(d=>{Object.entries(d.data).forEach(([p,f])=>{u+=`${p}${f}`,Array.isArray(f)?f.forEach(m=>u+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?u+=`${m.toFixed(4)}`:u+=`${m}`}):u+=`${f}`})}),u}e.getHash=i;function r(){return{layers:new Tt}}e.defaultEmptyData=r;function a(c="layer1",u="layer2"){return n("phong",c,u)}e.defaultData=a;function s(c,u){return{...c,name:u}}e.withName=s;function n(c,u="layer1",d="layer2"){let p=new Tt;return p.push({fi:0,data:qr.defaultData("light",c),id:u}),p.push({fi:1,data:qr.defaultData("color"),id:d}),{layers:p}}e.defaultTwoLayerData=n;function o(c){let u=qr.defaultData("texture");c&&Object.assign(u.texture,{image:c});let d=new Tt;return d.push({fi:0,data:u,id:"layer1"}),d.push({fi:1,data:{...qr.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...qr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}e.defaultUIObjectMaterial=o;function l(c,u="phong",d="layer1",p="layer2"){let f=qr.defaultData("texture");Object.assign(f.texture,{image:c});let m=new Tt;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:qr.defaultData("light",u),id:p}),{layers:m}}e.defaultTwoLayerTextureData=l;function h(c,u="phong",d="layer1",p="layer2"){let f=qr.defaultData("video");Object.assign(f.texture,{video:c});let m=new Tt;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:qr.defaultData("light",u),id:p}),{layers:m}}e.defaultTwoLayerVideoTextureData=h})(wa||(wa={}));var wg;(e=>{function t(){return{points:new Tt,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(wg||(wg={}));var _g;(e=>{function t(){return{points:new Tt,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(_g||(_g={}));var M3={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},F1;(e=>{function t(i,r){let a={...i};return T3.forEach(s=>{Object.assign(a,{[s]:r[s]??i[s]})}),a}e.merge=t})(F1||(F1={}));var C3={shape:M3,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},T3=["depth","offset","angle","twist","startScale","endScale"],Sg;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=i})(Sg||(Sg={}));var N1;(e=>{function t(i,r){let a={...i};return Object.assign(a,r),a.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(a.extrusion={...i.extrusion},Object.assign(a.extrusion,F1.merge(a.extrusion,r.extrusion))),a}e.merge=t})(N1||(N1={}));var Zc;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:_g.defaultData(),extrusion:C3};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:wg.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}e.defaultData=t})(Zc||(Zc={}));var aE=["width","height","depth"],z1;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:ga.white,near:.1,far:2e3})(z1||(z1={}));var Ag;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})(Ag||(Ag={}));var k1;(e=>e.defaultData={softShadowQuality:"low"})(k1||(k1={}));var V1;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(V1||(V1={}));var j1;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(j1||(j1={}));var vu;(e=>e.defaultData={usePhysics:!1,gravity:-10})(vu||(vu={}));var G1;(e=>e.defaultData={playCamera:Uu,gameControlObject:null})(G1||(G1={}));var H1;(e=>e.defaultData={backgroundColor:Li.fromHexAndA(Nq,1),postprocessing:Ag.defaultData,fog:z1.defaultData,globalPhysics:vu.defaultData,ambient:V1.defaultData,ao:j1.defaultData,shadow:k1.defaultData,publish:G1.defaultData})(H1||(H1={}));var W1;(e=>e.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(W1||(W1={}));var sE;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(sE||(sE={}));var yu;(e=>{e.identity={...D1.identity,hiddenMatrix:fu.identity};function t(a){return{position:a.position,rotation:a.rotation,scale:a.scale,hiddenMatrix:a.hiddenMatrix}}e.fromObject=t;function i(a,s){return{position:s?.position||a.position,rotation:s?.rotation||a.rotation,scale:s?.scale||a.scale,hiddenMatrix:s?.hiddenMatrix||a.hiddenMatrix}}e.merge=i;function r(a,s){return HP({position:vh.isEqual(a.position,s.position)?void 0:s.position,rotation:vh.isEqual(a.rotation,s.rotation)?void 0:s.rotation,scale:vh.isEqual(a.scale,s.scale)?null:s.scale,hiddenMatrix:fu.isEqual(a.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})}e.diff=r})(yu||(yu={}));var ha;(e=>e.defaultData={states:new Tt,events:new Tt,visible:!0,raycastLock:!1,physics:gu.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...yu.identity,cloner:null})(ha||(ha={}));var q1;(e=>e.defaultData={type:"Empty",...ha.defaultData})(q1||(q1={}));var nE;(e=>e.defaultData={type:"ParticleCollider",...W1.defaultData,...ha.defaultData})(nE||(nE={}));var oE;(e=>e.defaultData={type:"Component",...ha.defaultData})(oE||(oE={}));var lE;(e=>e.defaultData={type:"Particle",...ha.defaultData,...xg.defaultData})(lE||(lE={}));var Jc;(e=>e.defaultData={type:"Mesh",...ha.defaultData,...U1.defaultData})(Jc||(Jc={}));var lp;(e=>e.defaultData={...ha.defaultData,...yu.identity,position:[0,0,mu.DefaultTargetOffset],...mu.defaultData})(lp||(lp={}));var X1;(e=>{function t(i){return{...ha.defaultData,...L1.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(X1||(X1={}));var Eg;(e=>{function t(r,a,s=0){for(;s<a.length;){let n=r?r[a[s]]:void 0;if(a.length===s+1)return n;if(n)r=n.descendants,s+=1;else return}}e.resolveWithDes=t;function i(r,a,s=0){let n=t(r,a,s);if(n){let o=Object.keys(n);if(o.length===1&&o[0]==="descendants")return}return n}e.resolve=i})(Eg||(Eg={}));var fl;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,a){return{...ha.defaultData,...a,component:r,overrides:new Tr,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let a=yu.fromObject(r.data);return t(r.id,a)}e.fromComponentData=i})(fl||(fl={}));var xu;(e=>{e.defaultData={type:"Page",...ha.defaultData,physics:{...gu.defaultData,fusedBody:!1},...H1.defaultData,camera:lp.defaultData};function t(i){return i.uiScene!==void 0}e.isUIPage=t})(xu||(xu={}));var Y1;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:fu.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:gu.defaultData,states:new Tt,events:new Tt,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...mu.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...ha.defaultData,...Jc.defaultData,geometry:Zc.defaultData("RectangleGeometry"),material:wa.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...ha.defaultData,...Jc.defaultData,geometry:Zc.defaultData("BooleanGeometry"),material:wa.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...ha.defaultData,...Jc.defaultData,geometry:Zc.defaultData("TextGeometry"),material:wa.defaultTwoLayerData("phong","layer1","layer2")}))(Y1||(Y1={}));var lh;(e=>{function t(s,n){let o={name:n};return s.type==="Mesh"?(o.geometry={},"material"in s&&(o.material={layers:new Tr}),"materials"in s&&(o.materials=s.materials.map(l=>({layers:new Tr})))):Mh.is(s.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(s,n){if(n===void 0)return s;let o={...s};return"material"in o&&"material"in n&&n.material&&(o.material=op(o.material,l=>{if(typeof l!="string")for(let[h,c]of Object.entries(n.material.layers)){let u=l.layers.data(h);u&&qr.patch(u,c)}}).data),o.materials&&n.materials&&(o.materials=op(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let c=n.materials[h];if(typeof c!="string")for(let[u,d]of Object.entries(c.layers)){let p=l[h]?.layers?.data(u);p&&qr.patch(p,d)}}}).data),o}function r(s,n){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function c(u,d){for(let[p,f]of Object.entries(d.layers)){let{texture:m,...g}=f;if(m!==void 0&&Object.keys(m).length>0){let v={path:[...u,"layers",p,"texture"],props:m,type:0};l.push(v)}if(Object.keys(g).length>0){let v={path:[...u,"layers",p],props:g,type:0};l.push(v)}}}for(let[u,d]of Object.entries(n))if(u!=="name")if(u==="cloner")l.push(...R1.toOps(d,["cloner"]));else if(u==="pathSnapping")l.push({path:[u],props:{slide:d.slide,offset:d.offset},type:0});else if(u==="material")c(["material"],d);else if(u==="materials")for(let[p,f]of Object.entries(d))c(["materials",p],f);else if(h[u]===0){if(u==="geometry"&&d.extrusion!==void 0){let p={path:[u,"extrusion"],props:d.extrusion,type:0};l.push(p),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let p={path:[u],props:d,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[u]=d;return l}e.toOps=r;function a(s,n){if(n===void 0)return s;let o={...s};if(Object.assign(o,yu.merge(o,n)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:n.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??o.pathSnapping?.offset??0})}),Mh.is(s.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=n;l.orthographic?.zoom!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(o.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(o.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in n&&Object.assign(o,{geometry:N1.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:pl.merge(o.cloner,n.cloner)});else if(s.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:pl.merge(o.cloner,n.cloner)});else if(O1.is(s.type)){let l=n;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=ga.clone(l.color))}return o}e.patch=a})(lh||(lh={}));var Mg;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Mg||(Mg={}));var ml;(e=>e.defaultData={orbitControls:Mg.defaultData,playPage:Gd,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,a=0;return i<5?a=-30:i<10&&(a=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,a],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(ml||(ml={}));var Q1;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Q1||(Q1={}));var K1;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(K1||(K1={}));var hh;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Q1.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:K1.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(hh||(hh={}));var hp;(e=>{function t(r){return r.find(a=>a.data.type==="Page"&&a.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,a,s){r.scene.objects.traverseFrom(a,(n,o)=>{if(o.type==="Instance"){let l=Pg.getComponentData(r,o.component)?.data;l&&s(n,o,l.events)}else s(n,o,o.events)})}e.traverseModuleInstances=i})(hp||(hp={}));var ch;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(a=!0){let s=[],n=Y1.defaultMeshObject;a&&(s.push({fi:-1,data:X1.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:n,children:[]}));let o=new oa;return o.push({fi:1,id:Gd,data:{...xu.defaultData,name:"Scene 1"},children:s}),o}e.defaultData={objects:t(),publish:ml.defaultData,styles:hh.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new oa,publish:ml.defaultData,styles:hh.defaultData()}},e.emptyDataWithPage=function(a=!0){return{objects:t(a),publish:ml.defaultData,styles:hh.defaultData()}},e.emptyData=function(){return{objects:new oa,publish:{...ml.defaultData},styles:hh.defaultData()}};function i(a){return{...e.defaultData,objects:Ln(a,oa.prototype)}}e.withObjs=i;function r(a,s){return i([{id:a,data:s,children:[],fi:0}])}e.withObj=r})(ch||(ch={}));var Hd;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Hd||(Hd={}));var as;(e=>{function t(n){return n.textValue!==void 0}e.isTextValue=t;function i(n){return typeof n=="number"}e.isNumber=i;function r(n){return typeof n=="boolean"}e.isBoolean=r;function a(n){return t(n)?"string":r(n)?"boolean":"number"}e.typeOfVariable=a;function s(n){return e.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(o=>o.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():e.isBoolean(n)?n?"True":"False":e.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}e.getDisplayedValue=s})(as||(as={}));var Z1;(e=>e.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(Z1||(Z1={}));var hE;(e=>e.all=[...Z1.all,"components"])(hE||(hE={}));var cE;(e=>{function t(){return{images:new Vt,videos:new Vt,colors:new Vt,audios:new Vt,particles:new Vt,fonts:new Vt,materials:new Vt,components:new Vt,variables:new Vt}}e.defaultData=t})(cE||(cE={}));var Ch;(e=>{function t(){return{images:new Vt,videos:new Vt,colors:new Vt,audios:new Vt,particles:new Vt,fonts:new Vt,materials:new Vt,components:new Vt,variables:new Vt}}e.defaultData=t})(Ch||(Ch={}));var ws;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ln(n,Vt.prototype)}e.defaultColors=t;function i(){return Ln({},Vt.prototype)}e.defaultImages=i;function r(){return{catelogs:new Vt,materials:new Vt,images:new Vt,videos:new Vt,colors:new Vt,audios:new Vt,particles:new Vt,fonts:new Vt,variables:new Tt,lib:Ch.defaultData()}}e.emptyData=r;function a(n){switch(n){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let o=[0,0,0];return{name:"Time",value:{textValue:o,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:o,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",n)}}e.defaultVariables=a;function s(n,o){if(o.format==="HH:mm:ss"){let l=Math.floor(n/3600),h=Math.floor((n-l*3600)/60),c=Math.round(n-l*3600-h*60);return{textValue:[l,h,c]}}else if(o.format==="mm:ss"){let l=Math.floor(n/60),h=Math.round(n-l*60);return{textValue:[l,h]}}else return o.format==="number"?n=Math.round(n):n=Math.round(n*1e3)/1e3,n}e.getFormattedTimerTime=s})(ws||(ws={}));var Cg;(e=>e.list=["idle","move","jump","run"])(Cg||(Cg={}));var Tg;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new Tt,move:new Tt,jump:new Tt,run:new Tt},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Li.fromHexAndA(3728051,1)}}))(Tg||(Tg={}));function uE(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,a=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let o=2;o<10;o++)a.push(a[1]),s.push(1);let n={...Ao(Pr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:a,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,n)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...Pr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function nl(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function ol(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((a,s)=>{a===void 0&&(r.materials[s]=wa.defaultData(),a=r.materials[s]),typeof a!="string"&&t(a)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=wa.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=wa.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(a=>{a.material&&typeof a.material!="string"&&Object.getPrototypeOf(a.material)!==Tr.prototype&&t(a.material)})})}function Vq(e){Object.assign(e.scene.publish,{orbitControls:{...Mg.defaultData,...Pr(e.scene.publish.orbitControls)}})}function jq(e){Object.assign(e.scene.publish.settings,{video:{...ml.defaultData.settings.video,...Pr(e.scene.publish.settings.video)}})}function Gq(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[a,s]of Object.entries(r))if((E3.includes(a)||typeof s=="boolean")&&delete r[a],a==="texture")for(let[n,o]of Object.entries(s))(kq.includes(n)||typeof o=="boolean")&&delete s[n]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(a=>{let s=a;s.material?t(s.material):s.materials&&s.materials.forEach(n=>{t(n)})})})}function Hq(e){e.scene.publish.withBackground=!0}function Wq(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function qq(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(a=>a+1),r.linear.scale=r.linear.scale.map(a=>a+1))})}function Xq(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function Yq(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let a=Pr(e.scene.objects.data(r));a&&a.type==="Mesh"&&a.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=Pr(i).booleanExclude!==!0)}})}function Qq(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function Kq(e){function t(r){Object.setPrototypeOf(r,Tr.prototype),r.texture&&Object.setPrototypeOf(r.texture,Tr.prototype)}function i(r){Object.setPrototypeOf(r,Tr.prototype);for(let a in r)t(r[a])}e.scene.objects.traverse((r,a)=>{a.states.forEach(s=>{let n=s;if(n.material){let o=Pr(n.material).layers;i(o),n.material.layers=o}if(n.materials)for(let o=0;o<n.materials.length;o++){let l=n.materials[o],h=Pr(l).layers;i(h),l.layers=h}})})}function dE(e){e.layers===void 0&&Object.assign(e,wa.defaultTwoLayerData("lambert"))}function z0(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let a={...Pr(t),colors:i,steps:r};Object.assign(t,a)}})}function Zq(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function pE(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&z0(r)}):"material"in i&&typeof i.material!="string"&&z0(i.material)}),Object.values(e.shared.materials).forEach(t=>z0(t))}function Jq(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function $q(e){e.shared.audios=Ln({},Vt.prototype)}function eX(e){e.shared.videos=Ln({},Vt.prototype)}function tX(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let a={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:a})}})}function iX(e){Object.entries(Pr(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(Pr(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function rX(e){e.scene.publish.settings.web.preload=!1}function fE(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function mE(e){e.layers&&e.layers.forEach(t=>{zq(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function aX(e){e.shared.fonts=Ln({},Vt.prototype)}function sX(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function nX(e){let t=[];e.scene.objects.traverse((i,r)=>{let a=r;if(a.type==="TextFrame"){let s=wa.defaultTwoLayerData("phong"),n=typeof a.color=="string"?e.shared.colors[a.color]:a.color;s.layers[1].data.color={r:n.r,g:n.g,b:n.b},s.layers[1].data.alpha=a.alpha;let o=sX(a.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:a.name,...ha.defaultData,...Jc.defaultData,flatShading:!1,wireframe:!1,geometry:{...Zc.defaultData("TextGeometry"),width:a.width,height:a.height,font:o,depth:0,horizontalAlign:a.horizontalAlign,verticalAlign:a.verticalAlign,fontSize:a.fontSize*1.40625,lineHeight:a.lineHeight/1.40625,letterSpacing:a.letterSpacing-1,text:a.text,textTransform:a.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Pr(a.states),events:Pr(a.events),visible:a.visible,raycastLock:a.raycastLock,position:a.position,rotation:a.rotation,scale:a.scale,hiddenMatrix:a.hiddenMatrix},h=Pr(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function oX(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(a=>{if(t[Number(a.type)])if(Object.assign(a,{type:t[Number(a.type)]}),a.type==="Audio"&&"audioEvent"in a&&(Object.assign(a,{playAudio:a.audioEvent}),delete a.audioEvent),a.type==="GameControl")Object.assign(a,{gameActions:{idle:new Tt,move:new Tt,jump:new Tt}});else{let s=new Tt;Object.assign(a,{actions:s}),(a.type==="MouseDown"||a.type==="MouseUp"||a.type==="KeyDown"||a.type==="KeyUp")&&"url"in a&&s.push({fi:0,id:dt.generateUUID(),data:{type:"Link",url:a.url,delay:0}}),"targets"in a&&(a.targets.forEach((n,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(c,Ao(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(c,{control1:{...n.control1},control2:{...n.control2}});let u={repeat:n.repeat?-1:0,delay:n.delay,delayDirection:n.delayDirection,direction:n.cycle&&n.rewind?"pingpong-rewind":n.cycle?"pingpong":"normal"},d={state:n.state,...u,...c},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Tt({fi:0,id:dt.generateUUID(),data:h},{fi:1,id:dt.generateUUID(),data:d})};s.push({fi:l,id:o,data:p})}),delete a.targets)}})})}function lX(e){e.scene.objects.traverse((t,i)=>{function r(a,s){let n=new Tt,o=[];if(i.events.forEach((l,h,c)=>{if(l.type==="Audio"&&l.trigger===s){let u;o.push(h),l.interaction==="play"?u={...Ao(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")&&(u={...Ao(l,"interaction","delay","object","playAudio"),type:"Audio"}),u&&n.push({fi:c,id:h,data:u})}}),o.forEach(l=>i.events.delete(l)),n.length){let l=i.events.find(h=>h.type===a)?.data;l?"actions"in l&&l.actions.insertBefore(null,n):i.events.insertBefore(null,[{id:dt.generateUUID(),data:{type:a,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function gE(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=qr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function vE(e){nl(e,gE),ol(e,gE)}function hX(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function cX(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function uX(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=wa.defaultTwoLayerData("phong"))})}function dX(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function pX(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function fX(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function mX(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function gX(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function vX(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function yX(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Tg.defaultDataThirdPerson.navmesh)})})}function xX(e){e.scene.styles||(e.scene.styles=hh.defaultData())}function yE(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function bX(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),ol(e,yE),nl(e,yE)}function wX(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Tt})})})}function _X(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function xE(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function SX(e,t){if(t<1&&(ol(e,uE),nl(e,uE),e.schema=1),t<2&&(Vq(e),e.schema=2),t<3&&(Gq(e),e.schema=3),t<4&&(Hq(e),e.schema=4),t<5&&(Wq(e),e.schema=5),t<6&&(qq(e),e.schema=6),t<7&&(Xq(e),e.schema=7),t<8&&(e.schema=8),t<9&&(pE(e),e.schema=9),t<10&&(Zq(e),e.schema=10),t<11&&(Jq(e),e.schema=11),t<12&&(pE(e),e.schema=12),t<13&&($q(e),e.schema=13),t<14&&(tX(e),e.schema=14),t<15&&(iX(e),e.schema=15),t<16&&(rX(e),e.schema=16),t<17&&(ol(e,fE),nl(e,fE),e.schema=17),t<18&&(ol(e,dE),nl(e,dE),e.schema=18),t<19&&(jq(e),e.schema=19),t<20&&(aX(e),nX(e),e.schema=20),t<21&&(oX(e),lX(e),e.schema=21),t<22&&(vE(e),e.schema=22),t<23&&(hX(e),e.schema=23),t<24&&(cX(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(eX(e),t<25&&(e.schema=25)),t<26&&(Yq(e),e.schema=26),t<27&&(Qq(e),e.schema=27),t<28&&(vE(e),e.schema=28),t<29&&(Kq(e),e.schema=29),t<30&&(uX(e),e.schema=30),t<31&&(dX(e),e.schema=31),t<33&&(pX(e),e.schema=33),t<34&&(fX(e),e.schema=34),t<35&&(mX(e),e.schema=35),t<36&&(gX(e),e.schema=36),t<37&&(vX(e),e.schema=37),t<38&&(ol(e,mE),nl(e,mE),e.schema=38),t<39&&(yX(e),e.schema=39),t<40&&(xX(e),e.schema=40),t<41&&(bX(e),e.schema=41),t<42&&(wX(e),e.schema=42),t<43&&(_X(e),e.schema=43),t<99){ol(e,xE),nl(e,xE),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=Uu);let i=Pr(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=Gd,r.insertBefore(null,null,[{id:Gd,data:{...xu.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:Ao(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:Ao(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...vu.defaultData,...Ao(e.scene.environment,"usePhysics","gravity")},camera:Pr(e.scene.ownerCamera)??xu.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==ch.TRASH_CAN_ID&&r.move(Gd,n.fi,n.id);let a=0,s=0;e.shared.penumbraSize&&e.scene.objects.traverse((n,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(a,2)],a+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(s,1)],s+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,gu.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function bE(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function AX(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function EX(e){Array.isArray(Pr(e.events))&&e.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var Ic=180/Math.PI;function wE(e){e.rotation=e.rotation.slice(0,3).map(t=>t*Ic)}function P3(e){wE(e),e.type==="Page"&&wE(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Ic))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Ic),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Ic),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Ic,t.extrusion.twist*=Ic),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(Pr(e.events))&&e.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Repeat")})}function MX(e){e.shared.variables=Ln({},Vt.prototype)}function CX(e){let t=Pr(e.shared.variables);e.shared.variables=Ln(Object.entries(t??{}).map(([i,r],a)=>({fi:a,id:i,data:r})),Tt.prototype)}var po=112;function D3(e,t){t(e.data);for(let i of e.children)D3(i,t)}function TX(e){let t=e.schema??104;t!==po&&t<105&&(D3(e.asset,P3),e.schema=105)}function PX(e){e.shared.particles=Ln({},Vt.prototype),e.shared.lib&&(e.shared.lib.particles=Ch.defaultData().particles)}function DX(e){e.scene.objects.traverse((t,i)=>{i.type==="Particle"&&typeof i.renderMaterial.size=="number"&&Object.assign(i.renderMaterial,{size:[i.renderMaterial.size,i.renderMaterial.size]})})}function RX(e){e.scene.objects.traverse((t,i)=>{i.type==="Page"&&(i.postprocessing.depthOfField.focusDistance=100,i.postprocessing.depthOfField.focalLength=20,i.postprocessing.depthOfField.bokehScale=5)})}function R3(e){let t=e.schema??0;if(t!==po){console.warn("updating from ",t,"to ",po),SX(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=ml.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(ol(e,bE),nl(e,bE),e.schema=101),t<102&&(AX(e),e.schema=102),t<104&&(e.shared.catelogs=new Vt,e.shared.lib=Ch.defaultData(),e.schema=104),t<105&&(MX(e),e.scene.objects.traverse((i,r)=>{P3(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))TX(i);t<106&&(CX(e),e.schema=106),t<107&&(e.shared.lib.variables=Ch.defaultData().variables,e.schema=107),t<109&&(PX(e),e.schema=109),t<110&&(DX(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{EX(r)}),e.schema=111),t<112&&(RX(e),e.schema=112)}}var Pg;(e=>{e.defaultData={schema:po,scene:ch.defaultData,frames:new Vt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Hd.defaultData),shared:{...ws.emptyData(),colors:ws.defaultColors()}},e.emptyDataForImports=function(){let a=ch.emptyDataWithPage();return{schema:po,scene:a,frames:new Vt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Hd.defaultData),shared:{...ws.emptyData(),colors:ws.defaultColors(),images:ws.defaultImages()}}},e.emptyData=function(){return{schema:po,scene:ch.emptyDataWithPage(),frames:new Vt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Hd.defaultData),shared:ws.emptyData()}},e.clipboard2dData=function(){return{schema:po,scene:ch.emptyData(),frames:new Vt,shared:ws.emptyData()}},e.collabHelper={...v1,updateSchema(a){return(a.schema??0)<po?op(a,R3):(a.schema??0)-po}};function t(a){let s=e.collabHelper.updateSchema(a);return typeof s=="number"?s===0?a:null:s.data}e.updateSchemaDirectly=t;function i(a){return{...a,shared:{...a.shared,lib:Ch.defaultData()}}}e.withoutLib=i;function r(a,s){let n=a.scene.objects.get(s);if(n&&n.data.type==="Component")return n;{let o=a.shared.lib.components[s];if(o)return o.asset}}e.getComponentData=r})(Pg||(Pg={}));var J1;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(J1||(J1={}));var _E;(e=>{function t(i){return!0}e.is=t})(_E||(_E={}));var Dg;(e=>{e.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(r,a){return{position:a?.position??r.position,rotation:a?.rotation??r.rotation,scale:a?.scale??r.scale,shear:a?.shear??r.shear}}e.merge=t;function i(r,a){return HP({position:wo.isEqual(r.position,a.position)?void 0:a.position,rotation:r.rotation===a.rotation?void 0:a.rotation,scale:wo.isEqual(r.scale,a.scale)?void 0:a.scale,shear:r.shear&&a.shear&&wo.isEqual(r.shear,a.shear)?void 0:a.shear})}e.diff=i})(Dg||(Dg={}));var $1;(e=>e.defaultData={horizontalConstraint:0,verticalConstraint:0})($1||($1={}));var Rg;(e=>e.defaultData={opacity:1,fill:{color:Li.fromHexAndA(ss,1),enabled:!0},stroke:{color:Li.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Li.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Li.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Rg||(Rg={}));var uh;(e=>{function t(n,o){return{name:o}}e.newEmpty=t;function i(n,o){if(o===void 0)return n;let l={...n},h=["width","height","cornerRadius"];for(let c of h)c in l&&c in o&&o[c]!==void 0&&Object.assign(l,{[c]:o[c]});return l}function r(n,o){if(o===void 0)return n;let l={...n};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}function a(n,o){if(o===void 0)return n;let l={...n};return Object.assign(l,Dg.merge(l,o)),l=i(l,o),l=r(l,o),l}e.patch=a;function s(n,o){let l,h=[];for(let[c,u]of Object.entries(o))c!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},h.push(l)),l.props[c]=u);return h}e.toOps=s})(uh||(uh={}));var cp;(e=>e.defaultData={...Dg.defaultData,...$1.defaultData,states:new Tt,events:new Tt,visible:!0,raycastLock:!1})(cp||(cp={}));var bu;(e=>e.defaultData={...cp.defaultData,...Rg.defaultData})(bu||(bu={}));var Og;(e=>e.defaultData={cornerRadius:[0,0,0,0]})(Og||(Og={}));var ex;(e=>e.defaultData={...bu.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(ex||(ex={}));var up;(e=>e.defaultData={...bu.defaultData,...Og.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(up||(up={}));var tx;(e=>e.defaultData={...bu.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(tx||(tx={}));var ix;(e=>e.defaultData={...bu.defaultData,type:"path2d",path:"",name:"Path"})(ix||(ix={}));var SE;(e=>{function t(i){return i.type==="ellipse2d"||i.type==="rectangle2d"||i.type==="text2d"||i.type==="vector2d"||i.type==="path2d"}e.is=t})(SE||(SE={}));var Lg;(e=>e.defaultData={...cp.defaultData,name:"Group",type:"group2d"})(Lg||(Lg={}));var rx;(e=>e.defaultData=()=>({...cp.defaultData,...Og.defaultData,...Rg.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Li.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Li.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(rx||(rx={}));var yh;(e=>{function t(s){switch(s){case"rectangle2d":return{...up.defaultData};case"ellipse2d":return{...ex.defaultData};case"text2d":return{...tx.defaultData};case"vector2d":return{...up.defaultData};case"path2d":return{...ix.defaultData};case"frame2d":return{...rx.defaultData()};case"group2d":return{...Lg.defaultData}}}e.defaultData=t;function i(s){return"width"in s&&"height"in s?[typeof s.width=="number"?s.width*.5:0,typeof s.height=="number"?s.height*.5:0]:[0,0]}e.getPivot=i;function r(s){return s.type==="rectangle2d"||s.type==="ellipse2d"||s.type==="text2d"||s.type==="frame2d"}e.isResizeable=r;function a(s){return s.type==="rectangle2d"||s.type==="frame2d"}e.hasCorners=a})(yh||(yh={}));var ax;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new oa},e.emptyData=function(){return{type:"scene2d",objects:new oa}}))(ax||(ax={}));function dh(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),a=new Set(Object.keys(e[0].morphAttributes)),s={},n={},o=e[0].morphTargetsRelative,l=new St,h=0;for(let c=0;c<e.length;++c){let u=e[c],d=0;if(i!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() 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 p in u.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(u.attributes[p]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in u.morphAttributes){if(!a.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;n[p]===void 0&&(n[p]=[]),n[p].push(u.morphAttributes[p])}if(t){let p;if(i)p=u.index.count;else if(u.attributes.position!==void 0)p=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,c),h+=p}}if(i){let c=0,u=[];for(let d=0;d<e.length;++d){let p=e[d].index;for(let f=0;f<p.count;++f)u.push(p.getX(f)+c);c+=e[d].attributes.position.count}l.setIndex(u)}for(let c in s){let u=AE(s[c]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,u)}for(let c in n){let u=n[c][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let d=0;d<u;++d){let p=[];for(let m=0;m<n[c].length;++m)p.push(n[c][m][d]);let f=AE(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(f)}}return l}function AE(e){let t,i,r,a=-1,s=0;for(let h=0;h<e.length;++h){let c=e[h];if(t===void 0&&(t=c.array.constructor),t!==c.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=c.itemSize),i!==c.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=c.normalized),r!==c.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(a===-1&&(a=c.gpuType),a!==c.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=c.count*i}let n=new t(s),o=new Ut(n,i,r),l=0;for(let h=0;h<e.length;++h){let c=e[h];if(c.isInterleavedBufferAttribute){let u=l/i;for(let d=0,p=c.count;d<p;d++)for(let f=0;f<i;f++){let m=c.getComponent(d,f);o.setComponent(d+u,f,m)}}else n.set(c.array,l);l+=c.count*i}return a!==void 0&&(o.gpuType=a),o}var OX=Math.pow(2,-24),zf=class{constructor(){}};function An(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function EE(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let a=e[r+3]-e[r];a>i&&(i=a,t=r)}return t}function ME(e,t){t.set(e)}function CE(e,t,i){let r,a;for(let s=0;s<3;s++){let n=s+3;r=e[s],a=t[s],i[s]=r<a?r:a,r=e[n],a=t[n],i[n]=r>a?r:a}}function kf(e,t,i){for(let r=0;r<3;r++){let a=t[e+2*r],s=t[e+2*r+1],n=a-s,o=a+s;n<i[r]&&(i[r]=n),o>i[r+3]&&(i[r+3]=o)}}function dd(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function LX(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,a;i>65535?a=new Uint32Array(new r(4*i)):a=new Uint16Array(new r(2*i)),e.setIndex(new Ut(a,1));for(let s=0;s<i;s++)a[s]=s}}function IX(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let a of e.groups)i.add(a.start),i.add(a.start+a.count);let r=Array.from(i.values()).sort((a,s)=>a-s);for(let a=0;a<r.length-1;a++){let s=r[a],n=r[a+1];t.push({offset:s/3,count:(n-s)/3})}return t}function k0(e,t,i,r,a=null){let s=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0,u=1/0,d=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0,v=a!==null;for(let x=t*6,b=(t+i)*6;x<b;x+=6){let _=e[x+0],M=e[x+1],A=_-M,S=_+M;A<s&&(s=A),S>l&&(l=S),v&&_<u&&(u=_),v&&_>f&&(f=_);let P=e[x+2],L=e[x+3],E=P-L,T=P+L;E<n&&(n=E),T>h&&(h=T),v&&P<d&&(d=P),v&&P>m&&(m=P);let B=e[x+4],V=e[x+5],I=B-V,H=B+V;I<o&&(o=I),H>c&&(c=H),v&&B<p&&(p=B),v&&B>g&&(g=B)}r[0]=s,r[1]=n,r[2]=o,r[3]=l,r[4]=h,r[5]=c,v&&(a[0]=u,a[1]=d,a[2]=p,a[3]=f,a[4]=m,a[5]=g)}function BX(e,t,i,r){let a=1/0,s=1/0,n=1/0,o=-1/0,l=-1/0,h=-1/0;for(let c=t*6,u=(t+i)*6;c<u;c+=6){let d=e[c+0];d<a&&(a=d),d>o&&(o=d);let p=e[c+2];p<s&&(s=p),p>l&&(l=p);let f=e[c+4];f<n&&(n=f),f>h&&(h=f)}r[0]=a,r[1]=s,r[2]=n,r[3]=o,r[4]=l,r[5]=h}function UX(e,t,i,r,a){let s=i,n=i+r-1,o=a.pos,l=a.axis*2;for(;;){for(;s<=n&&t[s*6+l]<o;)s++;for(;s<=n&&t[n*6+l]>=o;)n--;if(s<n){for(let h=0;h<3;h++){let c=e[s*3+h];e[s*3+h]=e[n*3+h],e[n*3+h]=c;let u=t[s*6+h*2+0];t[s*6+h*2+0]=t[n*6+h*2+0],t[n*6+h*2+0]=u;let d=t[s*6+h*2+1];t[s*6+h*2+1]=t[n*6+h*2+1],t[n*6+h*2+1]=d}s++,n--}else return s}}var oo=32,FX=(e,t)=>e.candidate-t.candidate,Yo=new Array(oo).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Vf=new Float32Array(6);function NX(e,t,i,r,a,s){let n=-1,o=0;if(s===0)n=EE(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(s===1)n=EE(e),n!==-1&&(o=zX(i,r,a,n));else if(s===2){let l=dd(e),h=1.25*a,c=r*6,u=(r+a)*6;for(let d=0;d<3;d++){let p=t[d],f=(t[d+3]-p)/oo;if(a<oo/4){let m=[...Yo];m.length=a;let g=0;for(let x=c;x<u;x+=6,g++){let b=m[g];b.candidate=i[x+2*d],b.count=0;let{bounds:_,leftCacheBounds:M,rightCacheBounds:A}=b;for(let S=0;S<3;S++)A[S]=1/0,A[S+3]=-1/0,M[S]=1/0,M[S+3]=-1/0,_[S]=1/0,_[S+3]=-1/0;kf(x,i,_)}m.sort(FX);let v=a;for(let x=0;x<v;x++){let b=m[x];for(;x+1<v&&m[x+1].candidate===b.candidate;)m.splice(x+1,1),v--}for(let x=c;x<u;x+=6){let b=i[x+2*d];for(let _=0;_<v;_++){let M=m[_];b>=M.candidate?kf(x,i,M.rightCacheBounds):(kf(x,i,M.leftCacheBounds),M.count++)}}for(let x=0;x<v;x++){let b=m[x],_=b.count,M=a-b.count,A=b.leftCacheBounds,S=b.rightCacheBounds,P=0;_!==0&&(P=dd(A)/l);let L=0;M!==0&&(L=dd(S)/l);let E=1+1.25*(P*_+L*M);E<h&&(n=d,h=E,o=b.candidate)}}else{for(let v=0;v<oo;v++){let x=Yo[v];x.count=0,x.candidate=p+f+v*f;let b=x.bounds;for(let _=0;_<3;_++)b[_]=1/0,b[_+3]=-1/0}for(let v=c;v<u;v+=6){let x=~~((i[v+2*d]-p)/f);x>=oo&&(x=oo-1);let b=Yo[x];b.count++,kf(v,i,b.bounds)}let m=Yo[oo-1];ME(m.bounds,m.rightCacheBounds);for(let v=oo-2;v>=0;v--){let x=Yo[v],b=Yo[v+1];CE(x.bounds,b.rightCacheBounds,x.rightCacheBounds)}let g=0;for(let v=0;v<oo-1;v++){let x=Yo[v],b=x.count,_=x.bounds,M=Yo[v+1].rightCacheBounds;b!==0&&(g===0?ME(_,Vf):CE(_,Vf,Vf)),g+=b;let A=0,S=0;g!==0&&(A=dd(Vf)/l);let P=a-g;P!==0&&(S=dd(M)/l);let L=1+1.25*(A*g+S*P);L<h&&(n=d,h=L,o=x.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:n,pos:o}}function zX(e,t,i,r){let a=0;for(let s=t,n=t+i;s<n;s++)a+=e[s*6+r*2];return a/i}function kX(e,t){let i=e.attributes.position,r=e.index.array,a=r.length/3,s=new Float32Array(a*6),n=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let c=["getX","getY","getZ"];for(let u=0;u<a;u++){let d=u*3,p=u*6,f,m,g;n?(f=r[d+0],m=r[d+1],g=r[d+2]):(f=r[d+0]*h+l,m=r[d+1]*h+l,g=r[d+2]*h+l);for(let v=0;v<3;v++){let x,b,_;n?(x=i[c[v]](f),b=i[c[v]](m),_=i[c[v]](g)):(x=o[f+v],b=o[m+v],_=o[g+v]);let M=x;b<M&&(M=b),_<M&&(M=_);let A=x;b>A&&(A=b),_>A&&(A=_);let S=(A-M)/2,P=v*2;s[p+P+0]=M+S,s[p+P+1]=S+(Math.abs(M)+S)*OX,M<t[v]&&(t[v]=M),A>t[v+3]&&(t[v+3]=A)}}return s}function VX(e,t){function i(v){d&&d(v/p)}function r(v,x,b,_=null,M=0){if(!f&&M>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),b<=c||M>=l)return i(x+b),v.offset=x,v.count=b,v;let A=NX(v.boundingData,_,n,x,b,u);if(A.axis===-1)return i(x+b),v.offset=x,v.count=b,v;let S=UX(o,n,x,b,A);if(S===x||S===x+b)i(x+b),v.offset=x,v.count=b;else{v.splitAxis=A.axis;let P=new zf,L=x,E=S-x;v.left=P,P.boundingData=new Float32Array(6),k0(n,L,E,P.boundingData,s),r(P,L,E,s,M+1);let T=new zf,B=S,V=b-E;v.right=T,T.boundingData=new Float32Array(6),k0(n,B,V,T.boundingData,s),r(T,B,V,s,M+1)}return v}LX(e,t);let a=new Float32Array(6),s=new Float32Array(6),n=kX(e,a),o=e.index.array,l=t.maxDepth,h=t.verbose,c=t.maxLeafTris,u=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,m=[],g=IX(e);if(g.length===1){let v=g[0],x=new zf;x.boundingData=a,BX(n,v.offset,v.count,s),r(x,v.offset,v.count,s),m.push(x)}else for(let v of g){let x=new zf;x.boundingData=new Float32Array(6),k0(n,v.offset,v.count,x.boundingData,s),r(x,v.offset,v.count,s),m.push(x)}return m}function jX(e,t){let i=VX(e,t),r,a,s,n=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<i.length;c++){let u=i[c],d=l(u),p=new o(32*d);r=new Float32Array(p),a=new Uint32Array(p),s=new Uint16Array(p),h(0,u),n.push(p)}return n;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function h(c,u){let d=c/4,p=c/2,f=!!u.count,m=u.boundingData;for(let g=0;g<6;g++)r[d+g]=m[g];if(f){let g=u.offset,v=u.count;return a[d+6]=g,s[p+14]=v,s[p+15]=65535,c+32}else{let g=u.left,v=u.right,x=u.splitAxis,b;if(b=h(c+32,g),b/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return a[d+6]=b/4,b=h(b,v),a[d+7]=x,b}}}var In=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let a=0,s=e.length;a<s;a++){let n=e[a][t];i=n<i?n:i,r=n>r?n:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let a=0,s=t.length;a<s;a++){let n=t[a],o=e.dot(n);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};In.prototype.setFromBox=function(){let e=new O;return function(t,i){let r=i.min,a=i.max,s=1/0,n=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+a.x*(1-o),e.y=r.y*l+a.y*(1-l),e.z=r.z*h+a.z*(1-h);let c=t.dot(e);s=Math.min(c,s),n=Math.max(c,n)}this.min=s,this.max=n}}();var Pse=function(){let e=new In;return function(t,i){let r=t.points,a=t.satAxes,s=t.satBounds,n=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let c=s[h],u=a[h];if(e.setFromPoints(u,n),c.isSeparated(e))return!1}for(let h=0;h<3;h++){let c=l[h],u=o[h];if(e.setFromPoints(u,r),c.isSeparated(e))return!1}}}(),GX=function(){let e=new O,t=new O,i=new O;return function(r,a,s){let n=r.start,o=e,l=a.start,h=t;i.subVectors(n,l),e.subVectors(r.end,r.start),t.subVectors(a.end,a.start);let c=i.dot(h),u=h.dot(o),d=h.dot(h),p=i.dot(o),f=o.dot(o)*d-u*u,m,g;f!==0?m=(c*u-p*d)/f:m=0,g=(c+m*u)/d,s.x=m,s.y=g}}(),Gb=function(){let e=new ae,t=new O,i=new O;return function(r,a,s,n){GX(r,a,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,s),a.at(l,n);return}else if(o>=0&&o<=1){l<0?a.at(0,n):a.at(1,n),r.closestPointToPoint(n,!0,s);return}else if(l>=0&&l<=1){o<0?r.at(0,s):r.at(1,s),a.closestPointToPoint(s,!0,n);return}else{let h;o<0?h=r.start:h=r.end;let c;l<0?c=a.start:c=a.end;let u=t,d=i;if(r.closestPointToPoint(c,!0,t),a.closestPointToPoint(h,!0,i),u.distanceToSquared(c)<=d.distanceToSquared(h)){s.copy(u),n.copy(c);return}else{s.copy(h),n.copy(d);return}}}}(),HX=function(){let e=new O,t=new O,i=new ts,r=new Es;return function(a,s){let{radius:n,center:o}=a,{a:l,b:h,c}=s;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let u=s.getPlane(i);if(Math.abs(u.distanceToPoint(o))<=n){let d=u.projectPoint(o,t);if(s.containsPoint(d))return!0}return!1}}(),WX=1e-15;function mc(e){return Math.abs(e)<WX}var To=class extends Kr{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new O),this.satBounds=new Array(4).fill().map(()=>new In),this.points=[this.a,this.b,this.c],this.sphere=new Sa,this.plane=new ts,this.needsUpdate=!0}intersectsSphere(e){return HX(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,a=this.satAxes,s=this.satBounds,n=a[0],o=s[0];this.getNormal(n),o.setFromPoints(n,r);let l=a[1],h=s[1];l.subVectors(e,t),h.setFromPoints(l,r);let c=a[2],u=s[2];c.subVectors(t,i),u.setFromPoints(c,r);let d=a[3],p=s[3];d.subVectors(i,e),p.setFromPoints(d,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(n,e),this.needsUpdate=!1}};To.prototype.closestPointToSegment=function(){let e=new O,t=new O,i=new Es;return function(r,a=null,s=null){let{start:n,end:o}=r,l=this.points,h,c=1/0;for(let u=0;u<3;u++){let d=(u+1)%3;i.start.copy(l[u]),i.end.copy(l[d]),Gb(i,r,e,t),h=e.distanceToSquared(t),h<c&&(c=h,a&&a.copy(e),s&&s.copy(t))}return this.closestPointToPoint(n,e),h=n.distanceToSquared(e),h<c&&(c=h,a&&a.copy(e),s&&s.copy(n)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<c&&(c=h,a&&a.copy(e),s&&s.copy(o)),Math.sqrt(c)}}();To.prototype.intersectsTriangle=function(){let e=new To,t=new Array(3),i=new Array(3),r=new In,a=new In,s=new O,n=new O,o=new O,l=new O,h=new Es,c=new Es,u=new Es;return function(d,p=null,f=!1){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(e.copy(d),e.update(),d=e);let m=this.plane,g=d.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){let v=this.satBounds,x=this.satAxes;i[0]=d.a,i[1]=d.b,i[2]=d.c;for(let M=0;M<4;M++){let A=v[M],S=x[M];if(r.setFromPoints(S,i),A.isSeparated(r))return!1}let b=d.satBounds,_=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let M=0;M<4;M++){let A=b[M],S=_[M];if(r.setFromPoints(S,t),A.isSeparated(r))return!1}for(let M=0;M<4;M++){let A=x[M];for(let S=0;S<4;S++){let P=_[S];if(s.crossVectors(A,P),r.setFromPoints(s,t),a.setFromPoints(s,i),r.isSeparated(a))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,x=!1,b=0;for(let V=0;V<3;V++){let I=v[V],H=v[(V+1)%3];h.start.copy(I),h.end.copy(H),h.delta(n);let q=x?c.start:c.end,X=mc(g.distanceToPoint(I));if(mc(g.normal.dot(n))&&X){c.copy(h),b=2;break}if((g.intersectLine(h,q)||X)&&!mc(q.distanceTo(H))){if(b++,x)break;x=!0}}if(b===1&&d.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(b!==2)return!1;let _=d.points,M=!1,A=0;for(let V=0;V<3;V++){let I=_[V],H=_[(V+1)%3];h.start.copy(I),h.end.copy(H),h.delta(o);let q=M?u.start:u.end,X=mc(m.distanceToPoint(I));if(mc(m.normal.dot(o))&&X){u.copy(h),A=2;break}if((m.intersectLine(h,q)||X)&&!mc(q.distanceTo(H))){if(A++,M)break;M=!0}}if(A===1&&this.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(A!==2)return!1;if(c.delta(n),u.delta(o),n.dot(o)<0){let V=u.start;u.start=u.end,u.end=V}let S=c.start.dot(n),P=c.end.dot(n),L=u.start.dot(n),E=u.end.dot(n),T=P<L,B=S<E;return S!==E&&L!==P&&T===B?!1:(p&&(l.subVectors(c.start,u.start),l.dot(n)>0?p.start.copy(c.start):p.start.copy(u.start),l.subVectors(c.end,u.end),l.dot(n)<0?p.end.copy(c.end):p.end.copy(u.end)),!0)}}}();To.prototype.distanceToPoint=function(){let e=new O;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();To.prototype.distanceToTriangle=function(){let e=new O,t=new O,i=["a","b","c"],r=new Es,a=new Es;return function(s,n=null,o=null){let l=n||o?r:null;if(this.intersectsTriangle(s,l))return(n||o)&&(n&&l.getCenter(n),o&&l.getCenter(o)),0;let h=1/0;for(let c=0;c<3;c++){let u,d=i[c],p=s[d];this.closestPointToPoint(p,e),u=p.distanceToSquared(e),u<h&&(h=u,n&&n.copy(e),o&&o.copy(p));let f=this[d];s.closestPointToPoint(f,e),u=f.distanceToSquared(e),u<h&&(h=u,n&&n.copy(f),o&&o.copy(e))}for(let c=0;c<3;c++){let u=i[c],d=i[(c+1)%3];r.set(this[u],this[d]);for(let p=0;p<3;p++){let f=i[p],m=i[(p+1)%3];a.set(s[f],s[m]),Gb(r,a,e,t);let g=e.distanceToSquared(t);g<h&&(h=g,n&&n.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Bn=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new O,this.max=new O,this.matrix=new je,this.invMatrix=new je,this.points=new Array(8).fill().map(()=>new O),this.satAxes=new Array(3).fill().map(()=>new O),this.satBounds=new Array(3).fill().map(()=>new In),this.alignedSatBounds=new Array(3).fill().map(()=>new In),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Bn.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let c=0;c<=1;c++){let u=1*l|2*h|4*c,d=r[u];d.x=l?i.x:t.x,d.y=h?i.y:t.y,d.z=c?i.z:t.z,d.applyMatrix4(e)}let a=this.satBounds,s=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=s[l],c=a[l],u=1<<l,d=r[u];h.subVectors(n,d),c.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Bn.prototype.intersectsBox=function(){let e=new In;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,a=this.satBounds,s=this.satAxes,n=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,n[0].isSeparated(e)||(e.min=i.y,e.max=r.y,n[1].isSeparated(e))||(e.min=i.z,e.max=r.z,n[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=s[o],h=a[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();Bn.prototype.intersectsTriangle=function(){let e=new To,t=new Array(3),i=new In,r=new In,a=new O;return function(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(e.copy(s),e.update(),s=e);let n=this.satBounds,o=this.satAxes;t[0]=s.a,t[1]=s.b,t[2]=s.c;for(let u=0;u<3;u++){let d=n[u],p=o[u];if(i.setFromPoints(p,t),d.isSeparated(i))return!1}let l=s.satBounds,h=s.satAxes,c=this.points;for(let u=0;u<3;u++){let d=l[u],p=h[u];if(i.setFromPoints(p,c),d.isSeparated(i))return!1}for(let u=0;u<3;u++){let d=o[u];for(let p=0;p<4;p++){let f=h[p];if(a.crossVectors(d,f),i.setFromPoints(a,t),r.setFromPoints(a,c),i.isSeparated(r))return!1}}return!0}}();Bn.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();Bn.prototype.distanceToPoint=function(){let e=new O;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Bn.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new Es),i=new Array(12).fill().map(()=>new Es),r=new O,a=new O;return function(s,n=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||l)&&(s.getCenter(a),this.closestPointToPoint(a,r),s.closestPointToPoint(r,a),o&&o.copy(r),l&&l.copy(a)),0;let h=n*n,c=s.min,u=s.max,d=this.points,p=1/0;for(let m=0;m<8;m++){let g=d[m];a.copy(g).clamp(c,u);let v=g.distanceToSquared(a);if(v<p&&(p=v,o&&o.copy(g),l&&l.copy(a),v<h))return Math.sqrt(v)}let f=0;for(let m=0;m<3;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){let x=(m+1)%3,b=(m+2)%3,_=g<<x|v<<b,M=1<<m|g<<x|v<<b,A=d[_],S=d[M];t[f].set(A,S);let P=e[m],L=e[x],E=e[b],T=i[f],B=T.start,V=T.end;B[P]=c[P],B[L]=g?c[L]:u[L],B[E]=v?c[E]:u[L],V[P]=u[P],V[L]=g?c[L]:u[L],V[E]=v?c[E]:u[L],f++}for(let m=0;m<=1;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){a.x=m?u.x:c.x,a.y=g?u.y:c.y,a.z=v?u.z:c.z,this.closestPointToPoint(a,r);let x=a.distanceToSquared(r);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(a),x<h))return Math.sqrt(x)}for(let m=0;m<12;m++){let g=t[m];for(let v=0;v<12;v++){let x=i[v];Gb(g,x,r,a);let b=r.distanceToSquared(a);if(b<p&&(p=b,o&&o.copy(r),l&&l.copy(a),b<h))return Math.sqrt(b)}}return Math.sqrt(p)}}();var gc=new O,vc=new O,yc=new O,jf=new ae,Gf=new ae,Hf=new ae,TE=new O,PE=new O,DE=new O,Wf=new O;function qX(e,t,i,r,a,s){let n;return s===Fr?n=e.intersectTriangle(r,i,t,!0,a):n=e.intersectTriangle(t,i,r,s!==Oa,a),n===null?null:{distance:e.origin.distanceTo(a),point:a.clone()}}function XX(e,t,i,r,a,s,n,o,l){gc.fromBufferAttribute(t,s),vc.fromBufferAttribute(t,n),yc.fromBufferAttribute(t,o);let h=qX(e,gc,vc,yc,Wf,l);if(h){r&&(jf.fromBufferAttribute(r,s),Gf.fromBufferAttribute(r,n),Hf.fromBufferAttribute(r,o),h.uv=Kr.getInterpolation(Wf,gc,vc,yc,jf,Gf,Hf,new ae)),a&&(jf.fromBufferAttribute(a,s),Gf.fromBufferAttribute(a,n),Hf.fromBufferAttribute(a,o),h.uv1=Kr.getInterpolation(Wf,gc,vc,yc,jf,Gf,Hf,new ae)),i&&(TE.fromBufferAttribute(i,s),PE.fromBufferAttribute(i,n),DE.fromBufferAttribute(i,o),h.normal=Kr.getInterpolation(Wf,gc,vc,yc,TE,PE,DE,new O),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let c={a:s,b:n,c:o,normal:new O,materialIndex:0};Kr.getNormal(gc,vc,yc,c.normal),h.face=c,h.faceIndex=s}return h}function O3(e,t,i,r,a){let s=r*3,n=e.index.getX(s),o=e.index.getX(s+1),l=e.index.getX(s+2),{position:h,normal:c,uv:u,uv1:d}=e.attributes,p=XX(i,h,c,u,d,n,o,l,t);return p?(p.faceIndex=r,a&&a.push(p),p):null}function YX(e,t,i,r,a,s){for(let n=r,o=r+a;n<o;n++)O3(e,t,i,n,s)}function QX(e,t,i,r,a){let s=1/0,n=null;for(let o=r,l=r+a;o<l;o++){let h=O3(e,t,i,o);h&&h.distance<s&&(n=h,s=h.distance)}return n}function wn(e,t,i,r){let a=e.a,s=e.b,n=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),a.x=r.getX(o),a.y=r.getY(o),a.z=r.getZ(o),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),n.x=r.getX(h),n.y=r.getY(h),n.z=r.getZ(h)}function RE(e,t,i,r,a,s,n){let o=i.index,l=i.attributes.position;for(let h=e,c=t+e;h<c;h++)if(wn(n,h*3,o,l),n.needsUpdate=!0,r(n,h,a,s))return!0;return!1}var L3=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function ll(e,t){return t[e+15]===65535}function $c(e,t){return t[e+6]}function dp(e,t){return t[e+14]}function pp(e){return e+8}function fp(e,t){return t[e+6]}function KX(e,t){return t[e+7]}var Hc=new sr,Ig=new O,ZX=["x","y","z"];function sx(e,t,i,r,a){let s=e*2,n=Fu,o=Al,l=El;if(ll(s,o)){let h=$c(e,l),c=dp(s,o);YX(t,i,r,h,c,a)}else{let h=pp(e);Bg(h,n,r,Ig)&&sx(h,t,i,r,a);let c=fp(e,l);Bg(c,n,r,Ig)&&sx(c,t,i,r,a)}}function nx(e,t,i,r){let a=e*2,s=Fu,n=Al,o=El;if(ll(a,n)){let l=$c(e,o),h=dp(a,n);return QX(t,i,r,l,h)}else{let l=KX(e,o),h=ZX[l],c=r.direction[h]>=0,u,d;c?(u=pp(e),d=fp(e,o)):(u=fp(e,o),d=pp(e));let p=Bg(u,s,r,Ig)?nx(u,t,i,r):null;if(p){let m=p.point[h];if(c?m<=s[d+l]:m>=s[d+l+3])return p}let f=Bg(d,s,r,Ig)?nx(d,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var JX=function(){let e,t,i=[],r=new L3(()=>new sr);return function(...s){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let n=a(...s);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),n};function a(s,n,o,l,h=null,c=0,u=0){function d(x){let b=x*2,_=Al,M=El;for(;!ll(b,_);)x=pp(x),b=x*2;return $c(x,M)}function p(x){let b=x*2,_=Al,M=El;for(;!ll(b,_);)x=fp(x,M),b=x*2;return $c(x,M)+dp(b,_)}let f=s*2,m=Fu,g=Al,v=El;if(ll(f,g)){let x=$c(s,v),b=dp(f,g);return An(s,m,e),l(x,b,!1,u,c+s,e)}else{let x=pp(s),b=fp(s,v),_=x,M=b,A,S,P,L;if(h&&(P=e,L=t,An(_,m,P),An(M,m,L),A=h(P),S=h(L),S<A)){_=b,M=x;let q=A;A=S,S=q,P=L}P||(P=e,An(_,m,P));let E=ll(_*2,g),T=o(P,E,A,u+1,c+_),B;if(T===2){let q=d(_),X=p(_)-q;B=l(q,X,!0,u+1,c+_,P)}else B=T&&a(_,n,o,l,h,c,u+1);if(B)return!0;L=t,An(M,m,L);let V=ll(M*2,g),I=o(L,V,S,u+1,c+M),H;if(I===2){let q=d(M),X=p(M)-q;H=l(q,X,!0,u+1,c+M,L)}else H=I&&a(M,n,o,l,h,c,u+1);return!!H}}}(),$X=function(){let e=new To,t=new To,i=new je,r=new Bn,a=new Bn;return function s(n,o,l,h,c=null){let u=n*2,d=Fu,p=Al,f=El;if(c===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),c=r),ll(u,p)){let m=o,g=m.index,v=m.attributes.position,x=l.index,b=l.attributes.position,_=$c(n,f),M=dp(u,p);if(i.copy(h).invert(),l.boundsTree)return An(n,d,a),a.matrix.copy(i),a.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:A=>a.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(h),A.b.applyMatrix4(h),A.c.applyMatrix4(h),A.needsUpdate=!0;for(let S=_*3,P=(M+_)*3;S<P;S+=3)if(wn(t,S,g,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=_*3,S=M+_*3;A<S;A+=3){wn(e,A,g,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let P=0,L=x.count;P<L;P+=3)if(wn(t,P,x,b),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let m=n+8,g=f[n+6];return An(m,d,Hc),!!(c.intersectsBox(Hc)&&s(m,o,l,h,c)||(An(g,d,Hc),c.intersectsBox(Hc)&&s(g,o,l,h,c)))}}}();function Bg(e,t,i,r){return An(e,t,Hc),i.intersectBox(Hc,r)}var ox=[],Om,Fu,Al,El;function Rd(e){Om&&ox.push(Om),Om=e,Fu=new Float32Array(e),Al=new Uint16Array(e),El=new Uint32Array(e)}function qf(){Om=null,Fu=null,Al=null,El=null,ox.length&&Rd(ox.pop())}var V0=Symbol("skip tree generation"),j0=new sr,G0=new sr,xc=new je,Xl=new Bn,pd=new Bn,fd=new O,Xf=new O,eY=new O,tY=new O,iY=new O,OE=new sr,hn=new L3(()=>new To),Wd=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Wd.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,a=i.getIndex(),s;return t.cloneBuffers?s={roots:r.map(n=>n.slice()),index:a.array.slice()}:s={roots:r,index:a.array},s}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Wd.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:a}=e,s=new Wd(t,{...i,[V0]:!0});if(s._roots=a,i.setIndex){let n=t.getIndex();if(n===null){let o=new Ut(e.index,1,!1);t.setIndex(o)}else n.array!==r&&(n.array.set(r),n.needsUpdate=!0)}return s}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[V0]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[V0]||(this._roots=jX(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new sr))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,a,s,n,o,l=0,h=this._roots;for(let u=0,d=h.length;u<d;u++)a=h[u],s=new Uint32Array(a),n=new Uint16Array(a),o=new Float32Array(a),c(0,l),l+=a.byteLength;function c(u,d,p=!1){let f=u*2;if(n[f+15]===65535){let m=s[u+6],g=n[f+14],v=1/0,x=1/0,b=1/0,_=-1/0,M=-1/0,A=-1/0;for(let S=3*m,P=3*(m+g);S<P;S++){let L=i[S],E=r.getX(L),T=r.getY(L),B=r.getZ(L);E<v&&(v=E),E>_&&(_=E),T<x&&(x=T),T>M&&(M=T),B<b&&(b=B),B>A&&(A=B)}return o[u+0]!==v||o[u+1]!==x||o[u+2]!==b||o[u+3]!==_||o[u+4]!==M||o[u+5]!==A?(o[u+0]=v,o[u+1]=x,o[u+2]=b,o[u+3]=_,o[u+4]=M,o[u+5]=A,!0):!1}else{let m=u+8,g=s[u+6],v=m+d,x=g+d,b=p,_=!1,M=!1;e?b||(_=e.has(v),M=e.has(x),b=!_&&!M):(_=!0,M=!0);let A=b||_,S=b||M,P=!1;A&&(P=c(m,d,b));let L=!1;S&&(L=c(g,d,b));let E=P||L;if(E)for(let T=0;T<3;T++){let B=m+T,V=g+T,I=o[B],H=o[B+3],q=o[V],X=o[V+3];o[u+T]=I<q?I:q,o[u+T+3]=H>X?H:X}return E}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),a=new Uint16Array(i);s(0);function s(n,o=0){let l=n*2,h=a[l+15]===65535;if(h){let c=r[n+6],u=a[l+14];e(o,h,new Float32Array(i,n*4,6),c,u)}else{let c=n+8,u=r[n+6],d=r[n+7];e(o,h,new Float32Array(i,n*4,6),d)||(s(c,o+1),s(u,o+1))}}}raycast(e,t=Qs){let i=this._roots,r=this.geometry,a=[],s=t.isMaterial,n=Array.isArray(t),o=r.groups,l=s?t.side:t;for(let h=0,c=i.length;h<c;h++){let u=n?t[o[h].materialIndex].side:l,d=a.length;if(Rd(i[h]),sx(0,r,u,e,a),qf(),n){let p=o[h].materialIndex;for(let f=d,m=a.length;f<m;f++)a[f].face.materialIndex=p}}return a}raycastFirst(e,t=Qs){let i=this._roots,r=this.geometry,a=t.isMaterial,s=Array.isArray(t),n=null,o=r.groups,l=a?t.side:t;for(let h=0,c=i.length;h<c;h++){let u=s?t[o[h].materialIndex].side:l;Rd(i[h]);let d=nx(0,r,u,e);qf(),d!=null&&(n==null||d.distance<n.distance)&&(n=d,s&&(d.face.materialIndex=o[h].materialIndex))}return n}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let a of this._roots)if(Rd(a),r=$X(0,i,e,t),qf(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let u=t;t=(d,p,f,m)=>{let g=p*3;return u(d,g,g+1,g+2,f,m)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let a=hn.getPrimitive(),{boundsTraverseOrder:s,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let u=o;o=(d,p,f,m,g)=>u(d,p,f,m,g)?!0:RE(d,p,r,l,f,m,a)}else o||(l?o=(u,d,p,f)=>RE(u,d,r,l,p,f,a):o=(u,d,p)=>p);let h=!1,c=0;for(let u of this._roots){if(Rd(u),h=JX(0,r,n,o,s,c),qf(),h)break;c+=u.byteLength}return hn.releasePrimitive(a),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:a}=i,s=this.geometry.index,n=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;xc.copy(t).invert();let h=hn.getPrimitive(),c=hn.getPrimitive();if(a){let d=function(p,f,m,g,v,x,b,_){for(let M=m,A=m+g;M<A;M++){wn(c,M*3,o,l),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let S=p,P=p+f;S<P;S++)if(wn(h,S*3,s,n),h.needsUpdate=!0,a(h,c,S,M,v,x,b,_))return!0}return!1};if(r){let p=r;r=function(f,m,g,v,x,b,_,M){return p(f,m,g,v,x,b,_,M)?!0:d(f,m,g,v,x,b,_,M)}}else r=d}e.getBoundingBox(G0),G0.applyMatrix4(t);let u=this.shapecast({intersectsBounds:d=>G0.intersectsBox(d),intersectsRange:(d,p,f,m,g,v)=>(j0.copy(v),j0.applyMatrix4(xc),e.shapecast({intersectsBounds:x=>j0.intersectsBox(x),intersectsRange:(x,b,_,M,A)=>r(d,p,x,b,m,g,M,A)}))});return hn.releasePrimitive(h),hn.releasePrimitive(c),u}intersectsBox(e,t){return Xl.set(e.min,e.max,t),Xl.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Xl.intersectsBox(i),intersectsTriangle:i=>Xl.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},a=0,s=1/0){e.boundingBox||e.computeBoundingBox(),Xl.set(e.boundingBox.min,e.boundingBox.max,t),Xl.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,c=e.index,u=hn.getPrimitive(),d=hn.getPrimitive(),p=Xf,f=eY,m=null,g=null;r&&(m=tY,g=iY);let v=1/0,x=null,b=null;return xc.copy(t).invert(),pd.matrix.copy(xc),this.shapecast({boundsTraverseOrder:_=>Xl.distanceToBox(_),intersectsBounds:(_,M,A)=>A<v&&A<s?(M&&(pd.min.copy(_.min),pd.max.copy(_.max),pd.needsUpdate=!0),!0):!1,intersectsRange:(_,M)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>pd.distanceToBox(A),intersectsBounds:(A,S,P)=>P<v&&P<s,intersectsRange:(A,S)=>{for(let P=A*3,L=(A+S)*3;P<L;P+=3){wn(d,P,c,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let E=_*3,T=(_+M)*3;E<T;E+=3){wn(u,E,l,o),u.needsUpdate=!0;let B=u.distanceToTriangle(d,p,m);if(B<v&&(f.copy(p),g&&g.copy(m),v=B,x=E/3,b=P/3),B<a)return!0}}}});{let A=c?c.count:h.count;for(let S=0,P=A;S<P;S+=3){wn(d,S,c,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let L=_*3,E=(_+M)*3;L<E;L+=3){wn(u,L,l,o),u.needsUpdate=!0;let T=u.distanceToTriangle(d,p,m);if(T<v&&(f.copy(p),g&&g.copy(m),v=T,x=L/3,b=S/3),T<a)return!0}}}}}),hn.releasePrimitive(u),hn.releasePrimitive(d),v===1/0?null:(i.point?i.point.copy(f):i.point=f.clone(),i.distance=v,i.faceIndex=x,r&&(r.point?r.point.copy(g):r.point=g.clone(),r.point.applyMatrix4(xc),f.applyMatrix4(xc),r.distance=f.sub(r.point).length(),r.faceIndex=b),i)}closestPointToPoint(e,t={},i=0,r=1/0){let a=i*i,s=r*r,n=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(fd.copy(e).clamp(h.min,h.max),fd.distanceToSquared(e)),intersectsBounds:(h,c,u)=>u<n&&u<s,intersectsTriangle:(h,c)=>{h.closestPointToPoint(e,fd);let u=e.distanceToSquared(fd);return u<n&&(Xf.copy(fd),n=u,o=c),u<a}}),n===1/0)return null;let l=Math.sqrt(n);return t.point?t.point.copy(Xf):t.point=Xf.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{An(0,new Float32Array(t),OE),e.union(OE)}),e}},md=Ro(VB()),rY=.5*(Math.sqrt(3)-1),gd=(3-Math.sqrt(3))/6,aY=1/3,cn=1/6,Dse=(Math.sqrt(5)-1)/4,Rse=(5-Math.sqrt(5))/20,qd=e=>Math.floor(e)|0,LE=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]),H0=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 W0(e=Math.random){let t=I3(e),i=new Float64Array(t).map(a=>LE[a%12*2]),r=new Float64Array(t).map(a=>LE[a%12*2+1]);return function(a,s){let n=0,o=0,l=0,h=(a+s)*rY,c=qd(a+h),u=qd(s+h),d=(c+u)*gd,p=c-d,f=u-d,m=a-p,g=s-f,v,x;m>g?(v=1,x=0):(v=0,x=1);let b=m-v+gd,_=g-x+gd,M=m-1+2*gd,A=g-1+2*gd,S=c&255,P=u&255,L=.5-m*m-g*g;if(L>=0){let B=S+t[P],V=i[B],I=r[B];L*=L,n=L*L*(V*m+I*g)}let E=.5-b*b-_*_;if(E>=0){let B=S+v+t[P+x],V=i[B],I=r[B];E*=E,o=E*E*(V*b+I*_)}let T=.5-M*M-A*A;if(T>=0){let B=S+1+t[P+1],V=i[B],I=r[B];T*=T,l=T*T*(V*M+I*A)}return 70*(n+o+l)}}function sY(e=Math.random){let t=I3(e),i=new Float64Array(t).map(s=>H0[s%12*3]),r=new Float64Array(t).map(s=>H0[s%12*3+1]),a=new Float64Array(t).map(s=>H0[s%12*3+2]);return function(s,n,o){let l,h,c,u,d=(s+n+o)*aY,p=qd(s+d),f=qd(n+d),m=qd(o+d),g=(p+f+m)*cn,v=p-g,x=f-g,b=m-g,_=s-v,M=n-x,A=o-b,S,P,L,E,T,B;_>=M?M>=A?(S=1,P=0,L=0,E=1,T=1,B=0):_>=A?(S=1,P=0,L=0,E=1,T=0,B=1):(S=0,P=0,L=1,E=1,T=0,B=1):M<A?(S=0,P=0,L=1,E=0,T=1,B=1):_<A?(S=0,P=1,L=0,E=0,T=1,B=1):(S=0,P=1,L=0,E=1,T=1,B=0);let V=_-S+cn,I=M-P+cn,H=A-L+cn,q=_-E+2*cn,X=M-T+2*cn,Y=A-B+2*cn,ie=_-1+3*cn,ce=M-1+3*cn,de=A-1+3*cn,ue=p&255,re=f&255,se=m&255,he=.6-_*_-M*M-A*A;if(he<0)l=0;else{let Re=ue+t[re+t[se]];he*=he,l=he*he*(i[Re]*_+r[Re]*M+a[Re]*A)}let _e=.6-V*V-I*I-H*H;if(_e<0)h=0;else{let Re=ue+S+t[re+P+t[se+L]];_e*=_e,h=_e*_e*(i[Re]*V+r[Re]*I+a[Re]*H)}let Ee=.6-q*q-X*X-Y*Y;if(Ee<0)c=0;else{let Re=ue+E+t[re+T+t[se+B]];Ee*=Ee,c=Ee*Ee*(i[Re]*q+r[Re]*X+a[Re]*Y)}let fe=.6-ie*ie-ce*ce-de*de;if(fe<0)u=0;else{let Re=ue+1+t[re+1+t[se+1]];fe*=fe,u=fe*fe*(i[Re]*ie+r[Re]*ce+a[Re]*de)}return 32*(l+h+c+u)}}function I3(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),a=t[i];t[i]=t[r],t[r]=a}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Us=new Kr,nY=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let a=1;Us.a.fromBufferAttribute(e,r),Us.b.fromBufferAttribute(e,r+1),Us.c.fromBufferAttribute(e,r+2),a*=Us.getArea(),t[r/3]=a}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,a=-1;for(;i<=r;){let s=Math.ceil((i+r)/2);if(s===0||t[s-1]<=e&&t[s]>e){a=s;break}else e<t[s]?r=s-1:i=s+1}return a}sampleFace(e,t,i){let r=this.randomFunction(),a=this.randomFunction();return r+a>1&&(r=1-r,a=1-a),Us.a.fromBufferAttribute(this.positionAttribute,e*3),Us.b.fromBufferAttribute(this.positionAttribute,e*3+1),Us.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Us.a,r).addScaledVector(Us.b,a).addScaledVector(Us.c,1-(r+a)),Us.getNormal(i),this}},oY=Ro(cT()),lY=new je,hY=new je,cY=new je,mp;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(mp||(mp={}));var Hb=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new je,this.copyPreviousMatrix=!0,this.hiddenMatrix=new je,this.matrixWorldRigid=new je,this.shearScale=new je,this.shearScaleInv=new je}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Mi&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)mp.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)mp.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:a,q:s}=(0,oY.SVD)(i),n=lY.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=hY.set(a[0][0],a[0][1],a[0][2],0,a[1][0],a[1][1],a[1][2],0,a[2][0],a[2][1],a[2][2],0,0,0,0,1),l=cY.copy(o).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(n,l).copyPosition(this.matrixWorld),s.every(h=>Math.abs(s[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new je().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof je?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,a,s,n){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},uY=class extends Hb(Mi){},dY=e=>e.type==="Mesh",xa=class extends uY{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new xa(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return dY(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}},ih=new O,rh=new O,eu=new je,B3=[new O(-1,1,1),new O(-1,-1,1),new O(1,-1,1),new O(1,1,1),new O(-1,1,-1),new O(-1,-1,-1),new O(1,-1,-1),new O(1,1,-1)],pY=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],fY=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],IE=(e,t,i)=>{e.updateEntityBoxSize(ih,rh),eu.copy(t).multiply(e.matrixWorld),rh.x===0&&rh.y===0&&rh.z===0?i.push(new O(ih.x,ih.y,ih.z).applyMatrix4(eu)):B3.forEach(r=>{i.push(r.clone().multiply(rh).add(ih).applyMatrix4(eu))})},BE=class extends sr{constructor(){super(...arguments),this.matrix=new je,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new je().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){r.push(new O);return}IE(a,t,r)}}):IE(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(eu.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(rh).multiplyScalar(.5),this.getCenter(ih),eu.copy(this.matrix).setPosition(ih),this.vertices=B3.map(e=>e.clone().multiply(rh).applyMatrix4(eu))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=pY.map(([e,t])=>new Es(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new O))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=fY.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},gl={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},mY=class extends HT{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),a=r[r.length-1]/r.length;for(let s=0,n=this.curves;s<n.length;s++){let o=n[s],l=s===0?r[s]:r[s]-r[s-1],h=Math.ceil(e*l/a),c=o.getPoints(h);for(let u=0;u<c.length;u++){let d=c[u];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},lx=.001;function hx(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=lx}function q0(e,t){let i=new O(...e.position),r=new O(...e.controlNext.position),a=new O(...t.controlPrevious.position),s=new O(...t.position);return hx(i,r,s)&&hx(i,a,s)}function U3(e){let t=e.points.map(c=>new O(...c.data.position)),i=[e.points[0]],r=new O(...i[0].data.position);for(let c=0;c<e.points.length-1;c++)hx(r,t[c],t[c+1])||(i.push(e.points[c]),r=t[c]);i.push(e.points[e.points.length-1]);let a=e.isClosed,s=i.length-(a?0:1),n=i.length,o=[];for(let c=0;c<n;c++){let u=i[c].data,d=new O(...u.position),p=new O(...u.controlPrevious.position),f=new O(...u.controlNext.position),m={position:d,baseRoundness:u.roundness,controlPrevious:p,controlNext:f};if(u.roundness===0||!e.isClosed&&(c===0||c===n-1)){o[c]={...m,removedLength:0};continue}let g=a&&c==0?n-1:c-1,v=a&&c==n-1?0:c+1,x=i[g].data,b=i[v].data,_=new O(...x.position),M=new O(...b.position),A=_.clone().sub(d).normalize(),S=M.clone().sub(d).normalize();Object.assign(m,{prevDir:A,nextDir:S});let P=q0(x,u),L=q0(u,b);if(!P||!L)o[c]={...m,removedLength:0};else{let E=A.clone().add(S).normalize(),T=E.clone().cross(A).length()/A.dot(E);o[c]={...m,tan:T,removedLength:u.roundness/T}}}for(let c=0;c<s;c++){let u=c,d=a&&c===n-1?0:c+1,p=o[u],f=o[d];if(p.removedLength!==0||f.removedLength!==0){let m=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let c=0;c<s;c++){let u=c,d=a&&c===n-1?0:c+1,p=o[u],f=o[d],m=null;if(!q0(i[u].data,i[d].data))p.position.distanceTo(f.position)>lx&&(m=new Cm(p.position,p.controlNext,f.controlPrevious,f.position));else{let g=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&g.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),g.distanceTo(v)>lx&&(m=new Cm(g,g.clone().lerp(v,.3),v.clone().lerp(g,.3),v))}l[2*c+1]=m}for(let c=0;c<n;c++){let u=o[c];if(u.removedLength===0){l[2*c]=null;continue}let d=u.position,p=u.prevDir.clone().multiplyScalar(u.removedLength).add(d),f=u.nextDir.clone().multiplyScalar(u.removedLength).add(d),m=u.tan*u.removedLength,g=u.prevDir.clone().add(u.nextDir).normalize(),v=p.clone().lerp(f,.5),x=p.distanceTo(f)/2,b=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(x,2))).add(v),_=g.clone().multiplyScalar(-m).add(b),M=d.distanceTo(_)/d.distanceTo(v),A=u.prevDir.clone().multiplyScalar(M*d.distanceTo(p)).add(d),S=A.clone().lerp(_,2),P=p.clone().lerp(A,4/3),L=f.clone().lerp(S,4/3);l[2*c]=new Cm(p,P,L,f)}let h=new mY;return l.forEach(c=>{c&&h.add(c)}),h}var ui;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(ui||(ui={}));var fo=e=>ui.is(e),gY={type:"completeState",isfromEntity:!0},vY=["x","y","z"],X0=new O,yY=new O().set(0,1,0),Wb=e=>class extends Hb(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new BE,this._recursiveBBox=new BE,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(ui.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(ui.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(ui.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let a of this.data.states)lh.toOps(this.data,a.data).forEach(s=>{let n=fg.replaceProps(s,this.data);this.dataPatched=this.data,this.updateByPatchedOp(n,this.data,i)});if(t!==null){let a=this.data.states.data(t);a&&(this.dataPatched=lh.patch(this.data,a),lh.toOps(this.data,a).forEach(s=>{this.updateByPatchedOp(s,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{fo(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(ui.is(i[r]))return i[r];if(ui.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&ui.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)fo(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{ui.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)fo(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)fo(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)fo(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>fo(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x*dt.RAD2DEG,this.rotation.y*dt.RAD2DEG,this.rotation.z*dt.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return g1(i,t)}getTransformValues(t,i,r){return i[t].map((a,s)=>r?.shared.getVariable(a,[this.uuid,t,vY[s]])??a)}updateTransformState(t,i){let r=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(X0.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(dt.DEG2RAD),this.rotation.setFromVector3(X0),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??fu.identity)),r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)ui.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{ui.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return g1(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,a){let s=this.data;this.data=i;let n=t,o=Fi(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(c=>c===void 0)){let c=this.data;if(c!==void 0){let u=na.zoom(c,t.path.slice(2));if(u)for(let d in t.props)t.props[d]===void 0&&d in u&&(h[d]=u[d])}}n={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:c,...u}=l;l=u}if(t.props.material!==void 0&&"material"in l){let{material:c,...u}=l;l=u}let h=na.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,lh.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Fi(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let c of Object.keys(t.props)){l[l.length-1]=c;let u=r.scene.findInstance([this.uuid,...l]);u&&(u.overrideData=t.props[c],u.updateState(_l.apply(u.component.data,u.overrideData),r))}}else{let c=r.scene.findInstance([this.uuid,...l]);if(c){let u=na.zoom(c.component.data,h);if(t={...t,path:h},t.type===0){let d=t.props;if(u)for(let[p,f]of Object.entries(t.props))f===void 0&&(d===t.props&&(d={...t.props}),d[p]=u[p]);t={...t,props:d}}c.overrideData=Eg.resolve(i.overrides,l),c.updateByOp(t,Zr.applySimple(c.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let c of fl.rootOverrideProps)c in t.props&&(h===void 0&&(h={}),h[c]=t.props[c]);h&&(l={...t,props:h})}else for(let h of fl.rootOverrideProps)if(Fi(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let c=_l.filterOp(h.overrideData,l);c&&h.updateByOp(c,Zr.applySimple(h.data,c),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let c=_l.filterOp(h.overrideData,t);if(c){let u;s===h.data&&t===c?u=i:u=Zr.applySimple(h.data,c),h.updateByOp(c,u,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Mh.is(t.props.type)&&gl.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){gl.changeEntityProptotype(this,i,r);for(let a of this.children)ui.is(a)&&a.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0&&this.updateState(t.props,r),Fi(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Fi(t.path,["cloner"])!==null){let a=Zr.drop(t,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r.scene):(this.setFromClonerState(i.cloner,r),this.expandCloner(r.scene)),this.updateVisible(r.scene)}}updatePathSnapping(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let n=t.find(i);if(!n||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=n.data;if(o.geometry.path.points.length<=1)return;let l=U3(o.geometry.path),h=(r+a)%1;r+a===1&&h===0&&(h=1);let c=l.getPointAt(h);if(c===null)return;let u=this.parent?this.parent?.matrixWorld:new je;n.updateMatrixWorld();let d=new je().multiplyMatrices(u.clone().invert(),n.matrixWorld);c.applyMatrix4(d);let p={position:c.toArray(),rotation:o.rotation};if(s==="tangential"){let f=new je().extractRotation(n.matrixWorld),m=l.getTangentAt(h).applyMatrix4(f).add(c),g=new je().lookAt(c,m,yY),v=X0.setFromEuler(new Qi().setFromRotationMatrix(g)).multiplyScalar(dt.RAD2DEG);p={...p,rotation:v.toArray()}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(gY)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof gl.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new gl.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}},F3=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);i.thetaLength=dt.clamp(i.thetaLength,0,360);let r=i.width/2,a=i.radiusTop??r,s=i.radiusBottom??r;return a===s?(a=r,s=r):a>s?(a=r,s=s*r/a):(a=a*r/s,s=r),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:a,radiusBottom:s})}}static build(e){let{width:t,depth:i,height:r,radialSegments:a,heightSegments:s,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:c,cornerRadius:u,cornerSegments:d,hollow:p}=e.parameters,f;return l===0?(f=new St,f.setAttribute("position",new ut([],3))):u||p?f=new N3(h,c,r,a,s,n,o,l*Math.PI/180,u,u,d,p):f=new hb(h,c,r,a,s,n,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function Qo(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function UE(e){return new ae(e.y,-e.x)}var N3=class extends St{constructor(e,t,i,r,a,s,n,o,l,h,c,u,d=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,a=Math.floor(a)||1,s=s!==void 0?s:!1,n=n!==void 0?n:0,o=o!==void 0?o:Math.PI*2,s&&(l=0,h=0);let p=[],f=[],m=[],g=[],v=0,x=i/2,b=new O,_=new O;d&&e==0&&(e=l),d&&t==0&&(t=h);let M=new ae(e,x),A=new ae(t,-x),S=null,P=null,L=null,E=null,T=M.clone().sub(A),B=0,V=0,I=0;u>0&&(B=Math.min(e,t)*(1-u),V=e-B,I=t-B);let H=M.clone();H.x-=B;let q=Math.PI-T.angle(),X=T.angle(),Y=Math.tan(X/2),ie=Math.tan(q/2),ce=Y+ie,de=u?ce:ie,ue=u?ce:Y;if(l=Math.min(l,(e-V)/de,T.length()/ce),h=Math.min(h,(t-I)/ue,T.length()/ce),l>0){let fe=l/Y;S=M.clone().sub(new ae(fe,l)),u&&(L=S.clone(),L.x-=B-ce*l),M.sub(T.clone().setLength(fe))}if(h>0){let fe=h/ie;P=A.clone().sub(new ae(fe,-h)),A.add(T.clone().setLength(fe)),u&&(E=P.clone(),E.x-=B-ce*h,H.sub(T.clone().setLength(fe)))}T=M.clone().sub(A);let re=T.length()<.5,se=[];for(let fe=0;fe<=r;fe++){let Re=[],Pe=fe/r,te=Pe*o+n,We=new ae(Math.sin(te),Math.cos(te));E&&P?(he(Re,Pe,We,q,h,E,-1,!0),he(Re,Pe,We,X,h,P,-1,!1)):P?(_e(Re,We,P.x,0,-1),he(Re,Pe,We,X,h,P,-1,!1)):s||_e(Re,We,t,I,-1);let Be=UE(T).normalize();if(Qo(Be,We,b),!re)for(let Ue=0;Ue<=a;Ue++){let Ge=Ue/a,tt=T.clone().multiplyScalar(Ge).add(A);Qo(tt,We,_),f.push(_.x,_.y,_.z),m.push(b.x,b.y,b.z),g.push(Pe,.5+_.y/i),Re.push(v++)}if(L&&S?(he(Re,Pe,We,q,l,S,1,!1),he(Re,Pe,We,X,l,L,1,!0)):S?(he(Re,Pe,We,q,l,S,1,!1),_e(Re,We,S.x,0,1)):s||_e(Re,We,e,V,1),u&&!re){let Ue=UE(T).multiplyScalar(-1).normalize();Qo(Ue,We,b);for(let Ge=0;Ge<=a;Ge++){let tt=Ge/a,Fe=T.clone().multiplyScalar(-tt).add(H);Qo(Fe,We,_),f.push(_.x,_.y,_.z),m.push(b.x,b.y,b.z),g.push(Pe,.5+_.y/i),Re.push(v++)}}u&&!s&&Re.push(Re[0]),se.push(Re)}for(let fe=0;fe<se.length-1;fe++)for(let Re=0;Re<se[0].length-1;Re++){if(s&&u&&Re==a)continue;let Pe=se[fe][Re],te=se[fe+1][Re],We=se[fe+1][Re+1],Be=se[fe][Re+1],Ue=f[We*3+0],Ge=f[We*3+2];p.push(Pe,te,Be),(Ue!=0||Ge!=0)&&p.push(te,We,Be)}o<Math.PI*2&&(Ee(-1,se[0],n),Ee(1,se[se.length-1],n+o)),this.setIndex(p),this.setAttribute("position",new ut(f,3)),this.setAttribute("normal",new ut(m,3)),this.setAttribute("uv",new ut(g,2));function he(fe,Re,Pe,te,We,Be,Ue,Ge){for(let tt=0;tt<c+1;tt++){let Fe=tt/c,He=Ue<0?Fe:1-Fe;Ge&&(He-=1),He*=te;let nt=new ae(Math.sin(He),Math.cos(He)*Ue),ht=nt.clone().multiplyScalar(We).add(Be);Qo(ht,Pe,_),f.push(_.x,_.y,_.z),Qo(nt,Pe,b),m.push(b.x,b.y,b.z),g.push(Re,.5+_.y/i),fe.push(v++)}}function _e(fe,Re,Pe,te,We){let Be=new O,Ue=new ae,Ge=[Pe,te];We<0&&Ge.reverse();for(let tt of Ge)Ue.set(tt,x*We),Qo(Ue,Re,Be),f.push(Be.x,Be.y,Be.z),m.push(0,We,0),g.push(.5,.5),fe.push(v++)}function Ee(fe,Re,Pe){let te=new ae(Math.sin(Pe),Math.cos(Pe)),We=new ae(-Math.cos(Pe),Math.sin(Pe)),Be=new O,Ue=fe<0?(Fe,He,nt)=>p.push(Fe,He,nt):(Fe,He,nt)=>p.push(Fe,nt,He),Ge=new ae((e+t+V+I)/4,0);Qo(Ge,te,Be),f.push(Be.x,Be.y,Be.z),m.push(We.x,0,We.y),g.push(.5,.5);let tt=v++;for(let Fe of Re){let He=f.slice(Fe*3,Fe*3+3);f.push(...He),m.push(We.x,0,We.y);let nt=g.slice(Fe*2,Fe*2+2);g.push(...nt),v++}for(let Fe=tt+1;Fe<v-1;Fe++)Ue(tt,Fe,Fe+1);Ue(tt,v-1,tt+1)}}},xY=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=dt.clamp(i.thetaLength,0,360),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:a,heightSegments:s,openEnded:n,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:c,cornerSegments:u}=e.parameters,d;return l===0?(d=new St,d.setAttribute("position",new ut([],3))):h>0||c>0||l<360?d=new N3(0,t/2,r,a,s,n,o,l*Math.PI/180,h,c,u,0,!0):d=new cb(t/2,r,a,s,n),d.scale(1,1,i/t),Object.assign(d,{userData:{...e,type:"ConeGeometry"}})}},bY=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:a,heightSegments:s,depthSegments:n,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o==0?h=new Ks(t,i,r,a,s,n):h=new wY(t,i,r,a,s,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Y0=Math.PI/2,wY=class extends St{constructor(e=1,t=1,i=1,r=1,a=1,s=1,n=0,o=4){super(),this.type="BoxGeometry";let l=this;r=Math.floor(r),a=Math.floor(a),s=Math.floor(s),o=Math.floor(o),n=Math.min(n,e/2,t/2,i/2);let h=[],c=[],u=[],d=[],p=0,f=0;m("z","y","x",-1,-1,i,t,e,s,a,0),m("z","y","x",1,-1,i,t,-e,s,a,1),m("x","z","y",1,1,e,i,t,r,s,2),m("x","z","y",1,-1,e,i,-t,r,s,3),m("x","y","z",1,-1,e,t,i,r,a,4),m("x","y","z",-1,-1,e,t,-i,r,a,5),n>0&&(g("z","y","x",-1,-1,1,i,t,e,s,0),g("z","y","x",1,-1,-1,i,t,e,s,1),g("z","y","x",-1,1,-1,i,t,e,s,1),g("z","y","x",1,1,1,i,t,e,s,0),g("x","y","z",-1,-1,-1,e,t,i,r,0),g("x","y","z",1,-1,1,e,t,i,r,1),g("x","y","z",-1,1,1,e,t,i,r,0),g("x","y","z",1,1,-1,e,t,i,r,1),g("y","x","z",-1,-1,1,t,e,i,a,0),g("y","x","z",1,-1,-1,t,e,i,a,1),g("y","x","z",1,1,1,t,e,i,a,1),g("y","x","z",-1,1,-1,t,e,i,a,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new ut(c,3)),this.setAttribute("normal",new ut(u,3)),this.setAttribute("uv",new ut(d,2));function m(x,b,_,M,A,S,P,L,E,T,B){let V=(S-2*n)/E,I=(P-2*n)/T,H=S/2-n,q=P/2-n,X=L/2,Y=E+1,ie=T+1,ce=0,de=0,ue=new O;for(let re=0;re<ie;re++){let se=re*I-q;for(let he=0;he<Y;he++){let _e=he*V-H;ue[x]=_e*M,ue[b]=se*A,ue[_]=X,c.push(ue.x,ue.y,ue.z),ue[x]=0,ue[b]=0,ue[_]=L>0?1:-1,u.push(ue.x,ue.y,ue.z),d.push(he/E),d.push(1-re/T),ce+=1}}for(let re=0;re<T;re++)for(let se=0;se<E;se++){let he=p+se+Y*re,_e=p+se+Y*(re+1),Ee=p+(se+1)+Y*(re+1),fe=p+(se+1)+Y*re;h.push(he,_e,fe),h.push(_e,Ee,fe),de+=6}l.addGroup(f,de,B),f+=de,p+=ce}function g(x,b,_,M,A,S,P,L,E,T,B){let V=(P-2*n)/T,I=P/2-n,H=L/2-n,q=E/2,X=T+1,Y=0,ie=0,ce=new O,de=new O;for(let ue=0;ue<o+1;ue++){let re=ue/o*Y0,se=Math.sin(re)*n,he=(1-Math.cos(re))*n,_e=Math.sin(re),Ee=Math.cos(re);ce[b]=(H+se)*A,ce[_]=(q-he)*S,de[x]=0,de[b]=_e*Math.sign(ce[b]),de[_]=Ee*Math.sign(ce[_]);for(let fe=0;fe<X;fe++){let Re=fe*V-I;ce[x]=Re*M,c.push(ce.x,ce.y,ce.z),u.push(de.x,de.y,de.z),d.push(fe/T),d.push(0),Y+=1}}for(let ue=0;ue<o;ue++)for(let re=0;re<T;re++){let se=p+re+X*ue,he=p+re+X*(ue+1),_e=p+(re+1)+X*(ue+1),Ee=p+(re+1)+X*ue;h.push(se,he,Ee),h.push(he,_e,Ee),ie+=6}l.addGroup(f,ie,B),f+=ie,p+=Y}function v(x,b,_){let M=new O,A=new O(e/2,t/2,i/2);A.subScalar(n);let S=[],P=x*b*_>0?(E,T,B)=>h.push(E,T,B):(E,T,B)=>h.push(E,B,T);for(let E=0;E<=o;E++){let T=[],B=Y0*(1-E/o),V=Math.cos(B),I=Math.sin(B),H=0;for(let q=0;q<=E;q++){let X=Math.cos(H),Y=Math.sin(H);M.x=V*X,M.y=I,M.z=V*Y;let ie=A.clone().addScaledVector(M,n);c.push(x*ie.x,b*ie.y,_*ie.z),u.push(x*M.x,b*M.y,_*M.z),d.push(0,0),T.push(p++),H+=Y0/E}S.push(T)}let L=S.length-1;for(let E=0;E<L;E++){let T=S[E],B=S[E+1],V=T.length-1;P(T[0],B[1],B[0]);for(let I=1;I<=V;I++)P(T[I-1],T[I],B[I]),P(T[I],B[I+1],B[I])}}}},qb=class extends St{constructor(e=[],t=[],i="",r=1,a=.2,s=4){super(),this.type="PolyhedronGeometryRound";let n=[],o=[],l=[];h(),c(),this.setAttribute("position",new ut(n,3)),this.setAttribute("normal",new ut(l,3)),this.setAttribute("uv",new ut(o,2));return;function h(){a=Math.min(1-1e-5,a),a==0&&(s=0);let u={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new O,p=d.clone(),f=new Kr,m=a*r,g=r-m,v=s+1,x=new O,b=(X,Y)=>x.subVectors(X,Y).normalize(),_=(X,Y)=>Array(X).fill(void 0).map(Y),M=_(e.length/3,(X,Y)=>new O().fromArray(e,Y*3).setLength(r)),A=[],S=1e6;for(let X=0;X<M.length;X++){let Y=M[X],ie=[],ce,de,ue,re=1e10,se=-1;for(;(se=t.indexOf(X,se+1))!=-1;){let fe=se-se%3;ce=t[fe+(se+1)%3],de=t[fe+(se+2)%3],ue=Y.distanceToSquared(M[ce]),re=Math.min(re,ue),ie.push([ce,de,ue])}re+=1e-6;let he=[],_e=0,Ee=ie.length;for(let fe=0;fe<Ee;fe++){[ce,de,ue]=ie[_e];let Re=A[ce]?.includes(X)==!0;ue<=re&&he.push(ce+ +Re*S),_e=ie.findIndex(Pe=>Pe[0]==de)}A.push(he)}let P=[];{let X=0,Y=0,ie,ce,de=u==3;for(let ue=0;ue<=s;ue++){ie=ue*(ue+1)/2,ce=(ue+1)*(ue+2)/2;for(let re=0;re<s-ue;re++)[X,Y]=[ie+re+ue+2,ce+re+ue+3],P.push(ie,ce,...de?[Y,ie]:[X,ce],Y,X),[ie,ce]=[X,Y];P.push(ie,ce,ie+s+2)}}let L=d.clone(),E=d.clone(),T=d.clone(),B=d.clone(),V=d.clone(),I=[],H=_(M.length,()=>_(u,()=>d.clone()));for(let X=0;X<M.length;X++){d.copy(M[X]).normalize(),L.copy(d).multiplyScalar(g);let Y=A[X];for(let he=0;he<Y.length;he++){let _e=Y[he],Ee=Y[(he+1)%u];f.setFromPointsAndIndices(M,X,_e%S,Ee%S),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(L,H[X][he])}let ie=[],ce=[],de=[],ue=new O;s==0&&[...H[X]].reduce((he,_e)=>he.add(_e),ue).multiplyScalar(1/u);for(let he=0;he<u;he++){let _e=[],Ee=(he-1+u)%u,fe=H[X][Ee],Re=H[X][he];d.copy(fe).sub(L),p.copy(Re).sub(L);let Pe=L.angleTo(d),te=d.angleTo(p),We=Math.cos(Pe)*m;s==0?E.copy(ue):E.copy(L).setLength(g+We),ce.push(We);let Be=[E,fe,Re];for(let Ue=0;Ue<2;Ue++){let Ge=Be[Ue],tt=Be[Ue+1];B.subVectors(Ge,L),V.subVectors(tt,L),T.crossVectors(B,V).normalize();for(let Fe=0;Fe<v;Fe++){let He=[Pe,te][Ue]*Fe/v;d.copy(B).applyAxisAngle(T,He).add(L),ie.push(d.clone()),Ue&&(b(d,L),_e.push([Fe==0?Ge:d.clone(),x.clone()]))}Ue&&(b(tt,L),_e.push([tt,x.clone()]))}de.push(_e)}I.push(de);let re=2*v,se=2;for(let he=0;he<u;he++){let _e=re*he,Ee=re*((he+1)%u),fe=[ie[_e]];for(let Pe=1;Pe<v;Pe++){B=ie[_e+Pe],V=ie[Ee+Pe],fe.push(B);for(let te=1,We=Pe-se+1;te<=We;te++)d.lerpVectors(B,V,te/(We+1)),d.sub(L).setLength(ce[he]).add(L),fe.push(d.clone());fe.push(V)}for(let Pe=0;Pe<v;Pe++)fe.push(ie[Pe+v+_e]);fe.push(ie[Ee+v]);let Re=P.map(Pe=>fe[Pe]);n.push(...Re.map(Pe=>[Pe.x,Pe.y,Pe.z]).flat()),l.push(...Re.map(Pe=>(b(Pe,L),[x.x,x.y,x.z])).flat())}}let q=[];for(let X=0;X<A.length;X++)for(let Y=0;Y<u;Y++){let ie=A[X][Y];if(ie<S){let ce=A[ie].findIndex(re=>re%S==X),de=I[X][Y],ue=I[ie][ce];for(let re=0;re<v;re++){let se=de[re],he=ue[v-re],_e=de[re+1],Ee=ue[v-(re+1)];[se,he,_e,_e,he,Ee].forEach(fe=>{n.push(fe[0].x,fe[0].y,fe[0].z),l.push(fe[1].x,fe[1].y,fe[1].z)})}q.push(de[0][0],ue[v][0],de[v][0],ue[0][0])}}for(;q.length;){let X,Y,ie,ce;[X,Y]=q.splice(0,2);let de=[X];for(;X!=Y;)de.push(Y),ie=q.indexOf(Y),ce=ie%2,Y=q.splice(ie-ce,2)[1-ce];x.subVectors(de[0],de[1]).cross(d.subVectors(de[0],de[2])).normalize();let ue=x.dot(de[0])<0;ue&&x.negate();for(let re=1;re<=de.length-2;re++)[de[re+ +ue],de[re+1-+ue],de[0]].forEach(se=>{n.push(se.x,se.y,se.z),l.push(x.x,x.y,x.z)})}}function c(){let u=new O;for(let A=0;A<n.length;A+=3){u.x=n[A+0],u.y=n[A+1],u.z=n[A+2];let S=_(u)/2/Math.PI+.5,P=M(u)/Math.PI+.5;o.push(S,1-P)}let d=new O,p=new O,f=new O,m=new O,g=new ae,v=new ae,x=new ae,b=(A,S,P,L)=>{L<0&&A.x===1&&(o[S]=A.x-1),P.x===0&&P.z===0&&(o[S]=L/2/Math.PI+.5)};for(let A=0,S=0;A<n.length;A+=9,S+=6){d.set(n[A+0],n[A+1],n[A+2]),p.set(n[A+3],n[A+4],n[A+5]),f.set(n[A+6],n[A+7],n[A+8]),g.set(o[S+0],o[S+1]),v.set(o[S+2],o[S+3]),x.set(o[S+4],o[S+5]),m.copy(d).add(p).add(f).divideScalar(3);let P=_(m);b(g,S+0,d,P),b(v,S+2,p,P),b(x,S+4,f,P)}for(let A=0;A<o.length;A+=6){let S=o[A+0],P=o[A+2],L=o[A+4],E=Math.max(S,P,L),T=Math.min(S,P,L);E>.9&&T<.1&&(S<.2&&(o[A+0]+=1),P<.2&&(o[A+2]+=1),L<.2&&(o[A+4]+=1))}function _(A){return Math.atan2(A.z,-A.x)}function M(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(e){return new qb(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},_Y=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:a,corner:s,cornerSides:n}=e.parameters,o=a===0&&s!==0?new z3(t*.5,s,n):new qT(t*.5,a);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},z3=class extends qb{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,a=1/r,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,-a,-r,0,-a,r,0,a,-r,0,a,r,-a,-r,0,-a,r,0,a,-r,0,a,r,0,-r,0,-a,r,0,-a,-r,0,a,r,0,a],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(s,n,o,e,t,i),this.type=o}static fromJSON(e){return new z3(e.radius,e.corner,e.cornerSides)}},vd=1e-12,Xb=class{constructor(e){this.position=new ae,this.startPosition=new ae,this.uuid=dt.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new Xb(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},cx=class extends Xb{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new cx(this.parent).copy(this)}},tu=class extends Xb{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new cx(this),new cx(this))}static create(e,t){let i=new tu(e,new ae(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let a=this.controls[i];this.position.distanceTo(a.position)<=t?a.position.copy(this.position):a.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 tu(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new ae,t=new ae){let[i,r]=this.computeTangents();return i&&r&&(FE(i,e),FE(r,t)),[e,t]}computeTangent(e=new ae){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new ae){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function FE(e,t=new ae){let i=e.length();return t.set(-e.y/i,e.x/i)}var Yb=e=>e,Nu=new ae,dv=new ae,SY=new ae,AY=new ae,EY=new ae,MY=new ae,k3=new O,V3=new O;function CY(e){let t=new ae;t.addVectors(e.v0,Nu.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new ae;return i.addVectors(e.v2,dv.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Ws(e.v0,t,i,e.v2)}function Od(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function TY(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function PY(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function j3(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),s=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((a*a+r*r-s*s)/(2*a*r))}function DY(e,t,i){return zE(e,t)&&zE(t,i)&&ux(e.position,t.position,i.position)}function ux(e,t,i){return Nu.copy(t).sub(e).cross(dv.copy(i).sub(e))===0}function RY(e,t,i,r,a){let s=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(e.y-t.y)/s,h=Math.sqrt(Math.pow(i,2)-Math.pow(s/2,2))*(t.x-e.x)/s;return r.set(o+l,n+h),a.set(o-l,n-h),[r,a]}function OY(e,t,i){let r=e.distanceTo(i),a=t.distanceTo(i);return r<a?t:e}function LY(e,t,i,r,a,s){let n=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,c=Math.sqrt((n+l)*(n+l)+(o+h)*(o+h)),u;return j3(t,e,i)>Math.PI&&(c*=-1),Od(h,o)?u=(o+h)*(r/c-.5)*8/3/(n-l):u=(n+l)*(r/c-.5)*8/3/(h-o),a.set(t.x-u*o,t.y+u*n),s.set(i.x+u*h,i.y-u*l),[a,s]}function NE(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function zE(e,t){return ux(e.position,e.controls[1].position,t.position)&&ux(e.position,t.controls[0].position,t.position)}function IY(e,t,i,r,a=.5){let s=Nu.subVectors(t,e).multiplyScalar(a).add(e),n=dv.subVectors(i,t).multiplyScalar(a).add(t),o=SY.subVectors(r,i).multiplyScalar(a).add(i),l=s,h=AY.subVectors(n,s).multiplyScalar(a).add(s),c=EY.subVectors(o,n).multiplyScalar(a).add(n),u=o,d=MY.subVectors(c,h).multiplyScalar(a).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,d.x,d.y,c.x,c.y,u.x,u.y,r.x,r.y]}function BY(e,t,i=12,r=!0){let a=V3.set(0,0,0),s,n=0,o=[];for(let l=0;l<t.length;l++){let h=Yb(t[l]),c=Nu,u=xh(h,i);o.push(u);for(let d=0;d<=u;d++)if(h instanceof Ws||h instanceof Ml||h instanceof Pn){if(h.getPoint(d/u,c),a.set(c.x,c.y,0),s!==void 0&&PY(s,a))continue;s===void 0&&(s=k3),s.copy(a),e.setXYZ(n,a.x,a.y,a.z),n++}}return r&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),e}function UY(e,t,i,r=12,a=!0){let s=V3.set(0,0,0),n=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,c=Yb(t[l]),u=Nu,d=xh(c,r);o.push(d);for(let p=0;p<=d;p++)if(c instanceof Ws||c instanceof Ml||c instanceof Pn){if(c.getPoint(p/d,u),s.set(u.x,u.y,0),h?.equals(s))continue;h===void 0?h=k3:(e.setXYZ(n,h.x,h.y,h.z),n++,e.setXYZ(n,s.x,s.y,s.z),n++),h.copy(s)}}return a&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),o}function kE(e,t=12,i=!1){let r=[];for(let a=0,s=e.length;a<s;a++){let n=e[a],o=0;if(i&&n.roundedCurveCorner!==void 0){let l=xh(n.roundedCurveCorner,t)*.5;a>0&&(r[a-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=xh(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=xh(e[0].roundedCurveCorner,t)*.5),r}function xh(e,t=12){return e&&e instanceof Kg?t*2:e&&(e instanceof Pn||e instanceof GT)?1:e&&e instanceof lb?t*e.points.length:t}function FY(e,t,i=12,r=!0){let a,s=0;for(let n=0;n<t.length;n++){let o=Yb(t[n]),l=xh(o,i),h=Nu;for(let c=0;c<=l;c++)if(o instanceof Ws||o instanceof Ml||o instanceof Pn){if(o.getPoint(c/l,h),a!==void 0&&TY(a,h,vd))continue;a===void 0&&(a=dv),a.copy(h),e.push(h.x,h.y),s++}}return Od(e[0],e[e.length-2],vd)&&Od(e[1],e[e.length-1],vd)&&(e.pop(),e.pop()),r&&s>1&&!(Od(e[s-1],e[1],vd)&&Od(e[s-2],e[0],vd))&&(e.push(e[0],e[1]),s++),e}var Q0=new ae,NY=new ae,zY=new ae,kY=new ae,VY=new ae,jY=new ae,ur=class extends $m{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new ts(new O(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=dt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new ur;return r.isClosed=e.isClosed,r.points=e.points.map(a=>tu.create(a.id,a.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(a=>ur.createFromState(a)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let a=0,s=this.shapeHoles.length;a<s;a++){let n=this.shapeHoles[a],o=n.points.length,l=n.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let a=this.shapeHoles[i],s=e-t;if(s<=a.points.length-1)return a.points[s];t+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let a=this.shapeHoles[i],s=a.points.indexOf(e);if(s>=0)return t+s;t+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=Q0.set(e,t);for(let r=0,a=this.points.length;r<a;r++){let s=this.points[r];s.position.multiply(i),s.controls[0].position.multiply(i),s.controls[1].position.multiply(i)}for(let r=0,a=this.shapeHoles.length;r<a;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=dt.generateUUID()){let r;e instanceof ae?r=e:r=new ae(e,t);let a=new tu(i,r);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return BY(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=kE(this.points,e,!1),this.roundedCurveDivisions=kE(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return UY(e,this.curves,t,i,this.autoClose).reduce((r,a)=>r+a,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),FY(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,a=0;t&&this.points[0].roundedCurveCorner!==void 0&&(a=xh(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=r.reduce((n,o)=>n+o,0));for(let n=0,o=r.length;n<o;n++){let l=r[n];if(s<i+l)return[n,(s-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,n=s[e];if(NE(r,a)){let l=r.position.distanceTo(a.position);return r.position.distanceTo(Q0.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=s[l];return(t-o)/n}dispose(){}_applyCurveForPoint(e,t){NE(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let a=this.points[t-1];this._applyCurveForPoint(r,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let a=this.points[i],s=this.points[i-1]??this.points[this.points.length-1],n=this.points[i+1]??this.points[0],o=a.roundness,l=s&&n&&DY(s,a,n);if(!a.controlsMoved()&&o>0&&!l){let h=a.curveBefore,c=a.curveAfter;if(h===void 0||c===void 0)continue;let u=a.roundedCurveBefore,d=a.roundedCurveAfter,p=h.getLength(),f=c.getLength(),m=Math.min(o,p*.499),g=Math.min(o,f*.499),v=Math.min(m,g),x=1-v/p,b=v/f,_=h.getPointAt(x,Q0),M=c.getPointAt(b,NY);this._subSplitCurve(h,u,x,_,void 0),this._subSplitCurve(c,d,b,void 0,M);let A;if(this.useCubicForRoundedCorners){let S=j3(_,a.position,M)/2,P=Math.tan(S)*_.distanceTo(a.position),[L,E]=RY(_,M,P,zY,kY),T=OY(L,E,a.position),[B,V]=LY(T,_,M,P,VY,jY);A=new Ws(_.clone(),B.clone(),V.clone(),M.clone())}else A=new Ml(_.clone(),a.position.clone(),M.clone());a.roundedCurveCorner=A,this.roundedCurves.splice(i+t,0,A),t++}}}}_subSplitCurve(e,t,i,r,a){if(e instanceof Pn)r!==void 0&&t.v2.copy(r),a!==void 0&&t.v1.copy(a);else{let s=e,n=t,o=s.getUtoTmapping(i,0),l=IY(s.v0,s.v1,s.v2,s.v3,o);return r!==void 0&&(n.v0.set(l[0],l[1]),n.v1.set(l[2],l[3]),n.v2.set(l[4],l[5]),n.v3.set(l[6],l[7])),a!==void 0&&(n.v0.set(l[6],l[7]),n.v1.set(l[8],l[9]),n.v2.set(l[10],l[11]),n.v3.set(l[12],l[13])),n}return t}clone(){let e=new ur(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=i*7,a=e.points[r+0],s=e.points[r+1],n=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],c=e.points[r+6],u=new tu(dt.generateUUID(),new ae(a,s));u.controls[0].position.set(n,o),u.controls[1].position.set(l,h),u.roundness=c,this.points.push(u)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new ur;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(a,s)=>{s instanceof Ws&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},r=a=>{let s=[],n,o;for(n=0,o=a.length;n<o;n++)a[n]instanceof Ml&&(a[n]=CY(a[n]));for(n=0,o=a.length;n<o;n++){let c=a[n],u=n>0?a[n-1]:null,d;c instanceof Ws?(d=this.createPoint(c.v0),d.controls[1].position.copy(c.v1)):c instanceof Pn&&(d=this.createPoint(c.v1)),d!==void 0&&(u!==null&&i(d,u),s.push(d))}let l=a[a.length-1],h=!1;return l instanceof Ws?l.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(l.v2),h=!0):l instanceof Pn&&l.v2.equals(s[0].position)&&(h=!0),this.isClosed=h,s};return this.points=r(e.curves),e instanceof $m&&(this.shapeHoles=e.holes.map(a=>{let s=new ur;return s.fromShape(a),s})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},dx=Math.PI*2;function K0({x:e,y:t},i,r,a,s){return{x:e*i+a,y:t*r+s}}function GY(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),a=Math.sin(e),s=Math.cos(e+t),n=Math.sin(e+t);return[{x:r-a*i,y:a+r*i},{x:s+n*i,y:n-s*i},{x:s,y:n}]}function VE(e,t,i,r){let a=e*r-t*i<0?-1:1,s=Math.min(1,Math.max(-1,e*i+t*r));return a*Math.acos(s)}function HY(e,t,i,r,a,s,n,o,l,h){let c=Math.pow(a,2),u=Math.pow(s,2),d=Math.pow(n,2),p=Math.pow(o,2),f=c*u-c*p-u*d;f<0&&(f=0),f/=c*p+u*d,f=Math.sqrt(f)*(l===h?-1:1);let m=f*a/s*o,g=f*-s/a*n,v=m+(e+i)/2,x=g+(t+r)/2,b=(n-m)/a,_=(o-g)/s,M=(-n-m)/a,A=(-o-g)/s,S=VE(1,0,b,_),P=VE(b,_,M,A);return!h&&P>0&&(P-=dx),h&&P<0&&(P+=dx),{centerx:v,centery:x,ang1:S,ang2:P}}function WY({px:e,py:t,cx:i,cy:r,rx:a,ry:s,largeArcFlag:n,sweepFlag:o}){let l=[];if(a===0||s===0)return[];let h=(e-i)/2,c=(t-r)/2;if(h===0&&c===0)return[];a=Math.abs(a),s=Math.abs(s);let u=Math.pow(h,2)/Math.pow(a,2)+Math.pow(c,2)/Math.pow(s,2);u>1&&(a*=Math.sqrt(u),s*=Math.sqrt(u));let d=HY(e,t,i,r,a,s,h,c,n,o),{ang1:p,ang2:f}=d,{centerx:m,centery:g}=d,v=Math.abs(f)/(dx/4);Math.abs(1-v)<1e-7&&(v=1);let x=Math.max(Math.ceil(v),1);f/=x;for(let b=0;b<x;b++)l.push(GY(p,f)),p+=f;return l.map(b=>{let{x:_,y:M}=K0(b[0],a,s,m,g),{x:A,y:S}=K0(b[1],a,s,m,g),{x:P,y:L}=K0(b[2],a,s,m,g);return{x1:_,y1:M,x2:A,y2:S,x:P,y:L}})}var Oi;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Oi||(Oi={}));var Mr;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Mr||(Mr={}));function It(e,t){if(!e)throw t||"Assertion Failed!"}var Ct=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){It(e.vertLeq(t,i)&&e.vertLeq(i,r));var a=i.s-t.s,s=r.s-i.s;return a+s>0?a<s?i.t-t.t+(t.t-r.t)*(a/(a+s)):i.t-r.t+(r.t-t.t)*(s/(a+s)):0},e.edgeSign=function(t,i,r){It(e.vertLeq(t,i)&&e.vertLeq(i,r));var a=i.s-t.s,s=r.s-i.s;return a+s>0?(i.t-r.t)*a+(i.t-t.t)*s:0},e.transEval=function(t,i,r){It(e.transLeq(t,i)&&e.transLeq(i,r));var a=i.t-t.t,s=r.t-i.t;return a+s>0?a<s?i.s-t.s+(t.s-r.s)*(a/(a+s)):i.s-r.s+(r.s-t.s)*(s/(a+s)):0},e.transSign=function(t,i,r){It(e.transLeq(t,i)&&e.transLeq(i,r));var a=i.t-t.t,s=r.t-i.t;return a+s>0?(i.s-r.s)*a+(i.s-t.s)*s:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,a){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+a)/2:i+(a-i)*(t/(t+r)):a+(i-a)*(r/(t+r))},e.intersect=function(t,i,r,a,s){var n,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,a)||(l=r,r=a,a=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=a,a=l),e.vertLeq(r,i)?e.vertLeq(i,a)?(n=e.edgeEval(t,r,i),o=e.edgeEval(r,i,a),n+o<0&&(n=-n,o=-o),s.s=e.interpolate(n,r.s,o,i.s)):(n=e.edgeSign(t,r,i),o=-e.edgeSign(t,a,i),n+o<0&&(n=-n,o=-o),s.s=e.interpolate(n,r.s,o,a.s)):s.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,a)||(l=r,r=a,a=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=a,a=l),e.transLeq(r,i)?e.transLeq(i,a)?(n=e.transEval(t,r,i),o=e.transEval(r,i,a),n+o<0&&(n=-n,o=-o),s.t=e.interpolate(n,r.t,o,i.t)):(n=e.transSign(t,r,i),o=-e.transSign(t,a,i),n+o<0&&(n=-n,o=-o),s.t=e.interpolate(n,r.t,o,a.t)):s.t=(r.t+i.t)/2},e}(),yd=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),Yf=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),Bc=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),jE=function(){function e(){var t=new Bc,i=new yd,r=new Yf(0),a=new Yf(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=a,a.next=a,a.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=a}return e.prototype.makeEdge_=function(t){var i=new Yf(0),r=new Yf(1);t.Sym.side<t.side&&(t=t.Sym);var a=t.Sym.next;return r.next=a,a.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,a=i.Onext;r.Sym.Lnext=i,a.Sym.Lnext=t,t.Onext=a,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var a=t;It(a,"Vertex can't be null!");var s=r.prev;a.prev=s,s.next=a,a.next=r,r.prev=a,a.anEdge=i;var n=i;do n.Org=a,n=n.Onext;while(n!==i)},e.prototype.makeFace_=function(t,i,r){var a=t;It(a,"Face can't be null");var s=r.prev;a.prev=s,s.next=a,a.next=r,r.prev=a,a.anEdge=i,a.trail=null,a.marked=!1,a.inside=r.inside;var n=i;do n.Lface=a,n=n.Lnext;while(n!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,a=r;do a.Org=i,a=a.Onext;while(a!==r);var s=t.prev,n=t.next;n.prev=s,s.next=n},e.prototype.killFace_=function(t,i){var r=t.anEdge,a=r;do a.Lface=i,a=a.Lnext;while(a!==r);var s=t.prev,n=t.next;n.prev=s,s.next=n},e.prototype.makeEdge=function(){var t=new Bc,i=new Bc,r=new yd,a=this.makeEdge_(this.eHead);return this.makeVertex_(t,a,this.vHead),this.makeVertex_(i,a.Sym,this.vHead),this.makeFace_(r,a,this.fHead),a},e.prototype.splice=function(t,i){var r=!1,a=!1;if(t!==i){if(i.Org!==t.Org&&(a=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!a){var s=new Bc;this.makeVertex_(s,i,t.Org),t.Org.anEdge=t}if(!r){var n=new yd;this.makeFace_(n,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var a=new yd;this.makeFace_(a,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var a=new Bc;return this.makeVertex_(a,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,a=this.makeEdge_(t),s=a.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(a,t.Lnext),this.splice_(s,i),a.Org=t.Dst,s.Org=i.Org,a.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!r){var n=new yd;this.makeFace_(n,a,t.Lface)}return a},e.prototype.zapFace=function(t){var i=t.anEdge,r,a,s,n,o;a=i.Lnext;do r=a,a=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=i);n=t.prev,o=t.next,o.prev=n,n.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,a,s,n,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,n=r.Org;a=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(s.Lface),o+l-2<=t&&Ct.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&Ct.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(a=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===n);)r=a;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,a,s,n,o,l,h;for(s=t,s=t;(a=s.next)!==t;s=a){It(a.prev===s),l=a.anEdge;do It(l.Sym!==l),It(l.Sym.Sym===l),It(l.Lnext.Onext.Sym===l),It(l.Onext.Sym.Lnext===l),It(l.Lface===a),l=l.Lnext;while(l!==a.anEdge)}for(It(a.prev===s&&a.anEdge===null),o=i,o=i;(n=o.next)!==i;o=n){It(n.prev===o),l=n.anEdge;do It(l.Sym!==l),It(l.Sym.Sym===l),It(l.Lnext.Onext.Sym===l),It(l.Onext.Sym.Lnext===l),It(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(It(n.prev===o&&n.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)It(l.Sym.next===h.Sym),It(l.Sym!==l),It(l.Sym.Sym===l),It(l.Org!==null),It(l.Dst!==null),It(l.Lnext.Onext.Sym===l),It(l.Onext.Sym.Lnext===l);It(l.Sym.next===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),GE=function(){function e(){this.handle=null}return e}(),HE=function(){function e(){this.key=null,this.node=0}return e}(),qY=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new GE,this.handles[r]=new HE;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,a,s,n;for(a=i[t].handle;;){if(n=t<<1,n<this.size&&this.leq(r[i[n+1].handle].key,r[i[n].handle].key)&&++n,It(n<=this.max),s=i[n].handle,n>this.size||this.leq(r[a].key,r[s].key)){i[t].handle=a,r[a].node=t;break}i[t].handle=s,r[s].node=t,t=n}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,a,s,n;for(a=i[t].handle;;){if(n=t>>1,s=i[n].handle,n===0||this.leq(r[s].key,r[a].key)){i[t].handle=a,r[a].node=t;break}i[t].handle=s,r[s].node=t,t=n}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var a,s;for(s=this.nodes.length,this.nodes.length=this.max+1,a=s;a<this.nodes.length;a++)this.nodes[a]=new GE;for(s=this.handles.length,this.handles.length=this.max+1,a=s;a<this.handles.length;a++)this.handles[a]=new HE}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,a=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),a},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,a;It(t>=1&&t<=this.max&&r[t].key!==null),a=r[t].node,i[a].handle=i[this.size].handle,r[i[a].handle].node=a,--this.size,a<=this.size&&(a<=1||this.leq(r[i[a>>1].handle].key,r[i[a].handle].key)?this.floatDown_(a):this.floatUp_(a)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),Z0=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),WE=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),XY=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new WE,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new WE;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),YY=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var a=t.event,s=i.eUp,n=r.eUp;if(s.Dst===a)return n.Dst===a?Ct.vertLeq(s.Org,n.Org)?Ct.edgeSign(n.Dst,s.Org,n.Org)<=0:Ct.edgeSign(s.Dst,n.Org,s.Org)>=0:Ct.edgeSign(n.Dst,a,n.Org)<=0;if(n.Dst===a)return Ct.edgeSign(s.Dst,a,s.Org)>=0;var o=Ct.edgeEval(s.Dst,a,s.Org),l=Ct.edgeEval(n.Dst,a,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&It(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){It(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,a;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(a=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),a===null)return null;e.fixUpperEdge(t,i,a),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var a=new Z0;return a.eUp=r,a.nodeUp=t.dict.insertBefore(i.nodeUp,a),a.fixUpperEdge=!1,a.sentinel=!1,a.dirty=!1,r.activeRegion=a,a},e.isWindingInside=function(t,i){switch(t.windingRule){case Oi.ODD:return(i&1)!==0;case Oi.NONZERO:return i!==0;case Oi.POSITIVE:return i>0;case Oi.NEGATIVE:return i<0;case Oi.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,a=r.Lface;a.inside=i.inside,a.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var a,s=null,n=i,o=i.eUp;n!==r;){if(n.fixUpperEdge=!1,s=e.regionBelow(n),a=s.eUp,a.Org!=o.Org){if(!s.fixUpperEdge){e.finishRegion(t,n);break}a=t.mesh.connect(o.Lprev,a.Sym),e.fixUpperEdge(t,s,a)}o.Onext!==a&&(t.mesh.splice(a.Oprev,a),t.mesh.splice(o,a)),e.finishRegion(t,n),o=s.eUp,n=s}return o},e.addRightEdges=function(t,i,r,a,s,n){var o,l,h,c,u=!0;h=r;do It(Ct.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==a);for(s===null&&(s=e.regionBelow(i).eUp.Rprev),l=i,c=s;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===c.Org;)h.Onext!==c&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(c.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!u&&e.checkForRightSplice(t,l)&&(e.addWinding(h,c),e.deleteRegion(t,l),t.mesh.delete(c)),u=!1,l=o,c=h;l.dirty=!0,It(l.windingNumber-h.winding===o.windingNumber),n&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var a=Ct.vertL1dist(i,t),s=Ct.vertL1dist(r,t),n=.5*s/(a+s),o=.5*a/(a+s);t.coords[0]+=n*i.coords[0]+o*r.coords[0],t.coords[1]+=n*i.coords[1]+o*r.coords[1],t.coords[2]+=n*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,a,s,n){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,a),e.vertexWeights(i,s,n)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),a=i.eUp,s=r.eUp;if(Ct.vertLeq(a.Org,s.Org)){if(Ct.edgeSign(s.Dst,a.Org,s.Org)>0)return!1;Ct.vertEq(a.Org,s.Org)?a.Org!==s.Org&&(t.pq.delete(a.Org.pqHandle),e.spliceMergeVertices(t,s.Oprev,a)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(a,s.Oprev),i.dirty=r.dirty=!0)}else{if(Ct.edgeSign(a.Dst,s.Org,a.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(a.Sym),t.mesh.splice(s.Oprev,a)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),a=i.eUp,s=r.eUp,n;if(It(!Ct.vertEq(a.Dst,s.Dst)),Ct.vertLeq(a.Dst,s.Dst)){if(Ct.edgeSign(a.Dst,s.Dst,a.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,n=t.mesh.splitEdge(a),t.mesh.splice(s.Sym,n),n.Lface.inside=i.inside}else{if(Ct.edgeSign(s.Dst,a.Dst,s.Org)>0)return!1;i.dirty=r.dirty=!0,n=t.mesh.splitEdge(s),t.mesh.splice(a.Lnext,s.Sym),n.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),a=i.eUp,s=r.eUp,n=a.Org,o=s.Org,l=a.Dst,h=s.Dst,c,u,d=new Bc,p,f;if(It(!Ct.vertEq(h,l)),It(Ct.edgeSign(l,t.event,n)<=0),It(Ct.edgeSign(h,t.event,o)>=0),It(n!==t.event&&o!==t.event),It(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(c=Math.min(n.t,l.t),u=Math.max(o.t,h.t),c>u))return!1;if(Ct.vertLeq(n,o)){if(Ct.edgeSign(h,n,o)>0)return!1}else if(Ct.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),Ct.intersect(l,n,h,o,d),It(Math.min(n.t,l.t)<=d.t),It(d.t<=Math.max(o.t,h.t)),It(Math.min(h.s,l.s)<=d.s),It(d.s<=Math.max(o.s,n.s)),Ct.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),p=Ct.vertLeq(n,o)?n:o,Ct.vertLeq(p,d)&&(d.s=p.s,d.t=p.t),Ct.vertEq(d,n)||Ct.vertEq(d,o)?(e.checkForRightSplice(t,i),!1):!Ct.vertEq(l,t.event)&&Ct.edgeSign(l,t.event,d)>=0||!Ct.vertEq(h,t.event)&&Ct.edgeSign(h,t.event,d)<=0?h===t.event?(t.mesh.splitEdge(a.Sym),t.mesh.splice(s.Sym,a),i=e.topLeftRegion(t,i),a=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,a.Oprev,a,a,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Lnext,s.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=s.Oprev,s=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,s.Onext,a.Rprev,f,!0),!0):(Ct.edgeSign(l,t.event,d)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(a.Sym),a.Org.s=t.event.s,a.Org.t=t.event.t),Ct.edgeSign(h,t.event,d)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(a.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,a),a.Org.s=d.s,a.Org.t=d.t,a.Org.pqHandle=t.pq.insert(a.Org),e.getIntersectData(t,a.Org,n,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),a,s;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,a=i.eUp,s=r.eUp,a.Dst!==s.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(s),r=e.regionBelow(i),s=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(a),i=e.regionAbove(r),a=i.eUp)),a.Org!==s.Org)if(a.Dst!==s.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(a.Dst===t.event||s.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);a.Org===s.Org&&a.Dst===s.Dst&&(e.addWinding(s,a),e.deleteRegion(t,i),t.mesh.delete(a),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var a,s=r.Onext,n=e.regionBelow(i),o=i.eUp,l=n.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Ct.vertEq(o.Org,t.event)&&(t.mesh.splice(s.Oprev,o),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),n),h=!0),Ct.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,n,null),h=!0),h){e.addRightEdges(t,i,r.Onext,s,s,!0);return}Ct.vertLeq(l.Org,o.Org)?a=l.Oprev:a=o,a=t.mesh.connect(r.Lprev,a),e.addRightEdges(t,i,a,a.Onext,a.Onext,!1),a.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var a,s,n,o,l;if(a=i.eUp,Ct.vertEq(a.Org,r)){It(!1),e.spliceMergeVertices(t,a,r.anEdge);return}if(!Ct.vertEq(a.Dst,r)){t.mesh.splitEdge(a.Sym),i.fixUpperEdge&&(t.mesh.delete(a.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,a),e.sweepEvent(t,r);return}It(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,s=o=n.Onext,l.fixUpperEdge&&(It(s!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=s.Oprev),t.mesh.splice(r.anEdge,n),Ct.edgeGoesLeft(s)||(s=null),e.addRightEdges(t,i,n.Onext,o,s,!0)},e.connectLeftVertex=function(t,i){var r,a,s,n,o,l,h=new Z0;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,a=e.regionBelow(r),!!a){if(n=r.eUp,o=a.eUp,Ct.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(s=Ct.vertLeq(o.Dst,n.Dst)?r:a,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(i.anEdge.Sym,n.Lnext);else{var c=t.mesh.connect(o.Dnext,i.anEdge);l=c.Sym}s.fixUpperEdge?e.fixUpperEdge(t,s,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var a=e.topLeftRegion(t,r.activeRegion);It(a!==null);var s=e.regionBelow(a),n=s.eUp,o=e.finishLeftRegions(t,s,null);o.Onext===n?e.connectRightVertex(t,a,o):e.addRightEdges(t,a,o.Onext,n,n,!0)},e.addSentinel=function(t,i,r,a){var s=new Z0,n=t.mesh.makeEdge();n.Org.s=r,n.Org.t=a,n.Dst.s=i,n.Dst.t=a,t.event=n.Dst,s.eUp=n,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},e.initEdgeDict=function(t){t.dict=new XY(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],a=t.bmin[0]-i,s=t.bmax[0]+i,n=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,a,s,n),e.addSentinel(t,a,s,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(It(i.fixUpperEdge),It(++r===1)),It(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,a,s=t.mesh.eHead;for(i=s.next;i!==s;i=r)r=i.next,a=i.Lnext,Ct.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,a,i),t.mesh.delete(i),i=a,a=i.Lnext),a.Lnext===i&&(a!==i&&((a===r||a===r.Sym)&&(r=r.next),t.mesh.delete(a)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,a,s=0;for(a=t.mesh.vHead,r=a.next;r!==a;r=r.next)s++;for(s+=8,i=t.pq=new qY(s,Ct.vertLeq),a=t.mesh.vHead,r=a.next;r!==a;r=r.next)r.pqHandle=i.insert(r);return r!==a?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,a,s;for(r=i.fHead.next;r!==i.fHead;r=a)a=r.next,s=r.anEdge,It(s.Lnext!==s),s.Lnext.Lnext===s&&(e.addWinding(s.Onext,s),t.mesh.delete(s));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,a;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;a=t.pq.min(),!(a===null||!Ct.vertEq(a,r));)a=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,a.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),QY=function(){function e(){this.mesh=new jE,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=Oi.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,a,s,n,o,l=[0,0,0],h=[0,0,0],c=[0,0,0],u=[0,0,0],d=[0,0,0],p=[null,null,null],f=[null,null,null],m=this.mesh.vHead;i=m.next;for(var g=0;g<3;++g)s=i.coords[g],h[g]=s,f[g]=i,l[g]=s,p[g]=i;for(i=m.next;i!==m;i=i.next)for(var v=0;v<3;++v)s=i.coords[v],s<h[v]&&(h[v]=s,f[v]=i),s>l[v]&&(l[v]=s,p[v]=i);var x=0;if(l[1]-h[1]>l[0]-h[0]&&(x=1),l[2]-h[2]>l[x]-h[x]&&(x=2),h[x]>=l[x]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=f[x],a=p[x],c[0]=r.coords[0]-a.coords[0],c[1]=r.coords[1]-a.coords[1],c[2]=r.coords[2]-a.coords[2],i=m.next;i!==m;i=i.next)u[0]=i.coords[0]-a.coords[0],u[1]=i.coords[1]-a.coords[1],u[2]=i.coords[2]-a.coords[2],d[0]=c[1]*u[2]-c[2]*u[1],d[1]=c[2]*u[0]-c[0]*u[2],d[2]=c[0]*u[1]-c[1]*u[0],n=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],n>o&&(o=n,t[0]=d[0],t[1]=d[1],t[2]=d[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,a,s=0,n=t.next;n!==t;n=n.next)if(a=n.anEdge,!(a.winding<=0))do s+=(a.Org.s-a.Dst.s)*(a.Org.t+a.Dst.t),a=a.Lnext;while(a!==n.anEdge);if(s<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,a,s=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),s=!0),r=this.sUnit,a=this.tUnit;var n=this.longAxis_(i);r[n]=0,r[(n+1)%3]=1,r[(n+2)%3]=0,a[n]=0,a[(n+1)%3]=0,a[(n+2)%3]=i[n]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,a);s&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,a;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Ct.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ct.vertLeq(r.Org,r.Dst);r=r.Lnext);a=r.Lprev;for(var s=void 0;r.Lnext!==a;)if(Ct.vertLeq(r.Dst,a.Org)){for(;a.Lnext!==r&&(Ct.edgeGoesLeft(a.Lnext)||Ct.edgeSign(a.Org,a.Dst,a.Lnext.Dst)<=0);)s=t.connect(a.Lnext,a),a=s.Sym;a=a.Lprev}else{for(;a.Lnext!==r&&(Ct.edgeGoesRight(r.Lprev)||Ct.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(a.Lnext===r)throw"Mono region invalid";for(;a.Lnext.Lnext!==r;)s=t.connect(a.Lnext,a),a=s.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var a,s=t.eHead.next;s!==t.eHead;s=a)a=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?i:-i:r?t.delete(s):s.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,a){var s,n=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var h=s.Org;h.n===-1&&(h.n=o,o++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=n,++n}this.elementCount=n,i===Mr.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*a,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var u=h.n*a;this.vertices[u+0]=h.coords[0],this.vertices[u+1]=h.coords[1],a>2&&(this.vertices[u+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var d=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(c.inside){s=c.anEdge,l=0;do{var h=s.Org;this.elements[d++]=h.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1;if(i===Mr.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1}}},e.prototype.outputContours_=function(t,i){var r,a,s=0,n=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){a=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==a);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,c=0;s=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){n=0,a=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,n++,r=r.Lnext;while(r!==a);this.elements[c++]=s,this.elements[c++]=n,s+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new jE),t<2&&(t=2),t>3&&(t=3);for(var r=null,a=0;a<i.length;a+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[a+0],r.Org.coords[1]=i[a+1],t>2?r.Org.coords[2]=i[a+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,a,s,n){if(t===void 0&&(t=Oi.ODD),i===void 0&&(i=Mr.POLYGONS),n===void 0&&(n=!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,a<2&&(a=2),a>3&&(a=3),!this.mesh)return!1;this.projectPolygon_(),YY.computeInterior(this,n);var o=this.mesh;return i===Mr.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===Mr.BOUNDARY_CONTOURS?this.outputContours_(o,a):this.outputPolymesh_(o,i,r,a),!0},e}();function vl(e){var t=e.windingRule,i=t===void 0?Oi.ODD:t,r=e.elementType,a=r===void 0?Mr.POLYGONS:r,s=e.polySize,n=s===void 0?3:s,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,c=h===void 0?[0,0,1]:h,u=e.contours,d=u===void 0?[]:u,p=e.strict,f=p===void 0?!0:p,m=e.debug,g=m===void 0?!1:m;if(!d&&f)throw new Error("Contours can't be empty");if(d){var v=new QY;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var x=0;x<d.length;x++)v.addContour(l||2,d[x]);return v.tesselate(i,a,n,l,c,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var Ose=Oi.ODD,Lse=Oi.NONZERO,Ise=Oi.POSITIVE,Bse=Oi.NEGATIVE,Use=Oi.ABS_GEQ_TWO,Fse=Mr.POLYGONS,Nse=Mr.CONNECTED_POLYGONS,zse=Mr.BOUNDARY_CONTOURS,px=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*px.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,a=0;this.positions=new Float32Array(this.buffer,a*r,3*e),a+=3*e,this.normals=new Float32Array(this.buffer,a*r,3*e),a+=3*e,this.uvs=new Float32Array(this.buffer,a*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let i=e*px.eSize,r=new ArrayBuffer(i),a=Float32Array.BYTES_PER_ELEMENT,s=0,n=new Float32Array(r,s*a,3*e);s+=3*e;let o=new Float32Array(r,s*a,3*e);s+=3*e;let l=new Float32Array(r,s*a,2*e);t?(n.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(n.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=n,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},G3=px;G3.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var KY=Ro(GB()),Qb={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},H3={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},W3={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},J0=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),Kb=class extends St{constructor(e,t,i=0,r=12,a=3,s=Oi.ODD,n=!1){super(),this.forPathBevel=n,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=a;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(L=>{let E=L.extractShapePointsToFlatArray([],r),T=[];for(let B=E.length-1;B>=1;B-=2){let V=E[B-1],I=E[B-0];T.push(V,I)}return T}),h=[],c=[];for(let L=0;L<o.length;L+=2)c.push([o[L],o[L+1]]);h.push(c);for(let L=0;L<l.length;L++){let E=l[L],T=[];for(let B=0;B<E.length;B+=2)T.push([E[B],E[B+1]]);h.push(T)}let u;e.isText?u=new oP().setFromPoints(e.points.map(L=>L.position)).getSize(new ae).length()*.1:h[0].length===0?u=i:u=(0,KY.default)(h).distance,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,u,t/2),this._bevelSegments=Math.floor(a));let d;try{d=vl({windingRule:s,elementType:Mr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{d=Qb}let p;try{p=vl({windingRule:Oi.ODD,elementType:Mr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=H3}if(!d)throw new Error("error generating geometry");let f=d.elementCount;if(p){d.elementCount+=p.elementCount;for(let L=0;L<p.elements.length;L++){let E=p.elements[L],T=L%2===0?d.vertexCount:0;d.elements.push(E+T)}for(let L=0;L<p.vertexIndices.length;L++){let E=p.vertexIndices[L],T=d.vertexCount;d.vertexIndices.push(E+T)}for(let L=0;L<p.vertices.length;L++){let E=p.vertices[L];d.vertices.push(E)}}let m=1/0,g=-1/0,v=1/0,x=-1/0;for(let L=0,E=d.vertexCount;L<E;L++){let T=L*2,B=d.vertices[T+0],V=d.vertices[T+1];B<m&&(m=B),B>g&&(g=B),V<v&&(v=V),V>x&&(x=V)}this._minX=m,this._minY=v,this._width=g-m,this._height=x-v,this._buffer=new G3(this._computeBufferEstimatedSize(d));let b=[],_=[];for(let L=d.elementCount-1;L>=0;L--){let E=L>=f,T=L*2,B=d.elements[T+0],V=d.elements[T+1],I=B+V,H={start:B,count:V,normals:[],continuous:[],concave:[]},q=B,X=I-1,Y=B+1,ie=this._shape.roundedCurves.length;do{let se=q-B,he=d.vertices[X*2+0],_e=d.vertices[X*2+1],Ee=d.vertices[q*2+0],fe=d.vertices[q*2+1],Re=d.vertices[Y*2+0],Pe=d.vertices[Y*2+1],te=Ee-he,We=fe-_e,Be=Math.sqrt(te*te+We*We);te/=Be,We/=Be;let Ue=Ee-Re,Ge=fe-Pe,tt=Math.sqrt(Ue*Ue+Ge*Ge);Ue/=tt,Ge/=tt,H.normals[se*2+0]=-Ge,H.normals[se*2+1]=Ue,H.concave[se]=te*Ge-We*Ue>0;let Fe=d.vertexIndices[q];if(Array.isArray(Fe))H.continuous[se]=!1;else{let[He,nt]=this._shape.getCurveIndexFromVertexId(Fe-1,!0);if(nt>0&&nt<1)H.continuous[se]=!0;else{let ht=nt===1?He+1:He-1;ht=(ht+ie)%ie;let Z=nt===1?0:1,j=this._shape.roundedCurves[He].getTangent(nt),ye=this._shape.roundedCurves[ht].getTangent(Z);H.continuous[se]=j.dot(ye)>.95}}E&&(H.normals[se*2+0]*=-1,H.normals[se*2+1]*=-1),[X,q,Y]=[q,Y,Y+1],Y>=I&&(Y-=V)}while(Y!==B+1);let ce=[];ce.push({bevelI:0,angle:0,size:0,boundary:{vertices:d.vertices.slice(B*2,I*2),vertexCount:V,vertexIndices:new Array(V).fill(!0).map((se,he)=>[he,he]),elements:[0,V],elementCount:1,mesh:null},reverseMap:[],insetPoints:d.vertices.slice(B*2,I*2)});let de=0;for(let se=1;se<=this._bevelSegments;se++){let he=se/this._bevelSegments*Math.PI/2,_e=(1-Math.cos(he))*this._bevel,Ee=[],fe=[],Re=[],Pe=[],te=0;for(let Be=0;Be<V;Be++){let Ue=Be*2,Ge=(Be-1+V)%V*2,tt=d.vertices[H.start*2+Ue+0],Fe=d.vertices[H.start*2+Ue+1],He=-H.normals[Ge+0]*_e,nt=-H.normals[Ge+1]*_e,ht=-H.normals[Ue+0]*_e,Z=-H.normals[Ue+1]*_e;if(H.concave[Be]||!H.concave[Be]&&E){let j=Math.atan2(nt,He),ye=Math.atan2(Z,ht);ye>j&&(ye-=Math.PI*2);let Me=ye-j;if(H.continuous[Be]||E){let Je=j+Me/2,z=Math.cos(Je)*_e,qe=Math.sin(Je)*_e;Ee[2*te+0]=tt+z*(E?-1:1),Ee[2*te+1]=Fe+qe*(E?-1:1),Pe[te]=Be,te++}else{let Je=Math.max(1,Math.floor(r/4*Math.abs(Me)/Math.PI));for(let z=0;z<=Je;z++){let qe=j+Me*(z/Je),ct=Math.cos(qe)*_e,ze=Math.sin(qe)*_e;Ee[2*te+0]=tt+ct,Ee[2*te+1]=Fe+ze,Pe[te]=Be,te++}}}else Ee[2*te+0]=tt+He,Ee[2*te+1]=Fe+nt,Pe[te]=Be,fe[Be]=te,te++,Ee[2*te+0]=tt,Ee[2*te+1]=Fe,Pe[te]=Be,te++,Ee[2*te+0]=tt+ht,Ee[2*te+1]=Fe+Z,Pe[te]=Be,Re[Be]=te,te++}let We=vl({windingRule:Oi.POSITIVE,elementType:Mr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Ee],edgeCreateCallback:Be=>{let Ue=Be.Org.idx,Ge=Pe[Ue],tt=Pe[(Ue+1)%Pe.length];Be.idx=[Ge,tt],Be.Sym.idx=[tt,Ge]},vertexIdCallback:Be=>{let Ue=Be.Lprev.idx;return[Ue?Ue[1]:0,Be.idx?Be.idx[0]:0]}});if(!We)throw console.log("Error"),new Error(`error generating bevel geometry for ${se}'th loop`);if(!We.vertexCount){let Be=(se-1)/this._bevelSegments*Math.PI/2;de=(1-Math.sin(Be))*this._bevel;break}for(let Be=0;Be<We.vertexIndices.length;Be++){let[Ue,Ge]=We.vertexIndices[Be];if(Ue===Ge)continue;let tt=Ge;Ge<Ue&&(tt+=V);for(let Fe=Ue;Fe<tt;Fe++){let He=Fe%V,nt=(Fe+1)%V;if(!H.continuous[He]||!H.continuous[nt]){We.vertexIndices[Be]=[Ue,He],We.vertexIndices.splice(Be+1,0,[nt,Ge]),We.vertices.splice((Be+1)*2,0,We.vertices[Be*2],We.vertices[Be*2+1]);break}}}ce.push({bevelI:se,angle:he,size:_e,boundary:We,reverseMap:Pe,insetPoints:Ee})}let ue=(se,he,_e)=>{let Ee=0,fe=se.boundary.vertexIndices.length;for(;Ee<fe&&_e(se.boundary.vertexIndices[he]);)he=(he+1)%fe,Ee++;return Ee},re=b.length;for(let se=1;se<ce.length;se++){let he=ce[se-1],_e=ce[se],Ee=he.boundary.vertexIndices.length,fe=_e.boundary.vertexIndices.length;if(!Ee||!fe)break;let Re=H.concave.length,Pe=0,te=J0(Pe,V);for(;!he.boundary.vertexIndices.filter(te).length||!_e.boundary.vertexIndices.filter(te).length;)Pe++,te=J0(Pe,V);let We=he.boundary.vertexIndices.findIndex(te),Be=_e.boundary.vertexIndices.findIndex(te);do We=(We+1)%Ee;while(te(he.boundary.vertexIndices[We]));do Be=(Be+1)%fe;while(te(_e.boundary.vertexIndices[Be]));Pe=(Pe+1)%V;let Ue=Pe,Ge=0,tt=this._buildBevelVert(H,he,(We-1+Ee)%Ee,void 0,Ge),Fe=this._buildBevelVert(H,_e,(Be-1+fe)%fe,void 0,Ge),He=tt,nt=Fe,ht,Z,j=!1;do{Ge=(Pe||Re)/Re,te=J0(Pe,V);let ye=ue(he,We,te),Me=ue(_e,Be,te),Je=j;if(j=!1,ye&&!Me){for(let z=0;z<ye;z++)ht=this._buildBevelVert(H,he,(We+z)%Ee,z/(ye-1),Ge),b.push(He.topN,ht.topP,nt.topN),n===!1&&b.push(ht.bottomP,He.bottomN,nt.bottomN),He=ht;j=!0}else if(!ye&&Me)for(let z=0;z<Me;z++)Z=this._buildBevelVert(H,_e,(Be+z)%fe,z/(Me-1),Ge),b.push(nt.topN,He.topP,Z.topP),n===!1&&b.push(He.bottomP,nt.bottomN,Z.bottomP),nt=Z;else if(ye&&Me)if(ht=this._buildBevelVert(H,he,We,0,Ge),Z=this._buildBevelVert(H,_e,Be,0,Ge),Je?(b.push(He.topN,Z.topP,nt.topN),b.push(He.topN,ht.topP,Z.topP),n===!1&&(b.push(Z.bottomP,He.bottomN,nt.bottomN),b.push(Z.bottomP,ht.bottomP,He.bottomN))):(b.push(nt.topN,He.topN,ht.topP),b.push(nt.topN,ht.topP,Z.topP),n===!1&&(b.push(ht.bottomP,He.bottomN,nt.bottomN),b.push(ht.bottomP,nt.bottomN,Z.bottomP))),He=ht,nt=Z,ye===Me)for(let z=1;z<ye;z++)ht=this._buildBevelVert(H,he,(We+z)%Ee,z/(ye-1),Ge),Z=this._buildBevelVert(H,_e,(Be+z)%fe,z/(Me-1),Ge),b.push(He.topN,ht.topP,nt.topN),b.push(nt.topN,ht.topP,Z.topP),n===!1&&(b.push(ht.bottomP,He.bottomN,nt.bottomN),b.push(ht.bottomP,nt.bottomN,Z.bottomP)),He=ht,nt=Z;else if(ye>Me){let z=ye/Me,qe=0;for(let ct=1;ct<ye;ct++)ht=this._buildBevelVert(H,he,(We+ct)%Ee,ct/(ye-1),Ge),b.push(He.topN,ht.topP,nt.topN),n===!1&&b.push(ht.bottomP,He.bottomN,nt.bottomN),He=ht,ct>(qe+1)*z&&(qe++,Z=this._buildBevelVert(H,_e,(Be+qe)%fe,qe/(Me-1),Ge),b.push(nt.topN,ht.topP,Z.topP),n===!1&&b.push(ht.bottomP,nt.bottomN,Z.bottomP),nt=Z)}else{let z=Me/ye,qe=0;for(let ct=1;ct<Me;ct++)Z=this._buildBevelVert(H,_e,(Be+ct)%fe,ct/(Me-1),Ge),b.push(nt.topN,ht.topP,Z.topP),n===!1&&b.push(ht.bottomP,nt.bottomN,Z.bottomP),nt=Z,ct>(qe+1)*z&&(qe++,ht=this._buildBevelVert(H,he,(We+qe)%Ee,qe/(ye-1),Ge),b.push(He.topN,ht.topP,nt.topN),n===!1&&b.push(ht.bottomP,He.bottomN,nt.bottomN),He=ht)}We=(We+ye)%Ee,Be=(Be+Me)%fe,Pe=(Pe+1)%Re}while(Pe!==Ue)}if(n===!1&&this._depth>this._bevel*2&&this._buildWall(ce,H,b),E){let se=[];for(let he=b.length-1;he>=re+2;he-=3){let _e=b[he-2],Ee=b[he-1],fe=b[he-0];se.push(fe,Ee,_e)}b.splice(re,b.length-re,...se)}if(E){let se=[];for(let he=ce[ce.length-1].boundary.vertices.length-1;he>=1;he-=2){let _e=ce[ce.length-1].boundary.vertices[he-1],Ee=ce[ce.length-1].boundary.vertices[he-0];se.push(_e,Ee)}_.push(se)}if(!E){let se=ce[ce.length-1],he;try{he=vl({windingRule:ce.length>1?Oi.POSITIVE:Oi.ODD,elementType:Mr.POLYGONS,vertexSize:2,strict:!0,contours:[se.insetPoints,..._]})}catch{he=W3}if(!he)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<u&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let _e=0;_e<he.elementCount*3;_e+=3){let Ee=this._buildSurfaceVert(he,he.elements[_e+0],de),fe=this._buildSurfaceVert(he,he.elements[_e+1],de),Re=this._buildSurfaceVert(he,he.elements[_e+2],de);b.push(Ee.top,fe.top,Re.top),n===!1&&b.push(Re.bottom,fe.bottom,Ee.bottom)}}this.vertexCache={}}this._buffer.shrink();let M=new Ut(Uint32Array.from(b),1),A=new Ut(this._buffer.positions,3),S=new Ut(this._buffer.normals,3),P=new Ut(this._buffer.uvs,2);A.needsUpdate=!0,S.needsUpdate=!0,P.needsUpdate=!0,M.needsUpdate=!0,this.setAttribute("position",A),this.setAttribute("normal",S),this.setAttribute("uv",P),this.setIndex(M)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let a=0,s=r.boundary.vertexCount;a<s;a++){let n=this._buildBevelVert(t,r,a),o=this._buildBevelVert(t,r,(a+1)%s);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}_buildSurfaceVert(e,t,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let a=e.vertices[t*2+0],s=e.vertices[t*2+1],n=(a-this._minX)/this._width,o=(s-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=l*3,c=l*2,u={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=a,this._buffer.positions[h+1]=s,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[c+0]=n,this._buffer.uvs[c+1]=o,this.forPathBevel===!1&&(this._buffer.positions[h+3]=a,this._buffer.positions[h+4]=s,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[c+2]=n,this._buffer.uvs[c+3]=o),this.vertexCache[r]=u,u}_buildBevelVert(e,t,i,r=1,a){let s=`${t.bevelI}:${i}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[n,o]=t.boundary.vertexIndices[i],l,h,c,u;n!==o?(h=n,l=o,u=!1,c=e.continuous[h]&&e.continuous[l]):(l=n,h=(l-1+e.count)%e.count,u=e.concave[l]&&t.bevelI>0,c=e.continuous[l]||u);let d=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,m=l*2,g=h*2,v=t.boundary.vertices[f+0],x=t.boundary.vertices[f+1],b=(1-p)*this._bevel,_=(v-this._minX)/this._width,M=(x-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(_=a),M=1);let A=e.normals[m+0],S=e.normals[m+1],P=e.normals[g+0],L=e.normals[g+1];if(u){let I=P-A,H=L-S;A=A+I*(1-r),S=S+H*(1-r);let q=Math.sqrt(A*A+S*S);A/=q,S/=q}let E=this.forPathBevel?this._buffer.get(c?1:2):this._buffer.get(c?2:4),T=E*3,B=E*2,V={i,fi:l,topP:E+0,topN:E+0,bottomP:E+1,bottomN:E+1,pathBevelUCoord:a};return this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=x,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[T+0]=A*d,this._buffer.normals[T+1]=S*d,this._buffer.normals[T+2]=p,this._buffer.uvs[B+0]=_,this._buffer.uvs[B+1]=M,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=x,this._buffer.positions[T+5]=b,this._buffer.normals[T+3]=A*d,this._buffer.normals[T+4]=S*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[B+2]=M,this._buffer.uvs[B+3]=_),c||(this.forPathBevel?(E+=1,T+=3,B+=2):(E+=2,T+=6,B+=4),V.topP=E+0,V.bottomP=E+1,this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=x,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[T+0]=P*d,this._buffer.normals[T+1]=L*d,this._buffer.normals[T+2]=p,this._buffer.uvs[B+0]=_,this._buffer.uvs[B+1]=M,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=x,this._buffer.positions[T+5]=b,this._buffer.normals[T+3]=P*d,this._buffer.normals[T+4]=L*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[B+2]=M,this._buffer.uvs[B+3]=_)),this.vertexCache[s]=V,V}clone(){let e=new Kb(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=sv(this.userData),e}},q3=class extends St{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=Oi.ODD,this.elementType=Mr.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Oi.ODD,elementType:Mr.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(d=>d.extractShapePointsToFlatArray([],this._curveSegments)),s,n=!0,o=!0,l,h;for(let d=0,p=r.length/2;d<p;d++){let f=d*2,m=r[f+0],g=r[f+1];if(l!==void 0&&m!==l&&(n=!1),h!==void 0&&g!==h&&(o=!1),l=m,h=g,!n&&!o)break}if(!n&&!o)try{s=vl({contours:[r,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=Qb}let c=s?.vertexCount??1,u=s?.elementCount??1;if(this._positionAttribute=new Ut(new Float32Array(c*3),3),this._normalAttribute=new Ut(new Float32Array(c*3),3),this._uvAttribute=new Ut(new Float32Array(c*2),2),this._indexAttribute=new Ut(new Uint32Array(u*3),1),s){let d=1/0,p=-1/0,f=1/0,m=-1/0;for(let x=0,b=c;x<b;x++){let _=x*2,M=s.vertices[_+0],A=s.vertices[_+1];M<d&&(d=M),M>p&&(p=M),A<f&&(f=A),A>m&&(m=A)}let g=p-d,v=m-f;for(let x=0,b=c;x<b;x++){let _=x*2,M=s.vertices[_+0],A=s.vertices[_+1],S=(M-d)/g,P=(A-f)/v;this._positionAttribute.setXYZ(x,M,A,0),this._normalAttribute.setXYZ(x,0,0,1),this._uvAttribute.setXY(x,S,P)}for(let x=0,b=u;x<b;x++){let _=x*3,M=s.elements[_+0],A=s.elements[_+1],S=s.elements[_+2];this._indexAttribute.setX(_+0,M),this._indexAttribute.setX(_+1,A),this._indexAttribute.setX(_+2,S)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new q3(this._shape,this._curveSegments);return e.userData=sv(this.userData),e}},X3=class extends Kb{constructor(e,t,i=0,r=12,a=3,s=Oi.ODD){super(e,t,i,r,a,s),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let a=0,s=r.boundary.vertexCount;a<s;a++){let n=this._buildBevelVert(t,r,a),o=this._buildBevelVert(t,r,(a+1)%s);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}clone(){let e=new X3(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=sv(this.userData),e}},Bh=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Oi.ODD},e.parameters),r=Math.abs(i.width),a=Math.abs(i.height??i.width),s=Math.abs(i.depth??0),n=e.shape??t?.shape,o=n?.roundness??i.roundness;n!==void 0&&(n instanceof ur?(n.width!==r||n.height!==a)&&n.applySize(r,a):n=new ur(r,a).fromJSON(n),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&n.update());let l=n??new ur(r,a);return{parameters:Object.assign(i,{width:r,height:a,depth:s,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:a,roundness:s,windingRule:n}=e.parameters;e.shape.roundness=s;let o;return t<=0?o=new q3(e.shape,a,{windingRule:n}):o=new X3(e.shape,t,i,a,r,n),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},Y3=Math.PI*2,Zb=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return i.angle=dt.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof ur?e.shape:new ur,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,angle:a,innerRadius:s,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,c=t*.5,u=i*.5,d=ZY(h,c,u,a*Math.PI/180,r,s);h.isClosed=!0,h.update();let p;return a===0?(p=new St,p.setAttribute("position",new ut([],3))):p=Bh.create({shape:h,parameters:{subdivisions:d,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}}),Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function ZY(e,t,i,r,a,s){if(r>=Y3)return a>30||a%4===0?($Y(e,t,i,s),Math.round(a/4)):qE(e,r,a,t,i,s);r=Math.max(r,.001);let n={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=WY({px:n.x,py:n.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return a>30||a%h.length===0?JY(e,n.x,n.y,h,a,t,i,s):qE(e,r,a,t,i,s)}function JY(e,t,i,r,a,s,n,o){let l=Math.round(a/r.length);e.addPoint(iu(t,i));for(let h=0,c=r.length;h<c;h++){let u=r[h],d=e.points[h],p=iu(u.x,u.y);d.controls[1].position.set(u.x1,u.y1),p.controls[0].position.set(u.x2,u.y2),e.addPoint(p)}return o>0?Q3(e,s,n,o):e.addPoint(iu(0,0)),l}function qE(e,t,i,r,a,s){let n=-t/i;for(let o=0;o<=i;o++){let l=n*o,h=Math.sin(l)*r,c=Math.cos(l)*a;e.addPoint(iu(h,c))}return t<Y3?s>0?Q3(e,r,a,s):e.addPoint(iu(0,0)):(e.removePoint(e.points[e.points.length-1]),s>0&&K3(e,r,a,s)),1}function $Y(e,t,i,r=0,a=0,s=0){let n=.5522847498,o=t*n,l=i*n;e.addPoint(Qf(a-t,s,a-t,s-l,a-t,s+l)),e.addPoint(Qf(a,s+i,a-o,s+i,a+o,s+i)),e.addPoint(Qf(a+t,s,a+t,s+l,a+t,s-l)),e.addPoint(Qf(a,s-i,a+o,s-i,a-o,s-i)),r>0&&K3(e,t,i,r)}function iu(e,t){return new tu(dt.generateUUID(),new ae(e,t))}function Qf(e,t,i,r,a,s){let n=iu(e,t);return n.controls[0].position.set(i,r),n.controls[1].position.set(a,s),n}function Q3(e,t,i,r){Z3(e,t,i,r).forEach(a=>e.addPoint(a))}function K3(e,t,i,r){let a=Z3(e,t,i,r),s=new ur;a.forEach(n=>s.addPoint(n)),s.isClosed=!0,e.shapeHoles.push(s)}function Z3(e,t,i,r){let a=r*t/100,s=a*(Math.abs(i)/Math.abs(t)),n=new ae(a/t,s/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=dt.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(n);let h=l.controls[0].position.clone().multiply(n),c=l.controls[1].position.clone().multiply(n);l.controls[0].position.copy(c),l.controls[1].position.copy(h)}),o}var eQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),a=Math.abs(i.height??r),s=Math.abs(i.depth??r),n=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(i,{width:r,height:a,depth:s,radius:n,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:a,revolutions:s,segments:n,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:c,cornerSegments:u}=e.parameters,d=new J3(!1,t,i,r,a,s,n,o,l,h,c,u);return Object.assign(d,{userData:{...e,type:"HelixGeometry"}})}},$0=new Yc([0,0,0],1),J3=class extends St{constructor(e=!0,t=1,i=1,r=1,a=1,s=1,n=1,o=1,l=1,h=1,c=1,u=1){if(super(),s===0)return;let d=e&&s===1;d&&(u=0),c>100&&(c=100),c===0&&(u=0);let p=()=>new O,f=new O,m=p(),g=p(),v=p(),x,b,_,M,A,S,P,L,E=p(),T=p(),B=p(),V=p(),I=p(),H=p(),q=p(),X=p(),Y=i-2*o+.001,ie=Y/s,ce=Math.ceil(n*s),de=ce+1,ue=Y/ce,re=-Y/2,se=h+1,he=2*Math.PI/h,_e=Math.PI/2/u,Ee=.01,fe=Math.min((1-c/100)*o,o-Ee),Re=o-fe,Pe=0,te=2,We=u*te+te,Be=se*We/te,Ue=Be+se*de,Ge=Math.max(0,se*(de+We)),[tt,Fe,He]=[3,3,2].map(Qe=>Array(Ge*Qe).fill(0)),nt=[],ht=a-o;function Z(Qe,Ze){let Zt=Math.PI/2;S=Ze*ue,L=2*Math.PI*(S%ie)/ie+Zt,S+=re,P=Math.sin(L)*ht,A=Math.cos(L)*ht,e?Qe.set(A,P,S):Qe.set(A,S,P)}Z(f,-1e-10),Z(m,0),E.copy(f),Z(f,1);let j=f.distanceTo(m),ye=d?0:Re+fe,Me=j*ce+2*ye,Je=fe,z=Me-ye;for(let Qe=0;Qe<=ce;Qe++){Z(g,Qe),X.subVectors(g,E).normalize(),E.copy(g),H.copy(g).setComponent(+e+1,0).normalize(),q.crossVectors(X,H).normalize();let Ze=Qe===0,Zt=Qe===ce,Ot=Ze?3*Math.PI/2:_e,Pt=Ze?Je:z,At=Ze?se:Ue,bt=Ze?0:Ge-se,mt=X.clone().multiplyScalar(Ze?-Re:Re).add(g),gi=X.clone().multiplyScalar(Ze?-1:1).normalize();for(let Jt=0;Jt<se;Jt++){let pe=Jt*he;if(T.addVectors(f.copy(H).multiplyScalar(o*Math.cos(pe)),m.copy(q).multiplyScalar(o*Math.sin(pe))),B.copy(T).normalize(),Ze||Zt){d||(Pe=bt+Jt,[0,1,2].forEach(et=>{tt[Pe*3+et]=mt.getComponent(et),Fe[Pe*3+et]=gi.getComponent(et)}),He[Pe*2]=+Zt,He[Pe*2+1]=Jt/h),m.copy(B).multiplyScalar(fe),v.addVectors(g,m);for(let et=0;et<u;et++){let Se=et*_e+Ot;V.addVectors(f.copy(X).multiplyScalar(Re*Math.sin(Se)),m.copy(B).multiplyScalar(Re*Math.cos(Se))),I.copy(V).normalize(),m.addVectors(v,V),V.normalize(),Pe=At+et*se+Jt,[0,1,2].forEach(rt=>{tt[Pe*3+rt]=m.getComponent(rt),Fe[Pe*3+rt]=I.getComponent(rt)});let Ke=+Ze+Math.sin(Se);He[Pe*2]=(Pt+Re*Ke)/Me,He[Pe*2+1]=Jt/h}}m.addVectors(g,T),Pe=Be+Qe*se+Jt,[0,1,2].forEach(et=>{tt[Pe*3+et]=m.getComponent(et),Fe[Pe*3+et]=B.getComponent(et)}),He[Pe*2]=(ye+Qe*j)/Me,He[Pe*2+1]=Jt/h}}let qe=de+2*u+te,ct=1,[ze,at]=[+d,qe-1];for(let Qe=ze;Qe<=at-1;Qe++){let Ze=d&&Qe===at-1;for(let Zt=0;Zt<se-1;Zt++)x=Qe*se+Zt,b=x+1,_=(Ze?Zt:x)+se,M=(Ze?Zt+1:b)+se,Qe===0?nt.push(b,M,_):Qe===qe-2?nt.push(x,b,_):nt.push(x,b,_,b,M,_)}this.setIndex(nt),this.setAttribute("position",new ut(tt,3)),this.setAttribute("normal",new ut(Fe,3)),this.setAttribute("uv",new ut(He,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),a,s,n,o,l=6*(t-1)*e.radialSegments,h=t,c=h===t;for(let u=0;u<e.radialSegments;u++)a=h*i+u,s=a+1,n=(c?u:a)+i,o=(c?u+1:s)+i,r[l++]=a,r[l++]=s,r[l++]=n,r[l++]=s,r[l++]=o,r[l++]=n;return r.length=l,$0.array=r,$0.count=r.length,$0}},tQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:a,corner:s,cornerSides:n}=e.parameters,o=a===0&&s!==0?new $3(t*.5,s,n):new ZT(t*.5,a);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},$3=class extends qb{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,a=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],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],n="IcosahedronGeometry";super(a,s,n,e,t,i),this.type=n}static fromJSON(e){return new $3(e.radius,e.corner,e.cornerSides)}},iQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,a=new $m;a.moveTo(t[0].x,t[0].y),a.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new WT(a.extractPoints(r).shape,i);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...e,type:"LatheGeometry"}})}},un=new je,ey=new Mi,Kf=new O,Ug=class extends ua{constructor(){super(),this.uuid=dt.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new Ht().getNormalMatrix(e);for(let i=0,r=this.vertices.length;i<r;i++)this.vertices[i].applyMatrix4(e);for(let i=0,r=this.faces.length;i<r;i++){let a=this.faces[i];a.normal.applyMatrix3(t).normalize();for(let s=0,n=a.vertexNormals.length;s<n;s++)a.vertexNormals[s].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return un.makeRotationX(e),this.applyMatrix4(un),this}rotateY(e){return un.makeRotationY(e),this.applyMatrix4(un),this}rotateZ(e){return un.makeRotationZ(e),this.applyMatrix4(un),this}translate(e,t,i){return un.makeTranslation(e,t,i),this.applyMatrix4(un),this}scale(e,t,i){return un.makeScale(e,t,i),this.applyMatrix4(un),this}lookAt(e){return ey.lookAt(e),ey.updateMatrix(),this.applyMatrix4(ey.matrix),this}fromBufferGeometry(e){let t=this,i=e.index!==null?e.index:void 0,r=e.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let a=r.position,s=r.normal,n=r.color,o=r.uv,l=r.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let u=0;u<a.count;u++)t.vertices.push(new O().fromBufferAttribute(a,u)),n!==void 0&&t.colors.push(new _t().fromBufferAttribute(n,u));function h(u,d,p,f){let m=n===void 0?[]:[t.colors[u].clone(),t.colors[d].clone(),t.colors[p].clone()],g=s===void 0?[]:[new O().fromBufferAttribute(s,u),new O().fromBufferAttribute(s,d),new O().fromBufferAttribute(s,p)],v=new fx(u,d,p,g,m,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new ae().fromBufferAttribute(o,u),new ae().fromBufferAttribute(o,d),new ae().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new ae().fromBufferAttribute(l,u),new ae().fromBufferAttribute(l,d),new ae().fromBufferAttribute(l,p)])}let c=e.groups;if(c.length>0)for(let u=0;u<c.length;u++){let d=c[u],p=d.start,f=d.count;for(let m=p,g=p+f;m<g;m+=3)i!==void 0?h(i.getX(m),i.getX(m+1),i.getX(m+2),d.materialIndex):h(m,m+1,m+2,d.materialIndex)}else if(i!==void 0)for(let u=0;u<i.count;u+=3)h(i.getX(u),i.getX(u+1),i.getX(u+2));else for(let u=0;u<a.count;u+=3)h(u,u+1,u+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Kf).negate(),this.translate(Kf.x,Kf.y,Kf.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new je;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let e=new O,t=new O;for(let i=0,r=this.faces.length;i<r;i++){let a=this.faces[i],s=this.vertices[a.a],n=this.vertices[a.b],o=this.vertices[a.c];e.subVectors(o,n),t.subVectors(s,n),e.cross(t),e.normalize(),a.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let i=0,r=this.vertices.length;i<r;i++)t[i]=new O;if(e){let i=new O,r=new O;for(let a=0,s=this.faces.length;a<s;a++){let n=this.faces[a],o=this.vertices[n.a],l=this.vertices[n.b],h=this.vertices[n.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[n.a].add(i),t[n.b].add(i),t[n.c].add(i)}}else{this.computeFaceNormals();for(let i=0,r=this.faces.length;i<r;i++){let a=this.faces[i];t[a.a].add(a.normal),t[a.b].add(a.normal),t[a.c].add(a.normal)}}for(let i=0,r=this.vertices.length;i<r;i++)t[i].normalize();for(let i=0,r=this.faces.length;i<r;i++){let a=this.faces[i],s=a.vertexNormals;s.length===3?(s[0].copy(t[a.a]),s[1].copy(t[a.b]),s[2].copy(t[a.c])):(s[0]=t[a.a].clone(),s[1]=t[a.b].clone(),s[2]=t[a.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let i=this.faces[e],r=i.vertexNormals;r.length===3?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let a=0,s=r.vertexNormals.length;a<s;a++)r.__originalVertexNormals[a]?r.__originalVertexNormals[a].copy(r.vertexNormals[a]):r.__originalVertexNormals[a]=r.vertexNormals[a].clone()}let e=new Ug;e.faces=this.faces;for(let t=0,i=this.morphTargets.length;t<i;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let a=this.morphNormals[t].faceNormals,s=this.morphNormals[t].vertexNormals;for(let n=0,o=this.faces.length;n<o;n++){let l=new O,h={a:new O,b:new O,c:new O};a.push(l),s.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let a=0,s=this.faces.length;a<s;a++){let n=this.faces[a],o=r.faceNormals[a],l=r.vertexNormals[a];o.copy(n.normal),l.a.copy(n.vertexNormals[0]),l.b.copy(n.vertexNormals[1]),l.c.copy(n.vertexNormals[2])}}for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new sr),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Sa),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,i=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let r,a=this.vertices.length,s=this.vertices,n=e.vertices,o=this.faces,l=e.faces,h=this.colors,c=e.colors;t!==void 0&&(r=new Ht().getNormalMatrix(t));for(let u=0,d=n.length;u<d;u++){let p=n[u].clone();t!==void 0&&p.applyMatrix4(t),s.push(p)}for(let u=0,d=c.length;u<d;u++)h.push(c[u].clone());for(let u=0,d=l.length;u<d;u++){let p=l[u],f,m,g=p.vertexNormals,v=p.vertexColors,x=new fx(p.a+a,p.b+a,p.c+a);x.normal.copy(p.normal),r!==void 0&&x.normal.applyMatrix3(r).normalize();for(let b=0,_=g.length;b<_;b++)f=g[b].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),x.vertexNormals.push(f);x.color.copy(p.color);for(let b=0,_=v.length;b<_;b++)m=v[b],x.vertexColors.push(m.clone());x.materialIndex=p.materialIndex+i,o.push(x)}for(let u=0,d=e.faceVertexUvs.length;u<d;u++){let p=e.faceVertexUvs[u];this.faceVertexUvs[u]===void 0&&(this.faceVertexUvs[u]=[]);for(let f=0,m=p.length;f<m;f++){let g=p[f],v=[];for(let x=0,b=g.length;x<b;x++)v.push(g[x].clone());this.faceVertexUvs[u].push(v)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},i=[],r=[],a=Math.pow(10,e);for(let o=0,l=this.vertices.length;o<l;o++){let h=this.vertices[o],c=Math.round(h.x*a)+"_"+Math.round(h.y*a)+"_"+Math.round(h.z*a);t[c]===void 0?(t[c]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[c]]}let s=[];for(let o=0,l=this.faces.length;o<l;o++){let h=this.faces[o];h.a=r[h.a],h.b=r[h.b],h.c=r[h.c];let c=[h.a,h.b,h.c];for(let u=0;u<3;u++)if(c[u]===c[(u+1)%3]){s.push(o);break}}for(let o=s.length-1;o>=0;o--){let l=s[o];this.faces.splice(l,1);for(let h=0,c=this.faceVertexUvs.length;h<c;h++)this.faceVertexUvs[h].splice(l,1)}let n=this.vertices.length-i.length;return this.vertices=i,n}setFromPoints(e){this.vertices=[];for(let t=0,i=e.length;t<i;t++){let r=e[t];this.vertices.push(new O(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let o=0;o<t;o++)e[o]._id=o;function i(o,l){return o.materialIndex-l.materialIndex}e.sort(i);let r=this.faceVertexUvs[0],a=this.faceVertexUvs[1],s,n;r&&r.length===t&&(s=[]),a&&a.length===t&&(n=[]);for(let o=0;o<t;o++){let l=e[o]._id;s&&s.push(r[l]),n&&n.push(a[l])}s&&(this.faceVertexUvs[0]=s),n&&(this.faceVertexUvs[1]=n)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let f in p)p[f]!==void 0&&(e[f]=p[f]);return e}let t=[];for(let p=0;p<this.vertices.length;p++){let f=this.vertices[p];t.push(f.x,f.y,f.z)}let i=[],r=[],a={},s=[],n={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],m=!0,g=!1,v=this.faceVertexUvs[0][p]!==void 0,x=f.normal.length()>0,b=f.vertexNormals.length>0,_=f.color.r!==1||f.color.g!==1||f.color.b!==1,M=f.vertexColors.length>0,A=0;if(A=h(A,0,0),A=h(A,1,m),A=h(A,2,g),A=h(A,3,v),A=h(A,4,x),A=h(A,5,b),A=h(A,6,_),A=h(A,7,M),i.push(A),i.push(f.a,f.b,f.c),i.push(f.materialIndex),v){let S=this.faceVertexUvs[0][p];i.push(d(S[0]),d(S[1]),d(S[2]))}if(x&&i.push(c(f.normal)),b){let S=f.vertexNormals;i.push(c(S[0]),c(S[1]),c(S[2]))}if(_&&i.push(u(f.color)),M){let S=f.vertexColors;i.push(u(S[0]),u(S[1]),u(S[2]))}}function h(p,f,m){return m?p|1<<f:p&~(1<<f)}function c(p){let f=p.x.toString()+p.y.toString()+p.z.toString();return a[f]!==void 0||(a[f]=r.length/3,r.push(p.x,p.y,p.z)),a[f]}function u(p){let f=p.r.toString()+p.g.toString()+p.b.toString();return n[f]!==void 0||(n[f]=s.length,s.push(p.getHex())),n[f]}function d(p){let f=p.x.toString()+p.y.toString();return l[f]!==void 0||(l[f]=o.length/2,o.push(p.x,p.y)),l[f]}return e.data={},e.data.vertices=t,e.data.normals=r,s.length>0&&(e.data.colors=s),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new Ug().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let u=0,d=t.length;u<d;u++)this.vertices.push(t[u].clone());let i=e.colors;for(let u=0,d=i.length;u<d;u++)this.colors.push(i[u].clone());let r=e.faces;for(let u=0,d=r.length;u<d;u++)this.faces.push(r[u].clone());for(let u=0,d=e.faceVertexUvs.length;u<d;u++){let p=e.faceVertexUvs[u];this.faceVertexUvs[u]===void 0&&(this.faceVertexUvs[u]=[]);for(let f=0,m=p.length;f<m;f++){let g=p[f],v=[];for(let x=0,b=g.length;x<b;x++){let _=g[x];v.push(_.clone())}this.faceVertexUvs[u].push(v)}}let a=e.morphTargets;for(let u=0,d=a.length;u<d;u++){let p={};if(p.name=a[u].name,a[u].vertices!==void 0){p.vertices=[];for(let f=0,m=a[u].vertices.length;f<m;f++)p.vertices.push(a[u].vertices[f].clone())}if(a[u].normals!==void 0){p.normals=[];for(let f=0,m=a[u].normals.length;f<m;f++)p.normals.push(a[u].normals[f].clone())}this.morphTargets.push(p)}let s=e.morphNormals;for(let u=0,d=s.length;u<d;u++){let p={};if(s[u].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,m=s[u].vertexNormals.length;f<m;f++){let g=s[u].vertexNormals[f],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),p.vertexNormals.push(v)}}if(s[u].faceNormals!==void 0){p.faceNormals=[];for(let f=0,m=s[u].faceNormals.length;f<m;f++)p.faceNormals.push(s[u].faceNormals[f].clone())}this.morphNormals.push(p)}let n=e.skinWeights;for(let u=0,d=n.length;u<d;u++)this.skinWeights.push(n[u].clone());let o=e.skinIndices;for(let u=0,d=o.length;u<d;u++)this.skinIndices.push(o[u].clone());let l=e.lineDistances;for(let u=0,d=l.length;u<d;u++)this.lineDistances.push(l[u]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new rQ().fromGeometry(this),t=new St,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",Zf.call(new Ut(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",Zf.call(new Ut(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",XE.call(new Ut(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",YE.call(new Ut(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",YE.call(new Ut(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let a=[],s=e.morphTargets[r];for(let n=0,o=s.length;n<o;n++){let l=s[n],h=new ut(l.data.length*3,3);h.name=l.name,a.push(Zf.call(h,l.data))}t.morphAttributes[r]=a}if(e.skinIndices.length>0){let r=new ut(e.skinIndices.length*4,4);t.setAttribute("skinIndex",QE.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new ut(e.skinWeights.length*4,4);t.setAttribute("skinWeight",QE.call(r,e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new St,i=e.geometry;if(e.isPoints||e.isLine){let r=new ut(i.vertices.length*3,3),a=new ut(i.colors.length*3,3);if(t.setAttribute("position",Zf.call(r,i.vertices)),t.setAttribute("color",XE.call(a,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let s=new ut(i.lineDistances.length,1);t.setAttribute("lineDistance",aQ.call(s,i.lineDistances))}i.boundingSphere!==null&&(t.boundingSphere=i.boundingSphere.clone()),i.boundingBox!==null&&(t.boundingBox=i.boundingBox.clone())}else e.isMesh&&(t=i.toBufferGeometry());return t}};Ug.prototype.isGeometry=!0;var rQ=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],i,r,a,s=e.faces;for(r=0;r<s.length;r++){let n=s[r];n.materialIndex!==a&&(a=n.materialIndex,i!==void 0&&(i.count=r*3-i.start,t.push(i)),i={start:r*3,materialIndex:a})}i!==void 0&&(i.count=r*3-i.start,t.push(i)),this.groups=t}fromGeometry(e){let t=e.faces,i=e.vertices,r=e.faceVertexUvs,a=r[0]&&r[0].length>0,s=r[1]&&r[1].length>0,n=e.morphTargets,o=n.length,l;if(o>0){l=[];for(let g=0;g<o;g++)l[g]={name:n[g].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,c=h.length,u;if(c>0){u=[];for(let g=0;g<c;g++)u[g]={name:h[g].name,data:[]};this.morphTargets.normal=u}let d=e.skinIndices,p=e.skinWeights,f=d.length===i.length,m=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<t.length;g++){let v=t[g];this.vertices.push(i[v.a],i[v.b],i[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let _=v.normal;this.normals.push(_,_,_)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let _=v.color;this.colors.push(_,_,_)}if(a===!0){let _=r[0][g];_!==void 0?this.uvs.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new ae,new ae,new ae))}if(s===!0){let _=r[1][g];_!==void 0?this.uvs2.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new ae,new ae,new ae))}for(let _=0;_<o;_++){let M=n[_].vertices;l[_].data.push(M[v.a],M[v.b],M[v.c])}for(let _=0;_<c;_++){let M=h[_].vertexNormals[g];u[_].data.push(M.a,M.b,M.c)}f&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),m&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},fx=class{constructor(e,t,i,r,a,s=0){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new O,this.vertexNormals=Array.isArray(r)?r:[],this.color=a&&a.isColor?a:new _t,this.vertexColors=Array.isArray(a)?a:[],this.materialIndex=s}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};function aQ(e){return this.array.set(e),this}function XE(e){let t=this.array,i=0;for(let r=0,a=e.length;r<a;r++){let s=e[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),s=new _t),t[i++]=s.r,t[i++]=s.g,t[i++]=s.b}return this}function YE(e){let t=this.array,i=0;for(let r=0,a=e.length;r<a;r++){let s=e[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),s=new ae),t[i++]=s.x,t[i++]=s.y}return this}function Zf(e){let t=this.array,i=0;for(let r=0,a=e.length;r<a;r++){let s=e[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),s=new O),t[i++]=s.x,t[i++]=s.y,t[i++]=s.z}return this}function QE(e){let t=this.array,i=0;for(let r=0,a=e.length;r<a;r++){let s=e[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),s=new Nt),t[i++]=s.x,t[i++]=s.y,t[i++]=s.z,t[i++]=s.w}return this}var sQ=["a","b","c"];function nQ(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function ty(e,t,i){let r=Math.min(e,t),a=Math.max(e,t),s=r+"_"+a;return i.get(s)}function iy(e,t,i,r,a,s){let n=Math.min(e,t),o=Math.max(e,t),l=n+"_"+o,h;if(r.has(l))h=r.get(l);else{let c=i[n],u=i[o];h={a:c,b:u,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(a),s[e].edges.push(h),s[t].edges.push(h)}function oQ(e,t,i,r){let a,s,n;for(a=0,s=e.length;a<s;a++)i[a]={edges:[]};for(a=0,s=t.length;a<s;a++)n=t[a],iy(n.a,n.b,e,r,n,i),iy(n.b,n.c,e,r,n,i),iy(n.c,n.a,e,r,n,i)}function Jf(e,t,i,r,a){e.push(new fx(t,i,r,void 0,void 0,a))}function bc(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function $f(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var lQ=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof St?e=new Ug().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new O,i,r,a,s,n,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],c=h!==void 0&&h.length>0,u=[],d=new Map;oQ(o,l,u,d);let p=[],f,m,g,v,x,b,_;for(let Ee of Array.from(d.keys())){for(m=d.get(Ee),g=new O,x=3/8,b=1/8,_=m.faces.length,_!=2&&(x=.5,b=0,_!=1),g.addVectors(m.a,m.b).multiplyScalar(x),t.set(0,0,0),s=0;s<_;s++){for(v=m.faces[s],n=0;n<3&&(f=o[nQ(v,sQ[n])],!(f!==m.a&&f!==m.b));n++);f&&t.add(f)}t.multiplyScalar(b),g.add(t),m.newEdge=p.length,p.push(g)}let M,A,S,P,L,E,T,B=[];for(r=0,a=o.length;r<a;r++){for(E=o[r],L=u[r].edges,i=L.length,i==3?M=3/16:i>3&&(M=3/(8*i)),A=1-i*Number(M),S=M,i<=2&&(i==2?(A=3/4,S=1/8):i==1||i==0),T=E.clone().multiplyScalar(A),t.set(0,0,0),s=0;s<i;s++)P=L[s],f=P.a!==E?P.a:P.b,t.add(f);t.multiplyScalar(Number(S)),T.add(t),B.push(T)}let V=B.concat(p),I=B.length,H,q,X,Y=[],ie=[],ce,de,ue,re,se=new ae,he=new ae,_e=new ae;for(r=0,a=l.length;r<a;r++)v=l[r],H=Number(ty(v.a,v.b,d).newEdge)+I,q=Number(ty(v.b,v.c,d).newEdge)+I,X=Number(ty(v.c,v.a,d).newEdge)+I,Jf(Y,H,q,X,v.materialIndex),Jf(Y,v.a,H,X,v.materialIndex),Jf(Y,v.b,q,H,v.materialIndex),Jf(Y,v.c,X,q,v.materialIndex),c&&(ce=h[r],de=ce[0],ue=ce[1],re=ce[2],se.set(bc(de.x,ue.x),bc(de.y,ue.y)),he.set(bc(ue.x,re.x),bc(ue.y,re.y)),_e.set(bc(de.x,re.x),bc(de.y,re.y)),$f(ie,se,he,_e),$f(ie,de,se,_e),$f(ie,ue,he,se),$f(ie,re,_e,he));e.vertices=V,e.faces=Y,c&&(e.faceVertexUvs[0]=ie)}},Lr=new O,hQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new St().copy(new Ks(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Lr),r={width:Lr.x,height:Lr.y,depth:Lr.z,subdivisions:0}):r=t.parameters;let a={...r,...e.parameters};return{parameters:{width:Math.abs(a.width),height:Math.abs(a.height),depth:Math.abs(a.depth),subdivisions:Math.abs(a.subdivisions)},geometry:i}}static build(e){let{width:t,height:i,depth:r,subdivisions:a}=e.parameters,s=e.geometry??new St().copy(new Ks(100,100,100)),n=s.userData.parameters;n===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Lr)):Lr.set(n.width,n.height,n.depth),(t!==Lr.x||i!==Lr.y||r!==Lr.z)&&s.scale(Lr.x===0?1:t/Lr.x,Lr.y===0?1:i/Lr.y,Lr.z===0?1:r/Lr.z);let o=s.originalGeometry;try{a>0?(o===void 0||n?.subdivisions!==a)&&(o===void 0&&(o=s),s=new lQ(a).modify(o).toBufferGeometry()):(o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{o!==void 0&&(s=o),o=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return o!==void 0&&Object.assign(s,{originalGeometry:o}),delete e.geometry,Object.assign(s,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new sP(i).load(e,r=>{let a=this.normalizeInputs({geometry:r});r.boundingBox.getSize(Lr);let s=100/Lr.x;Object.assign(a.parameters,{width:100,height:Lr.y*s,depth:Lr.z*s}),t(this.build(a))})}},eD=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof ur?e.shape:new ur,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:a,depth:s,extrudeBevelSize:n,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,c=i*.5,u=0,d=0,p=2*Math.PI/r;for(let m=0;m<r;m++){let g=p*m,v=u+Math.sin(g)*h,x=d+Math.cos(g)*c;l.addPoint(l.createPoint(v,x))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=a;l.roundness=a,l.update();let f=Bh.create({shape:l,parameters:{roundness:a,depth:s,extrudeBevelSize:n,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},cQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,radialSegments:a,heightSegments:s,openEnded:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=new dQ(t*.5,i,a,s,n,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function xd(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function ry(e,t,i,r,a,s){let n=t.clone().sub(e),o=i.clone().sub(e),l=n.angleTo(o);if(n.normalize(),o.normalize(),r===a){let h=n.add(o).normalize();s.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=n.angleTo(o);s.copy(e),s.addScaledVector(n,a/Math.sin(h)),s.addScaledVector(o,r/Math.sin(h))}}function uQ(e,t,i){let r=e.clone().sub(t),a=i.clone().sub(t);return r.projectOnVector(a),r.add(t)}var dQ=class extends St{constructor(e=.5,t=1,i=4,r=1,a=!1,s=0,n=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),n=Math.floor(n);let o=[],l=[],h=[],c=[],u=0,d=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),m=2*Math.PI/i,g=(i-2)*Math.PI/i,v=Math.PI-g,x=new O(0,-d,0),b=new O(0,d,0),_=new ae(e,-d),M=new ae(f,-d),A=new ae(0,b.y).sub(M),S=new ae(0,b.y).sub(_),P=new ae(A.y,-A.x).normalize(),L=new ae(S.y,-S.x).normalize(),E=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-A.angle())/2)-1e-8;s=Math.min(s,E);let T;{let Y=new O(P.x,P.y,0),ie=new O(Math.cos(m)*Y.x,Y.y,Math.sin(m)*Y.x);T=Y.angleTo(ie)}let B=s/Math.tan((Math.PI-A.angle())/2),V=s/Math.tan((Math.PI-T)/2),I=new O;if(!a){l.push(x.x,x.y,x.z),h.push(0,-1,0),c.push(0,0);let Y=u++,ie=[],ce=_.clone(),de=B/Math.cos(Math.PI/i);ce.x-=de;for(let ue=0;ue<i;ue++){let re=ue/i*Math.PI*2+p,se=new ae(Math.sin(re),Math.cos(re));xd(ce,se,I),l.push(I.x,I.y,I.z),h.push(0,-1,0),c.push(0,0),ie.push(u++)}for(let ue=0;ue<ie.length;ue++)o.push(ie[ue],Y,ie[(ue+1)%ie.length])}let H=[];{let Y=new O,ie=new O,ce=new O,de=new O,ue=new O,re=new O;for(let se=0;se<i;se++){let he=se/i*Math.PI*2+p,_e=(se+.5)/i*Math.PI*2+p,Ee=(se+1)/i*Math.PI*2+p,fe=new ae(Math.sin(he),Math.cos(he)),Re=new ae(Math.sin(_e),Math.cos(_e)),Pe=new ae(Math.sin(Ee),Math.cos(Ee));xd(_,fe,ie),xd(_,Pe,ce),xd(P,Re,Y),ry(b,ie,ce,V,V,de),l.push(de.x,de.y,de.z),ry(ie,b,ce,V,B,ue),l.push(ue.x,ue.y,ue.z),ry(ce,ie,b,B,V,re),l.push(re.x,re.y,re.z),h.push(Y.x,Y.y,Y.z),h.push(Y.x,Y.y,Y.z),h.push(Y.x,Y.y,Y.z),c.push(0,0),c.push(0,0),c.push(0,0);let te=u++,We=u++,Be=u++;if(o.push(te,We,Be),s>0){{let tt=ie.clone().add(ce).multiplyScalar(.5),Fe=b.clone().sub(tt).normalize(),He=x.clone().sub(tt).normalize().add(Fe).normalize().multiplyScalar(-1),nt=re.clone().sub(ue);q(tt,nt,He,A.angle())}let Ue,Ge;{let tt=new O;xd(L,Pe,tt);let Fe=re.clone().add(de).multiplyScalar(.5);Fe=uQ(Fe,ce,b);let He=re.clone().sub(de);[Ue,Ge]=q(Fe,He,tt,T,de.y)}{let tt=Ue,Fe=tt.clone().setY(0).normalize(),He=new O(0,-1,0),nt=Fe.clone().cross(He);X(tt,Fe,He,nt)}H.concat(Ge);{let tt=A.angle(),Fe=Math.PI-tt,He=b.clone();He.y-=s/Math.sin(tt-Math.PI/2);let nt=new O,ht=[];for(let j=0;j<n;j++){let ye=[],Me=Math.PI/2-Fe*j/n,Je=Math.cos(Me),z=Math.sin(Me),qe=_e;for(let ct=0;ct<=j;ct++){let ze=Math.cos(qe),at=Math.sin(qe);Y.x=Je*at,Y.y=z,Y.z=Je*ze,nt.copy(He).addScaledVector(Y,s),l.push(nt.x,nt.y,nt.z),h.push(Y.x,Y.y,Y.z),c.push(0,0),ye.push(u++),qe+=Math.PI*2/j/i}ht.push(ye)}Ge.reverse(),ht.push(Ge);let Z=ht.length-1;for(let j=0;j<Z;j++){let ye=ht[j],Me=ht[j+1],Je=ye.length-1;o.push(Me[1],ye[0],Me[0]);for(let z=1;z<=Je;z++)o.push(ye[z],ye[z-1],Me[z]),o.push(Me[z+1],ye[z],Me[z])}}}}}this.setIndex(o),this.setAttribute("position",new ut(l,3)),this.setAttribute("normal",new ut(h,3)),this.setAttribute("uv",new ut(c,2));function q(Y,ie,ce,de,ue){let re=-de/2,se=(Math.PI-de)/2,he=ie.clone().normalize().cross(ce);Y.addScaledVector(ce,-s/Math.sin(se));let _e=new O,Ee=new O,fe=1,Re=u,Pe=[];for(let te=0;te<=n;te++){let We=re+te/n*de;Ee.set(0,0,0),Ee.addScaledVector(he,Math.sin(We)),Ee.addScaledVector(ce,Math.cos(We));for(let Be=0;Be<=fe;Be++){let Ue=Be/fe-.5;if(_e.copy(Y),_e.addScaledVector(ie,Ue),_e.addScaledVector(Ee,s),ue!=null){let Ge=Math.max(0,_e.y-ue);_e.addScaledVector(ie,-Ge/ie.y)}l.push(_e.x,_e.y,_e.z),h.push(Ee.x,Ee.y,Ee.z),c.push(0,0),Be===0&&Pe.push(u),u++}}for(let te=0;te<n;te++)for(let We=0;We<fe;We++){let Be=Re+We+(fe+1)*te,Ue=Be+(fe+1),Ge=Ue+1,tt=Be+1;o.push(Be,Ue,tt),o.push(Ue,Ge,tt)}return[Y.clone().addScaledVector(ie,.5),Pe]}function X(Y,ie,ce,de){let ue=Math.PI/2,re=S.angle()-ue,se=[],he=new O,_e=new O;for(let fe=0;fe<=n;fe++){let Re=[],Pe=fe/n;for(let te=0;te<=fe;te++){let We=((fe?te/fe:0)-.5)*v,Be=Math.cos(We),Ue=Math.sin(We),Ge=Math.atan(Math.tan(re)*Be),tt=(ue+Ge)*Pe,Fe=Math.cos(tt),He=Math.sin(tt);he.set(0,0,0),he.addScaledVector(ie,He*Be),he.addScaledVector(ce,Fe),he.addScaledVector(de,He*Ue),_e.copy(Y).addScaledVector(he,s),l.push(_e.x,_e.y,_e.z),h.push(he.x,he.y,he.z),c.push(0,0),Re.push(u++)}se.push(Re)}let Ee=se.length-1;for(let fe=0;fe<Ee;fe++){let Re=se[fe],Pe=se[fe+1],te=Re.length-1;o.push(Re[0],Pe[1],Pe[0]);for(let We=1;We<=te;We++)o.push(Re[We-1],Re[We],Pe[We]),o.push(Re[We],Pe[We+1],Pe[We])}}}},Jb=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof ur?e.shape:new ur,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(e){let t=e.shape,{width:i,height:r,cornerRadius:a,cornerType:s,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},c={x:-h.x,y:-h.y},u={x:h.x,y:h.y};function d(_,M,A){return M>i&&A>r?Math.min(_*i/M,_*r/A):M>i?_*i/M:A>r?_*r/A:_}let p=[];p[0]=a[0]===0?0:d(a[0],a[0]+a[3],a[0]+a[1]),p[1]=a[1]===0?0:d(a[1],a[1]+a[2],a[1]+a[0]),p[2]=a[2]===0?0:d(a[2],a[2]+a[1],a[2]+a[3]),p[3]=a[3]===0?0:d(a[3],a[3]+a[0],a[3]+a[2]);let f=c.x,m=u.x,g=u.y,v=c.y;t.addPoint(t.createPoint(f,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let x=!0;for(let _=0,M=t.points.length;_<M;_++)t.points[_].roundness=p[_],_>0&&p[_]!==p[_-1]&&(x=!1);x&&(t.roundness=p[0]),t.useCubicForRoundedCorners=s!==1,t.update();let b=Bh.create({shape:t,parameters:{depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...e,type:"RectangleGeometry"}})}},pQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},e.parameters);return i.thetaLength=dt.clamp(i.thetaLength,0,180),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t=100,height:i=t,depth:r=t,widthSegments:a=64,heightSegments:s=64,phiStart:n,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,c;return h===0?(c=new St,c.setAttribute("position",new ut([],3))):c=new Qc(.5*t,a,s,n,o,l,h*dt.DEG2RAD),c.scale(1,i/t,r/t),Object.assign(c,{userData:{...e,type:"SphereGeometry"}})}},fQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:a=8}=e.parameters,s=new Pl(t,i,r,a);return s.scale(1,1,1),Object.assign(s,{userData:{...e,type:"PlaneGeometry"}})}},mQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:a,cornerRadius:s,cornerSegments:n}=e.parameters,o=new gQ(t,i,r,a,s,n);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},gQ=class extends St{constructor(e=1,t=1,i=1,r=90,a=10,s=24){super(),this.type="BackdropGeometry";let n=[],o=[],l=[],h=.001;a==0&&(s=1),s=Math.max(1,Math.floor(s)),a=Math.min(a,100),r=Math.min(180-h,r),r*=Math.PI/180;let c=[],u=Math.PI/2,d=(Ee=0,fe=0,Re=0)=>new O(Ee,fe,Re),p=d(),f=d(),[m,g,v]=[t/2,e/2,i/2],x=-g,b=+g,[_,M,A]=[d(x,-m,+v),d(x,-m,-v),d(x,+m,-v)],S=(Ee,fe=!1)=>Math.sin(Ee-Math.PI/(1+ +fe)),P=(Ee,fe=!1)=>Math.cos(Ee-Math.PI/(1+ +fe));A.y=Math.sin(r)*t-m;let L=Math.cos(r)*t-v,E=_.z-h;r<=u?(A.z=Math.min(L,E),A.z==E&&(A.y-=(L-E)/Math.tan(u-r))):M.z=Math.min(M.z-L-v,_.z-h),p.subVectors(_,M),f.subVectors(A,M);let T=Math.min(p.length(),f.length())*a/100,B=T*Math.tan(r/2),V=T/Math.cos(r/2),I=p.clone().normalize().add(f.normalize()).setLength(V).add(M);p.set(0,S(r,!0),P(r,!0)),c.push([A,p.clone()]);let H=(Math.PI-r)/s;for(let Ee=0;Ee<=s;Ee++){let fe=u+r+Ee*H;p.set(0,Math.sin(fe)*B,Math.cos(fe)*B),p.add(I),f.set(0,S(fe),P(fe)),c.push([p.clone(),f.clone()])}c.push([_,d(0,1,0)]);let q=Math.sin(H/2)*B*2,X=c.length-1,Y=c[0][0].distanceTo(c[1][0]),ie=c[X-1][0].distanceTo(c[X][0]),ce=Y+q*s+ie;c[0].push(1);for(let Ee=0;Ee<=s;Ee++)c[Ee+1].push(1-(Y+Ee*q)/ce);c[X].push(0);let[de,ue,re]=c[0],se,he,_e;for(let Ee=1;Ee<c.length;Ee++)[se,he,_e]=c[Ee],n.push(x,de.y,de.z,x,se.y,se.z,b,de.y,de.z,b,de.y,de.z,x,se.y,se.z,b,se.y,se.z),o.push(0,ue.y,ue.z,0,he.y,he.z,0,ue.y,ue.z,0,ue.y,ue.z,0,he.y,he.z,0,he.y,he.z),l.push(0,re,0,_e,1,re,1,re,0,_e,1,_e),[de,ue,re]=[se,he,_e];this.setAttribute("position",new ut(n,3)),this.setAttribute("normal",new ut(o,3)),this.setAttribute("uv",new ut(l,2))}},tD=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof ur?e.shape:new ur,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:a,cornerRadius:s,angle:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,c=e.shape,u=t*.5,d=i*.5,p=0,f=0,m=n*Math.PI/360/a,g=Math.PI/2*3*-1,v=u*r/100,x=d*r/100;if(a===3&&r===50){m=2*Math.PI/a;for(let _=0;_<a;_++){let M=m*_,A=p+Math.sin(M)*u,S=f+Math.cos(M)*d;c.addPoint(c.createPoint(A,S))}}else for(let _=0;_<a;_++){let M=p+Math.cos(g)*u,A=f+Math.sin(g)*d;c.addPoint(c.createPoint(M,A)),g+=m,M=p+Math.cos(g)*v,A=f+Math.sin(g)*x,_<=a,c.addPoint(c.createPoint(M,A)),g+=m}c.isClosed=!0;for(let _=0,M=c.points.length;_<M;_++)c.points[_].roundness=s;c.roundness=s,c.update();let b=Bh.create({shape:c,parameters:{roundness:s,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(b,{userData:{...e,type:"StarGeometry"}})}},vQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i}=e.parameters,r=new Pl(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},yQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),a=Math.abs(i.height??i.width),s=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:a,depth:s})}}static build(e){let{width:t,height:i,depth:r,radialSegments:a,tubularSegments:s,arc:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=xQ(t,i,r,t*.5,n,s,0,0,a,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function xQ(e,t,i,r,a,s,n,o,l,h,c){[t,i]=[i,t],n=t/2;let u=dt.clamp(a/360,0,1);if(u===0){let d=new St;return d.setAttribute("position",new ut([],3)),d}return u===1&&(h=0),new J3(!0,e,t,i,r,u,s,n,o,l,h,c)}var bQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??i.width*.125})}}static build(e){let{width:t,tube:i,tubularSegments:r,radialSegments:a,p:s,q:n}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new $T(o,i,r,a,s,n);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},wQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof ur?e.shape:new ur,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t=100,height:i,cornerRadius:r,depth:a,extrudeBevelSize:s,extrudeBevelSegments:n,isRect:o}=e.parameters,l=e.shape,h=t*.5,c=i*.5;o?(l.addPoint(l.createPoint(-h,c)),l.addPoint(l.createPoint(h,-c)),l.addPoint(l.createPoint(-h,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(h,-c)),l.addPoint(l.createPoint(-h,-c))),l.isClosed=!0;for(let d=0,p=l.points.length;d<p;d++)l.points[d].roundness=r;l.roundness=r,l.update();let u=Bh.create({shape:l,parameters:{roundness:r,depth:a,extrudeBevelSize:s,extrudeBevelSegments:n}});return Object.assign(u,{userData:{...e,type:"TriangleGeometry"}})}};function _Q(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}var SQ=class{add(e,t,i){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(r){this[r]=this[r]||[],t&&this[r][i?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(i){i.call(t&&t.context?t.context:t,t)})}},AQ=class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(t=>{if(typeof t!="object"||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");this.registered[t.name]||(t.init(this.jsep),this.registered[t.name]=t)})}},Ie=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+Ie.version}static addUnaryOp(e){return Ie.max_unop_len=Math.max(e.length,Ie.max_unop_len),Ie.unary_ops[e]=1,Ie}static addBinaryOp(e,t,i){return Ie.max_binop_len=Math.max(e.length,Ie.max_binop_len),Ie.binary_ops[e]=t,i?Ie.right_associative.add(e):Ie.right_associative.delete(e),Ie}static addIdentifierChar(e){return Ie.additional_identifier_chars.add(e),Ie}static addLiteral(e,t){return Ie.literals[e]=t,Ie}static removeUnaryOp(e){return delete Ie.unary_ops[e],e.length===Ie.max_unop_len&&(Ie.max_unop_len=Ie.getMaxKeyLen(Ie.unary_ops)),Ie}static removeAllUnaryOps(){return Ie.unary_ops={},Ie.max_unop_len=0,Ie}static removeIdentifierChar(e){return Ie.additional_identifier_chars.delete(e),Ie}static removeBinaryOp(e){return delete Ie.binary_ops[e],e.length===Ie.max_binop_len&&(Ie.max_binop_len=Ie.getMaxKeyLen(Ie.binary_ops)),Ie.right_associative.delete(e),Ie}static removeAllBinaryOps(){return Ie.binary_ops={},Ie.max_binop_len=0,Ie}static removeLiteral(e){return delete Ie.literals[e],Ie}static removeAllLiterals(){return Ie.literals={},Ie}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new Ie(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(t=>t.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return Ie.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!Ie.binary_ops[String.fromCharCode(e)]||Ie.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return Ie.isIdentifierStart(e)||Ie.isDecimalDigit(e)}throwError(e){let t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(Ie.hooks[e]){let i={context:this,node:t};return Ie.hooks.run(e,i),i.node}return t}searchHook(e){if(Ie.hooks[e]){let t={context:this};return Ie.hooks[e].find(function(i){return i.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===Ie.SPACE_CODE||e===Ie.TAB_CODE||e===Ie.LF_CODE||e===Ie.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=e.length===1?e[0]:{type:Ie.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],i,r;for(;this.index<this.expr.length;)if(i=this.code,i===Ie.SEMCOL_CODE||i===Ie.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(i===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,Ie.max_binop_len),t=e.length;for(;t>0;){if(Ie.binary_ops.hasOwnProperty(e)&&(!Ie.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!Ie.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,i,r,a,s,n,o,l;if(s=this.gobbleToken(),!s||(t=this.gobbleBinaryOp(),!t))return s;for(a={value:t,prec:Ie.binaryPrecedence(t),right_a:Ie.right_associative.has(t)},n=this.gobbleToken(),n||this.throwError("Expected expression after "+t),r=[s,a,n];t=this.gobbleBinaryOp();){if(i=Ie.binaryPrecedence(t),i===0){this.index-=t.length;break}a={value:t,prec:i,right_a:Ie.right_associative.has(t)},l=t;let h=c=>a.right_a&&c.right_a?i>c.prec:i<=c.prec;for(;r.length>2&&h(r[r.length-2]);)n=r.pop(),t=r.pop().value,s=r.pop(),e={type:Ie.BINARY_EXP,operator:t,left:s,right:n},r.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),r.push(a,e)}for(o=r.length-1,e=r[o];o>1;)e={type:Ie.BINARY_EXP,operator:r[o-1].value,left:r[o-2],right:e},o-=2;return e}gobbleToken(){let e,t,i,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(e=this.code,Ie.isDecimalDigit(e)||e===Ie.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===Ie.SQUOTE_CODE||e===Ie.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===Ie.OBRACK_CODE)r=this.gobbleArray();else{for(t=this.expr.substr(this.index,Ie.max_unop_len),i=t.length;i>0;){if(Ie.unary_ops.hasOwnProperty(t)&&(!Ie.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!Ie.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=i;let a=this.gobbleToken();return a||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:Ie.UNARY_EXP,operator:t,argument:a,prefix:!0})}t=t.substr(0,--i)}Ie.isIdentifierStart(e)?(r=this.gobbleIdentifier(),Ie.literals.hasOwnProperty(r.name)?r={type:Ie.LITERAL,value:Ie.literals[r.name],raw:r.name}:r.name===Ie.this_str&&(r={type:Ie.THIS_EXP})):e===Ie.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===Ie.PERIOD_CODE||t===Ie.OBRACK_CODE||t===Ie.OPAREN_CODE||t===Ie.QUMARK_CODE;){let i;if(t===Ie.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==Ie.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===Ie.OBRACK_CODE?(e={type:Ie.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},this.gobbleSpaces(),t=this.code,t!==Ie.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===Ie.OPAREN_CODE?e={type:Ie.CALL_EXP,arguments:this.gobbleArguments(Ie.CPAREN_CODE),callee:e}:(t===Ie.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),e={type:Ie.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),i&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,i;for(;Ie.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===Ie.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);Ie.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(t=this.char,t==="e"||t==="E"){for(e+=this.expr.charAt(this.index++),t=this.char,(t==="+"||t==="-")&&(e+=this.expr.charAt(this.index++));Ie.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);Ie.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return i=this.code,Ie.isIdentifierStart(i)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(i===Ie.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===Ie.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:Ie.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,i=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let a=this.expr.charAt(this.index++);if(a===i){r=!0;break}else if(a==="\\")switch(a=this.expr.charAt(this.index++),a){case"n":e+=`
3837
3837
  `;break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=a}else e+=a}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:Ie.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(Ie.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,Ie.isIdentifierPart(e));)this.index++;return{type:Ie.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],i=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){i=!0,this.index++,e===Ie.CPAREN_CODE&&r&&r>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}else if(a===Ie.COMMA_CODE){if(this.index++,r++,r!==t.length){if(e===Ie.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===Ie.CBRACK_CODE)for(let s=t.length;s<r;s++)t.push(null)}}else if(t.length!==r&&r!==0)this.throwError("Expected comma");else{let s=this.gobbleExpression();(!s||s.type===Ie.COMPOUND)&&this.throwError("Expected comma"),t.push(s)}}return i||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(Ie.CPAREN_CODE);if(this.code===Ie.CPAREN_CODE)return this.index++,e.length===1?e[0]:e.length?{type:Ie.SEQUENCE_EXP,expressions:e}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:Ie.ARRAY_EXP,elements:this.gobbleArguments(Ie.CBRACK_CODE)}}},EQ=new SQ;Object.assign(Ie,{hooks:EQ,plugins:new AQ(Ie),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});Ie.max_unop_len=Ie.getMaxKeyLen(Ie.unary_ops);Ie.max_binop_len=Ie.getMaxKeyLen(Ie.binary_ops);var wu=e=>new Ie(e).parse(),MQ=Object.getOwnPropertyNames(Ie);MQ.forEach(e=>{wu[e]===void 0&&e!=="prototype"&&(wu[e]=Ie[e])});wu.Jsep=Ie;var CQ="ConditionalExpression",TQ={name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let i=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:CQ,test:i,consequent:r,alternate:a},i.operator&&e.binary_ops[i.operator]<=.9){let s=i;for(;s.right.operator&&e.binary_ops[s.right.operator]<=.9;)s=s.right;t.node.test=s.right,s.right=t.node,t.node=i}}else this.throwError("Expected :")}})}};wu.plugins.register(TQ);var PQ=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],DQ=["0","1","2","3","4","5","6","7","8","9","."],RQ=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function OQ(e){return typeof e!="string"?!1:!isNaN(e)&&!isNaN(parseFloat(e))}wu.addBinaryOp("^",11,!0);function iD(e,t,i="number"){let r="";for(let n=0;n<e.length;n++){let o=e[n];if("id"in o){let l=e[n-1];if(n>0&&"id"in l){console.error("Two variables in a row",e);return}let h=t.getVariable(o.id),c=as.getDisplayedValue(h);i==="number"&&as.isTextValue(h)&&Array.isArray(h.textValue)&&h.textValue.length===1?c=parseFloat(c).toString():i==="boolean"&&as.isBoolean(h)?c=h?"true":"false":i==="boolean"&&as.isTextValue(h)&&!Array.isArray(h.textValue)&&(c='"'+c+'"'),r+=c;continue}else if(i==="string"){o.name!=='"'&&o.name!=="+"&&(r+=o.name),o.name==="+"&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+o.name);continue}if(o.name==="and"){r+="&&";continue}if(o.name==="or"){r+="||";continue}if(o.name==="True"){r+="true";continue}if(o.name==="False"){r+="false";continue}if(i==="boolean"&&!OQ(o.name)&&!DQ.includes(o.name)&&!PQ.includes(o.name)&&!RQ.includes(o.name.replace(/\($/g,""))){r+='"'+o.name+'"';continue}r+=o.name}if(i==="string")return r;if(e.length===0){if(i==="number")return 0;if(i==="boolean")return!1}let a;try{a=wu(r)}catch(n){console.error(r,n);return}let s;try{s=mi(a)}catch(n){console.error(r,a,n)}return s}function mi(e){switch(e.type){case"BinaryExpression":switch(e.operator){case"==":return Number(mi(e.left)===mi(e.right));case"!=":return Number(mi(e.left)!==mi(e.right));case">":return Number(mi(e.left)>mi(e.right));case">=":return Number(mi(e.left)>=mi(e.right));case"<":return Number(mi(e.left)<mi(e.right));case"<=":return Number(mi(e.left)<=mi(e.right));case"+":return mi(e.left)+mi(e.right);case"-":return mi(e.left)-mi(e.right);case"*":return mi(e.left)*mi(e.right);case"/":return mi(e.left)/mi(e.right);case"%":return mi(e.left)%mi(e.right);case"&&":return mi(e.left)&&mi(e.right);case"||":return mi(e.left)||mi(e.right);case"^":return Math.pow(mi(e.left),mi(e.right));default:throw new Error("Unknown operator: "+e.operator)}case"UnaryExpression":switch(e.operator){case"-":return-mi(e.argument);case"!":return Number(!mi(e.argument));default:throw new Error("Unknown operator: "+e.operator)}case"Identifier":throw new Error("Unknown identifier: "+e.name);case"Literal":return e.value;case"CallExpression":if(e.callee.type==="Identifier"){if(e.callee.name==="random"){let t=0,i=1;if(e.arguments.length>=1)try{t=mi(e.arguments[0])}catch(r){console.warn(r)}if(e.arguments.length>=2)try{i=mi(e.arguments[1])}catch(r){console.warn(r)}return t=Math.min(i,t),i=Math.max(i,t),t+Math.random()*(i-t)}return Math[e.callee.name].apply(null,e.arguments.map(mi))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+e.type)}}var LQ=new je,IQ=new je;function BQ(e,t,i){let r=[new O,new O,new O],a=[new O,new O,new O];return e.extractBasis(r[0],r[1],r[2]),t.extractBasis(a[0],a[1],a[2]),r.forEach((s,n)=>{let o=a[n],l=dt.lerp(s.length(),o.length(),i);s.lerp(o,i).setLength(l)}),new je().makeBasis(r[0],r[1],r[2])}var UQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),r=Math.abs(i.width),a=Math.abs(i.height??i.width),s=Math.abs(i.depth??0),n=t?.shapeData??Zb.create({parameters:M3}).userData.shape;return{path:e.path??_g.defaultData(),parameters:Object.assign(i,{width:r,height:a,depth:s,extrusion:{...C3,...i.extrusion}}),shapeData:n}}static build(e){if(e.path.points.length>=2){let t=new FQ(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new St,{userData:{...e,type:"PathGeometry"}})}},FQ=class extends St{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)||!_Q(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:i,offset:r}=this.inputs.parameters.extrusion;i=Math.max(0,Math.min(i,1)),r=Math.max(0,Math.min(r,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(r*a),n=this.inputs.path.isClosed?Math.ceil((i+r)*a):Math.ceil(Math.min(1,i+r)*a),o=Math.min(Math.max(2,n-s+1),a+2),l=[],h=[];for(let X=0;X<o;X++){let Y=this.inputs.path.isClosed?(X+s)%e.length:Math.min(X+s,e.length-1);l.push(e[Y].clone()),h.push(t[Y].clone())}let c=(X,Y,ie)=>{l[X]=l[X].clone().lerp(l[Y],ie),h[X]=BQ(h[X],h[Y],ie)},u=0,d=r*a%1;(!this.inputs.path.isClosed||i<=1)&&(d||r===0)&&(u=d,c(0,1,u));let p=0,f=(r+i)*a%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&f&&(p=f,c(l.length-1,l.length-2,1-p)),i===0){let X=l.length-1;l[X].copy(l[0]),h[X].copy(h[0])}this._applyPathModifiers(h,u,p);let{bevel:m,bevelSides:g}=this.inputs.parameters.extrusion,v=m>0?this.inputs.parameters.extrusion.capType:"flat",x=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(x=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:b,infos:_,vertices:M}=this._computeShapePoints(x),A=0,S;v==="round"&&(S=new Kb(this.inputs.shapeData,2*m,m,x,g,void 0,!0),A=S.getAttribute("position").count);let P=0,L=0;_.sort((X,Y)=>X.start-Y.start),_.forEach(X=>{X.verticesStart=P,X.verticesCount=X.continuous.reduce((Y,ie,ce)=>Y+(ce===0||!ie?2:1),0),L+=X.verticesCount,P=L});let E=L*o,T,B=0;if(this._isOpenEnded()&&v==="flat"){try{T=vl({windingRule:Oi.ODD,elementType:Mr.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:b})}catch{T=W3}B=T.vertexCount}let V=E+2*B+A*2,I=E+2*B,H={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},q=[];if(_.forEach(X=>{this._extrudeRegion(X,M,h,l,H,q,this._isGeometryClosed()&&!this._isOpenEnded())}),T&&(this._closeEnd(T,E,q,H,h[0],l[0],!1),this._closeEnd(T,E+B,q,H,h[h.length-1],l[l.length-1],!0)),S){H.positions.set(S.getAttribute("position").array,I*3),H.normals.set(S.getAttribute("normal").array,I*3),H.uvs.set(S.getAttribute("uv").array,I*2);for(let ce=I;ce<I+A;ce++)H.uvs[ce*2+1]=1e-4;let X=q.length;q.push(...S.getIndex().array.map(ce=>ce+I)),I+=A,H.positions.set(S.getAttribute("position").array,I*3),H.normals.set(S.getAttribute("normal").array,I*3),H.uvs.set(S.getAttribute("uv").array,I*2);let Y=q.length;q.push(...S.getIndex().array.map(ce=>ce+I)),this.setAttribute("position",new Ut(H.positions,3)),this.setAttribute("normal",new Ut(H.normals,3)),this.setAttribute("uv",new Ut(H.uvs,2)),this.setIndex(q);let ie=LQ;ie.copy(h[h.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(ie,I,V),ie.copy(h[0]).setPosition(l[0]).multiply(IQ.makeScale(1,1,-1)),this.applyMatrix4OnRange(ie,I-A,I),this.reverseIndicesOnRange(X,Y)}else this.setAttribute("position",new Ut(H.positions,3)),this.setAttribute("normal",new Ut(H.normals,3)),this.setAttribute("uv",new Ut(H.uvs,2)),this.setIndex(q)}_extractPathPoints(){let e=U3(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(e.length<2)return[];let t=[e[0]];return e.forEach(i=>{t[t.length-1].distanceToSquared(i)>.001&&t.push(i)}),this.inputs.path.isClosed&&t[t.length-1].distanceTo(t[0])<.001&&t.pop(),t}_computeBasisMatrices(e){let t=[],i=e.length,r=this.inputs.path.isClosed,a=new O,s=new O,n=new O,o=new O,l=new O(0,1,0);for(let f=0;f<i;f++){let m=e[f],g;f===0?g=r?e[e.length-2]:m.clone().multiplyScalar(2).sub(e[1]):g=e[f-1];let v;f===i-1?v=r?e[1]:m.clone().multiplyScalar(2).sub(e[f-1]):v=e[f+1];let x=m.clone().sub(g).normalize(),b=v.clone().sub(m).normalize(),_=x.clone().add(b).normalize();n.copy(_),f===0&&(_.equals(l)||_.clone().negate().equals(l))&&l.set(0,0,1);let M=l.clone().cross(_).normalize(),A=_.clone().cross(M).normalize();l.copy(A),o.copy(M),f===0&&(a.copy(A),s.copy(_));let S=new je().makeBasis(M,A,_);t.push(S)}let h=r?s:n,c=r?a:new O(0,1,0),u=h.clone().cross(o).normalize(),d=Math.acos(c.dot(u));if(isNaN(d))return t;let p=c.clone().cross(u);h.dot(p)>0&&(d*=-1);for(let f=1;f<t.length;f++){let m=new je().makeRotationZ(d*f/t.length);t[f].multiply(m)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:a,twist:s,startScale:n,endScale:o}=this.inputs.parameters.extrusion,l=new je,h=new je;return e.forEach((c,u)=>{let d=u===0?0:u===r-1?1:(u-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(dt.lerp(a,a+s,d)*dt.DEG2RAD);let p=dt.lerp(n,o,d);h.makeScale(p,p,p),c.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=Oi.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),a=i.shapeHoles.map(p=>{let f=p.extractShapePointsToFlatArray([],e),m=[];for(let g=f.length-1;g>=1;g-=2){let v=f[g-1],x=f[g-0];m.push(v,x)}return m}),s;try{s=vl({windingRule:t,elementType:Mr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{s=Qb}let n;try{n=vl({windingRule:Oi.ODD,elementType:Mr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{n=H3}if(!s)throw new Error("error generating geometry");let o=s.elementCount;if(n){s.elementCount+=n.elementCount;for(let p=0;p<n.elements.length;p++){let f=n.elements[p],m=p%2===0?s.vertexCount:0;s.elements.push(f+m)}for(let p=0;p<n.vertexIndices.length;p++){let f=n.vertexIndices[p],m=s.vertexCount;s.vertexIndices.push(f+m)}for(let p=0;p<n.vertices.length;p++){let f=n.vertices[p];s.vertices.push(f)}}let l=1/0,h=-1/0,c=1/0,u=-1/0;for(let p=0,f=s.vertexCount;p<f;p++){let m=p*2,g=s.vertices[m+0],v=s.vertices[m+1];g<l&&(l=g),g>h&&(h=g),v<c&&(c=v),v>u&&(u=v)}let d=[];for(let p=s.elementCount-1;p>=0;p--){let f=p>=o,m=p*2,g=s.elements[m+0],v=s.elements[m+1],x=g+v,b={start:g,count:v,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};d.push(b);let _=g,M=x-1,A=g+1,S=i.roundedCurves.length;do{let P=_-g,L=s.vertices[M*2+0],E=s.vertices[M*2+1],T=s.vertices[_*2+0],B=s.vertices[_*2+1],V=s.vertices[A*2+0],I=s.vertices[A*2+1],H=T-L,q=B-E,X=Math.sqrt(H*H+q*q);H/=X,q/=X;let Y=T-V,ie=B-I,ce=Math.sqrt(Y*Y+ie*ie);Y/=ce,ie/=ce,b.normals[P*2+0]=-ie,b.normals[P*2+1]=Y;let de=s.vertexIndices[_];if(Array.isArray(de))b.continuous[P]=!1;else{let[ue,re]=i.getCurveIndexFromVertexId(de-1,!0);if(re>0&&re<1)b.continuous[P]=!0;else{let se=re===1?ue+1:ue-1;se=(se+S)%S;let he=re===1?0:1,_e=i.roundedCurves[ue].getTangent(re),Ee=i.roundedCurves[se].getTangent(he);b.continuous[P]=_e.dot(Ee)>.95}}f&&(b.normals[P*2+0]*=-1,b.normals[P*2+1]*=-1),[M,_,A]=[_,A,A+1],A>=x&&(A-=v)}while(A!==g+1)}return{regions:[r,...a],infos:d,vertices:s.vertices}}_insertVertex(e,t,i,r,a){let s=t*2,n=t*3;e.positions[n+0]=i.x,e.positions[n+1]=i.y,e.positions[n+2]=i.z,e.normals[n+0]=r.x,e.normals[n+1]=r.y,e.normals[n+2]=r.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,t,i,r,a,s,n){let o=new O,l=new O,h=new O,c=new O,u=new ae;i.forEach((p,f)=>{let m=r[f],g=e.verticesStart*i.length+e.verticesCount*f;for(let v=0;v<e.count;v++){let x=(e.start+v)*2;if(o.set(t[x+0],t[x+1],0),h.copy(o).applyMatrix4(p).add(m),e.continuous[v])c.set(e.normals[v*2+0],e.normals[v*2+1],0);else{let b=v===0?(e.start+e.count-1)*2:x-2;l.set(t[b+0],t[b+1],0),c.copy(o).sub(l),c.set(-c.y,c.x,0),e.isHole||c.negate()}if(c.applyMatrix4(p).normalize(),u.set(v===0?1:v/e.count,f/(i.length-1)),this._insertVertex(a,g,h,c,u),g++,!e.continuous[v]||v===0){if(v===0)c.set(e.normals[v*2+0],e.normals[v*2+1],0),u.set(0,f/(i.length-1));else{let b=v===e.count-1?e.start*2:x+2;l.set(t[b+0],t[b+1],0),c.copy(l).sub(o),c.set(-c.y,c.x,0),e.isHole||c.negate()}c.applyMatrix4(p).normalize(),this._insertVertex(a,g,h,c,u),g++}}});let d=i.length-1;for(let p=0;p<d;p++){let f=e.verticesStart*i.length+e.verticesCount*p,m=e.verticesStart*i.length+e.verticesCount*(p+1),g=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&g++;let x=v===e.count-1?0:g+1,b=f+g,_=f+x,M=m+x,A=m+g;e.isHole?s.push(b,M,_,b,A,M):s.push(b,_,M,b,M,A),g++}}}_closeEnd(e,t,i,r,a,s,n){let o=e.vertexCount,l=new O(0,0,n?-1:1).applyMatrix4(a),h=new O,c=new ae;for(let d=0;d<o;d++){let p=2*d;h.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(a).add(s),this._insertVertex(r,t+d,h,l,c)}let u=e.elements;for(let d=0;d<e.elementCount;d++){let p=3*d,f=u[p+0]+t,m=u[p+(n?1:2)]+t,g=u[p+(n?2:1)]+t;i.push(f,m,g)}}applyMatrix4OnRange(e,t,i){let r=e.elements,a=new Ht().getNormalMatrix(e).elements,s,n,o,l,h=this.attributes.position,c=this.attributes.normal;if(!h||!c)return;let u=h.array,d=c.array,p=h.itemSize;for(let f=t*p,m=i*p;f<m;f+=p){if(f===t)debugger;s=u[f+0],n=u[f+1],o=u[f+2],l=1/(r[3]*s+r[7]*n+r[11]*o+r[15]),u[f+0]=(r[0]*s+r[4]*n+r[8]*o+r[12])*l,u[f+1]=(r[1]*s+r[5]*n+r[9]*o+r[13])*l,u[f+2]=(r[2]*s+r[6]*n+r[10]*o+r[14])*l,s=d[f+0],n=d[f+1],o=d[f+2],d[f+0]=a[0]*s+a[3]*n+a[6]*o,d[f+1]=a[1]*s+a[4]*n+a[7]*o,d[f+2]=a[2]*s+a[5]*n+a[8]*o}h.needsUpdate=!0,c.needsUpdate=!0}reverseIndicesOnRange(e,t){let i=this.index;if(i){for(let r=e;r<t;r+=3){let a=i.getX(r),s=i.getX(r+1),n=i.getX(r+2);i.setXYZ(r,n,s,a)}i.needsUpdate=!0}}};function rD(){let e=new St;return e.setAttribute("position",new Ut(new Float32Array([]),3)),e.setIndex(new Ut(new Uint16Array([]),1)),e}var NQ=rD().attributes,zQ=12,kQ=1,aD=class extends St{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,NQ),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:r,depth:a,extrudeBevelSize:s,extrudeBevelSegments:n,text:o,textTransform:l}=e,h=as.getDisplayedValue(o),c=l===2?h.toUpperCase():l===3?h.toLowerCase():h,u=VQ(e,t,c),{shapes:d,charWidths:p,charCoords:f}=t.generateShapes(u,e),m=(typeof i=="number"?i:1)*.5,g=(typeof r=="number"?r:1)*.5,v=d.map(_=>new ur().fromShape(_,!0));this.vectorShapes=v;let x=v.map(_=>Bh.create({shape:_,parameters:{depth:a,extrudeBevelSegments:n,extrudeBevelSize:s,windingRule:a<=0?Oi.NONZERO:Oi.ODD,subdivisions:this.isLowResolution&&a>0?kQ:zQ}})),b=x.length?dh(x):rD();b.translate(-m,g,0),this.dispose(),this.wrappedText=u,this.charCoords=f,this.charWidths=p,this.deleteAttribute("extrudeNormal"),Object.entries(b.attributes).forEach(([_,M])=>{this.setAttribute(_,M)}),this.setIndex(b.index),this.computeBoundingSphere()}clone(){let e=Ln(new St,aD.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function VQ(e,t,i){let r=[""],a="";for(let s of i)a+=s,s===" "||s===`
3838
3838
  `?(r[r.length-1]+=a,a="",s===`
3839
- `&&r.push("")):t.getTextWidth(r[r.length-1]+a,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+a,e)>e.width&&(a.length===1?(r[r.length-1]+=a,a=""):(r[r.length-1]+=a.slice(0,-1),a=a[a.length-1],r.push(""))));return r[r.length-1]+=a,r}var sD,nD=new Promise(e=>{sD=e}),KE=!1,em;function jQ(){if(KE)return;if(em)return em;async function e(){let t="https://unpkg.com/@splinetool/modelling-wasm@1.0.84/build",i=import("./process.js"),[r,a]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),s=r.default,n=await s({wasmBinary:a});sD(n),KE=!0}return em=e(),em}var GQ=["font"];function gp(e,t,i,r){let a,s,n;e.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(e)),n=[[],["extrusion"]]):(s={...e},n=[[]]);for(let h of n){let c=s;for(let u of h)c=c[u];for(a in c){let u=c[a];eE(u)&&!GQ.includes(a)&&(c[a]=t.getVariable(u,[r.uuid,"geometry",...h,a]),eE(c[a])&&(c[a]=1))}}let o={parameters:s,type:s.type};if(s.type==="PathGeometry")o.path=s.path;else if(s.type==="VectorGeometry"){let h=ur.createFromState(s.shape,s.width,s.height);o.shape=h}else if(s.type==="NonParametricGeometry")s.data.groups&&s.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),o.geometry=new sP().parse(s);else if(s.type==="SubdivGeometry"){let h=new Ra(s,i);return h.data=e,h}else{if(s.type==="TextGeometry")return new aD(s,t);if(s.type==="UIGeometry")return Jb.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}let l;try{l=tM(o)}catch(h){console.error(h)}if(!l){let h=ur.createFromState(wg.defaultData(),100,100);o.shape=h,l=tM(o)}return l}var HQ=new je;function mx(e,t,i,r){let a=e.position.array,s=e.normal.array,n=HQ.makeScale(t,i,r).invert().elements,o,l,h;for(var c=0,u=a.length;c<u;c+=3)a[c]*=t,a[c+1]*=i,a[c+2]*=r,o=s[c],l=s[c+1],h=s[c+2],s[c]=n[0]*o+n[4]*l+n[8]*h,s[c+1]=n[1]*o+n[5]*l+n[9]*h,s[c+2]=n[2]*o+n[6]*l+n[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var tm=new sr,wc=new O,Dt;nD.then(e=>{Dt=e});var ZE=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),JE=new Uint32Array([0,1,2,3]),$E=new Uint8Array([4]),Ra=class extends St{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=vh.div(t,i);this.subdividedGeometry&&mx(this.subdividedGeometry.attributes,...r),this.originalGeometry&&mx(this.originalGeometry.attributes,...r),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*r[0],height:a.height*r[1],depth:a.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(wc.fromArray(r));let s=wc.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Ra.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Ks(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Ra.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Sa,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;tm.setFromBufferAttribute(t),tm.getCenter(i),e.boundingSphere.radius=i.distanceTo(tm.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),tm.getSize(wc);let r={width:wc.x,height:wc.y,depth:wc.z};return this.userData.parameters=r,r}static build(e,t,i,r){let a,s,n,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Dt.free_bvh(t),Dt.free_subdivision_surface(t));try{a=Ra.allocate(e,r)}catch(l){console.error(l,e),a=Ra.allocate({positionWASM:ZE,indexWASM:JE,verticesPerFaceWASM:$E},r)}if(Dt.set_destination_refinement_level(a,0),s=Ra.buildLevel(a,!0,o),e.subdivisions>0)try{Dt.set_destination_refinement_level(a,e.subdivisions),n=Ra.buildLevel(a,!1,o)}catch{try{Dt.set_destination_refinement_level(a,e.subdivisions-1),n=Ra.buildLevel(a,!1,o)}catch{n=null}}else n=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:n}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0||e.path!==void 0?t.geometry:gp(e,i,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=r.getClosedTorusIndicesForBooleanOrSubdiv():a=r.getIndex();let s,n,o,l;({positions:s,triIndices:l}=pv(r.getAttribute("position"),a));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let c=e.radialSegments*e.heightSegments*3*2,u=c+e.radialSegments*3;h=[c,u]}return{indices:n,verticesPerFace:o}=oD(s,l,r,h),{positions:s,indices:n,verticesPerFace:o}}static allocate(e,t){let i,r,a,s=[],n=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,a=e.verticesPerFaceWASM):(i=ZE,r=JE,a=$E);let o=i.length,l=r.length,h=a.length,c=i.length+s.length+n.length,u=r.length+a.length,d=c*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,p=c*Float32Array.BYTES_PER_ELEMENT,f=u*Uint32Array.BYTES_PER_ELEMENT,m=Dt._malloc(d),g=new Float32Array(Dt.HEAPF32.buffer,m,c),v=new Uint32Array(Dt.HEAPU32.buffer,m+p,u);g.set(i,0),g.set(s,i.length),g.set(n,i.length+s.length),v.set(r,0),v.set(a,r.length);let x;e?.scaleBaked?.some(_=>_!==1)&&(x=new je().makeScale(...e.scaleBaked)),t&&(x?x.premultiply(t):x=t);let b=x?Dt.alloc_subdivision_surface2(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,x.elements):Dt.alloc_subdivision_surface(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Dt._free(m),b}static buildLevel(e,t,i,r,a){let s=a?Dt.get_mesh_data2(e,t?Dt.Level.CONTROL:Dt.Level.REFINED,i,a.elements):Dt.get_mesh_data(e,t?Dt.Level.CONTROL:Dt.Level.REFINED,i),n=8,o=Dt.HEAPU32.subarray(s>>2,(s>>2)+n),l=o.subarray(4,4+4),h=0,c=Dt.HEAPU32[o[h]>>2],u=Dt.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let d=Dt.HEAPU32[o[h]>>2],p=Dt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=Dt.HEAPU32[o[h]>>2],m=Dt.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let g=Dt.HEAPU32[o[h]>>2],v=Dt.HEAPU32.subarray(g>>2,(g>>2)+l[h]);if(h++,r===void 0){let x=new St;if(x.setIndex(new Yc(v,1)),x.setAttribute("position",new ut(u,3)),x.setAttribute("normal",new ut(p,3)),t){x.setAttribute("faceMap",new Yc(m,1));let b=new Float32Array(p.length/3*4).fill(0);x.setAttribute("color",new Ut(b,4))}return Dt.free_mesh_data(s),x.userData.type="SubdivGeometry",x}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Dt.free_mesh_data(s)}static freeSubdivPointer(e){Dt.free_bvh(e),Dt.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Dt.get_wireframe_data_for_base_level(e),a=4,s=Dt.HEAPU32.subarray(r>>2,(r>>2)+a),n=s.subarray(2,2+2),o=0,l=Dt.HEAPU32[s[o]>>2],h=Dt.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let c=Dt.HEAPU32[s[o]>>2],u=Dt.HEAPU32.subarray(c>>2,(c>>2)+n[o]);if(t===void 0){let d=new St;d.setAttribute("position",new ut(h,3));let p=new Float32Array(h.length);for(let f=0,m=h.length;f<m;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new Ut(p,3)),d.setIndex(new Yc(u,1)),Dt.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Dt.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Dt.set_destination_refinement_level(e,t);let a=i?Dt.get_topological_data2(e,r?Dt.Level.CONTROL:Dt.Level.REFINED,i.elements):Dt.get_topological_data(e,r?Dt.Level.CONTROL:Dt.Level.REFINED),s=6,n=Dt.HEAPU32.subarray(a>>2,(a>>2)+s),o=n.subarray(3,3+3),l=0,h=Dt.HEAPU32[n[l]>>2],c=new Float32Array(Dt.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let u=Dt.HEAPU32[n[l]>>2],d=new Uint32Array(Dt.HEAPU32.subarray(u>>2,(u>>2)+o[l]));l++;let p=Dt.HEAPU32[n[l]>>2],f=new Uint8Array(Dt.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Dt.free_topological_data(a),{positions:c,indices:d,verticesPerFace:f}}},eM=["getX","getY","getZ"];function pv(e,t){let i={},r=t?t.count:e.count,a=0,s=[],n=[],o=1e4;for(let h=0;h<r;h++){let c=t?t.getX(h):h,u="";for(let d=0;d<3;d++)u+=`${~~(e[eM[d]](c)*o)},`;if(u in i)s.push(i[u]);else{for(let d=0;d<3;d++)n.push(e[eM[d]](c));i[u]=a,s.push(a),a++}}let l=[];for(let h=0;h<s.length;h+=3)s[h]===s[h+1]||s[h]===s[h+2]||s[h+1]===s[h+2]||l.push(s[h],s[h+1],s[h+2]);return{positions:n,triIndices:l}}var im=new O,ay=new O,sy=new O,ny=new O;function oD(e,t,i,r){let a=[],s=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let d=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%d===0)}let c=0;for(let d=0;d<l.length;d+=2)c+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);e.length=0;let u=0;if(c<0)for(let d=0;d<l.length;d+=2)e.push(l[d],l[d+1],0),a.push(u++);else for(let d=l.length-2;d>=0;d-=2)e.push(l[d],l[d+1],0),a.push(u++);return s.push(u),{indices:a,verticesPerFace:s}}let n=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===n||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===n||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===n||e[t[o+2]*3+2]===0)&&l++,l===3)break}if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){im.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),ay.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),sy.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),ny.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),ay.sub(im).normalize(),sy.sub(im).normalize(),ny.sub(im).normalize();let l=ay.cross(sy).dot(ny);Math.abs(l)>.005||r&&r.some((h,c)=>c%2===1?!1:o>=r[c]&&o<r[c+1])?(a.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3):(a.push(t[o],t[o+1],t[o+4],t[o+5]),s.push(4),o+=6)}else a.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],c=0;for(let u=0,d=0;u<e.length;u+=3,d++)e[u+2]===0&&(l.push(d),c++),e[u+2]===n&&h.push(d);if(i.userData.parameters.extrudeBevelSize===0){let u=h[0];h[0]=h[1],h[1]=u}l.reverse(),a.push(...l,...h),s.push(c,c)}return{indices:a,verticesPerFace:s}}var co={};zB(co,{calcBoolean:()=>QQ,calcBooleanTopological:()=>YQ,freeMeshSet:()=>$Q,getMeshSet:()=>KQ,hasOpenEdges:()=>ZQ,transformMeshSet:()=>JQ});var lD,WQ=new Promise(e=>{lD=e}),rm;function qQ(){if(rm)return rm;async function e(){let t="https://unpkg.com/@splinetool/boolean-wasm@1.0.84/build",i=import("./boolean.js"),[r,a]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=r.default,n=await s({wasmBinary:a});lD(n)}return rm=e(),rm}var si,ru;WQ.then(e=>si=e);function XQ(e,t,i){let r,a;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?a=e.getClosedTorusIndicesForBooleanOrSubdiv():a=e.getIndex();let{positions:s,triIndices:n}=pv(e.getAttribute("position"),a),o;if(t&&i){let{indices:l,verticesPerFace:h}=oD(s,n,e);o=h.length,r=[];for(let c=0,u=0;c<o;c++){r.push(h[c]);for(let d=0;d<h[c];d++)r.push(l[u++])}}else{let l=n.length;r=Array(l+l/3),o=0;for(let h=0,c=0;c<r.length;)r[c++]=3,o++,r[c++]=n[h++],r[c++]=n[h++],r[c++]=n[h++]}return{positions:s,faceIndices:r,nFaces:o}}function hD(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,a=Number.isInteger(e[0])?i:r,s=si._malloc(a);return(Number.isInteger(e[0])?new Uint32Array(si.HEAPU32.buffer,s,t):new Float32Array(si.HEAPF32.buffer,s,t)).set(e,0),s}function cD(e){switch(e){case 0:return si.OP.UNION;case 1:return si.OP.INTERSECTION;case 2:return si.OP.A_MINUS_B;case 3:return si.OP.B_MINUS_A;case 4:return si.OP.SYMMETRIC_DIFFERENCE;case 5:return si.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function YQ(e,t){ru===void 0&&(ru=si.init_csg());let i=hD(e),r=si.csg_calc_topological(ru,i,e.length,cD(t));si._free(i);let a=6,s=si.HEAPU32.subarray(r>>2,(r>>2)+a),n=s.subarray(3,3+3),o=0,l=si.HEAPU32[s[o]>>2],h=new Float32Array(si.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let c=si.HEAPU32[s[o]>>2],u=new Uint32Array(si.HEAPU32.subarray(c>>2,(c>>2)+n[o]));o++;let d=si.HEAPU32[s[o]>>2],p=new Uint8Array(si.HEAPU32.subarray(d>>2,(d>>2)+n[o]));return si.free_mesh_data(r),{positions:h,indices:u,verticesPerFace:p}}function QQ(e,t,i,r){ru===void 0&&(ru=si.init_csg());let a=hD(e),s=si.csg_calc(ru,a,e.length,r,cD(t));si._free(a);let n=5,o=si.HEAPU32.subarray(s>>2,(s>>2)+n),l=o.subarray(2,2+3),h=0,c=si.HEAPU32[o[h]>>2],u=si.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let d=si.HEAPU32[o[h]>>2],p=si.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new ut(u,3)),i.setAttribute("normal",new ut(p,3));let m=si.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Sa),i.boundingSphere.center.set(m[0],m[1],m[2]),i.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,i.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},si.free_mesh_data(s),f}function KQ(e,t,i){if(si===void 0)return-1;let r,a,s;if(t&&e.userData.positions!==void 0){let v=e.userData;s=v.verticesPerFace.length,r=v.positions,a=Array(v.verticesPerFace.reduce((x,b)=>x+b,0)+s);for(let x=0,b=0,_=0;x<v.verticesPerFace.length;x++){a[_++]=v.verticesPerFace[x];for(let M=0;M<v.verticesPerFace[x];M++)a[_++]=v.indices[b++]}}else({positions:r,faceIndices:a,nFaces:s}=XQ(e,t,i));let n=r.length,o=a.length,l=r.length,h=a.length,c=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,u=l*Float32Array.BYTES_PER_ELEMENT,d=h*Uint32Array.BYTES_PER_ELEMENT,p=si._malloc(c),f=new Float32Array(si.HEAPF32.buffer,p,l),m=new Uint32Array(si.HEAPU32.buffer,p+u,h);f.set(r,0),m.set(a,0);let g=si.get_csg_mesh(p,n,p+u,o,s);return si._free(p),g}function ZQ(e){return si.has_open_edges(e)}function JQ(e,t){si.transform_csg_mesh(e,t.elements)}function $Q(e){si.free_csg_mesh(e)}var eK={ConeGeometry:xY,CubeGeometry:bY,CylinderGeometry:F3,DodecahedronGeometry:_Y,EllipseGeometry:Zb,HelixGeometry:eQ,IcosahedronGeometry:tQ,LatheGeometry:iQ,NonParametricGeometry:hQ,PolygonGeometry:eD,PyramidGeometry:cQ,RectangleGeometry:Jb,SphereGeometry:pQ,PlaneGeometry:fQ,BackdropGeometry:mQ,StarGeometry:tD,TextFrameGeometry:vQ,TorusGeometry:yQ,TorusKnotGeometry:bQ,TriangleGeometry:wQ,PathGeometry:UQ,VectorGeometry:Bh},tM=e=>eK[e.type].create(e);function _c(e){return e!==null&&"booleanOp"in e}var uD=class extends Wb(xr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new je}updateVisible(e){super.updateVisible(e),this.visible=!_c(this.parent)&&this.visible,_c(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(co.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),_c(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof uD&&(e.freeBooleanPointer(),_c(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&_c(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),_c(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},am=new sr;function $b(e,t=0,i=e.count,r,a){let s=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0;for(let u=t;u<i;u++){let d=e.getX(u),p=e.getY(u),f=e.getZ(u);d<s&&(s=d),p<n&&(n=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>c&&(c=f)}am.min.set(s,n,o),am.max.set(l,h,c),am.getCenter(r),am.getSize(a).multiplyScalar(.5)}var tK=new St,iK=new Dh,Fa=class extends uD{constructor(e,t){super(tK,iK),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?$b(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},al=class{constructor(e){if(this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},al.uuidContext===null)throw new Error("plz startContext");al.uuidContext===al.globalContext?this.uuid="_gid"+al.uuidContext.nodeContextUuid++:this.uuid="_uid"+al.uuidContext.nodeContextUuid++,this.type=e,this.name=""}static startContext(e){this.uuidContext===null||this.uuidContext===al.globalContext?this.uuidContext=e:console.error("Can't start context twice")}static endContext(e){this.uuidContext!==e&&console.error("Can't end context twice"),this.uuidContext=null}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,a,s){return""}generate(e,t,i,r,a){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}},Ur=al;Ur.globalContext={nodeContextUuid:0},Ur.uuidContext=al.globalContext;var iM=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},rK=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Xa=new rK,Ii=class extends Ur{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&this.uuid===void 0&&(this.uuid=dt.generateUUID()),i=e.getUUID(i??this.getUUID(),!a);let s=e.getNodeData(i),n=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,t),this.generate(e,t,i)):super.build(e,t,i);if(a)return s.name=s.name||super.build(e,t,i),s.name;if(!this.getLabel()&&(!this.getShared(e,n)||e.context.ignoreCache||s.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,n,t);{o=super.generate(e,t,i,s.output,r);let l=this.generate(e,n,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,n,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,a){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),a,this.getLabel()).name}},Ka=class extends Ii{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,a,s){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,a,s):e.isShader("vertex")?(n.vertex||(n.vertex=e.createVertexUniform(r,this,a,s,this.getLabel())),e.format(n.vertex.name,r,t)):(n.fragment||(n.fragment=e.createFragmentUniform(r,this,a,s,this.getLabel())),e.format(n.fragment.name,r,t))}},aa=class extends Ka{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof ae?e:new ae(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},ys=class extends Ka{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof O?e:new O(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},ca=class extends _t{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},uo=class extends Ka{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof ca?e:new ca(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},aK=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,rM=/[a-z_0-9]+/gi,lt=class extends Ii{constructor(e,t,i,r,a){super(a),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,a){let s,n=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;s=rM.exec(this.src);)l.push(s);for(let h=0;h<l.length;h++){let c=l[h],u=c[0],d=this.isMethod?!this.getInputByName(u):!0,p=u;if(this.keywords[u]||this.useKeywords&&d&&Xa.containsKeyword(u)){let f=this.keywords[u];if(!f){let m=Xa.getKeywordData(u);m.cache&&(f=e.keywords[u]),f=f||Xa.getKeyword(u,e),m.cache&&(e.keywords[u]=f)}p=f.build(e)}u!==p&&o[c.index+n-1]!=="."&&(o=o.substring(0,c.index+n)+p+o.substring(c.index+u.length+n),n+=p.length-u.length),this.getIncludeByName(p)===void 0&&Xa.contains(p)&&e.include(Xa.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let a=aK.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(rM);if(s){let n=0;for(;n<s.length;){let o=s[n++],l;o==="in"||o==="out"||o==="inout"?l=s[n++]:(l=o,o="");let h=s[n++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},sK=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,dD=class extends Ii{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||dD.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,a){this.src=e||"";let s,n,o="",l=sK.exec(e);this.useDefine=a??this.src.charAt(0)==="#",l&&l.length>1?(n=l[1],s=l[2],o=l[3]):(s=this.src,n="f"),this.name=s,this.type=n,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,a){return e.format(this.name,this.getType(e),t)}},Ti=dD;Ti.PI="PI",Ti.PI2="PI2",Ti.RECIPROCAL_PI="RECIPROCAL_PI",Ti.RECIPROCAL_PI2="RECIPROCAL_PI2",Ti.LOG2="LOG2",Ti.EPSILON="EPSILON";var nK=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3839
+ `&&r.push("")):t.getTextWidth(r[r.length-1]+a,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+a,e)>e.width&&(a.length===1?(r[r.length-1]+=a,a=""):(r[r.length-1]+=a.slice(0,-1),a=a[a.length-1],r.push(""))));return r[r.length-1]+=a,r}var sD,nD=new Promise(e=>{sD=e}),KE=!1,em;function jQ(){if(KE)return;if(em)return em;async function e(){let t="https://unpkg.com/@splinetool/modelling-wasm@1.0.85/build",i=import("./process.js"),[r,a]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),s=r.default,n=await s({wasmBinary:a});sD(n),KE=!0}return em=e(),em}var GQ=["font"];function gp(e,t,i,r){let a,s,n;e.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(e)),n=[[],["extrusion"]]):(s={...e},n=[[]]);for(let h of n){let c=s;for(let u of h)c=c[u];for(a in c){let u=c[a];eE(u)&&!GQ.includes(a)&&(c[a]=t.getVariable(u,[r.uuid,"geometry",...h,a]),eE(c[a])&&(c[a]=1))}}let o={parameters:s,type:s.type};if(s.type==="PathGeometry")o.path=s.path;else if(s.type==="VectorGeometry"){let h=ur.createFromState(s.shape,s.width,s.height);o.shape=h}else if(s.type==="NonParametricGeometry")s.data.groups&&s.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),o.geometry=new sP().parse(s);else if(s.type==="SubdivGeometry"){let h=new Ra(s,i);return h.data=e,h}else{if(s.type==="TextGeometry")return new aD(s,t);if(s.type==="UIGeometry")return Jb.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}let l;try{l=tM(o)}catch(h){console.error(h)}if(!l){let h=ur.createFromState(wg.defaultData(),100,100);o.shape=h,l=tM(o)}return l}var HQ=new je;function mx(e,t,i,r){let a=e.position.array,s=e.normal.array,n=HQ.makeScale(t,i,r).invert().elements,o,l,h;for(var c=0,u=a.length;c<u;c+=3)a[c]*=t,a[c+1]*=i,a[c+2]*=r,o=s[c],l=s[c+1],h=s[c+2],s[c]=n[0]*o+n[4]*l+n[8]*h,s[c+1]=n[1]*o+n[5]*l+n[9]*h,s[c+2]=n[2]*o+n[6]*l+n[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var tm=new sr,wc=new O,Dt;nD.then(e=>{Dt=e});var ZE=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),JE=new Uint32Array([0,1,2,3]),$E=new Uint8Array([4]),Ra=class extends St{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=vh.div(t,i);this.subdividedGeometry&&mx(this.subdividedGeometry.attributes,...r),this.originalGeometry&&mx(this.originalGeometry.attributes,...r),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*r[0],height:a.height*r[1],depth:a.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(wc.fromArray(r));let s=wc.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Ra.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Ks(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Ra.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Sa,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;tm.setFromBufferAttribute(t),tm.getCenter(i),e.boundingSphere.radius=i.distanceTo(tm.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),tm.getSize(wc);let r={width:wc.x,height:wc.y,depth:wc.z};return this.userData.parameters=r,r}static build(e,t,i,r){let a,s,n,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Dt.free_bvh(t),Dt.free_subdivision_surface(t));try{a=Ra.allocate(e,r)}catch(l){console.error(l,e),a=Ra.allocate({positionWASM:ZE,indexWASM:JE,verticesPerFaceWASM:$E},r)}if(Dt.set_destination_refinement_level(a,0),s=Ra.buildLevel(a,!0,o),e.subdivisions>0)try{Dt.set_destination_refinement_level(a,e.subdivisions),n=Ra.buildLevel(a,!1,o)}catch{try{Dt.set_destination_refinement_level(a,e.subdivisions-1),n=Ra.buildLevel(a,!1,o)}catch{n=null}}else n=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:n}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0||e.path!==void 0?t.geometry:gp(e,i,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=r.getClosedTorusIndicesForBooleanOrSubdiv():a=r.getIndex();let s,n,o,l;({positions:s,triIndices:l}=pv(r.getAttribute("position"),a));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let c=e.radialSegments*e.heightSegments*3*2,u=c+e.radialSegments*3;h=[c,u]}return{indices:n,verticesPerFace:o}=oD(s,l,r,h),{positions:s,indices:n,verticesPerFace:o}}static allocate(e,t){let i,r,a,s=[],n=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,a=e.verticesPerFaceWASM):(i=ZE,r=JE,a=$E);let o=i.length,l=r.length,h=a.length,c=i.length+s.length+n.length,u=r.length+a.length,d=c*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,p=c*Float32Array.BYTES_PER_ELEMENT,f=u*Uint32Array.BYTES_PER_ELEMENT,m=Dt._malloc(d),g=new Float32Array(Dt.HEAPF32.buffer,m,c),v=new Uint32Array(Dt.HEAPU32.buffer,m+p,u);g.set(i,0),g.set(s,i.length),g.set(n,i.length+s.length),v.set(r,0),v.set(a,r.length);let x;e?.scaleBaked?.some(_=>_!==1)&&(x=new je().makeScale(...e.scaleBaked)),t&&(x?x.premultiply(t):x=t);let b=x?Dt.alloc_subdivision_surface2(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,x.elements):Dt.alloc_subdivision_surface(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Dt._free(m),b}static buildLevel(e,t,i,r,a){let s=a?Dt.get_mesh_data2(e,t?Dt.Level.CONTROL:Dt.Level.REFINED,i,a.elements):Dt.get_mesh_data(e,t?Dt.Level.CONTROL:Dt.Level.REFINED,i),n=8,o=Dt.HEAPU32.subarray(s>>2,(s>>2)+n),l=o.subarray(4,4+4),h=0,c=Dt.HEAPU32[o[h]>>2],u=Dt.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let d=Dt.HEAPU32[o[h]>>2],p=Dt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=Dt.HEAPU32[o[h]>>2],m=Dt.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let g=Dt.HEAPU32[o[h]>>2],v=Dt.HEAPU32.subarray(g>>2,(g>>2)+l[h]);if(h++,r===void 0){let x=new St;if(x.setIndex(new Yc(v,1)),x.setAttribute("position",new ut(u,3)),x.setAttribute("normal",new ut(p,3)),t){x.setAttribute("faceMap",new Yc(m,1));let b=new Float32Array(p.length/3*4).fill(0);x.setAttribute("color",new Ut(b,4))}return Dt.free_mesh_data(s),x.userData.type="SubdivGeometry",x}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Dt.free_mesh_data(s)}static freeSubdivPointer(e){Dt.free_bvh(e),Dt.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Dt.get_wireframe_data_for_base_level(e),a=4,s=Dt.HEAPU32.subarray(r>>2,(r>>2)+a),n=s.subarray(2,2+2),o=0,l=Dt.HEAPU32[s[o]>>2],h=Dt.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let c=Dt.HEAPU32[s[o]>>2],u=Dt.HEAPU32.subarray(c>>2,(c>>2)+n[o]);if(t===void 0){let d=new St;d.setAttribute("position",new ut(h,3));let p=new Float32Array(h.length);for(let f=0,m=h.length;f<m;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new Ut(p,3)),d.setIndex(new Yc(u,1)),Dt.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Dt.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Dt.set_destination_refinement_level(e,t);let a=i?Dt.get_topological_data2(e,r?Dt.Level.CONTROL:Dt.Level.REFINED,i.elements):Dt.get_topological_data(e,r?Dt.Level.CONTROL:Dt.Level.REFINED),s=6,n=Dt.HEAPU32.subarray(a>>2,(a>>2)+s),o=n.subarray(3,3+3),l=0,h=Dt.HEAPU32[n[l]>>2],c=new Float32Array(Dt.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let u=Dt.HEAPU32[n[l]>>2],d=new Uint32Array(Dt.HEAPU32.subarray(u>>2,(u>>2)+o[l]));l++;let p=Dt.HEAPU32[n[l]>>2],f=new Uint8Array(Dt.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Dt.free_topological_data(a),{positions:c,indices:d,verticesPerFace:f}}},eM=["getX","getY","getZ"];function pv(e,t){let i={},r=t?t.count:e.count,a=0,s=[],n=[],o=1e4;for(let h=0;h<r;h++){let c=t?t.getX(h):h,u="";for(let d=0;d<3;d++)u+=`${~~(e[eM[d]](c)*o)},`;if(u in i)s.push(i[u]);else{for(let d=0;d<3;d++)n.push(e[eM[d]](c));i[u]=a,s.push(a),a++}}let l=[];for(let h=0;h<s.length;h+=3)s[h]===s[h+1]||s[h]===s[h+2]||s[h+1]===s[h+2]||l.push(s[h],s[h+1],s[h+2]);return{positions:n,triIndices:l}}var im=new O,ay=new O,sy=new O,ny=new O;function oD(e,t,i,r){let a=[],s=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let d=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%d===0)}let c=0;for(let d=0;d<l.length;d+=2)c+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);e.length=0;let u=0;if(c<0)for(let d=0;d<l.length;d+=2)e.push(l[d],l[d+1],0),a.push(u++);else for(let d=l.length-2;d>=0;d-=2)e.push(l[d],l[d+1],0),a.push(u++);return s.push(u),{indices:a,verticesPerFace:s}}let n=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===n||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===n||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===n||e[t[o+2]*3+2]===0)&&l++,l===3)break}if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){im.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),ay.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),sy.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),ny.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),ay.sub(im).normalize(),sy.sub(im).normalize(),ny.sub(im).normalize();let l=ay.cross(sy).dot(ny);Math.abs(l)>.005||r&&r.some((h,c)=>c%2===1?!1:o>=r[c]&&o<r[c+1])?(a.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3):(a.push(t[o],t[o+1],t[o+4],t[o+5]),s.push(4),o+=6)}else a.push(t[o],t[o+1],t[o+2]),s.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],c=0;for(let u=0,d=0;u<e.length;u+=3,d++)e[u+2]===0&&(l.push(d),c++),e[u+2]===n&&h.push(d);if(i.userData.parameters.extrudeBevelSize===0){let u=h[0];h[0]=h[1],h[1]=u}l.reverse(),a.push(...l,...h),s.push(c,c)}return{indices:a,verticesPerFace:s}}var co={};zB(co,{calcBoolean:()=>QQ,calcBooleanTopological:()=>YQ,freeMeshSet:()=>$Q,getMeshSet:()=>KQ,hasOpenEdges:()=>ZQ,transformMeshSet:()=>JQ});var lD,WQ=new Promise(e=>{lD=e}),rm;function qQ(){if(rm)return rm;async function e(){let t="https://unpkg.com/@splinetool/boolean-wasm@1.0.85/build",i=import("./boolean.js"),[r,a]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=r.default,n=await s({wasmBinary:a});lD(n)}return rm=e(),rm}var si,ru;WQ.then(e=>si=e);function XQ(e,t,i){let r,a;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?a=e.getClosedTorusIndicesForBooleanOrSubdiv():a=e.getIndex();let{positions:s,triIndices:n}=pv(e.getAttribute("position"),a),o;if(t&&i){let{indices:l,verticesPerFace:h}=oD(s,n,e);o=h.length,r=[];for(let c=0,u=0;c<o;c++){r.push(h[c]);for(let d=0;d<h[c];d++)r.push(l[u++])}}else{let l=n.length;r=Array(l+l/3),o=0;for(let h=0,c=0;c<r.length;)r[c++]=3,o++,r[c++]=n[h++],r[c++]=n[h++],r[c++]=n[h++]}return{positions:s,faceIndices:r,nFaces:o}}function hD(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,a=Number.isInteger(e[0])?i:r,s=si._malloc(a);return(Number.isInteger(e[0])?new Uint32Array(si.HEAPU32.buffer,s,t):new Float32Array(si.HEAPF32.buffer,s,t)).set(e,0),s}function cD(e){switch(e){case 0:return si.OP.UNION;case 1:return si.OP.INTERSECTION;case 2:return si.OP.A_MINUS_B;case 3:return si.OP.B_MINUS_A;case 4:return si.OP.SYMMETRIC_DIFFERENCE;case 5:return si.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function YQ(e,t){ru===void 0&&(ru=si.init_csg());let i=hD(e),r=si.csg_calc_topological(ru,i,e.length,cD(t));si._free(i);let a=6,s=si.HEAPU32.subarray(r>>2,(r>>2)+a),n=s.subarray(3,3+3),o=0,l=si.HEAPU32[s[o]>>2],h=new Float32Array(si.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let c=si.HEAPU32[s[o]>>2],u=new Uint32Array(si.HEAPU32.subarray(c>>2,(c>>2)+n[o]));o++;let d=si.HEAPU32[s[o]>>2],p=new Uint8Array(si.HEAPU32.subarray(d>>2,(d>>2)+n[o]));return si.free_mesh_data(r),{positions:h,indices:u,verticesPerFace:p}}function QQ(e,t,i,r){ru===void 0&&(ru=si.init_csg());let a=hD(e),s=si.csg_calc(ru,a,e.length,r,cD(t));si._free(a);let n=5,o=si.HEAPU32.subarray(s>>2,(s>>2)+n),l=o.subarray(2,2+3),h=0,c=si.HEAPU32[o[h]>>2],u=si.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let d=si.HEAPU32[o[h]>>2],p=si.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new ut(u,3)),i.setAttribute("normal",new ut(p,3));let m=si.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Sa),i.boundingSphere.center.set(m[0],m[1],m[2]),i.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,i.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},si.free_mesh_data(s),f}function KQ(e,t,i){if(si===void 0)return-1;let r,a,s;if(t&&e.userData.positions!==void 0){let v=e.userData;s=v.verticesPerFace.length,r=v.positions,a=Array(v.verticesPerFace.reduce((x,b)=>x+b,0)+s);for(let x=0,b=0,_=0;x<v.verticesPerFace.length;x++){a[_++]=v.verticesPerFace[x];for(let M=0;M<v.verticesPerFace[x];M++)a[_++]=v.indices[b++]}}else({positions:r,faceIndices:a,nFaces:s}=XQ(e,t,i));let n=r.length,o=a.length,l=r.length,h=a.length,c=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,u=l*Float32Array.BYTES_PER_ELEMENT,d=h*Uint32Array.BYTES_PER_ELEMENT,p=si._malloc(c),f=new Float32Array(si.HEAPF32.buffer,p,l),m=new Uint32Array(si.HEAPU32.buffer,p+u,h);f.set(r,0),m.set(a,0);let g=si.get_csg_mesh(p,n,p+u,o,s);return si._free(p),g}function ZQ(e){return si.has_open_edges(e)}function JQ(e,t){si.transform_csg_mesh(e,t.elements)}function $Q(e){si.free_csg_mesh(e)}var eK={ConeGeometry:xY,CubeGeometry:bY,CylinderGeometry:F3,DodecahedronGeometry:_Y,EllipseGeometry:Zb,HelixGeometry:eQ,IcosahedronGeometry:tQ,LatheGeometry:iQ,NonParametricGeometry:hQ,PolygonGeometry:eD,PyramidGeometry:cQ,RectangleGeometry:Jb,SphereGeometry:pQ,PlaneGeometry:fQ,BackdropGeometry:mQ,StarGeometry:tD,TextFrameGeometry:vQ,TorusGeometry:yQ,TorusKnotGeometry:bQ,TriangleGeometry:wQ,PathGeometry:UQ,VectorGeometry:Bh},tM=e=>eK[e.type].create(e);function _c(e){return e!==null&&"booleanOp"in e}var uD=class extends Wb(xr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new je}updateVisible(e){super.updateVisible(e),this.visible=!_c(this.parent)&&this.visible,_c(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(co.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),_c(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof uD&&(e.freeBooleanPointer(),_c(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&_c(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),_c(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},am=new sr;function $b(e,t=0,i=e.count,r,a){let s=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0;for(let u=t;u<i;u++){let d=e.getX(u),p=e.getY(u),f=e.getZ(u);d<s&&(s=d),p<n&&(n=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>c&&(c=f)}am.min.set(s,n,o),am.max.set(l,h,c),am.getCenter(r),am.getSize(a).multiplyScalar(.5)}var tK=new St,iK=new Dh,Fa=class extends uD{constructor(e,t){super(tK,iK),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?$b(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},al=class{constructor(e){if(this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},al.uuidContext===null)throw new Error("plz startContext");al.uuidContext===al.globalContext?this.uuid="_gid"+al.uuidContext.nodeContextUuid++:this.uuid="_uid"+al.uuidContext.nodeContextUuid++,this.type=e,this.name=""}static startContext(e){this.uuidContext===null||this.uuidContext===al.globalContext?this.uuidContext=e:console.error("Can't start context twice")}static endContext(e){this.uuidContext!==e&&console.error("Can't end context twice"),this.uuidContext=null}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,a,s){return""}generate(e,t,i,r,a){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}},Ur=al;Ur.globalContext={nodeContextUuid:0},Ur.uuidContext=al.globalContext;var iM=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},rK=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Xa=new rK,Ii=class extends Ur{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let a=this.getUnique(e,t);a&&this.uuid===void 0&&(this.uuid=dt.generateUUID()),i=e.getUUID(i??this.getUUID(),!a);let s=e.getNodeData(i),n=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,t),this.generate(e,t,i)):super.build(e,t,i);if(a)return s.name=s.name||super.build(e,t,i),s.name;if(!this.getLabel()&&(!this.getShared(e,n)||e.context.ignoreCache||s.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,n,t);{o=super.generate(e,t,i,s.output,r);let l=this.generate(e,n,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,n,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,a){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),a,this.getLabel()).name}},Ka=class extends Ii{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,a,s){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,a,s):e.isShader("vertex")?(n.vertex||(n.vertex=e.createVertexUniform(r,this,a,s,this.getLabel())),e.format(n.vertex.name,r,t)):(n.fragment||(n.fragment=e.createFragmentUniform(r,this,a,s,this.getLabel())),e.format(n.fragment.name,r,t))}},aa=class extends Ka{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof ae?e:new ae(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},ys=class extends Ka{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof O?e:new O(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},ca=class extends _t{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},uo=class extends Ka{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof ca?e:new ca(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},aK=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,rM=/[a-z_0-9]+/gi,lt=class extends Ii{constructor(e,t,i,r,a){super(a),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,a){let s,n=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;s=rM.exec(this.src);)l.push(s);for(let h=0;h<l.length;h++){let c=l[h],u=c[0],d=this.isMethod?!this.getInputByName(u):!0,p=u;if(this.keywords[u]||this.useKeywords&&d&&Xa.containsKeyword(u)){let f=this.keywords[u];if(!f){let m=Xa.getKeywordData(u);m.cache&&(f=e.keywords[u]),f=f||Xa.getKeyword(u,e),m.cache&&(e.keywords[u]=f)}p=f.build(e)}u!==p&&o[c.index+n-1]!=="."&&(o=o.substring(0,c.index+n)+p+o.substring(c.index+u.length+n),n+=p.length-u.length),this.getIncludeByName(p)===void 0&&Xa.contains(p)&&e.include(Xa.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let a=aK.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(rM);if(s){let n=0;for(;n<s.length;){let o=s[n++],l;o==="in"||o==="out"||o==="inout"?l=s[n++]:(l=o,o="");let h=s[n++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},sK=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,dD=class extends Ii{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||dD.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,a){this.src=e||"";let s,n,o="",l=sK.exec(e);this.useDefine=a??this.src.charAt(0)==="#",l&&l.length>1?(n=l[1],s=l[2],o=l[3]):(s=this.src,n="f"),this.name=s,this.type=n,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,a){return e.format(this.name,this.getType(e),t)}},Ti=dD;Ti.PI="PI",Ti.PI2="PI2",Ti.RECIPROCAL_PI="RECIPROCAL_PI",Ti.RECIPROCAL_PI2="RECIPROCAL_PI2",Ti.LOG2="LOG2",Ti.EPSILON="EPSILON";var nK=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3840
3840
  )*?)}`,"gim"),oK=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),pD=class extends Ii{constructor(e=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,i,r,a){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=nK.exec(e);if(t){let i=t[2],r;for(;r=oK.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},ew=class extends Ii{constructor(e){super("v2",{shared:!1}),this.nodeType="UV",this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",r=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(r,this.getType(e),t)}};Xa.addKeyword("uv",function(){return new ew});Xa.addKeyword("uv2",function(){return new ew(1)});var Uc=class extends Ii{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??Uc.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Cs:return["Linear"];case wi:return["sRGB"];default:return[]}}generate(e,t){let i=this.input.build(e,"v4"),r=this.getType(e),a=Uc.Nodes[this.method],s=e.include(a);if(s===Uc.LINEAR_TO_LINEAR)return e.format(i,r,t);if(a.inputs?.length===2){let n=this.factor.build(e,"f");return e.format(s+"( "+i+", "+n+" )",r,t)}else return e.format(s+"( "+i+" )",r,t)}fromEncoding(e){let t=Uc.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Uc.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Mn=Uc;Mn.Nodes={LinearToLinear:new lt(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3841
3841
  `)),sRGBToLinear:new lt(["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(`
3842
3842
  `)),LinearTosRGB:new lt(["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(`
@@ -4779,7 +4779,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
4779
4779
  vID = randomColor.r;
4780
4780
  vec2 ${i}_offset = vec2(0.0);
4781
4781
  if (${s}) {
4782
- vec4 ${i}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(position, 1.0));
4782
+ vec4 ${i}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(transformed, 1.0));
4783
4783
  // NOTE: For certain shapes, like spheres, we get incorrect extrusion when the
4784
4784
  // normals face the camera directly. So we hackily fix this by offsetting the normal
4785
4785
  // by a tiny amount.
@@ -5655,7 +5655,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
5655
5655
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
5656
5656
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
5657
5657
  return displaced_position;
5658
- }`,[e,t])}}();var Rt={normalRenderTarget:new yo,normalRenderTargetDepth:new yo,transmissionRenderTarget:new yo,aspectRatio:new aa,transmissionSize:new aa(2048,2048),transmissionRenderTargetDepth:new yo,aoRenderTarget:new yo,aoEnabled:new La,pixelRatioNode:new pt(1),resolution:new aa,penumbraSize:new Jl(5,.5),frameIndex:new Ui(0),transmissionLod:new Ui(2)};for(let e of Object.values(Rt))e.isRenderGlobal=!0;var FD={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.84/build/ui.wasm"},aw=class extends Ur{constructor(){super("basic"),this.nodeType="Basic",this.color=new dr(ss),this.shadingAlpha=new pt(1),this.shadingBlend=new Ui(0),this.previousModelViewMatrix=new Un,this.previouseProjectionMatrix=new Un}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Rt.frameIndex}),e.mergeUniform({resolution:Rt.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Eu.merge([st.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
5658
+ }`,[e,t])}}();var Rt={normalRenderTarget:new yo,normalRenderTargetDepth:new yo,transmissionRenderTarget:new yo,aspectRatio:new aa,transmissionSize:new aa(2048,2048),transmissionRenderTargetDepth:new yo,aoRenderTarget:new yo,aoEnabled:new La,pixelRatioNode:new pt(1),resolution:new aa,penumbraSize:new Jl(5,.5),frameIndex:new Ui(0),transmissionLod:new Ui(2)};for(let e of Object.values(Rt))e.isRenderGlobal=!0;var FD={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.85/build/ui.wasm"},aw=class extends Ur{constructor(){super("basic"),this.nodeType="Basic",this.color=new dr(ss),this.shadingAlpha=new pt(1),this.shadingBlend=new Ui(0),this.previousModelViewMatrix=new Un,this.previouseProjectionMatrix=new Un}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Rt.frameIndex}),e.mergeUniform({resolution:Rt.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Eu.merge([st.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
5659
5659
  `));let r=["#include <beginnormal_vertex>",`
5660
5660
  #if !defined( USE_LAYER_DISPLACE )
5661
5661
  #include <defaultnormal_vertex>
@@ -5675,14 +5675,16 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
5675
5675
  `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(`
5676
5676
  `)}else{this.color===void 0&&(this.color=new dr(ss)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let i=this.color.flow(e,"c",{slot:"color"}),r=this.alpha?this.alpha.flow(e,"f"):void 0,a=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=r!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
5677
5677
  `));let n=["#include <normal_fragment_begin>",i.code];r&&n.push(r.code,"#ifdef ALPHATEST"," if ( "+r.result+" <= ALPHATEST ) discard;","#endif"),s?n.push(s.code,`vec3 outgoingLight = ${i.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):n.push(`vec3 finalColor = ${i.result};`);let o="1.0";this.mask&&(this.mask.analyze(e),o=`luminance(${this.mask.flow(e,"v3").result})`),r?n.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${r.result} * ${o} );`):n.push("gl_FragColor = vec4("+i.result+", 1.0 );"),a&&n.push(`gl_FragColor.a *= ${a.result};`),n.push("#include <fog_fragment>","#include <dithering_fragment>"),t=n.join(`
5678
- `)}return t}},AK=class extends Ur{constructor(){super("lambert"),this.nodeType="Lambert",this.color=new dr(ss),this.emissive=new dr(0),this.emissiveIntensity=new pt(1),this.previousModelViewMatrix=new Un,this.previouseProjectionMatrix=new Un,this.shadingAlpha=new pt(1),this.shadingBlend=new Ui(0),this.occlusion=new La(!0)}get category(){return"lambert"}build(e){let t;if(e.define("LAMBERT"),e.define("USE_LIGHT_PROBES"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Rt.frameIndex}),e.mergeUniform({resolution:Rt.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Eu.merge([st.fog,st.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
5678
+ `)}return t}},AK=class extends Ur{constructor(){super("lambert"),this.nodeType="Lambert",this.color=new dr(ss),this.emissive=new dr(0),this.emissiveIntensity=new pt(1),this.previousModelViewMatrix=new Un,this.previouseProjectionMatrix=new Un,this.shadingAlpha=new pt(1),this.shadingBlend=new Ui(0),this.occlusion=new La(!0)}get category(){return"lambert"}build(e){let t;if(e.define("LAMBERT"),e.define("USE_LIGHT_PROBES"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Rt.frameIndex}),e.mergeUniform({resolution:Rt.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Eu.merge([st.fog,st.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
5679
5679
  `));let r=["#include <beginnormal_vertex>",`
5680
+ #include <skinbase_vertex>
5681
+ #include <skinnormal_vertex>
5680
5682
  #ifndef USE_LAYER_DISPLACE
5681
5683
  #include <defaultnormal_vertex>
5682
5684
  #endif
5683
5685
 
5684
5686
  vec3 displaced_position = position;
5685
- vec3 displaced_normal = normal;
5687
+ vec3 displaced_normal = objectNormal;
5686
5688
 
5687
5689
  #ifdef USE_LAYER_DISPLACE
5688
5690
  vec3 transformed;
@@ -5692,7 +5694,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
5692
5694
  #ifndef USE_LAYER_DISPLACE
5693
5695
  #include <begin_vertex>
5694
5696
  #endif
5695
- `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>",`
5697
+ `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>",`
5696
5698
  vec3 diffuse = vec3( 1.0 );
5697
5699
  vec3 geometryPosition = mvPosition.xyz;
5698
5700
  vec3 geometryNormal = normalize( transformedNormal );
@@ -5879,14 +5881,16 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
5879
5881
  outgoingLight *= ao;
5880
5882
  }
5881
5883
  `),l&&u.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),h?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result});`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),c&&u.push(`gl_FragColor.a *= ${c.result};`),u.push("#include <colorspace_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=u.join(`
5882
- `)}return t}},MK=class extends Ur{constructor(){super("standard"),this.nodeType="Standard",this.color=new dr(ss),this.roughness=new pt(.3),this.metalness=new pt(0),this.reflectivity=new pt(.5),this.previousModelViewMatrix=new Un,this.previouseProjectionMatrix=new Un,this.shadingAlpha=new pt(1),this.shadingBlend=new Ui(0),this.occlusion=new La(!0)}get category(){return"physical"}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Rt.frameIndex}),e.mergeUniform({resolution:Rt.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Eu.merge([st.fog,st.lights])),st.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
5884
+ `)}return t}},MK=class extends Ur{constructor(){super("standard"),this.nodeType="Standard",this.color=new dr(ss),this.roughness=new pt(.3),this.metalness=new pt(0),this.reflectivity=new pt(.5),this.previousModelViewMatrix=new Un,this.previouseProjectionMatrix=new Un,this.shadingAlpha=new pt(1),this.shadingBlend=new Ui(0),this.occlusion=new La(!0)}get category(){return"physical"}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Rt.frameIndex}),e.mergeUniform({resolution:Rt.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Eu.merge([st.fog,st.lights])),st.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
5883
5885
  `));let r=["#include <beginnormal_vertex>",`
5886
+ #include <skinbase_vertex>
5887
+ #include <skinnormal_vertex>
5884
5888
  #if !defined( USE_LAYER_DISPLACE )
5885
5889
  #include <defaultnormal_vertex>
5886
5890
  #endif
5887
5891
 
5888
5892
  vec3 displaced_position = position;
5889
- vec3 displaced_normal = normal;
5893
+ vec3 displaced_normal = objectNormal;
5890
5894
 
5891
5895
  #if defined( USE_LAYER_DISPLACE )
5892
5896
  vec3 transformed;
@@ -5896,7 +5900,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
5896
5900
  #if !defined( USE_LAYER_DISPLACE )
5897
5901
  #include <begin_vertex>
5898
5902
  #endif /* !USE_LAYER_DISPLACE */
5899
- `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(`
5903
+ `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(`
5900
5904
  `)}else{e.mergeUniform({penumbraSize:Rt.penumbraSize}),e.mergeUniform({frameIndex:Rt.frameIndex}),e.mergeUniform({aoMap:Rt.aoRenderTarget}),e.mergeUniform({aoEnabled:Rt.aoEnabled});let i={gamma:!0};this.color===void 0&&(this.color=new dr(ss)),this.color.analyze(e,{slot:"color",context:i}),this.roughness.analyze(e),this.metalness.analyze(e);let r=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let a=this.color.flow(e,"c",{slot:"color",context:i}),s=this.roughness.flow(e,"f"),n=this.metalness.flow(e,"f"),o=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),h=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,u=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,d=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
5901
5905
  `));let p=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
5902
5906
  // NOTE: gl_FrontFacing alternative using face normal estimation.
@@ -5970,14 +5974,16 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
5970
5974
  outgoingLight *= ao;
5971
5975
  }
5972
5976
  `),h&&p.push(h.code,`outgoingLight = spe_blend(outgoingLight, ${h.result}, 1.0, SPE_BLENDING_NORMAL);`),c?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),u&&p.push(`gl_FragColor.a *= ${u.result};`),p.push("#include <colorspace_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=p.join(`
5973
- `)}return t}},CK=class extends Ur{constructor(){super("toon"),this.nodeType="Toon",this.color=new dr(ss),this.specular=new dr(1118481),this.shininess=new pt(30),this.previousModelViewMatrix=new Un,this.previouseProjectionMatrix=new Un,this.shadingAlpha=new pt(1),this.shadingBlend=new Ui(0)}get category(){return"toon"}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Rt.frameIndex}),e.mergeUniform({resolution:Rt.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Eu.merge([st.fog,st.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
5977
+ `)}return t}},CK=class extends Ur{constructor(){super("toon"),this.nodeType="Toon",this.color=new dr(ss),this.specular=new dr(1118481),this.shininess=new pt(30),this.previousModelViewMatrix=new Un,this.previouseProjectionMatrix=new Un,this.shadingAlpha=new pt(1),this.shadingBlend=new Ui(0)}get category(){return"toon"}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Rt.frameIndex}),e.mergeUniform({resolution:Rt.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Eu.merge([st.fog,st.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
5974
5978
  `));let r=["#include <beginnormal_vertex>",`
5979
+ #include <skinbase_vertex>
5980
+ #include <skinnormal_vertex>
5975
5981
  #ifndef USE_LAYER_DISPLACE
5976
5982
  #include <defaultnormal_vertex>
5977
5983
  #endif
5978
5984
 
5979
5985
  vec3 displaced_position = position;
5980
- vec3 displaced_normal = normal;
5986
+ vec3 displaced_normal = objectNormal;
5981
5987
 
5982
5988
  #ifdef USE_LAYER_DISPLACE
5983
5989
  vec3 transformed;
@@ -5987,7 +5993,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
5987
5993
  #ifndef USE_LAYER_DISPLACE
5988
5994
  #include <begin_vertex>
5989
5995
  #endif
5990
- `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push(" #include <project_vertex>"," #include <fog_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(`
5996
+ `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push(" #include <project_vertex>"," #include <fog_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(`
5991
5997
  `)}else{e.mergeUniform({penumbraSize:Rt.penumbraSize}),e.mergeUniform({frameIndex:Rt.frameIndex}),e.mergeUniform({aoMap:Rt.aoRenderTarget}),e.mergeUniform({aoEnabled:Rt.aoEnabled}),this.color===void 0&&(this.color=new dr(ss)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),r=this.specular.flow(e,"c"),a=this.shininess.flow(e,"f"),s=this.shadingAlpha.flow(e,"f"),n=this.shadingBlend.flow(e,"i"),o=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,l=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=l!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
5992
5998
  varying vec3 vViewPosition;
5993
5999
  struct ToonMaterial {
@@ -6954,12 +6960,19 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
6954
6960
  attribute vec3 randomColor;
6955
6961
  varying vec3 vNormal;
6956
6962
  flat out vec3 vColor;
6963
+ #include <skinning_pars_vertex>
6957
6964
 
6958
6965
  void main()
6959
6966
  {
6967
+ #include <beginnormal_vertex>
6968
+ #include <skinbase_vertex>
6969
+ #include <skinnormal_vertex>
6970
+ vec3 transformed = vec3(position);
6971
+ #include <skinning_vertex>
6972
+
6960
6973
  vNormal = normal;
6961
6974
  vColor = randomColor;
6962
- gl_Position = projectionMatrix * (modelViewMatrix * vec4(position, 1.0));
6975
+ gl_Position = projectionMatrix * (modelViewMatrix * vec4(transformed, 1.0));
6963
6976
  }
6964
6977
  `,bee=`
6965
6978
  uniform float depthContrast;
@@ -6975,7 +6988,7 @@ vec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4);
6975
6988
  gl_FragColor = vec4(resultColor, vColor.r);
6976
6989
  gl_FragColor = vec4(resultColor, vColor.r);
6977
6990
  }
6978
- `,Sy=new vi({vertexShader:xee,fragmentShader:bee,uniforms:{depthContrast:{value:1}}}),qM=new Ki,wee=class extends kT{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new ae,this.pipeline=new pee(this),this.dummyCamera=new _a,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.isXRCopyPassSet=!1,this.clear=(a=!0,s=!0,n=!0)=>{let o=this.getContext(),l=0;a&&(l|=o.COLOR_BUFFER_BIT),s&&(l|=o.DEPTH_BUFFER_BIT),n&&(l|=o.STENCIL_BUFFER_BIT),o.clear(l),o.clearBufferfv(o.COLOR,1,[0,0,0,1])},this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=Yx,Di.enabled=!1,this.useLegacyLights=!0,this.dummyCamera.matrixAutoUpdate=!1,this.domElement.removeAttribute("data-engine");let r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(a){console.warn(a)}this.setPixelRatio=a=>{this._pixelRatio!==a&&(this._pixelRatio=a,t(a))},this.setSize=(a,s,n=!0)=>{(this.viewportWidth!==a||this.viewportHeight!==s)&&(this.viewportWidth=a,this.viewportHeight=s,i(a,s,n),this.normalRenderTarget?.setSize(a*this._pixelRatio,s*this._pixelRatio),this._resizeTransmission(a,s),this.transmissionDepthTarget?.setSize(a*this._pixelRatio/2,s*this._pixelRatio/2),this.pipeline.resize(a,s,n))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new _i(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Wt,magFilter:Wt,wrapS:qi,wrapT:qi,depthBuffer:!1}))}_resizeTransmission(e,t){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),t*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,t*this._pixelRatio/1)}get hdTransmission(){return Rt.transmissionLod.value===1}set hdTransmission(e){Rt.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new _i(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:cl,magFilter:Wt,wrapS:qi,wrapT:qi,depthBuffer:!1}),this.transmissionDepthTarget=new _i(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:bi,magFilter:bi,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new _i(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:bi,magFilter:bi,type:ir,depthTexture:new Ah(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t,i){this.normalRenderTarget&&(this.setClearColor(0),i.layers.enable(8),i.layers.disable(0),i.layers.disable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),i instanceof _a?Sy.uniforms.depthContrast.value=(i.far-i.near)/1e4:Sy.uniforms.depthContrast.value=1,t.overrideMaterial=Sy,this.render(t,i),this.setClearColor(t.bgColor,t.bgColor.a),this.setRenderTarget(null),t.overrideMaterial=e.wireframeState?Ux:null,i.layers.enable(0),i.layers.enable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,t,i=1){this.dummyCamera.updateCameraState(t.dataPatched),this.dummyCamera.matrix.copy(t.matrixWorld);let r=t.height,a=t.width,s=this.viewportWidth/this.viewportHeight;a<r?a=r*s:r=a/s,this.dummyCamera.setViewplaneSize(a,r);for(let n=0;n<i;n++)this.renderSplineScene(e,this.dummyCamera)}renderSplineScene(e,t,{sceneHelpers:i=void 0,sceneHelpersOnTop:r=void 0,overrideTransmission:a=void 0,overrideNormal:s=void 0}={}){let n=e instanceof yw?e.activePage:e,o=n.visible;n.visible=!0;let l=n.scene;this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(t)),this.setClearColor(n.bgColor,n.bgColor.a),n.penumbraSizeArray.forEach((d,p)=>{Rt.penumbraSize.value[p]=d}),Rt.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Rt.resolution.value.set(this.resolution.x,this.resolution.y):Rt.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),s!==void 0?(Rt.normalRenderTarget.value=s,Rt.normalRenderTargetDepth.value=qM):l.needsNormal()&&(this.createNormalRenderTarget(),Rt.normalRenderTarget.value=this.normalRenderTarget.texture,Rt.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(l,n,t));let h=n.data.ao,c=h.occlusion;c&&(this.createAORenderTarget(),Rt.aoRenderTarget.value=this.aoRenderTarget.texture),Rt.aoEnabled.value=c,this.pipeline.setAmbientOcclusionParams(h.occlusion,h.radius,h.bias,n.aoColor,n.fog!==null,n.backupFog.near,n.backupFog.far,h.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture),this.pipeline.isUIOverlayEnabled&&n.uiCanvas?.enabled&&n.uiCanvas.texture&&n.uiCanvas.texture.image.width>0?((n.uiCanvas.width!==this.viewportWidth||n.uiCanvas.height!==this.viewportHeight)&&n.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight}),n.uiCanvas.render(),this.pipeline.uiOverlayPass.uiCanvas=n.uiCanvas,this.pipeline.uiOverlayPass.enabled=!0,this.pipeline.uiOverlayPass.setResolution(this.domElement.width,this.domElement.height,window.devicePixelRatio),this.pipeline.updateRenderToScreen()):(this.pipeline.uiOverlayPass.enabled=!1,this.pipeline.updateRenderToScreen());let u=!1;if(a!==void 0)Rt.transmissionRenderTarget.value=a,Rt.transmissionRenderTargetDepth.value=qM,this.pipeline.setTransmissionPassEnabled(!1);else{let d=l.needsTransmission();d&&(this.transmissionRenderTarget===void 0&&(u=!0),this.createTransmissionRenderTarget(),Rt.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Rt.aspectRatio.value=SK(this.viewportWidth,this.viewportHeight),Rt.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(d)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=n,this.pipeline.camera=t,u&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==n.postprocessing&&(this.pipeline.updatePostprocessing(n.postprocessing),!i&&!r&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),n.overrideMaterial=l.wireframeState?Ux:null,this.pipeline.render(),Rt.frameIndex.value=(Rt.frameIndex.value+1)%16,t instanceof _a&&t.copyHistory(),n.visible=o}renderFromSceneForSceneTransitionPass(e,t,i){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,t),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=i,this.sceneTransitionTimeRemaining=i,this.pipeline.renderToScreen=!0;let r=this.pipeline.sceneTransitionPass.uniforms;r.uDPR.value=window.devicePixelRatio,r.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},iR=class extends Cp(I6){constructor(e,t=15,i=7829367){super(e,t,i),this.object=e,this.added=!1,this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Tp(this.object,iR.geometryHelper,e,t)}},rR=class extends Cp(L6){constructor(e,t=15,i=4473924){super(e,t,i),this.object=e,this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Tp(this.object,rR.geometryHelper,e,t)}},Dx=class extends Cp(O6){constructor(e,t=4473924){super(e,t),this.object=e,this.matrix=e.matrixWorld,this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Tp(this.object,Dx.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Dx._vector,t=this.object.distance?this.object.distance:1e3,i=t*Math.tan(this.object.angle);this.cone.scale.set(i,i,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let a=0,s=this.cone.material.length;a<s;a++)this.cone.material[a].color.set(r);else this.cone.material.color.set(r)}}},aR=Dx;aR._vector=new O;function _ee(e,t){e.shadow.camera.right=t/2,e.shadow.camera.left=-t/2,e.shadow.camera.top=t/2,e.shadow.camera.bottom=-t/2,e.shadow.needsUpdate=!0}var sR=class extends hw(v6,iR){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let a=new rg(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof rg&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t);let i=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;e.size!==void 0&&_ee(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),i&&this.update()}},XM=new O,YM=new O,QM=new zt,nR=class extends hw(p6,aR){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=dt.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let a=new rg(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof rg&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),YM.setFromMatrixPosition(this.matrixWorld),QM.setFromRotationMatrix(this.matrixWorld),XM.copy(this.up).applyQuaternion(QM).negate().multiplyScalar(this.distance),this.target.position.copy(YM).add(XM),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};function See(e){let t=(e[0][0]+e[1][1])/2,i=(e[0][0]-e[1][1])/2,r=(e[1][0]+e[0][1])/2,a=(e[1][0]-e[0][1])/2,s=Math.sqrt(t*t+a*a),n=Math.sqrt(i*i+r*r),o=s+n,l=s-n,h=Math.atan2(r,i),c=Math.atan2(a,t),u=(c-h)/2,d=(c+h)/2,p=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]],f=[[o,0],[0,l]],m=[[Math.cos(u),Math.sin(u)],[-Math.sin(u),Math.cos(u)]];return p[0][0]*=-1,p[0][1]*=-1,m[0][0]*=-1,m[1][0]*=-1,[p,f,m]}function Im(e,t){return[[e[0][0]*t[0][0]+e[0][1]*t[1][0],e[0][0]*t[0][1]+e[0][1]*t[1][1]],[e[1][0]*t[0][0]+e[1][1]*t[1][0],e[1][0]*t[0][1]+e[1][1]*t[1][1]]]}function KM(e){return[[e[0][0],e[1][0]],[e[0][1],e[1][1]]]}function Aee(e){let[t,i,r]=See(e),a=Im(t,KM(r)),s=Im(Im(r,i),KM(r)),n=Math.atan2(a[1][0],a[0][0]),o=[s[0][0],s[1][1]],l=[s[0][1]/s[1][1],s[1][0]/s[0][0]];return{rotation:n,scale:o,shear:l}}function Eee({rotation:e,scale:t,shear:i}){let r=Math.cos(e),a=Math.sin(e),s=[[r,-a],[a,r]],n=[[t[0],i[0]*t[1]],[i[1]*t[0],t[1]]],o=Im(s,n);return[o[0][0],o[1][0],o[0][1],o[1][1]]}var Ri;(e=>{function t(){return[1,0,0,0,1,0,0,0,1]}e.identity=t;function i(A,S=e.identity()){for(let P=0,L=A.length;P<L;P++)S[P]=A[P];return S}e.copy=i;function r(A,S,P,L,E,T){return e.setAbcdef(e.identity(),A,S,P,L,E,T)}e.create=r;function a(A,S,P,L,E,T,B){return A[0]=S,A[1]=L,A[2]=T,A[3]=P,A[4]=E,A[5]=B,A}e.setAbcdef=a;function s(A,S){let[P,L,E,T,B,V]=o(A),[I,H,q,X,Y,ie]=o(S),ce=I*P+H*E,de=I*L+H*T,ue=q*P+X*E,re=q*L+X*T,se=Y*P+ie*E+B,he=Y*L+ie*T+V;return e.create(ce,de,ue,re,se,he)}e.append=s;function n(A,S){let[P,L,E,T,B,V]=o(A),[I,H,q,X,Y,ie]=o(S),ce=P,de=L,ue=E,re=T;(I!==1||H!==0||q!==0||X!==1)&&(ce=P*I+L*q,de=P*H+L*X,ue=E*I+T*q,re=E*H+T*X);let se=B*I+V*q+Y,he=B*H+V*X+ie;return e.create(ce,de,ue,re,se,he)}e.prepend=n;function o(A){return[A[0],A[3],A[1],A[4],A[2],A[5]]}e.getAbcdef=o;function l(A){let[S,P,L,E,T,B]=e.getAbcdef(A),V=S*E-P*L,I=E/V,H=-P/V,q=-L/V,X=S/V,Y=(L*B-E*T)/V,ie=-(S*B-P*T)/V;return e.create(I,H,q,X,Y,ie)}e.invert=l;function h([A,S],P){let[L,E,T,B,V,I]=e.getAbcdef(P);return[L*A+T*S+V,E*A+B*S+I]}e.apply=h;function c(A,S){let[P,L,E,T,B,V]=e.getAbcdef(S),I=1/(P*T+E*-L),[H,q]=A;return[T*I*H+-E*I*q+(V*E-B*T)*I,P*I*q+-L*I*H+(-V*P+B*L)*I]}e.applyInverse=c;function u(A,S,P=S){let[L,E,T,B,V,I]=e.getAbcdef(A);return e.setAbcdef(A,L*S,E*P,T*S,B*P,V*S,I*P),A}e.scale=u;function d(A,S){let P=Math.cos(S),L=Math.sin(S),[E,T,B,V,I,H]=e.getAbcdef(A);return e.setAbcdef(A,E*P-T*L,E*L+T*P,B*P-V*L,B*L+V*P,I*P-H*L,I*L+H*P),A}e.rotate=d;function p(A,S,P){let[L,E]=P,T=e.translate(A,-L,-E);return T=e.rotate(T,S),T=e.translate(T,L,E),T}e.rotateAround=p;function f(A,S,P){let[L,E,T,B,V,I]=e.getAbcdef(A);return e.setAbcdef(A,L,E,T,B,V+S,I+P),A}e.translate=f;function m(A,S,P){let[L,E,T,B]=e.getAbcdef(A);return e.setAbcdef(A,L,E,T,B,S,P),A}e.setTranslate=m;function g(A,S,P){let[L,E,T,B]=e.getAbcdef(A);return e.setAbcdef(A,L,E,T,B,S,P),A}e.setPosition=g;function v(A){let[S,P,L,E]=e.getAbcdef(A),T=Math.sqrt(S*S+P*P),B=Math.sqrt(L*L+E*E);return[T,B]}e.getScale=v;function x(A){let[,,,,S,P]=e.getAbcdef(A);return[S,P]}e.getPosition=x;function b(A,S){return e.decompose(A,S).rotation}e.getRotation=b;function _(A,S){let[P,L,E,T,B,V]=e.getAbcdef(A),{rotation:I,scale:H,shear:q}=Aee([[P,E],[L,T]]);return{position:[B+(S[0]*P+S[1]*E)-S[0],V+(S[0]*L+S[1]*T)-S[1]],scale:H,rotation:I,shear:q,pivot:S}}e.decompose=_;function M(A,S,P,L,E=[0,0]){let[T,B]=A,[V,I]=L,[H,q,X,Y]=Eee({rotation:P,scale:S,shear:E}),ie=T-(V*H+I*X)+V,ce=B-(V*q+I*Y)+I;return e.create(H,q,X,Y,ie,ce)}e.compose=M})(Ri||(Ri={}));var Mee=Math.PI/180,rne=180/Math.PI;function Cee(e,t,i,r,a,s){let n=e-i,o=t-r;return n*n/(a*a)+o*o/(s*s)<=1}function Tee(e){return e*Mee}function Pee(e){return{all:e=e||new Map,on:function(t,i){var r=e.get(t);r?r.push(i):e.set(t,[i])},off:function(t,i){var r=e.get(t);r&&(i?r.splice(r.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var r=e.get(t);r&&r.slice().map(function(a){a(i)}),(r=e.get("*"))&&r.slice().map(function(a){a(t,i)})}}}var $r=class{constructor(e,t,i){this.uuid=e,this.data=t,this.localMatrix=Ri.identity(),this.worldMatrix=Ri.identity(),this.ignoreCameraZoom=!1,this.visible=!0,this._singleBBox=new Rx,this._recursiveBBox=new Rx,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.stateSelection=null,this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this.name="",this.position=[0,0],this.scale=[1,1],this.rotation=0,this.shear=[0,0],this.emitter=Pee(),this.dpr=i.dpr??1,this.dataPatched=t}project(e,t){let i=this.worldMatrix;return t&&(i=Ri.append(t.worldMatrix,i)),Ri.applyInverse(e,i)}intersects(e,t,i,r=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([e,t],i),r)}intersectsInLocalSpace(e,t,i=!1){let{min:r,max:a}=i?this.recursiveBBox:this.singleBBox;return e>=r[0]&&e<=a[0]&&t>=r[1]&&t<=a[1]}applyTransforms(e){e.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=Ri.compose(this.position,this.scale,Tee(this.rotation),yh.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(e,t,i){let r=this.parent;t&&r!==null&&r!==void 0&&r.updateWorldMatrix(e,!0,!1),e&&this.updateLocalMatrix(),this.parent?this.worldMatrix=Ri.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=Ri.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return yh.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(e=>{e.resetBBoxNeedsUpdateSelf()})}updateTransformState(e){let t=!1;e.position!==void 0&&(t=!0,this.position=e.position),e.rotation!==void 0&&(t=!0,this.rotation=e.rotation),e.scale!==void 0&&(t=!0,this.scale=e.scale),e.shear!==void 0&&(t=!0,this.shear=e.shear),t&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(e,t,i){e.type===0&&e.props.visible!==void 0&&(this.visible=e.props.visible),this.data=t,this.data=t;let r=e,a=Fi(e.path,["states","*"]);if(a!==null){if(e.type===0){let[s]=a;if(this?.stateSelection===s){let n={...e.props};if(delete n.name,Object.values(e.props).some(o=>o===void 0)){let o=this.data;if(o!==void 0){let l=na.zoom(o,e.path.slice(2));if(l)for(let h in e.props)e.props[h]===void 0&&h in l&&(n[h]=l[h])}}r={...e,props:n,path:e.path.slice(2)}}}}else if(e.type===0){let s=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(s!==void 0){if(e.props.name!==void 0&&s.name){let{name:o,...l}=s;s=l}let n=na.removeOverridden(e.path,e.props,s);r={...e,props:n}}}this.updateByPatchedOpBase(r,uh.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i)}changeSelectedState(e,t,i=!1){if(!(this.data.states.length===0&&!i)){for(let r of this.data.states)uh.toOps(this.data,r.data).forEach(a=>{let s=fg.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,t)});if(e!==null){let r=this.data.states.data(e);r&&(this.dataPatched=uh.patch(this.data,r),uh.toOps(this.data,r).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,t)}))}i&&this.updateTransformState(this.dataPatched),this.stateSelection=e}}updateState(e,t){e.name!==void 0&&(this.name=e.name),e.visible!==void 0&&(this.visible=e.visible),this.updateTransformState(e)}updateByPatchedOpBase(e,t,i){this.dataPatched=t,this.updateByPatchedOp(e,t,i)}updateByPatchedOp(e,t,i){e.path.length===0&&e.type===0&&this.updateState(e.props,i),this.requestRender()}traverseFrameAncestors(e){this.traverseAncestors(t=>{t.data.type==="frame2d"&&e(t)})}traverseAncestors(e){let t=this.parent;for(;t;)e(t),t=t.parent}requestRender(){this.traverseFrameAncestors(e=>{e.requestRender()})}clone(e){let t=new $r(this.uuid,this.data,e);return t.parent=void 0,t}addEventListener(e,t){this.emitter.on(e,t)}removeEventListener(e,t){this.emitter.off(e,t)}dispatchEvent(e){this.emitter.emit(e.type,{...e,target:e.target??this})}traverseSortNextHelper(){let e=this.parent;if(e){let t=e.children;if(t){let i=t.indexOf(this)+1;return t[i]?t[i]:e.traverseSortNextHelper()}}}sortNext(){let e=this.children;return e&&e.length>0&&e[0]?e[0]:this.traverseSortNextHelper()}isDescendantOf(e){e instanceof $r&&(e=e.uuid);let t=this;for(;t.parent;){if(t.parent.uuid===e)return!0;t=t.parent}return!1}},Cn=class extends $r{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.context=i,this.children=[]}add(e){e.parent&&e.parent instanceof Cn&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=void 0)}traverse(e){let t=e(this);if(t!==!0)for(let i of this.children)i instanceof Cn?i.traverse(e):t=e(i)}intersectsChildren(e,t,i,r=!1,a=[],s=!1){for(let n of this.children){let o=n instanceof Po;if(n instanceof Cn&&!o&&s&&n.intersectsChildren(e,t,i,r,a,!1),n.intersects(e,t,i,o)&&(a.push(n),r))break}return a}updateWorldMatrix(e,t,i){if(super.updateWorldMatrix(e,t,i),i&&this.children)for(let r of this.children)r.updateWorldMatrix(e,!1,!0)}find(e){let t;return this.traverse(i=>{i.uuid===e&&(t=i)}),t}innerDrawChildren(e){for(let t=this.children.length-1;t>=0;t--)this.children[t].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let t=new Cn(this.uuid,this.data,e);t.parent=void 0;for(let i of this.children)t.add(i.clone(e));return t}},Po=class extends Cn{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.updateState(t,i)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let t=new Po(this.uuid,this.data,e);t.parent=void 0;for(let i of this.children)t.add(i.clone(e));return t}};function Dee(e,t){let[[i,r],[a,s]]=e,[[n,o],[l,h]]=t,c=(i-a)*(o-h)-(r-s)*(n-l);if(c===0)return!1;let u=((i-n)*(o-h)-(r-o)*(n-l))/c,d=-((i-a)*(r-o)-(r-s)*(i-n))/c;return u>=0&&u<=1&&d>=0&&d<=1}var oR=[[-1,1],[-1,-1],[1,-1],[1,1]],ZM=(e,t,i)=>{let r=e.getCenter(),a=e.getHalfSize(),s=Ri.append(t,e.worldMatrix);a[0]===0&&a[1]===0?i.push(Ri.apply(r,s)):oR.forEach(n=>{let o=[n[0]*a[0]+r[0],n[1]*a[1]+r[1]];i.push(Ri.apply(o,s))})},Rx=class{constructor(){this.matrix=Ri.identity(),this.min=[1/0,1/0],this.max=[-1/0,-1/0],this.vertices=[],this.edges=[]}setFromObjectSize(e,t=!1){e.updateWorldMatrix(),this.makeEmpty(),Ri.copy(e.worldMatrix,this.matrix);let i=Ri.invert(e.worldMatrix);this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];i===!0&&e instanceof Cn?e.traverse(a=>{a.visible&&ZM(a,t,r)}):ZM(e,t,r),this.setFromPoints(r)}getCenter(){let[e,t]=this.min,[i,r]=this.getHalfSize();return Ri.apply([e+i,t+r],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(e){this.makeEmpty();for(let t of e)this.expandByPoint(t)}expandByPoint(e){this.min=[Math.min(this.min[0],e[0]),Math.min(this.min[1],e[1])],this.max=[Math.max(this.max[0],e[0]),Math.max(this.max[1],e[1])]}computeVertices(){let[e,t]=this.getHalfSize(),i=this.getCenter(),[r,a,s,n]=Ri.getAbcdef(this.matrix),o=Ri.create(r,a,s,n,i[0],i[1]);this.vertices=oR.map(([l,h])=>Ri.apply([l*e,h*t],o))}computeEdges(){this.edges=[];for(let e=0,t=this.vertices.length;e<t;++e)this.edges.push([this.vertices[e],this.vertices[(e+1)%t]])}project(e,t){let i=this.matrix;return t&&(i=Ri.append(t.worldMatrix,i)),Ri.applyInverse(e,i)}intersects(e,t,i){return this.intersectsInLocalSpace(...this.project([e,t],i))}intersectsInLocalSpace(e,t){let{min:i,max:r}=this;return e>=i[0]&&e<=r[0]&&t>=i[1]&&t<=r[1]}containsPoint(e){let[t,i]=e,[r,a]=this.min,[s,n]=this.max;return t>=r&&t<=s&&i>=a&&i<=n}intersectsBBox2D(e){for(let t=0,i=this.edges.length;t<i;t++){let r=this.edges[t];for(let a=0,s=e.edges.length;a<s;a++){let n=e.edges[a];if(Dee(r,n))return!0}}for(let t=0,i=e.vertices.length;t<i;t++){let r=e.vertices[t];if(this.containsPoint(r))return!0}return!1}ensureMinMax(){let e=this.min,t=this.max;this.min=[Math.min(e[0],t[0]),Math.min(e[1],t[1])],this.max=[Math.max(e[0],t[0]),Math.max(e[1],t[1])]}copy(e){this.min=[...e.min],this.max=[...e.max],Ri.copy(e.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let e=new Rx;return e.copy(this),e}},lR,Ree=new Promise(e=>{lR=e}),JM=!1,gm;function Oee(){if(JM)return;if(gm)return gm;async function e(){let t=await Promise.resolve().then(()=>(S_(),__));lR(t.default??t),JM=!0}return gm=e(),gm}function $M(e){let t=!1;return e.scene.objects.traverse((i,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var kt,Ay;async function Lee(e){let t=await Ree;kt||(Ay||(Ay=t({locateFile:()=>e})),kt=await Ay)}var eC=Ri.identity(),tC=class{constructor(e,t=1){this.canvas=e,this.dpr=t,this._width=0,this._height=0,this._strokeMode="inside",this._layerBlur=0,this._backgroundBlur=0,this._dropShadowBlur=0,this._dropShadowOffsetX=0,this._dropShadowOffsetY=0,this._dropShadowColor=Li.transparent,this._innerShadowBlur=0,this._innerShadowOffsetX=0,this._innerShadowOffsetY=0,this._innerShadowSpread=0,this._innerShadowColor=Li.transparent,this._fonts=new Map;try{let i=e.getBoundingClientRect();e.width=i.width*t,e.height=i.height*t}catch{console.log(e.width,t)}this._currentM3Transform=eC,this._currentTransform=new Float32Array(eC)}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await Lee(this.wasmURL),this._surface=kt.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new kt.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(kt.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(kt.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(e){this._currentM3Transform=e,this._currentTransform.set(e)}async loadFont(e,t){let i=await(await fetch(e)).arrayBuffer();this.registerFont(i,t)}registerFont(e,t){if(this._fonts.has(t))return;let i=kt.FontMgr.FromData(e);if(i)this._fonts.set(t,i);else throw new Error("Invalid font data for "+t)}get width(){return this._width}get height(){return this._height}set strokeColor(e){this._paintStroke&&this._paintStroke.setColor(vm(e),kt.ColorSpace.DISPLAY_P3)}set fillColor(e){this._paintFill&&this._paintFill.setColor(vm(e),kt.ColorSpace.DISPLAY_P3)}set lineWidth(e){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?e:e*2)}set strokeMode(e){this._strokeMode=e}set dropShadowBlur(e){this._dropShadowBlur=e}set dropShadowColor(e){this._dropShadowColor=e}set dropShadowOffsetX(e){this._dropShadowOffsetX=e}set dropShadowOffsetY(e){this._dropShadowOffsetY=e}set innerShadowBlur(e){this._innerShadowBlur=e}set innerShadowColor(e){this._innerShadowColor=e}set innerShadowOffsetX(e){this._innerShadowOffsetX=e}set innerShadowOffsetY(e){this._innerShadowOffsetY=e}set innerShadowSpread(e){this._innerShadowSpread=e}set layerBlur(e){this._layerBlur=e}set backgroundBlur(e){this._backgroundBlur=e}clear(){this.ctx?.clear(kt.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new kt.Path}closePath(){let e=this._currentPath;if(e){if(e.isEmpty())return;let t=e.getBounds();(t[3]-t[1]||t[2]-t[0])&&e.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(e,t,i,r,a=0,s=0,n=0,o=0){let l=kt.XYWHRect(e,t,i,r);if(a===0&&s===0&&o===0&&n===0)this.ctx?.clipRect(l,kt.ClipOp.Intersect,!0);else{let h=kt.RRectXY(l,a,a);h[4]=h[5]=a,h[6]=h[7]=s,h[8]=h[9]=n,h[10]=h[11]=o,this.ctx?.clipRRect(h,kt.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let e=Ri.invert(this.currentTransform);this.ctx.concat(e);let t=Ri.translate(Ri.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(t),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(e,t,i=!0){if(this.ctx&&this._currentPath){let r,a=!1;if(i&&this._hasDropShadow()){let s=e.copy();s.setColor(vm(this._dropShadowColor));let n;this._dropShadowBlur>0&&(n=kt.MaskFilter.MakeBlur(kt.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),s.setMaskFilter(n)),this.ctx.save(),this.ctx.clipPath(this._currentPath,kt.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),t(s),this.ctx.restore(),s.delete(),n?.delete()}if(this._backgroundBlur>0&&i){this.ctx.save(),this.ctx.clipPath(this._currentPath,kt.ClipOp.Intersect,!0);let s=kt.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,kt.TileMode.Clamp,null),n=e.copy();n.setImageFilter(s),n.setAlphaf(1);let o=this._currentPath.computeTightBounds();this.ctx.saveLayer(n,o,null,kt.SaveLayerInitWithPrevious),this.ctx.drawColor(e.getColor()),this.ctx.restore(),this.ctx.restore(),n.delete(),s.delete(),a=!0}if(this._layerBlur>0){let s=e.copy();r=kt.MaskFilter.MakeBlur(kt.BlurStyle.Normal,this._layerBlur*this.dpr*(this.camera?.scale??1),!1),s.setMaskFilter(r),t(s),s.delete(),r.delete(),a=!0}if(a||t(e),i&&this._hasInnerShadow()){let s=new kt.Paint;s.setAntiAlias(!0),s.setStyle(kt.PaintStyle.Fill),s.setColor(vm(this._innerShadowColor));let n;this._innerShadowBlur>0&&(n=kt.MaskFilter.MakeBlur(kt.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),s.setMaskFilter(n));let o=this._currentPath.computeTightBounds(),[l,h,c,u]=o,d=c-l,p=u-h;this.ctx.save(),this.ctx.clipPath(this._currentPath,kt.ClipOp.Intersect,!0),this.ctx.saveLayer(s,o,null,kt.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(kt.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+d+Math.abs(this._innerShadowOffsetX*2),2e3+p+Math.abs(this._innerShadowOffsetY*2)),s),s.setBlendMode(kt.BlendMode.Clear),this.ctx.drawPath(this._currentPath,s),this.ctx.restore(),this.ctx.restore(),s.delete(),n?.delete()}}}_paintInner(e,t=!0){if(this.ctx&&this._currentPath&&e){let i=this.ctx,r=this._currentPath;this._applyEffectsToPaint(e,a=>{let s=!1;!t&&this._strokeMode!=="center"&&(i.save(),i.clipPath(r,this._strokeMode==="outside"?kt.ClipOp.Difference:kt.ClipOp.Intersect,!0),s=!0),i.drawPath(r,a),s&&i.restore()},t)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}path(e){this._currentPath?.addPath(kt.Path.MakeFromSVGString(e))}ellipse(e,t,i,r,a,s,n,o){if(!iC([e,t,i,r])||!this._currentPath)return;if(i<0||r<0)throw Error("radii cannot be negative");let l=kt.XYWHRect(e-i,t-r,i*2,r*2);this._currentPath?.addOval(l)}rect(e,t,i,r,a=0,s=0,n=0,o=0){let l=kt.XYWHRect(e,t,i,r);if(iC(l))if(a===0&&s===0&&o===0&&n===0)this._currentPath?.addRect(l);else{let h=kt.RRectXY(l,a,a);h[4]=h[5]=a,h[6]=h[7]=s,h[8]=h[9]=n,h[10]=h[11]=o,this._currentPath?.addRRect(h)}}getHorizontalAlign(e){switch(e){case 2:return kt.TextAlign.Right;case 3:return kt.TextAlign.Center;case 4:return kt.TextAlign.Justify;case 1:default:return kt.TextAlign.Left}}drawTextInner(e,t,i,[r,a,s,n],o,l,h=!0){let c=0,{ctx:u}=this;if(!u)return c;let d=l.copy(),p=l.copy();return p.setAlphaf(0),this._applyEffectsToPaint(d,f=>{t.pushPaintStyle(i,f,p),t.addText(e);let m=t.build();m.layout(s);let g=a;o===2?g+=(n-m.getHeight())/2:o===3&&(g+=n-m.getHeight()),u.drawParagraph(m,r,g),c=m.getHeight(),t.reset(),m.delete()},h),d.delete(),p.delete(),c}drawText(e,t){let i=0,r=this._fonts.get(t.font),{ctx:a,_paintFill:s,_paintStroke:n}=this;if(r&&a){let o=new kt.TextStyle({fontFamilies:[t.font],fontSize:t.fontSize,heightMultiplier:t.lineHeight,letterSpacing:t.letterSpacing}),l=new kt.ParagraphStyle({textStyle:o,textAlign:this.getHorizontalAlign(t.horizontalAlign)}),h=kt.XYWHRect(t.x,t.y,t.width,t.height),c=kt.ParagraphBuilder.Make(l,r);s&&(i=this.drawTextInner(e,c,o,h,t.verticalAlign,s,!0)),n&&(i=this.drawTextInner(e,c,o,h,t.verticalAlign,n,!1)),c.delete()}return{height:i}}render(){this._surface?.flush()}moveTo(e,t){this._currentPath?.moveTo(e,t)}lineTo(e,t){this._currentPath?.lineTo(e,t)}bezierCurveTo(e,t,i,r,a,s){this._currentPath?.cubicTo(e,t,i,r,a,s)}quadraticCurveTo(e,t,i,r){this._currentPath?.quadTo(e,t,i,r)}setTransform(e,t=!1){if(!this.ctx)return;let i=this.ctx.getTotalMatrix(),r=Ri.invert(i);if(r&&this.ctx.concat(r),this.ctx?.scale(this.dpr,this.dpr),this.camera?.enabled&&(this.ctx?.concat(this.camera.worldMatrix),t)){let a=Ri.getScale(this.camera.worldMatrix);this.ctx?.scale(1/a[0],1/a[1])}this.ctx?.concat(e),this.currentTransform=e}transform(e){this.ctx?.concat(e)}setSize(e,t){e===this._width&&t===this._height||(this._width=e,this._height=t,this.canvas.style.width=e+"px",this.canvas.style.height=t+"px",this.canvas.width=e*this.dpr,this.canvas.height=t*this.dpr,this._surface&&(this._surface=kt.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function iC(e){for(let t=0;t<e.length;t++)if(e[t]!==void 0&&!Number.isFinite(e[t]))return!1;return!0}function vm({r:e,g:t,b:i,a:r}){return kt.Color4f(e,t,i,r)}var rC=class{constructor(e,t,i){this.uuid=e,this.data=t,this.enabled=!1,this.color=Li.transparent,this.blurRadius=0,this.offset=[0,0],this.spread=0,this.update(t)}update(e){e.color!==void 0&&(this.color=e.color),e.enabled!==void 0&&(this.enabled=e.enabled),e.blurRadius!==void 0&&(this.blurRadius=e.blurRadius),e.offset!==void 0&&(this.offset=e.offset),e.spread!==void 0&&(this.spread=e.spread)}},aC=class{constructor(e,t,i){this.uuid=e,this.data=t,this.enabled=!1,this.radius=0,this.update(t)}update(e){e.enabled!==void 0&&(this.enabled=e.enabled),e.radius!==void 0&&(this.radius=e.radius)}},Iee=class{constructor(e,t,i){this.uuid=e,this.data=t,this.enabled=!1,this.color=Li.transparent,this.update(t)}update(e){e.enabled!==void 0&&(this.enabled=e.enabled),e.color!==void 0&&(this.color=e.color)}},Bee=class{constructor(e,t,i){this.uuid=e,this.data=t,this.enabled=!1,this.color=Li.transparent,this.thickness=0,this.mode="inside",this.update(t)}update(e){e.enabled!==void 0&&(this.enabled=e.enabled),e.color!==void 0&&(this.color=e.color),e.thickness!==void 0&&(this.thickness=e.thickness),e.mode!==void 0&&(this.mode=e.mode)}},Yr=class extends $r{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.autoClose=!0,this.fill=new Iee(e+"-fill",t.fill,i),this.stroke=new Bee(e+"-stroke",t.stroke,i),this.dropShadow=new rC(e+"-dropShadow",t.dropShadow,i),this.innerShadow=new rC(e+"-innerShadow",t.innerShadow,i),this.backgroundBlur=new aC(e+"-backgroundBlur",t.backgroundBlur,i),this.layerBlur=new aC(e+"-layerBlur",t.layerBlur,i)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Li.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Li.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Li.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Li.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.type===0&&(Fi(e.path,["fill"])?this.fill.update(e.props):Fi(e.path,["stroke"])?this.stroke.update(e.props):Fi(e.path,["dropShadow"])?this.dropShadow.update(e.props):Fi(e.path,["innerShadow"])?this.innerShadow.update(e.props):Fi(e.path,["layerBlur"])?this.layerBlur.update(e.props):Fi(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,t){super.updateState(e,t),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let t=new Yr(this.uuid,this.data,e);return t.parent=void 0,t}},dw=class extends Yr{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.width=0,this.height=0,this.updateState(t,i)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,t){return Cee(e,t,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e)}clone(e){let t=new dw(this.uuid,this.data,e);return t.parent=void 0,t}},Rp=class extends Yr{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.width=0,this.height=0,this.cornerRadius=[0,0,0,0],this.updateState(t,i)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let t=new Rp(this.uuid,this.data,e);return t.parent=void 0,t}},pw=class extends Yr{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this._textHeight=0,this._textHeightDirty=!0,this.width=0,this.height=0,this.updateState(t,i)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Li.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Li.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let t=this.data.textTransform,i=this.data.text.textValue.toString(),r=t===2?i.toUpperCase():t===3?i.toLowerCase():i,{height:a}=e.drawText(r,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:t}){e.font!==void 0&&(this._fontHolder=t.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateFontState(e,t)}clone(e){let t=new pw(this.uuid,this.data,e);return t.parent=void 0,t}},hR=class extends Yr{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.curves=[],this.extremasBBox={min:[0,0],max:[0,0]},this.updateState(t,i)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(r=>kg.extremas(r)),t=[1/0,1/0],i=[-1/0,-1/0];for(let r=0,a=e.length;r<a;r++){let s=e[r];s[0][0]<t[0]&&(t[0]=s[0][0]),s[0][1]<t[1]&&(t[1]=s[0][1]),s[1][0]>i[0]&&(i[0]=s[1][0]),s[1][1]>i[1]&&(i[1]=s[1][1])}return this.extremasBBox.min=[t[0],t[1]],this.extremasBBox.max=[i[0],i[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let i=1,r=this.data.points.length;i<r;i++){let a=this.data.points[i].data,s=this.data.points[i-1].data,n={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(n)}let e=this.data.points[0].data,t=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let i={start:t.position,cp1:t.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(i)}}getCenter(){let[e,t]=this.extremasBBox.min,[i,r]=this.getHalfSize();return[e+i,t+r]}getHalfSize(){let{min:e,max:t}=this.extremasBBox;return[(t[0]-e[0])*.5,(t[1]-e[1])*.5]}innerDraw(e){for(let r=0,a=this.data.points.length;r<a;r++){let s=this.data.points[r].data;if(r===0){let[n,o]=s.position;e.moveTo(n,o)}else{let n=this.data.points[r-1].data,[o,l]=n.controlNext.position,[h,c]=s.controlPrevious.position,[u,d]=s.position,p={start:n.position,cp1:n.controlNext.position,cp2:s.controlPrevious.position,end:s.position};kg.derive(p),e.bezierCurveTo(o,l,h,c,u,d)}}let t=this.data.points[0].data,i=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[r,a]=i.controlNext.position,[s,n]=t.controlPrevious.position,[o,l]=t.position;e.bezierCurveTo(r,a,s,n,o,l)}}updateState(e,t){super.updateState(e,t),this.computeExtremas()}clone(e){let t=new hR(this.uuid,this.data,e);return t.parent=void 0,t}},kg;(e=>{function t(n){let o=n.start,l=n.cp1,h=n.cp2,c=n.end,u=[3*(l[0]-o[0]),3*(l[1]-o[1])],d=[3*(h[0]-l[0]),3*(h[1]-l[1])],p=[3*(c[0]-h[0]),3*(c[1]-h[1])],f={start:u,cp:d,end:p};return n.derivative=f,f.derivative=Ox.derive(f),f}e.derive=t;function i(n,o,l,h=!1){let c=n-2*o+l;if(c!==0){let u=-Math.sqrt(Math.abs(o*o-n*l)),d=-n+o,p=-(u+d)/c,f=-(-u+d)/c;return[p,f]}else if(o!==l&&c===0)return[(2*o-l)/(2*(o-l))];return[]}function r(n){let o=n.derivative??e.derive(n),l=o.start,h=o.cp,c=o.end;return[i(l[0],h[0],c[0]),i(l[1],h[1],c[1])]}e.droot=r;function a(n){let[o,l]=e.droot(n),h=[n.start[0],n.end[0]],c=[n.start[1],n.end[1]];for(let u of o)h.push(e.compute(n,Math.min(1,Math.max(0,u)))[0]);for(let u of l)c.push(e.compute(n,Math.min(1,Math.max(0,u)))[1]);return h.sort((u,d)=>u-d),c.sort((u,d)=>u-d),[[h[0],c[0]],[h[h.length-1],c[c.length-1]]]}e.extremas=a;function s(n,o){if(o===0)return[...n.start];if(o===1)return[...n.end];let l=1-o,h=l*l,c=o*o,u=h*l,d=h*o*3,p=l*c*3,f=o*c;return[u*n.start[0]+d*n.cp1[0]+p*n.cp2[0]+f*n.end[0],u*n.start[1]+d*n.cp1[1]+p*n.cp2[1]+f*n.end[1]]}e.compute=s})(kg||(kg={}));var Ox;(e=>{function t(a){let s=a.start,n=a.cp,o=a.end,l=[2*(n[0]-s[0]),2*(n[1]-s[1])],h=[2*(o[0]-n[0]),2*(o[1]-n[1])],c={start:l,end:h};return c.derivative=Lx.derive(c),a.derivative=c,c}e.derive=t;function i(a){let s=a.derivative??e.derive(a),n=s.start,o=s.end;return[n[0]!==o[0]?n[0]/(n[0]-o[0]):0,n[1]!==o[1]?n[1]/(n[1]-o[1]):0]}e.droot=i;function r(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let n=1-s,o=n*n,l=s*s,h=o,c=n*s*2,u=l;return[h*a.start[0]+c*a.cp[0]+u*a.end[0],h*a.start[1]+c*a.cp[1]+u*a.end[1]]}e.compute=r})(Ox||(Ox={}));var Lx;(e=>{function t(r){let a=r.start,s=r.end,n=[s[0]-a[0],s[1]-a[1]];return r.derivative=n,r.derivative}e.derive=t;function i(r,a){if(a===0)return[...r.start];if(a===1)return[...r.end];let s=r.start,n=r.end;return[s[0]+(n[0]-s[0])*a,s[1]+(n[1]-s[1])*a]}e.compute=i})(Lx||(Lx={}));var Rn=class extends Cn{constructor(e,t,i){super(e,t,i),this.uuid=e,this.width=0,this.height=0,this.clipped=!0,this.background=new Rp(e+"-background",up.defaultData,i),this.background.parent=this,this.updateState(t,i)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,t,i){super.updateWorldMatrix(e,t,i),this.background?.updateWorldMatrix(e,t,i)}draw(e){if(!this.visible)return;e.save();let t=this.width,i=this.height;this.applyTransforms(e),this.background.width=t,this.background.height=i,this.background.draw(e),this.clipped&&e.clipRect(0,0,t,i,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.type===0&&(Fi(e.path,["fill"])?this.fill.update(e.props):Fi(e.path,["stroke"])?this.stroke.update(e.props):Fi(e.path,["dropShadow"])?this.dropShadow.update(e.props):Fi(e.path,["innerShadow"])?this.innerShadow.update(e.props):Fi(e.path,["layerBlur"])?this.layerBlur.update(e.props):Fi(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let t=new Rn(this.uuid,this.data,e);t.parent=void 0;for(let i of this.children)t.add(i.clone(e));return t}},Uee=Ro(uT(),1),gv=class extends Yr{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this._pathBBox=new DOMRect,this.path="",this.updateState(t,i),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),t=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(e),t.setAttribute("d",this.path),e.appendChild(t),this._pathBBox=t.getBBox(),e.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,t){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&t>=this._pathBBox.y&&t<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,t){super.updateState(e,t),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let t=new gv(this.uuid,this.data,e);return t.parent=void 0,t}};function Fee(e,t=1,i=1){if(t<=0||i<=0)return e;let r=(0,Uee.parseSVG)(e).map(a=>{let s={...a};return"x"in s&&(s.x=s.x*t),"y"in s&&(s.y=s.y*i),"x1"in s&&(s.x1=s.x1*t),"x2"in s&&(s.x2=s.x2*t),"y1"in s&&(s.y1=s.y1*i),"y2"in s&&(s.y2=s.y2*i),"rx"in s&&(s.rx=s.rx*t),"ry"in s&&(s.ry=s.ry*i),s});return Nee(r)}function Nee(e){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],i;return e.map(r=>{let a=[];t.forEach(n=>{if(n in r){let o=r[n]*1;a.length&&o>=0&&a.push(","),a.push(o)}});let s=(i===r.code?a[0]<0?"":",":r.code)+a.join("");return i=r.code,s}).join("")}function zee(e,t,i){switch(t.type){case"ellipse2d":return new dw(e,t,i);case"rectangle2d":return new Rp(e,t,i);case"text2d":return new pw(e,t,i);case"vector2d":return new hR(e,t,i);case"path2d":return new gv(e,t,i);case"frame2d":return new Rn(e,t,i);case"group2d":default:return new Po(e,t,i)}}var cR=class{constructor(e,t,i){this.uuid=e,this.data=t,this.group=new Po(cR.GROUP_ID,{...Lg.defaultData},i),this.createChildrenObjects(t.objects,this.group,i)}createObject(e,t,i,r,a,s){let n=zee(e,t,s);n&&(r.add(n),r.children.splice(a,0,r.children.pop()),n.updateWorldMatrix(),i.length>0&&(n instanceof Po||n instanceof Rn)&&this.createChildrenObjects(i,n,s))}createChildrenObjects(e,t,i){let r=0;for(let a of e)this.createObject(a.id,a.data,a.children,t,r,i),r+=1}draw(e){this.group.draw(e)}updateEntityByOp(e,t,i,r){let a=this.find(e);if(a)try{a.updateByOp(t,i,{shared:r})}catch(s){console.error(s)}}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this.group:this.find(e.parent);i!==void 0&&i instanceof Cn&&(this.createObject(e.id,e.data,e.children,i,e.localIndex,t),i.requestRender())}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i!==void 0&&i.parent!==void 0&&i.parent instanceof Cn){let r=i.parent;i.resetBBoxNeedsUpdate(),r?.remove(i),r?.requestRender()}}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i!==void 0){let r=i.parent,a=e.parent===null?this:this.find(e.parent);if(a instanceof Cn||a===this){a.add(i);let s=e.localIndex;a.children.splice(s,0,a.children.pop()),i.updateWorldMatrix(!0,!1,!0),r?.requestRender(),i.requestRender()}i.resetBBoxNeedsUpdate()}}}add(e){this.group.add(e)}remove(e){this.group.remove(e)}traverse(e){this.group.traverse(t=>{t!==this.group&&e(t)})}intersectsChildren(e,t,i,r=!1,a=[]){return this.group.intersectsChildren(e,t,i,r,a,!0)}find(e){return this.group.find(e)}get children(){return this.group.children}project(e,t){return this.group.project(e,t)}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this.group;){let a=r;r=r.parent;let s=r.children.indexOf(a);i.splice(0,0,s)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>qP(i.sortKey,r.sortKey)),t.map(i=>i.entity)}},fw=cR;fw.GROUP_ID="scene2d";function uR({constraints:e,newParentWidth:t,newParentHeight:i,initialParentWidth:r,initialParentHeight:a,objectInitialWidth:s,objectInitialHeight:n,objectInitialPosition:o}){let{horizontalConstraint:l,verticalConstraint:h}=e,c=t-r,u=i-a,d=s,p=n,f=o[0],m=o[1];if(l!==0){if(l===1)f+=c;else if(l===3)f+=c/2;else if(l===2)d=Math.max(1,d+c);else if(l===4){let g=t/r;d*=g,f*=g}}if(h!==0){if(h===1)m+=u;else if(h===3)m+=u/2;else if(h===2)p=Math.max(1,p+u);else if(h===4){let g=i/a;p*=g,m*=g}}return{width:d,height:p,position:[f,m]}}var ane=Ro(uT(),1),sne={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}},kee=Ri.identity(),dR=class{constructor(e,t,i,r){this.uuid=e,this.width=t,this.height=i,this.context=r,this.enabled=!0,this.isScreenSpace=!1,this.isFrameDirty=!1,this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()},this.onFrameOverrideObjectEvent=a=>{if(a.target?.uuid!==void 0){let s=this.frameRoot?.find(a.target.uuid);s&&s.dispatchEvent({...a,target:s})}},this.scene2d=new fw(dt.generateUUID(),ax.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=document.createElement("canvas"),this.renderer=new tC(this.canvas),r.shared.addCanvas(this.uuid,this.canvas),this.textureHolder=r.shared.canvas(this.uuid),this.promise=this.init()}async init(){this.renderer instanceof tC&&(this.renderer.wasmURL=FD.skiaWasmUrl),await this.renderer.init()}render(){this.isFrameDirty&&(this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.textureHolder?.setNeedsUpdate(!0),this.isFrameDirty=!1)}updateEntity2DByOp(e,t,i,r){this.scene2d.updateEntityByOp(e,t,i,r),this.applySize()}updateTreeByOp(e,t){this.scene2d.updateTreeByOp(e,t),this.applySize()}applyOverrides(e){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let t=e?.width??this.width,i=e?.height??this.height;this.frameOverride.width=t,this.frameOverride.height=i,this.frameOverride.localMatrix=kee,this.isScreenSpace&&(this.frameOverride.fill.color=Li.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:t,height:i},pR({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(e){let t=e?.width??this.width,i=e?.height??this.height;this.width=t,this.height=i,this.renderer.dpr=this.isScreenSpace?window.devicePixelRatio:Math.floor(2048/Math.max(t,i)),this.renderer.setSize(t,i),this.textureHolder?.dispose(),this.applyOverrides(e),this.frameOverride?.requestRender()}applyFrame(e){let t=this.context.scene.find2D(e);if(!(!t||!(t instanceof Rn)))return this.disposeFrameOverride(),this.frameRoot=t,this.frameOverride=t.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.textureHolder?.dispose(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(i=>{i.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(i=>{i.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),t}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(e){return this.scene2d.find(e)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(e=>{e.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(e=>{e.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function pR({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:a,initialParentHeight:s}){if(e instanceof Rn&&t instanceof Rn||e instanceof Po&&t instanceof Po)for(let n=0,o=e.children.length;n<o;n++){let l=e.children[n],h=t.children[n];l&&h&&l.uuid===h.uuid&&jee({objectOverride:l,objectRoot:h,newParentWidth:i,newParentHeight:r,initialParentWidth:a,initialParentHeight:s})}}function Vee(e){if(Ix(e))return[e.width,e.height];if(e instanceof gv){let[t,i]=e.getHalfSize();return[t*2,i*2]}else if(e instanceof Po){let[t,i]=e.recursiveBBox.getHalfSize();return[t*2,i*2]}return[0,0]}function jee({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:a,initialParentHeight:s}){let[n,o]=Vee(t),{width:l,height:h,position:c}=uR({constraints:e.data,newParentWidth:i,newParentHeight:r,initialParentWidth:a,initialParentHeight:s,objectInitialWidth:n,objectInitialHeight:o,objectInitialPosition:t.position});if(e.position=c,e.data={...e.data,position:c},e.states)for(let u in e.states)Gee({stateId:u,objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:a,initialParentHeight:s});if(Ix(e)||e instanceof Po)Ix(e)&&(e.width=l,e.height=h,e.data={...e.data,width:l,height:h}),pR({objectOverride:e,objectRoot:t,newParentWidth:l,newParentHeight:h,initialParentWidth:n,initialParentHeight:o});else if(e instanceof gv){let u=t,d=n!==0?l/n:1,p=o!==0?h/o:1;e.path=Fee(u.path,d,p),e.data={...e.data,path:e.path}}}function Gee({stateId:e,objectOverride:t,objectRoot:i,newParentWidth:r,newParentHeight:a,initialParentWidth:s,initialParentHeight:n}){let o=t.states?.[e],l=i.states?.[e];if(o&&l){let{width:h,height:c,position:u}=uR({constraints:t.data,newParentWidth:r,newParentHeight:a,initialParentWidth:s,initialParentHeight:n,objectInitialWidth:yh.isResizeable(l)?l.width:0,objectInitialHeight:yh.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[e],{position:u}),yh.isResizeable(o)&&Object.assign(t.states[e],{width:h,height:c})}}function Ix(e){return e instanceof Rp||e instanceof Rn||e instanceof dw||e instanceof pw}var Xr=class extends Wb(So){constructor(e,t,i){super(),this.data=t,this.bgColor=new ca(1,1,1,1),this.fog=null,this.backupFog=new VT(16777215,.1,2e3),this.fogUseBGColor=!1,this.isActive=!1,this.aoColor=new _t,this.penumbraSizeArrayCache=null,this.super_Entity(e,t),this.personalCamera=new _a(Uu,{...lp.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new u6(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene?this.uiScene=new fw((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:i.shared}):t.uiFrame&&this.createUICanvas(t.uiFrame,i)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,t){this.uiCanvas=new dR(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=Ba(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(t=>{t instanceof Ph&&t.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof zu)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&yee(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let i=this.scene;i.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ba(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=Ba(e.aoColor,t))}updateByOp(e,t,i,r){let a=this.data.uiFrame;super.updateByOp(e,t,i,r);let s=t;Fi(e.path,["fog"])?this.updateFog(s.fog,i.shared):Fi(e.path,["ao"])?this.updateAo(s.ao,i.shared):Fi(e.path,["ambient"])?this.updateAmbientLight(s.ambient,i.shared):Fi(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||a!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,i)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(Ba(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof sR&&i.visible&&e<3&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize,e+=1),i instanceof nR&&i.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+t]=i.data.penumbraSize,t+=1)})}raycastWithClones(e){let t=[],i=r=>{for(let a of r.children){let s=a.cloner;ui.is(a)&&(a.visible||s?.object.data.visible)&&((Hs(a)||Ax(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),Bx(a,e,t,!0)),i(a))}};return i(this),t}updateEntity2DByOp(e,t,i,r){this.uiCanvas?.updateEntity2DByOp(e,t,i,r)}},Hee=class extends hw(m6,rR){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let a=new O(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new O(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),n=new sr(a,s),o=new ag(n,new _t(16755200));o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let e in this.gizmos){let t=this.gizmos[e];if(t instanceof ag){let i=this.shadow.camera,r=new O(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),a=new O(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);t.box.set(r,a),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}},Wee=class extends ba{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?$b(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},mw=class extends ba{constructor(e,t,i){super(e,t,i),this._shapeId=null,this._context=i}updateState(e,t){super.updateState(e,t),this.updateShape()}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let r in e)typeof e[r]=="string"&&(e[r]=this._context.shared.getVariable(e[r],[this.uuid,"geometry","extrusion","shape",r]));let t;if(e.type==="Custom"){let r=e.shapeId;if(r!==this._shapeId&&this.detachShape(),r){this._shapeId=r;let a=this._context.scene.find(r);a?.data&&(a.attachedPaths.add(this),t=a.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let r;switch(e.type){case"Rectangle":r=Jb;break;case"Ellipse":r=Zb;break;case"Polygon":r=eD;break;case"Star":r=tD;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=r.create({parameters:e}).userData.shape}let i=this.geometry;t&&i.inputs&&(i.inputs.shapeData=t,i.build(),this.attachedSurfaceCloners.forEach(r=>r.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,t){return super.updateTransformState(e,t)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?$b(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},ou=class extends ku(nh,Pp){constructor(e,t,i){super(),t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,i)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let i=Pg.getComponentData({scene:t.scene.data,shared:t.shared.data},e.component);if(i){let r,a;for(let s of fl.rootOverrideProps)e[s]===void 0?(r===void 0&&(r={...e}),r[s]=i.data[s]):(a===void 0&&(a={}),a[s]=e[s],r===void 0&&(r={...e}),r[s]=_l.apply(i.data[s],e[s]));return this.overrideData=a,r}else return{...ha.defaultData,...e,...Ao(ha.defaultData,fl.rootOverrideProps)}}updateByOp(e,t,i,r){let a;if(this.isInstanceRoot&&!r){if(t=this.transformAssignData(t,i),e.type===0&&e.path.length===0&&this.component)for(let s of fl.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&fl.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:t[s]}})}}super.updateByOp(a??e,t,i,r)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let i=e.scene.find(t.component)??null,r=!1;if(i!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(ui.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),gw(s),a+=1;else break;this.children.splice(0,a)}r=!0}if(i){let a={};fR(e,[this.uuid],t.overrides,this,i,i,0,r,a);for(let s of this.children)if(ui.is(s)){let n=s.data;n.type==="Empty"&&n.animations&&s.traverseEntity(o=>{if(o instanceof ba&&o.isSkinnedMesh){let l=o.dataPatched;if(l.bones&&l.boneInverses){let h=l.bones.map(d=>e.scene.find(a[d])),c=l.boneInverses.map(d=>new je().fromArray(d)),u=new nb(h,c);o.bind(u,o.bindMatrix)}}else o.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function gw(e){if(e.component){let t=e.component.instances.indexOf(e);t>=0&&e.component.instances.splice(t,1);for(let i of e.children)ui.is(i)&&gw(i)}}function sC(e,t,i,r){return e.component===t&&GP(e.identity,r)?e.overrideData===i?2:1:0}function fR(e,t,i,r,a,s,n,o,l){if(n>50)return!1;if(r.component!==a){if(r.component){let c=r.component.instances.indexOf(r);c>=0&&r.component.instances.splice(c,1)}a.instances.find(c=>c===r)||a.instances.push(r),r.component=a}a instanceof ou&&a.isInstanceRoot&&a.expandInstanceChildren(e);let h=0;for(let c of a.children)if(ui.is(c)){let u=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],d=Eg.resolve(i,u,1);d!=null&&!(d instanceof Tr)&&(Object.setPrototypeOf(d,Tr.prototype),console.error("wrong prototype"));let p=null,f;if(!o){let m=r.children[h];if(p=ui.is(m)?m:null,p!==null){let g=sC(p,c,d,u);f=g>=1?p.stateSelection:void 0,g!==2&&(p=null)}if(p===null&&(p=e.scene.findInstance(u)??null,p!==null)){let g=sC(p,c,d,u);if(f=g>=1?p.stateSelection:void 0,g!==2)p=null;else{let v=p.parent.children.indexOf(p);p.parent.children.splice(v,1),r.children.splice(h,0,p),p.parent===r?v<=h&&console.error("not possible"):(p.parent=r,p.matrixWorldNeedsUpdate=!0,p.resetBBoxNeedsUpdate(),p.updateVisible(),e.pendingDeletes.delete(p))}}}if(p===null){let m=d?_l.apply(c.data,d):c.data;Mh.is(m.type)&&(m={...m,type:"Empty"}),p=gl.createEntity(u,m,e),p.overrideData=d,r.add(p),r.children.splice(r.children.length-1,1),r.children.splice(h,0,p),p.updateState(p.data,e),f&&p.changeSelectedState(f,e),e.scene.registerInstanceAndSetUuid(p)}if(p.isBone){let m=p.identity[p.identity.length-1];l[m]=p.uuid}h+=1,fR(e,t,i,p,c,s,n+1,o,l)}if(!o){let c=h;for(;;){let u=r.children[h];if(ui.is(u))e.pendingDeletes.add(u);else break;h+=1}r.children.splice(c,h-c)}return!0}var qee=class extends ku(jT,Pp){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(e,t){this.updateState_Entity(e,t)}},ya=class extends ba{constructor(e,t,i){super(e,t,i),this.onBeforeRender=()=>{this.uiCanvas.render()},this.uiCanvas=new dR(e+"-canvas",t.geometry.width,t.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(e,t,i){super.updateByPatchedOpGeometry(e,t,i),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,i.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,i.shared))}applySize(e,t){let i=e?.width??this.dataPatched.geometry.width,r=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),this.applyGeometryParametersFromFrame(t)}applyFrame(e,t){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(t),this.applyMaterialParametersFromFrame({shared:t})}applyGeometryParametersFromFrame(e){let t=this.frame;t&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=gp(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let t=this.frame;if(t){let i=t.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),this.material.reset(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,t,i,r){this.uiCanvas.updateEntity2DByOp(e,t,i,r),e===this.frameId&&t.type===0&&(t.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):Fi(t.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.applySize({width:e.width,height:e.height},t)}},Xee=class{constructor(e,t,i){this.variables=[],this.currentTextureIndex=0;let r=ir,a=new So,s=new Rh;s.position.z=1;let n={passThruTexture:{value:null}},o=c(d(),n),l=new xr(new Pl(2,2),o);a.add(l),this.setDataType=function(p){return r=p,this},this.addVariable=function(p,f,m){let g=this.createShaderMaterial(f),v={name:p,initialValueTexture:m,material:g,dependencies:null,renderTargets:[],wrapS:null,wrapT:null,minFilter:bi,magFilter:bi};return this.variables.push(v),v},this.setVariableDependencies=function(p,f){p.dependencies=f},this.init=function(){if(i.capabilities.isWebGL2===!1&&i.extensions.has("OES_texture_float")===!1)return"No OES_texture_float support for float textures.";if(i.capabilities.maxVertexTextures===0)return"No support for vertex shader textures.";for(let p=0;p<this.variables.length;p++){let f=this.variables[p];f.renderTargets[0]=this.createRenderTarget(e,t,f.wrapS,f.wrapT,f.minFilter,f.magFilter),f.renderTargets[1]=this.createRenderTarget(e,t,f.wrapS,f.wrapT,f.minFilter,f.magFilter),this.renderTexture(f.initialValueTexture,f.renderTargets[0]),this.renderTexture(f.initialValueTexture,f.renderTargets[1]);let m=f.material,g=m.uniforms;if(f.dependencies!==null)for(let v=0;v<f.dependencies.length;v++){let x=f.dependencies[v];if(x.name!==f.name){let b=!1;for(let _=0;_<this.variables.length;_++)if(x.name===this.variables[_].name){b=!0;break}if(!b)return"Variable dependency not found. Variable="+f.name+", dependency="+x.name}g[x.name]={value:null},m.fragmentShader=`
6991
+ `,Sy=new vi({vertexShader:xee,fragmentShader:bee,uniforms:{depthContrast:{value:1}}}),qM=new Ki,wee=class extends kT{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new ae,this.pipeline=new pee(this),this.dummyCamera=new _a,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.isXRCopyPassSet=!1,this.clear=(a=!0,s=!0,n=!0)=>{let o=this.getContext(),l=0;a&&(l|=o.COLOR_BUFFER_BIT),s&&(l|=o.DEPTH_BUFFER_BIT),n&&(l|=o.STENCIL_BUFFER_BIT),o.clear(l),o.clearBufferfv(o.COLOR,1,[0,0,0,1])},this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=Yx,Di.enabled=!1,this.useLegacyLights=!0,this.dummyCamera.matrixAutoUpdate=!1,this.domElement.removeAttribute("data-engine");let r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(a){console.warn(a)}this.setPixelRatio=a=>{this._pixelRatio!==a&&(this._pixelRatio=a,t(a))},this.setSize=(a,s,n=!0)=>{(this.viewportWidth!==a||this.viewportHeight!==s)&&(this.viewportWidth=a,this.viewportHeight=s,i(a,s,n),this.normalRenderTarget?.setSize(a*this._pixelRatio,s*this._pixelRatio),this._resizeTransmission(a,s),this.transmissionDepthTarget?.setSize(a*this._pixelRatio/2,s*this._pixelRatio/2),this.pipeline.resize(a,s,n))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new _i(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Wt,magFilter:Wt,wrapS:qi,wrapT:qi,depthBuffer:!1}))}_resizeTransmission(e,t){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),t*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,t*this._pixelRatio/1)}get hdTransmission(){return Rt.transmissionLod.value===1}set hdTransmission(e){Rt.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new _i(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:cl,magFilter:Wt,wrapS:qi,wrapT:qi,depthBuffer:!1}),this.transmissionDepthTarget=new _i(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:bi,magFilter:bi,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new _i(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:bi,magFilter:bi,type:ir,depthTexture:new Ah(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t,i){this.normalRenderTarget&&(this.setClearColor(0),i.layers.enable(8),i.layers.disable(0),i.layers.disable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),i instanceof _a?Sy.uniforms.depthContrast.value=(i.far-i.near)/1e4:Sy.uniforms.depthContrast.value=1,t.overrideMaterial=Sy,this.render(t,i),this.setClearColor(t.bgColor,t.bgColor.a),this.setRenderTarget(null),t.overrideMaterial=e.wireframeState?Ux:null,i.layers.enable(0),i.layers.enable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,t,i=1){this.dummyCamera.updateCameraState(t.dataPatched),this.dummyCamera.matrix.copy(t.matrixWorld);let r=t.height,a=t.width,s=this.viewportWidth/this.viewportHeight;a<r?a=r*s:r=a/s,this.dummyCamera.setViewplaneSize(a,r);for(let n=0;n<i;n++)this.renderSplineScene(e,this.dummyCamera)}renderSplineScene(e,t,{sceneHelpers:i=void 0,sceneHelpersOnTop:r=void 0,overrideTransmission:a=void 0,overrideNormal:s=void 0}={}){let n=e instanceof yw?e.activePage:e,o=n.visible;n.visible=!0;let l=n.scene;this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(t)),this.setClearColor(n.bgColor,n.bgColor.a),n.penumbraSizeArray.forEach((d,p)=>{Rt.penumbraSize.value[p]=d}),Rt.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Rt.resolution.value.set(this.resolution.x,this.resolution.y):Rt.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),s!==void 0?(Rt.normalRenderTarget.value=s,Rt.normalRenderTargetDepth.value=qM):l.needsNormal()&&(this.createNormalRenderTarget(),Rt.normalRenderTarget.value=this.normalRenderTarget.texture,Rt.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(l,n,t));let h=n.data.ao,c=h.occlusion;c&&(this.createAORenderTarget(),Rt.aoRenderTarget.value=this.aoRenderTarget.texture),Rt.aoEnabled.value=c,this.pipeline.setAmbientOcclusionParams(h.occlusion,h.radius,h.bias,n.aoColor,n.fog!==null,n.backupFog.near,n.backupFog.far,h.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture),this.pipeline.isUIOverlayEnabled&&n.uiCanvas?.enabled&&n.uiCanvas.texture&&n.uiCanvas.texture.image.width>0?((n.uiCanvas.width!==this.viewportWidth||n.uiCanvas.height!==this.viewportHeight)&&n.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight}),n.uiCanvas.render(),this.pipeline.uiOverlayPass.uiCanvas=n.uiCanvas,this.pipeline.uiOverlayPass.enabled=!0,this.pipeline.uiOverlayPass.setResolution(this.domElement.width,this.domElement.height,window.devicePixelRatio),this.pipeline.updateRenderToScreen()):(this.pipeline.uiOverlayPass.enabled=!1,this.pipeline.updateRenderToScreen());let u=!1;if(a!==void 0)Rt.transmissionRenderTarget.value=a,Rt.transmissionRenderTargetDepth.value=qM,this.pipeline.setTransmissionPassEnabled(!1);else{let d=l.needsTransmission();d&&(this.transmissionRenderTarget===void 0&&(u=!0),this.createTransmissionRenderTarget(),Rt.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Rt.aspectRatio.value=SK(this.viewportWidth,this.viewportHeight),Rt.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(d)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=n,this.pipeline.camera=t,u&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==n.postprocessing&&(this.pipeline.updatePostprocessing(n.postprocessing),!i&&!r&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),n.overrideMaterial=l.wireframeState?Ux:null,this.pipeline.render(),Rt.frameIndex.value=(Rt.frameIndex.value+1)%16,t instanceof _a&&t.copyHistory(),n.visible=o}renderFromSceneForSceneTransitionPass(e,t,i){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,t),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=i,this.sceneTransitionTimeRemaining=i,this.pipeline.renderToScreen=!0;let r=this.pipeline.sceneTransitionPass.uniforms;r.uDPR.value=window.devicePixelRatio,r.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},iR=class extends Cp(I6){constructor(e,t=15,i=7829367){super(e,t,i),this.object=e,this.added=!1,this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Tp(this.object,iR.geometryHelper,e,t)}},rR=class extends Cp(L6){constructor(e,t=15,i=4473924){super(e,t,i),this.object=e,this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Tp(this.object,rR.geometryHelper,e,t)}},Dx=class extends Cp(O6){constructor(e,t=4473924){super(e,t),this.object=e,this.matrix=e.matrixWorld,this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Tp(this.object,Dx.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Dx._vector,t=this.object.distance?this.object.distance:1e3,i=t*Math.tan(this.object.angle);this.cone.scale.set(i,i,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let a=0,s=this.cone.material.length;a<s;a++)this.cone.material[a].color.set(r);else this.cone.material.color.set(r)}}},aR=Dx;aR._vector=new O;function _ee(e,t){e.shadow.camera.right=t/2,e.shadow.camera.left=-t/2,e.shadow.camera.top=t/2,e.shadow.camera.bottom=-t/2,e.shadow.needsUpdate=!0}var sR=class extends hw(v6,iR){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let a=new rg(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof rg&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t);let i=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;e.size!==void 0&&_ee(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),i&&this.update()}},XM=new O,YM=new O,QM=new zt,nR=class extends hw(p6,aR){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=dt.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let a=new rg(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof rg&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),YM.setFromMatrixPosition(this.matrixWorld),QM.setFromRotationMatrix(this.matrixWorld),XM.copy(this.up).applyQuaternion(QM).negate().multiplyScalar(this.distance),this.target.position.copy(YM).add(XM),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};function See(e){let t=(e[0][0]+e[1][1])/2,i=(e[0][0]-e[1][1])/2,r=(e[1][0]+e[0][1])/2,a=(e[1][0]-e[0][1])/2,s=Math.sqrt(t*t+a*a),n=Math.sqrt(i*i+r*r),o=s+n,l=s-n,h=Math.atan2(r,i),c=Math.atan2(a,t),u=(c-h)/2,d=(c+h)/2,p=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]],f=[[o,0],[0,l]],m=[[Math.cos(u),Math.sin(u)],[-Math.sin(u),Math.cos(u)]];return p[0][0]*=-1,p[0][1]*=-1,m[0][0]*=-1,m[1][0]*=-1,[p,f,m]}function Im(e,t){return[[e[0][0]*t[0][0]+e[0][1]*t[1][0],e[0][0]*t[0][1]+e[0][1]*t[1][1]],[e[1][0]*t[0][0]+e[1][1]*t[1][0],e[1][0]*t[0][1]+e[1][1]*t[1][1]]]}function KM(e){return[[e[0][0],e[1][0]],[e[0][1],e[1][1]]]}function Aee(e){let[t,i,r]=See(e),a=Im(t,KM(r)),s=Im(Im(r,i),KM(r)),n=Math.atan2(a[1][0],a[0][0]),o=[s[0][0],s[1][1]],l=[s[0][1]/s[1][1],s[1][0]/s[0][0]];return{rotation:n,scale:o,shear:l}}function Eee({rotation:e,scale:t,shear:i}){let r=Math.cos(e),a=Math.sin(e),s=[[r,-a],[a,r]],n=[[t[0],i[0]*t[1]],[i[1]*t[0],t[1]]],o=Im(s,n);return[o[0][0],o[1][0],o[0][1],o[1][1]]}var Ri;(e=>{function t(){return[1,0,0,0,1,0,0,0,1]}e.identity=t;function i(A,S=e.identity()){for(let P=0,L=A.length;P<L;P++)S[P]=A[P];return S}e.copy=i;function r(A,S,P,L,E,T){return e.setAbcdef(e.identity(),A,S,P,L,E,T)}e.create=r;function a(A,S,P,L,E,T,B){return A[0]=S,A[1]=L,A[2]=T,A[3]=P,A[4]=E,A[5]=B,A}e.setAbcdef=a;function s(A,S){let[P,L,E,T,B,V]=o(A),[I,H,q,X,Y,ie]=o(S),ce=I*P+H*E,de=I*L+H*T,ue=q*P+X*E,re=q*L+X*T,se=Y*P+ie*E+B,he=Y*L+ie*T+V;return e.create(ce,de,ue,re,se,he)}e.append=s;function n(A,S){let[P,L,E,T,B,V]=o(A),[I,H,q,X,Y,ie]=o(S),ce=P,de=L,ue=E,re=T;(I!==1||H!==0||q!==0||X!==1)&&(ce=P*I+L*q,de=P*H+L*X,ue=E*I+T*q,re=E*H+T*X);let se=B*I+V*q+Y,he=B*H+V*X+ie;return e.create(ce,de,ue,re,se,he)}e.prepend=n;function o(A){return[A[0],A[3],A[1],A[4],A[2],A[5]]}e.getAbcdef=o;function l(A){let[S,P,L,E,T,B]=e.getAbcdef(A),V=S*E-P*L,I=E/V,H=-P/V,q=-L/V,X=S/V,Y=(L*B-E*T)/V,ie=-(S*B-P*T)/V;return e.create(I,H,q,X,Y,ie)}e.invert=l;function h([A,S],P){let[L,E,T,B,V,I]=e.getAbcdef(P);return[L*A+T*S+V,E*A+B*S+I]}e.apply=h;function c(A,S){let[P,L,E,T,B,V]=e.getAbcdef(S),I=1/(P*T+E*-L),[H,q]=A;return[T*I*H+-E*I*q+(V*E-B*T)*I,P*I*q+-L*I*H+(-V*P+B*L)*I]}e.applyInverse=c;function u(A,S,P=S){let[L,E,T,B,V,I]=e.getAbcdef(A);return e.setAbcdef(A,L*S,E*P,T*S,B*P,V*S,I*P),A}e.scale=u;function d(A,S){let P=Math.cos(S),L=Math.sin(S),[E,T,B,V,I,H]=e.getAbcdef(A);return e.setAbcdef(A,E*P-T*L,E*L+T*P,B*P-V*L,B*L+V*P,I*P-H*L,I*L+H*P),A}e.rotate=d;function p(A,S,P){let[L,E]=P,T=e.translate(A,-L,-E);return T=e.rotate(T,S),T=e.translate(T,L,E),T}e.rotateAround=p;function f(A,S,P){let[L,E,T,B,V,I]=e.getAbcdef(A);return e.setAbcdef(A,L,E,T,B,V+S,I+P),A}e.translate=f;function m(A,S,P){let[L,E,T,B]=e.getAbcdef(A);return e.setAbcdef(A,L,E,T,B,S,P),A}e.setTranslate=m;function g(A,S,P){let[L,E,T,B]=e.getAbcdef(A);return e.setAbcdef(A,L,E,T,B,S,P),A}e.setPosition=g;function v(A){let[S,P,L,E]=e.getAbcdef(A),T=Math.sqrt(S*S+P*P),B=Math.sqrt(L*L+E*E);return[T,B]}e.getScale=v;function x(A){let[,,,,S,P]=e.getAbcdef(A);return[S,P]}e.getPosition=x;function b(A,S){return e.decompose(A,S).rotation}e.getRotation=b;function _(A,S){let[P,L,E,T,B,V]=e.getAbcdef(A),{rotation:I,scale:H,shear:q}=Aee([[P,E],[L,T]]);return{position:[B+(S[0]*P+S[1]*E)-S[0],V+(S[0]*L+S[1]*T)-S[1]],scale:H,rotation:I,shear:q,pivot:S}}e.decompose=_;function M(A,S,P,L,E=[0,0]){let[T,B]=A,[V,I]=L,[H,q,X,Y]=Eee({rotation:P,scale:S,shear:E}),ie=T-(V*H+I*X)+V,ce=B-(V*q+I*Y)+I;return e.create(H,q,X,Y,ie,ce)}e.compose=M})(Ri||(Ri={}));var Mee=Math.PI/180,rne=180/Math.PI;function Cee(e,t,i,r,a,s){let n=e-i,o=t-r;return n*n/(a*a)+o*o/(s*s)<=1}function Tee(e){return e*Mee}function Pee(e){return{all:e=e||new Map,on:function(t,i){var r=e.get(t);r?r.push(i):e.set(t,[i])},off:function(t,i){var r=e.get(t);r&&(i?r.splice(r.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var r=e.get(t);r&&r.slice().map(function(a){a(i)}),(r=e.get("*"))&&r.slice().map(function(a){a(t,i)})}}}var $r=class{constructor(e,t,i){this.uuid=e,this.data=t,this.localMatrix=Ri.identity(),this.worldMatrix=Ri.identity(),this.ignoreCameraZoom=!1,this.visible=!0,this._singleBBox=new Rx,this._recursiveBBox=new Rx,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.stateSelection=null,this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this.name="",this.position=[0,0],this.scale=[1,1],this.rotation=0,this.shear=[0,0],this.emitter=Pee(),this.dpr=i.dpr??1,this.dataPatched=t}project(e,t){let i=this.worldMatrix;return t&&(i=Ri.append(t.worldMatrix,i)),Ri.applyInverse(e,i)}intersects(e,t,i,r=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([e,t],i),r)}intersectsInLocalSpace(e,t,i=!1){let{min:r,max:a}=i?this.recursiveBBox:this.singleBBox;return e>=r[0]&&e<=a[0]&&t>=r[1]&&t<=a[1]}applyTransforms(e){e.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=Ri.compose(this.position,this.scale,Tee(this.rotation),yh.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(e,t,i){let r=this.parent;t&&r!==null&&r!==void 0&&r.updateWorldMatrix(e,!0,!1),e&&this.updateLocalMatrix(),this.parent?this.worldMatrix=Ri.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=Ri.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return yh.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(e=>{e.resetBBoxNeedsUpdateSelf()})}updateTransformState(e){let t=!1;e.position!==void 0&&(t=!0,this.position=e.position),e.rotation!==void 0&&(t=!0,this.rotation=e.rotation),e.scale!==void 0&&(t=!0,this.scale=e.scale),e.shear!==void 0&&(t=!0,this.shear=e.shear),t&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(e,t,i){e.type===0&&e.props.visible!==void 0&&(this.visible=e.props.visible),this.data=t,this.data=t;let r=e,a=Fi(e.path,["states","*"]);if(a!==null){if(e.type===0){let[s]=a;if(this?.stateSelection===s){let n={...e.props};if(delete n.name,Object.values(e.props).some(o=>o===void 0)){let o=this.data;if(o!==void 0){let l=na.zoom(o,e.path.slice(2));if(l)for(let h in e.props)e.props[h]===void 0&&h in l&&(n[h]=l[h])}}r={...e,props:n,path:e.path.slice(2)}}}}else if(e.type===0){let s=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(s!==void 0){if(e.props.name!==void 0&&s.name){let{name:o,...l}=s;s=l}let n=na.removeOverridden(e.path,e.props,s);r={...e,props:n}}}this.updateByPatchedOpBase(r,uh.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i)}changeSelectedState(e,t,i=!1){if(!(this.data.states.length===0&&!i)){for(let r of this.data.states)uh.toOps(this.data,r.data).forEach(a=>{let s=fg.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,t)});if(e!==null){let r=this.data.states.data(e);r&&(this.dataPatched=uh.patch(this.data,r),uh.toOps(this.data,r).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,t)}))}i&&this.updateTransformState(this.dataPatched),this.stateSelection=e}}updateState(e,t){e.name!==void 0&&(this.name=e.name),e.visible!==void 0&&(this.visible=e.visible),this.updateTransformState(e)}updateByPatchedOpBase(e,t,i){this.dataPatched=t,this.updateByPatchedOp(e,t,i)}updateByPatchedOp(e,t,i){e.path.length===0&&e.type===0&&this.updateState(e.props,i),this.requestRender()}traverseFrameAncestors(e){this.traverseAncestors(t=>{t.data.type==="frame2d"&&e(t)})}traverseAncestors(e){let t=this.parent;for(;t;)e(t),t=t.parent}requestRender(){this.traverseFrameAncestors(e=>{e.requestRender()})}clone(e){let t=new $r(this.uuid,this.data,e);return t.parent=void 0,t}addEventListener(e,t){this.emitter.on(e,t)}removeEventListener(e,t){this.emitter.off(e,t)}dispatchEvent(e){this.emitter.emit(e.type,{...e,target:e.target??this})}traverseSortNextHelper(){let e=this.parent;if(e){let t=e.children;if(t){let i=t.indexOf(this)+1;return t[i]?t[i]:e.traverseSortNextHelper()}}}sortNext(){let e=this.children;return e&&e.length>0&&e[0]?e[0]:this.traverseSortNextHelper()}isDescendantOf(e){e instanceof $r&&(e=e.uuid);let t=this;for(;t.parent;){if(t.parent.uuid===e)return!0;t=t.parent}return!1}},Cn=class extends $r{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.context=i,this.children=[]}add(e){e.parent&&e.parent instanceof Cn&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=void 0)}traverse(e){let t=e(this);if(t!==!0)for(let i of this.children)i instanceof Cn?i.traverse(e):t=e(i)}intersectsChildren(e,t,i,r=!1,a=[],s=!1){for(let n of this.children){let o=n instanceof Po;if(n instanceof Cn&&!o&&s&&n.intersectsChildren(e,t,i,r,a,!1),n.intersects(e,t,i,o)&&(a.push(n),r))break}return a}updateWorldMatrix(e,t,i){if(super.updateWorldMatrix(e,t,i),i&&this.children)for(let r of this.children)r.updateWorldMatrix(e,!1,!0)}find(e){let t;return this.traverse(i=>{i.uuid===e&&(t=i)}),t}innerDrawChildren(e){for(let t=this.children.length-1;t>=0;t--)this.children[t].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let t=new Cn(this.uuid,this.data,e);t.parent=void 0;for(let i of this.children)t.add(i.clone(e));return t}},Po=class extends Cn{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.updateState(t,i)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let t=new Po(this.uuid,this.data,e);t.parent=void 0;for(let i of this.children)t.add(i.clone(e));return t}};function Dee(e,t){let[[i,r],[a,s]]=e,[[n,o],[l,h]]=t,c=(i-a)*(o-h)-(r-s)*(n-l);if(c===0)return!1;let u=((i-n)*(o-h)-(r-o)*(n-l))/c,d=-((i-a)*(r-o)-(r-s)*(i-n))/c;return u>=0&&u<=1&&d>=0&&d<=1}var oR=[[-1,1],[-1,-1],[1,-1],[1,1]],ZM=(e,t,i)=>{let r=e.getCenter(),a=e.getHalfSize(),s=Ri.append(t,e.worldMatrix);a[0]===0&&a[1]===0?i.push(Ri.apply(r,s)):oR.forEach(n=>{let o=[n[0]*a[0]+r[0],n[1]*a[1]+r[1]];i.push(Ri.apply(o,s))})},Rx=class{constructor(){this.matrix=Ri.identity(),this.min=[1/0,1/0],this.max=[-1/0,-1/0],this.vertices=[],this.edges=[]}setFromObjectSize(e,t=!1){e.updateWorldMatrix(),this.makeEmpty(),Ri.copy(e.worldMatrix,this.matrix);let i=Ri.invert(e.worldMatrix);this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];i===!0&&e instanceof Cn?e.traverse(a=>{a.visible&&ZM(a,t,r)}):ZM(e,t,r),this.setFromPoints(r)}getCenter(){let[e,t]=this.min,[i,r]=this.getHalfSize();return Ri.apply([e+i,t+r],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(e){this.makeEmpty();for(let t of e)this.expandByPoint(t)}expandByPoint(e){this.min=[Math.min(this.min[0],e[0]),Math.min(this.min[1],e[1])],this.max=[Math.max(this.max[0],e[0]),Math.max(this.max[1],e[1])]}computeVertices(){let[e,t]=this.getHalfSize(),i=this.getCenter(),[r,a,s,n]=Ri.getAbcdef(this.matrix),o=Ri.create(r,a,s,n,i[0],i[1]);this.vertices=oR.map(([l,h])=>Ri.apply([l*e,h*t],o))}computeEdges(){this.edges=[];for(let e=0,t=this.vertices.length;e<t;++e)this.edges.push([this.vertices[e],this.vertices[(e+1)%t]])}project(e,t){let i=this.matrix;return t&&(i=Ri.append(t.worldMatrix,i)),Ri.applyInverse(e,i)}intersects(e,t,i){return this.intersectsInLocalSpace(...this.project([e,t],i))}intersectsInLocalSpace(e,t){let{min:i,max:r}=this;return e>=i[0]&&e<=r[0]&&t>=i[1]&&t<=r[1]}containsPoint(e){let[t,i]=e,[r,a]=this.min,[s,n]=this.max;return t>=r&&t<=s&&i>=a&&i<=n}intersectsBBox2D(e){for(let t=0,i=this.edges.length;t<i;t++){let r=this.edges[t];for(let a=0,s=e.edges.length;a<s;a++){let n=e.edges[a];if(Dee(r,n))return!0}}for(let t=0,i=e.vertices.length;t<i;t++){let r=e.vertices[t];if(this.containsPoint(r))return!0}return!1}ensureMinMax(){let e=this.min,t=this.max;this.min=[Math.min(e[0],t[0]),Math.min(e[1],t[1])],this.max=[Math.max(e[0],t[0]),Math.max(e[1],t[1])]}copy(e){this.min=[...e.min],this.max=[...e.max],Ri.copy(e.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let e=new Rx;return e.copy(this),e}},lR,Ree=new Promise(e=>{lR=e}),JM=!1,gm;function Oee(){if(JM)return;if(gm)return gm;async function e(){let t=await Promise.resolve().then(()=>(S_(),__));lR(t.default??t),JM=!0}return gm=e(),gm}function $M(e){let t=!1;return e.scene.objects.traverse((i,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var kt,Ay;async function Lee(e){let t=await Ree;kt||(Ay||(Ay=t({locateFile:()=>e})),kt=await Ay)}var eC=Ri.identity(),tC=class{constructor(e,t=1){this.canvas=e,this.dpr=t,this._width=0,this._height=0,this._strokeMode="inside",this._layerBlur=0,this._backgroundBlur=0,this._dropShadowBlur=0,this._dropShadowOffsetX=0,this._dropShadowOffsetY=0,this._dropShadowColor=Li.transparent,this._innerShadowBlur=0,this._innerShadowOffsetX=0,this._innerShadowOffsetY=0,this._innerShadowSpread=0,this._innerShadowColor=Li.transparent,this._fonts=new Map;try{let i=e.getBoundingClientRect();e.width=i.width*t,e.height=i.height*t}catch{console.log(e.width,t)}this._currentM3Transform=eC,this._currentTransform=new Float32Array(eC)}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await Lee(this.wasmURL),this._surface=kt.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new kt.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(kt.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(kt.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(e){this._currentM3Transform=e,this._currentTransform.set(e)}async loadFont(e,t){let i=await(await fetch(e)).arrayBuffer();this.registerFont(i,t)}registerFont(e,t){if(this._fonts.has(t))return;let i=kt.FontMgr.FromData(e);if(i)this._fonts.set(t,i);else throw new Error("Invalid font data for "+t)}get width(){return this._width}get height(){return this._height}set strokeColor(e){this._paintStroke&&this._paintStroke.setColor(vm(e),kt.ColorSpace.DISPLAY_P3)}set fillColor(e){this._paintFill&&this._paintFill.setColor(vm(e),kt.ColorSpace.DISPLAY_P3)}set lineWidth(e){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?e:e*2)}set strokeMode(e){this._strokeMode=e}set dropShadowBlur(e){this._dropShadowBlur=e}set dropShadowColor(e){this._dropShadowColor=e}set dropShadowOffsetX(e){this._dropShadowOffsetX=e}set dropShadowOffsetY(e){this._dropShadowOffsetY=e}set innerShadowBlur(e){this._innerShadowBlur=e}set innerShadowColor(e){this._innerShadowColor=e}set innerShadowOffsetX(e){this._innerShadowOffsetX=e}set innerShadowOffsetY(e){this._innerShadowOffsetY=e}set innerShadowSpread(e){this._innerShadowSpread=e}set layerBlur(e){this._layerBlur=e}set backgroundBlur(e){this._backgroundBlur=e}clear(){this.ctx?.clear(kt.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new kt.Path}closePath(){let e=this._currentPath;if(e){if(e.isEmpty())return;let t=e.getBounds();(t[3]-t[1]||t[2]-t[0])&&e.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(e,t,i,r,a=0,s=0,n=0,o=0){let l=kt.XYWHRect(e,t,i,r);if(a===0&&s===0&&o===0&&n===0)this.ctx?.clipRect(l,kt.ClipOp.Intersect,!0);else{let h=kt.RRectXY(l,a,a);h[4]=h[5]=a,h[6]=h[7]=s,h[8]=h[9]=n,h[10]=h[11]=o,this.ctx?.clipRRect(h,kt.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let e=Ri.invert(this.currentTransform);this.ctx.concat(e);let t=Ri.translate(Ri.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(t),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(e,t,i=!0){if(this.ctx&&this._currentPath){let r,a=!1;if(i&&this._hasDropShadow()){let s=e.copy();s.setColor(vm(this._dropShadowColor));let n;this._dropShadowBlur>0&&(n=kt.MaskFilter.MakeBlur(kt.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),s.setMaskFilter(n)),this.ctx.save(),this.ctx.clipPath(this._currentPath,kt.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),t(s),this.ctx.restore(),s.delete(),n?.delete()}if(this._backgroundBlur>0&&i){this.ctx.save(),this.ctx.clipPath(this._currentPath,kt.ClipOp.Intersect,!0);let s=kt.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,kt.TileMode.Clamp,null),n=e.copy();n.setImageFilter(s),n.setAlphaf(1);let o=this._currentPath.computeTightBounds();this.ctx.saveLayer(n,o,null,kt.SaveLayerInitWithPrevious),this.ctx.drawColor(e.getColor()),this.ctx.restore(),this.ctx.restore(),n.delete(),s.delete(),a=!0}if(this._layerBlur>0){let s=e.copy();r=kt.MaskFilter.MakeBlur(kt.BlurStyle.Normal,this._layerBlur*this.dpr*(this.camera?.scale??1),!1),s.setMaskFilter(r),t(s),s.delete(),r.delete(),a=!0}if(a||t(e),i&&this._hasInnerShadow()){let s=new kt.Paint;s.setAntiAlias(!0),s.setStyle(kt.PaintStyle.Fill),s.setColor(vm(this._innerShadowColor));let n;this._innerShadowBlur>0&&(n=kt.MaskFilter.MakeBlur(kt.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),s.setMaskFilter(n));let o=this._currentPath.computeTightBounds(),[l,h,c,u]=o,d=c-l,p=u-h;this.ctx.save(),this.ctx.clipPath(this._currentPath,kt.ClipOp.Intersect,!0),this.ctx.saveLayer(s,o,null,kt.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(kt.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+d+Math.abs(this._innerShadowOffsetX*2),2e3+p+Math.abs(this._innerShadowOffsetY*2)),s),s.setBlendMode(kt.BlendMode.Clear),this.ctx.drawPath(this._currentPath,s),this.ctx.restore(),this.ctx.restore(),s.delete(),n?.delete()}}}_paintInner(e,t=!0){if(this.ctx&&this._currentPath&&e){let i=this.ctx,r=this._currentPath;this._applyEffectsToPaint(e,a=>{let s=!1;!t&&this._strokeMode!=="center"&&(i.save(),i.clipPath(r,this._strokeMode==="outside"?kt.ClipOp.Difference:kt.ClipOp.Intersect,!0),s=!0),i.drawPath(r,a),s&&i.restore()},t)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}path(e){this._currentPath?.addPath(kt.Path.MakeFromSVGString(e))}ellipse(e,t,i,r,a,s,n,o){if(!iC([e,t,i,r])||!this._currentPath)return;if(i<0||r<0)throw Error("radii cannot be negative");let l=kt.XYWHRect(e-i,t-r,i*2,r*2);this._currentPath?.addOval(l)}rect(e,t,i,r,a=0,s=0,n=0,o=0){let l=kt.XYWHRect(e,t,i,r);if(iC(l))if(a===0&&s===0&&o===0&&n===0)this._currentPath?.addRect(l);else{let h=kt.RRectXY(l,a,a);h[4]=h[5]=a,h[6]=h[7]=s,h[8]=h[9]=n,h[10]=h[11]=o,this._currentPath?.addRRect(h)}}getHorizontalAlign(e){switch(e){case 2:return kt.TextAlign.Right;case 3:return kt.TextAlign.Center;case 4:return kt.TextAlign.Justify;case 1:default:return kt.TextAlign.Left}}drawTextInner(e,t,i,[r,a,s,n],o,l,h=!0){let c=0,{ctx:u}=this;if(!u)return c;let d=l.copy(),p=l.copy();return p.setAlphaf(0),this._applyEffectsToPaint(d,f=>{t.pushPaintStyle(i,f,p),t.addText(e);let m=t.build();m.layout(s);let g=a;o===2?g+=(n-m.getHeight())/2:o===3&&(g+=n-m.getHeight()),u.drawParagraph(m,r,g),c=m.getHeight(),t.reset(),m.delete()},h),d.delete(),p.delete(),c}drawText(e,t){let i=0,r=this._fonts.get(t.font),{ctx:a,_paintFill:s,_paintStroke:n}=this;if(r&&a){let o=new kt.TextStyle({fontFamilies:[t.font],fontSize:t.fontSize,heightMultiplier:t.lineHeight,letterSpacing:t.letterSpacing}),l=new kt.ParagraphStyle({textStyle:o,textAlign:this.getHorizontalAlign(t.horizontalAlign)}),h=kt.XYWHRect(t.x,t.y,t.width,t.height),c=kt.ParagraphBuilder.Make(l,r);s&&(i=this.drawTextInner(e,c,o,h,t.verticalAlign,s,!0)),n&&(i=this.drawTextInner(e,c,o,h,t.verticalAlign,n,!1)),c.delete()}return{height:i}}render(){this._surface?.flush()}moveTo(e,t){this._currentPath?.moveTo(e,t)}lineTo(e,t){this._currentPath?.lineTo(e,t)}bezierCurveTo(e,t,i,r,a,s){this._currentPath?.cubicTo(e,t,i,r,a,s)}quadraticCurveTo(e,t,i,r){this._currentPath?.quadTo(e,t,i,r)}setTransform(e,t=!1){if(!this.ctx)return;let i=this.ctx.getTotalMatrix(),r=Ri.invert(i);if(r&&this.ctx.concat(r),this.ctx?.scale(this.dpr,this.dpr),this.camera?.enabled&&(this.ctx?.concat(this.camera.worldMatrix),t)){let a=Ri.getScale(this.camera.worldMatrix);this.ctx?.scale(1/a[0],1/a[1])}this.ctx?.concat(e),this.currentTransform=e}transform(e){this.ctx?.concat(e)}setSize(e,t){e===this._width&&t===this._height||(this._width=e,this._height=t,this.canvas.style.width=e+"px",this.canvas.style.height=t+"px",this.canvas.width=e*this.dpr,this.canvas.height=t*this.dpr,this._surface&&(this._surface=kt.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function iC(e){for(let t=0;t<e.length;t++)if(e[t]!==void 0&&!Number.isFinite(e[t]))return!1;return!0}function vm({r:e,g:t,b:i,a:r}){return kt.Color4f(e,t,i,r)}var rC=class{constructor(e,t,i){this.uuid=e,this.data=t,this.enabled=!1,this.color=Li.transparent,this.blurRadius=0,this.offset=[0,0],this.spread=0,this.update(t)}update(e){e.color!==void 0&&(this.color=e.color),e.enabled!==void 0&&(this.enabled=e.enabled),e.blurRadius!==void 0&&(this.blurRadius=e.blurRadius),e.offset!==void 0&&(this.offset=e.offset),e.spread!==void 0&&(this.spread=e.spread)}},aC=class{constructor(e,t,i){this.uuid=e,this.data=t,this.enabled=!1,this.radius=0,this.update(t)}update(e){e.enabled!==void 0&&(this.enabled=e.enabled),e.radius!==void 0&&(this.radius=e.radius)}},Iee=class{constructor(e,t,i){this.uuid=e,this.data=t,this.enabled=!1,this.color=Li.transparent,this.update(t)}update(e){e.enabled!==void 0&&(this.enabled=e.enabled),e.color!==void 0&&(this.color=e.color)}},Bee=class{constructor(e,t,i){this.uuid=e,this.data=t,this.enabled=!1,this.color=Li.transparent,this.thickness=0,this.mode="inside",this.update(t)}update(e){e.enabled!==void 0&&(this.enabled=e.enabled),e.color!==void 0&&(this.color=e.color),e.thickness!==void 0&&(this.thickness=e.thickness),e.mode!==void 0&&(this.mode=e.mode)}},Yr=class extends $r{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.autoClose=!0,this.fill=new Iee(e+"-fill",t.fill,i),this.stroke=new Bee(e+"-stroke",t.stroke,i),this.dropShadow=new rC(e+"-dropShadow",t.dropShadow,i),this.innerShadow=new rC(e+"-innerShadow",t.innerShadow,i),this.backgroundBlur=new aC(e+"-backgroundBlur",t.backgroundBlur,i),this.layerBlur=new aC(e+"-layerBlur",t.layerBlur,i)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Li.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Li.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Li.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Li.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.type===0&&(Fi(e.path,["fill"])?this.fill.update(e.props):Fi(e.path,["stroke"])?this.stroke.update(e.props):Fi(e.path,["dropShadow"])?this.dropShadow.update(e.props):Fi(e.path,["innerShadow"])?this.innerShadow.update(e.props):Fi(e.path,["layerBlur"])?this.layerBlur.update(e.props):Fi(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,t){super.updateState(e,t),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let t=new Yr(this.uuid,this.data,e);return t.parent=void 0,t}},dw=class extends Yr{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.width=0,this.height=0,this.updateState(t,i)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,t){return Cee(e,t,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e)}clone(e){let t=new dw(this.uuid,this.data,e);return t.parent=void 0,t}},Rp=class extends Yr{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.width=0,this.height=0,this.cornerRadius=[0,0,0,0],this.updateState(t,i)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let t=new Rp(this.uuid,this.data,e);return t.parent=void 0,t}},pw=class extends Yr{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this._textHeight=0,this._textHeightDirty=!0,this.width=0,this.height=0,this.updateState(t,i)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Li.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Li.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let t=this.data.textTransform,i=this.data.text.textValue.toString(),r=t===2?i.toUpperCase():t===3?i.toLowerCase():i,{height:a}=e.drawText(r,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:t}){e.font!==void 0&&(this._fontHolder=t.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateFontState(e,t)}clone(e){let t=new pw(this.uuid,this.data,e);return t.parent=void 0,t}},hR=class extends Yr{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.curves=[],this.extremasBBox={min:[0,0],max:[0,0]},this.updateState(t,i)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(r=>kg.extremas(r)),t=[1/0,1/0],i=[-1/0,-1/0];for(let r=0,a=e.length;r<a;r++){let s=e[r];s[0][0]<t[0]&&(t[0]=s[0][0]),s[0][1]<t[1]&&(t[1]=s[0][1]),s[1][0]>i[0]&&(i[0]=s[1][0]),s[1][1]>i[1]&&(i[1]=s[1][1])}return this.extremasBBox.min=[t[0],t[1]],this.extremasBBox.max=[i[0],i[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let i=1,r=this.data.points.length;i<r;i++){let a=this.data.points[i].data,s=this.data.points[i-1].data,n={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(n)}let e=this.data.points[0].data,t=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let i={start:t.position,cp1:t.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(i)}}getCenter(){let[e,t]=this.extremasBBox.min,[i,r]=this.getHalfSize();return[e+i,t+r]}getHalfSize(){let{min:e,max:t}=this.extremasBBox;return[(t[0]-e[0])*.5,(t[1]-e[1])*.5]}innerDraw(e){for(let r=0,a=this.data.points.length;r<a;r++){let s=this.data.points[r].data;if(r===0){let[n,o]=s.position;e.moveTo(n,o)}else{let n=this.data.points[r-1].data,[o,l]=n.controlNext.position,[h,c]=s.controlPrevious.position,[u,d]=s.position,p={start:n.position,cp1:n.controlNext.position,cp2:s.controlPrevious.position,end:s.position};kg.derive(p),e.bezierCurveTo(o,l,h,c,u,d)}}let t=this.data.points[0].data,i=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[r,a]=i.controlNext.position,[s,n]=t.controlPrevious.position,[o,l]=t.position;e.bezierCurveTo(r,a,s,n,o,l)}}updateState(e,t){super.updateState(e,t),this.computeExtremas()}clone(e){let t=new hR(this.uuid,this.data,e);return t.parent=void 0,t}},kg;(e=>{function t(n){let o=n.start,l=n.cp1,h=n.cp2,c=n.end,u=[3*(l[0]-o[0]),3*(l[1]-o[1])],d=[3*(h[0]-l[0]),3*(h[1]-l[1])],p=[3*(c[0]-h[0]),3*(c[1]-h[1])],f={start:u,cp:d,end:p};return n.derivative=f,f.derivative=Ox.derive(f),f}e.derive=t;function i(n,o,l,h=!1){let c=n-2*o+l;if(c!==0){let u=-Math.sqrt(Math.abs(o*o-n*l)),d=-n+o,p=-(u+d)/c,f=-(-u+d)/c;return[p,f]}else if(o!==l&&c===0)return[(2*o-l)/(2*(o-l))];return[]}function r(n){let o=n.derivative??e.derive(n),l=o.start,h=o.cp,c=o.end;return[i(l[0],h[0],c[0]),i(l[1],h[1],c[1])]}e.droot=r;function a(n){let[o,l]=e.droot(n),h=[n.start[0],n.end[0]],c=[n.start[1],n.end[1]];for(let u of o)h.push(e.compute(n,Math.min(1,Math.max(0,u)))[0]);for(let u of l)c.push(e.compute(n,Math.min(1,Math.max(0,u)))[1]);return h.sort((u,d)=>u-d),c.sort((u,d)=>u-d),[[h[0],c[0]],[h[h.length-1],c[c.length-1]]]}e.extremas=a;function s(n,o){if(o===0)return[...n.start];if(o===1)return[...n.end];let l=1-o,h=l*l,c=o*o,u=h*l,d=h*o*3,p=l*c*3,f=o*c;return[u*n.start[0]+d*n.cp1[0]+p*n.cp2[0]+f*n.end[0],u*n.start[1]+d*n.cp1[1]+p*n.cp2[1]+f*n.end[1]]}e.compute=s})(kg||(kg={}));var Ox;(e=>{function t(a){let s=a.start,n=a.cp,o=a.end,l=[2*(n[0]-s[0]),2*(n[1]-s[1])],h=[2*(o[0]-n[0]),2*(o[1]-n[1])],c={start:l,end:h};return c.derivative=Lx.derive(c),a.derivative=c,c}e.derive=t;function i(a){let s=a.derivative??e.derive(a),n=s.start,o=s.end;return[n[0]!==o[0]?n[0]/(n[0]-o[0]):0,n[1]!==o[1]?n[1]/(n[1]-o[1]):0]}e.droot=i;function r(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let n=1-s,o=n*n,l=s*s,h=o,c=n*s*2,u=l;return[h*a.start[0]+c*a.cp[0]+u*a.end[0],h*a.start[1]+c*a.cp[1]+u*a.end[1]]}e.compute=r})(Ox||(Ox={}));var Lx;(e=>{function t(r){let a=r.start,s=r.end,n=[s[0]-a[0],s[1]-a[1]];return r.derivative=n,r.derivative}e.derive=t;function i(r,a){if(a===0)return[...r.start];if(a===1)return[...r.end];let s=r.start,n=r.end;return[s[0]+(n[0]-s[0])*a,s[1]+(n[1]-s[1])*a]}e.compute=i})(Lx||(Lx={}));var Rn=class extends Cn{constructor(e,t,i){super(e,t,i),this.uuid=e,this.width=0,this.height=0,this.clipped=!0,this.background=new Rp(e+"-background",up.defaultData,i),this.background.parent=this,this.updateState(t,i)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,t,i){super.updateWorldMatrix(e,t,i),this.background?.updateWorldMatrix(e,t,i)}draw(e){if(!this.visible)return;e.save();let t=this.width,i=this.height;this.applyTransforms(e),this.background.width=t,this.background.height=i,this.background.draw(e),this.clipped&&e.clipRect(0,0,t,i,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.type===0&&(Fi(e.path,["fill"])?this.fill.update(e.props):Fi(e.path,["stroke"])?this.stroke.update(e.props):Fi(e.path,["dropShadow"])?this.dropShadow.update(e.props):Fi(e.path,["innerShadow"])?this.innerShadow.update(e.props):Fi(e.path,["layerBlur"])?this.layerBlur.update(e.props):Fi(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let t=new Rn(this.uuid,this.data,e);t.parent=void 0;for(let i of this.children)t.add(i.clone(e));return t}},Uee=Ro(uT(),1),gv=class extends Yr{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this._pathBBox=new DOMRect,this.path="",this.updateState(t,i),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),t=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(e),t.setAttribute("d",this.path),e.appendChild(t),this._pathBBox=t.getBBox(),e.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,t){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&t>=this._pathBBox.y&&t<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,t){super.updateState(e,t),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let t=new gv(this.uuid,this.data,e);return t.parent=void 0,t}};function Fee(e,t=1,i=1){if(t<=0||i<=0)return e;let r=(0,Uee.parseSVG)(e).map(a=>{let s={...a};return"x"in s&&(s.x=s.x*t),"y"in s&&(s.y=s.y*i),"x1"in s&&(s.x1=s.x1*t),"x2"in s&&(s.x2=s.x2*t),"y1"in s&&(s.y1=s.y1*i),"y2"in s&&(s.y2=s.y2*i),"rx"in s&&(s.rx=s.rx*t),"ry"in s&&(s.ry=s.ry*i),s});return Nee(r)}function Nee(e){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],i;return e.map(r=>{let a=[];t.forEach(n=>{if(n in r){let o=r[n]*1;a.length&&o>=0&&a.push(","),a.push(o)}});let s=(i===r.code?a[0]<0?"":",":r.code)+a.join("");return i=r.code,s}).join("")}function zee(e,t,i){switch(t.type){case"ellipse2d":return new dw(e,t,i);case"rectangle2d":return new Rp(e,t,i);case"text2d":return new pw(e,t,i);case"vector2d":return new hR(e,t,i);case"path2d":return new gv(e,t,i);case"frame2d":return new Rn(e,t,i);case"group2d":default:return new Po(e,t,i)}}var cR=class{constructor(e,t,i){this.uuid=e,this.data=t,this.group=new Po(cR.GROUP_ID,{...Lg.defaultData},i),this.createChildrenObjects(t.objects,this.group,i)}createObject(e,t,i,r,a,s){let n=zee(e,t,s);n&&(r.add(n),r.children.splice(a,0,r.children.pop()),n.updateWorldMatrix(),i.length>0&&(n instanceof Po||n instanceof Rn)&&this.createChildrenObjects(i,n,s))}createChildrenObjects(e,t,i){let r=0;for(let a of e)this.createObject(a.id,a.data,a.children,t,r,i),r+=1}draw(e){this.group.draw(e)}updateEntityByOp(e,t,i,r){let a=this.find(e);if(a)try{a.updateByOp(t,i,{shared:r})}catch(s){console.error(s)}}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this.group:this.find(e.parent);i!==void 0&&i instanceof Cn&&(this.createObject(e.id,e.data,e.children,i,e.localIndex,t),i.requestRender())}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i!==void 0&&i.parent!==void 0&&i.parent instanceof Cn){let r=i.parent;i.resetBBoxNeedsUpdate(),r?.remove(i),r?.requestRender()}}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i!==void 0){let r=i.parent,a=e.parent===null?this:this.find(e.parent);if(a instanceof Cn||a===this){a.add(i);let s=e.localIndex;a.children.splice(s,0,a.children.pop()),i.updateWorldMatrix(!0,!1,!0),r?.requestRender(),i.requestRender()}i.resetBBoxNeedsUpdate()}}}add(e){this.group.add(e)}remove(e){this.group.remove(e)}traverse(e){this.group.traverse(t=>{t!==this.group&&e(t)})}intersectsChildren(e,t,i,r=!1,a=[]){return this.group.intersectsChildren(e,t,i,r,a,!0)}find(e){return this.group.find(e)}get children(){return this.group.children}project(e,t){return this.group.project(e,t)}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this.group;){let a=r;r=r.parent;let s=r.children.indexOf(a);i.splice(0,0,s)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>qP(i.sortKey,r.sortKey)),t.map(i=>i.entity)}},fw=cR;fw.GROUP_ID="scene2d";function uR({constraints:e,newParentWidth:t,newParentHeight:i,initialParentWidth:r,initialParentHeight:a,objectInitialWidth:s,objectInitialHeight:n,objectInitialPosition:o}){let{horizontalConstraint:l,verticalConstraint:h}=e,c=t-r,u=i-a,d=s,p=n,f=o[0],m=o[1];if(l!==0){if(l===1)f+=c;else if(l===3)f+=c/2;else if(l===2)d=Math.max(1,d+c);else if(l===4){let g=t/r;d*=g,f*=g}}if(h!==0){if(h===1)m+=u;else if(h===3)m+=u/2;else if(h===2)p=Math.max(1,p+u);else if(h===4){let g=i/a;p*=g,m*=g}}return{width:d,height:p,position:[f,m]}}var ane=Ro(uT(),1),sne={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}},kee=Ri.identity(),dR=class{constructor(e,t,i,r){this.uuid=e,this.width=t,this.height=i,this.context=r,this.enabled=!0,this.isScreenSpace=!1,this.isFrameDirty=!1,this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()},this.onFrameOverrideObjectEvent=a=>{if(a.target?.uuid!==void 0){let s=this.frameRoot?.find(a.target.uuid);s&&s.dispatchEvent({...a,target:s})}},this.scene2d=new fw(dt.generateUUID(),ax.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=document.createElement("canvas"),this.renderer=new tC(this.canvas),r.shared.addCanvas(this.uuid,this.canvas),this.textureHolder=r.shared.canvas(this.uuid),this.promise=this.init()}async init(){this.renderer instanceof tC&&(this.renderer.wasmURL=FD.skiaWasmUrl),await this.renderer.init()}render(){this.isFrameDirty&&(this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.textureHolder?.setNeedsUpdate(!0),this.isFrameDirty=!1)}updateEntity2DByOp(e,t,i,r){this.scene2d.updateEntityByOp(e,t,i,r),this.applySize()}updateTreeByOp(e,t){this.scene2d.updateTreeByOp(e,t),this.applySize()}applyOverrides(e){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let t=e?.width??this.width,i=e?.height??this.height;this.frameOverride.width=t,this.frameOverride.height=i,this.frameOverride.localMatrix=kee,this.isScreenSpace&&(this.frameOverride.fill.color=Li.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:t,height:i},pR({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(e){let t=e?.width??this.width,i=e?.height??this.height;this.width=t,this.height=i,this.renderer.dpr=this.isScreenSpace?window.devicePixelRatio:Math.floor(2048/Math.max(t,i)),this.renderer.setSize(t,i),this.textureHolder?.dispose(),this.applyOverrides(e),this.frameOverride?.requestRender()}applyFrame(e){let t=this.context.scene.find2D(e);if(!(!t||!(t instanceof Rn)))return this.disposeFrameOverride(),this.frameRoot=t,this.frameOverride=t.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.textureHolder?.dispose(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(i=>{i.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(i=>{i.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),t}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(e){return this.scene2d.find(e)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(e=>{e.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(e=>{e.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function pR({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:a,initialParentHeight:s}){if(e instanceof Rn&&t instanceof Rn||e instanceof Po&&t instanceof Po)for(let n=0,o=e.children.length;n<o;n++){let l=e.children[n],h=t.children[n];l&&h&&l.uuid===h.uuid&&jee({objectOverride:l,objectRoot:h,newParentWidth:i,newParentHeight:r,initialParentWidth:a,initialParentHeight:s})}}function Vee(e){if(Ix(e))return[e.width,e.height];if(e instanceof gv){let[t,i]=e.getHalfSize();return[t*2,i*2]}else if(e instanceof Po){let[t,i]=e.recursiveBBox.getHalfSize();return[t*2,i*2]}return[0,0]}function jee({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:a,initialParentHeight:s}){let[n,o]=Vee(t),{width:l,height:h,position:c}=uR({constraints:e.data,newParentWidth:i,newParentHeight:r,initialParentWidth:a,initialParentHeight:s,objectInitialWidth:n,objectInitialHeight:o,objectInitialPosition:t.position});if(e.position=c,e.data={...e.data,position:c},e.states)for(let u in e.states)Gee({stateId:u,objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:a,initialParentHeight:s});if(Ix(e)||e instanceof Po)Ix(e)&&(e.width=l,e.height=h,e.data={...e.data,width:l,height:h}),pR({objectOverride:e,objectRoot:t,newParentWidth:l,newParentHeight:h,initialParentWidth:n,initialParentHeight:o});else if(e instanceof gv){let u=t,d=n!==0?l/n:1,p=o!==0?h/o:1;e.path=Fee(u.path,d,p),e.data={...e.data,path:e.path}}}function Gee({stateId:e,objectOverride:t,objectRoot:i,newParentWidth:r,newParentHeight:a,initialParentWidth:s,initialParentHeight:n}){let o=t.states?.[e],l=i.states?.[e];if(o&&l){let{width:h,height:c,position:u}=uR({constraints:t.data,newParentWidth:r,newParentHeight:a,initialParentWidth:s,initialParentHeight:n,objectInitialWidth:yh.isResizeable(l)?l.width:0,objectInitialHeight:yh.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[e],{position:u}),yh.isResizeable(o)&&Object.assign(t.states[e],{width:h,height:c})}}function Ix(e){return e instanceof Rp||e instanceof Rn||e instanceof dw||e instanceof pw}var Xr=class extends Wb(So){constructor(e,t,i){super(),this.data=t,this.bgColor=new ca(1,1,1,1),this.fog=null,this.backupFog=new VT(16777215,.1,2e3),this.fogUseBGColor=!1,this.isActive=!1,this.aoColor=new _t,this.penumbraSizeArrayCache=null,this.super_Entity(e,t),this.personalCamera=new _a(Uu,{...lp.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new u6(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene?this.uiScene=new fw((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:i.shared}):t.uiFrame&&this.createUICanvas(t.uiFrame,i)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,t){this.uiCanvas=new dR(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=Ba(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(t=>{t instanceof Ph&&t.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof zu)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&yee(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let i=this.scene;i.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ba(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=Ba(e.aoColor,t))}updateByOp(e,t,i,r){let a=this.data.uiFrame;super.updateByOp(e,t,i,r);let s=t;Fi(e.path,["fog"])?this.updateFog(s.fog,i.shared):Fi(e.path,["ao"])?this.updateAo(s.ao,i.shared):Fi(e.path,["ambient"])?this.updateAmbientLight(s.ambient,i.shared):Fi(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||a!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,i)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(Ba(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof sR&&i.visible&&e<3&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize,e+=1),i instanceof nR&&i.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+t]=i.data.penumbraSize,t+=1)})}raycastWithClones(e){let t=[],i=r=>{for(let a of r.children){let s=a.cloner;ui.is(a)&&(a.visible||s?.object.data.visible)&&((Hs(a)||Ax(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),Bx(a,e,t,!0)),i(a))}};return i(this),t}updateEntity2DByOp(e,t,i,r){this.uiCanvas?.updateEntity2DByOp(e,t,i,r)}},Hee=class extends hw(m6,rR){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let a=new O(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new O(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),n=new sr(a,s),o=new ag(n,new _t(16755200));o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let e in this.gizmos){let t=this.gizmos[e];if(t instanceof ag){let i=this.shadow.camera,r=new O(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),a=new O(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);t.box.set(r,a),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}},Wee=class extends ba{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?$b(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},mw=class extends ba{constructor(e,t,i){super(e,t,i),this._shapeId=null,this._context=i}updateState(e,t){super.updateState(e,t),this.updateShape()}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let r in e)typeof e[r]=="string"&&(e[r]=this._context.shared.getVariable(e[r],[this.uuid,"geometry","extrusion","shape",r]));let t;if(e.type==="Custom"){let r=e.shapeId;if(r!==this._shapeId&&this.detachShape(),r){this._shapeId=r;let a=this._context.scene.find(r);a?.data&&(a.attachedPaths.add(this),t=a.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let r;switch(e.type){case"Rectangle":r=Jb;break;case"Ellipse":r=Zb;break;case"Polygon":r=eD;break;case"Star":r=tD;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=r.create({parameters:e}).userData.shape}let i=this.geometry;t&&i.inputs&&(i.inputs.shapeData=t,i.build(),this.attachedSurfaceCloners.forEach(r=>r.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,t){return super.updateTransformState(e,t)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?$b(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},ou=class extends ku(nh,Pp){constructor(e,t,i){super(),t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,i)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let i=Pg.getComponentData({scene:t.scene.data,shared:t.shared.data},e.component);if(i){let r,a;for(let s of fl.rootOverrideProps)e[s]===void 0?(r===void 0&&(r={...e}),r[s]=i.data[s]):(a===void 0&&(a={}),a[s]=e[s],r===void 0&&(r={...e}),r[s]=_l.apply(i.data[s],e[s]));return this.overrideData=a,r}else return{...ha.defaultData,...e,...Ao(ha.defaultData,fl.rootOverrideProps)}}updateByOp(e,t,i,r){let a;if(this.isInstanceRoot&&!r){if(t=this.transformAssignData(t,i),e.type===0&&e.path.length===0&&this.component)for(let s of fl.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&fl.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:t[s]}})}}super.updateByOp(a??e,t,i,r)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let i=e.scene.find(t.component)??null,r=!1;if(i!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(ui.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),gw(s),a+=1;else break;this.children.splice(0,a)}r=!0}if(i){let a={};fR(e,[this.uuid],t.overrides,this,i,i,0,r,a);for(let s of this.children)if(ui.is(s)){let n=s.data;n.type==="Empty"&&n.animations&&s.traverseEntity(o=>{let l=o.dataPatched;if(o instanceof ba&&l.bones&&l.boneInverses){let h=o.dataPatched;if(h.bones&&h.boneInverses){let c=h.bones.map(p=>e.scene.find(a[p])),u=h.boneInverses.map(p=>new je().fromArray(p)),d=new nb(c,u);o.bind(d,o.bindMatrix)}}else o.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function gw(e){if(e.component){let t=e.component.instances.indexOf(e);t>=0&&e.component.instances.splice(t,1);for(let i of e.children)ui.is(i)&&gw(i)}}function sC(e,t,i,r){return e.component===t&&GP(e.identity,r)?e.overrideData===i?2:1:0}function fR(e,t,i,r,a,s,n,o,l){if(n>50)return!1;if(r.component!==a){if(r.component){let c=r.component.instances.indexOf(r);c>=0&&r.component.instances.splice(c,1)}a.instances.find(c=>c===r)||a.instances.push(r),r.component=a}a instanceof ou&&a.isInstanceRoot&&a.expandInstanceChildren(e);let h=0;for(let c of a.children)if(ui.is(c)){let u=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],d=Eg.resolve(i,u,1);d!=null&&!(d instanceof Tr)&&(Object.setPrototypeOf(d,Tr.prototype),console.error("wrong prototype"));let p=null,f;if(!o){let m=r.children[h];if(p=ui.is(m)?m:null,p!==null){let g=sC(p,c,d,u);f=g>=1?p.stateSelection:void 0,g!==2&&(p=null)}if(p===null&&(p=e.scene.findInstance(u)??null,p!==null)){let g=sC(p,c,d,u);if(f=g>=1?p.stateSelection:void 0,g!==2)p=null;else{let v=p.parent.children.indexOf(p);p.parent.children.splice(v,1),r.children.splice(h,0,p),p.parent===r?v<=h&&console.error("not possible"):(p.parent=r,p.matrixWorldNeedsUpdate=!0,p.resetBBoxNeedsUpdate(),p.updateVisible(),e.pendingDeletes.delete(p))}}}if(p===null){let m=d?_l.apply(c.data,d):c.data;Mh.is(m.type)&&(m={...m,type:"Empty"}),p=gl.createEntity(u,m,e),p.overrideData=d,r.add(p),r.children.splice(r.children.length-1,1),r.children.splice(h,0,p),p.updateState(p.data,e),f&&p.changeSelectedState(f,e),e.scene.registerInstanceAndSetUuid(p)}if(p.isBone){let m=p.identity[p.identity.length-1];l[m]=p.uuid}h+=1,fR(e,t,i,p,c,s,n+1,o,l)}if(!o){let c=h;for(;;){let u=r.children[h];if(ui.is(u))e.pendingDeletes.add(u);else break;h+=1}r.children.splice(c,h-c)}return!0}var qee=class extends ku(jT,Pp){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(e,t){this.updateState_Entity(e,t)}},ya=class extends ba{constructor(e,t,i){super(e,t,i),this.onBeforeRender=()=>{this.uiCanvas.render()},this.uiCanvas=new dR(e+"-canvas",t.geometry.width,t.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(e,t,i){super.updateByPatchedOpGeometry(e,t,i),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,i.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,i.shared))}applySize(e,t){let i=e?.width??this.dataPatched.geometry.width,r=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),this.applyGeometryParametersFromFrame(t)}applyFrame(e,t){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(t),this.applyMaterialParametersFromFrame({shared:t})}applyGeometryParametersFromFrame(e){let t=this.frame;t&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=gp(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let t=this.frame;if(t){let i=t.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),this.material.reset(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,t,i,r){this.uiCanvas.updateEntity2DByOp(e,t,i,r),e===this.frameId&&t.type===0&&(t.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):Fi(t.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.applySize({width:e.width,height:e.height},t)}},Xee=class{constructor(e,t,i){this.variables=[],this.currentTextureIndex=0;let r=ir,a=new So,s=new Rh;s.position.z=1;let n={passThruTexture:{value:null}},o=c(d(),n),l=new xr(new Pl(2,2),o);a.add(l),this.setDataType=function(p){return r=p,this},this.addVariable=function(p,f,m){let g=this.createShaderMaterial(f),v={name:p,initialValueTexture:m,material:g,dependencies:null,renderTargets:[],wrapS:null,wrapT:null,minFilter:bi,magFilter:bi};return this.variables.push(v),v},this.setVariableDependencies=function(p,f){p.dependencies=f},this.init=function(){if(i.capabilities.isWebGL2===!1&&i.extensions.has("OES_texture_float")===!1)return"No OES_texture_float support for float textures.";if(i.capabilities.maxVertexTextures===0)return"No support for vertex shader textures.";for(let p=0;p<this.variables.length;p++){let f=this.variables[p];f.renderTargets[0]=this.createRenderTarget(e,t,f.wrapS,f.wrapT,f.minFilter,f.magFilter),f.renderTargets[1]=this.createRenderTarget(e,t,f.wrapS,f.wrapT,f.minFilter,f.magFilter),this.renderTexture(f.initialValueTexture,f.renderTargets[0]),this.renderTexture(f.initialValueTexture,f.renderTargets[1]);let m=f.material,g=m.uniforms;if(f.dependencies!==null)for(let v=0;v<f.dependencies.length;v++){let x=f.dependencies[v];if(x.name!==f.name){let b=!1;for(let _=0;_<this.variables.length;_++)if(x.name===this.variables[_].name){b=!0;break}if(!b)return"Variable dependency not found. Variable="+f.name+", dependency="+x.name}g[x.name]={value:null},m.fragmentShader=`
6979
6992
  uniform sampler2D `+x.name+`;
6980
6993
  `+m.fragmentShader}}return this.currentTextureIndex=0,null},this.compute=function(){let p=this.currentTextureIndex,f=this.currentTextureIndex===0?1:0;for(let m=0,g=this.variables.length;m<g;m++){let v=this.variables[m];if(v.dependencies!==null){let x=v.material.uniforms;for(let b=0,_=v.dependencies.length;b<_;b++){let M=v.dependencies[b];x[M.name].value=M.renderTargets[p].texture}}this.doRenderTarget(v.material,v.renderTargets[f])}this.currentTextureIndex=f},this.getCurrentRenderTarget=function(p){return p.renderTargets[this.currentTextureIndex]},this.getAlternateRenderTarget=function(p){return p.renderTargets[this.currentTextureIndex===0?1:0]},this.dispose=function(){l.geometry.dispose(),l.material.dispose();let p=this.variables;for(let f=0;f<p.length;f++){let m=p[f];m.initialValueTexture&&m.initialValueTexture.dispose();let g=m.renderTargets;for(let v=0;v<g.length;v++)g[v].dispose()}};function h(p){p.defines.resolution="vec2( "+e.toFixed(1)+", "+t.toFixed(1)+" )"}this.addResolutionDefine=h;function c(p,f){f=f||{};let m=new vi({name:"GPUComputationShader",uniforms:f,vertexShader:u(),fragmentShader:p});return h(m),m}this.createShaderMaterial=c,this.createRenderTarget=function(p,f,m,g,v,x){return p=p||e,f=f||t,m=m||qi,g=g||qi,v=v||bi,x=x||bi,new _i(p,f,{wrapS:m,wrapT:g,minFilter:v,magFilter:x,format:Qr,type:r,depthBuffer:!1})},this.createTexture=function(){let p=new Float32Array(e*t*4),f=new is(p,e,t,Qr,ir);return f.needsUpdate=!0,f},this.renderTexture=function(p,f){n.passThruTexture.value=p,this.doRenderTarget(o,f),n.passThruTexture.value=null},this.doRenderTarget=function(p,f){let m=i.getRenderTarget(),g=i.xr.enabled,v=i.shadowMap.autoUpdate;i.xr.enabled=!1,i.shadowMap.autoUpdate=!1,l.material=p,i.setRenderTarget(f),i.render(a,s),l.material=o,i.xr.enabled=g,i.shadowMap.autoUpdate=v,i.setRenderTarget(m)};function u(){return`void main() {
6981
6994
 
@@ -8022,7 +8035,7 @@ void main() {
8022
8035
  gVelocity = vec4(0.0); // so it is ignored by TAA
8023
8036
  }`,r={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new ae},viewport:{type:"v2",value:new ae},basisViewport:{type:"v2",value:new ae},debugColor:{type:"v3",value:new _t},covariancesTextureSize:{type:"v2",value:new ae(1024,1024)},centersColorsTextureSize:{type:"v2",value:new ae(1024,1024)},orthoZoom:{type:"f",value:-1}};return new vi({uniforms:r,vertexShader:t,fragmentShader:i,transparent:!0,alphaTest:1,blending:mh,depthTest:!0,depthWrite:!1,side:Oa})}static buildGeomtery(e){let t=new St;t.setIndex([0,1,2,0,2,3]);let i=new Float32Array(4*3),r=new Ut(i,3);t.setAttribute("position",r),r.setXYZ(0,-1,-1,0),r.setXYZ(1,-1,1,0),r.setXYZ(2,1,1,0),r.setXYZ(3,1,-1,0),r.needsUpdate=!0;let a=new aP().copy(t),s=new Uint32Array(e),n=new Jd(s,1,!1);return n.setUsage(W4),a.setAttribute("splatIndex",n),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(r=>r.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,t=0,i=0;for(let r of this.splatBuffers){let a=r.nsplats;this.colors.subarray(e,e+a*4).set(r.colorsA),e+=a*4,this.centers.subarray(t,t+a*3).set(r.decoded.xyz.denormDequant().data),t+=a*3,this.covariances.subarray(i,i+a*6).set(new Float32Array(r.precomputedCovarianceBufferData)),i+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let e=this.splatCount,t=new ae(4096,1024);for(;t.x*t.y*2<e*6;)t.y*=2;let i=new ae(4096,1024);for(;i.x*i.y*4<e*4;)i.y*=2;let r,a;if(this.halfPrecisionCovariancesOnGPU){a=new Uint16Array(t.x*t.y*2);for(let c=0;c<this.covariances.length;c++)a[c]=EU.toHalfFloat(this.covariances[c]);r=new is(a,t.x,t.y,jm,_h)}else a=new Float32Array(t.x*t.y*2),a.set(this.covariances),r=new is(a,t.x,t.y,jm,ir);r.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=r,this.material.uniforms.covariancesTextureSize.value.copy(t);let s=new Uint32Array(i.x*i.y*4);for(let c=0;c<e;c++){let u=c*4,d=c*3,p=c*4;s[p]=Cte(this.colors[u],this.colors[u+1],this.colors[u+2],this.colors[u+3]),s[p+1]=Cy(this.centers[d]),s[p+2]=Cy(this.centers[d+1]),s[p+3]=Cy(this.centers[d+2])}let n=new is(s,i.x,i.y,Kx,En);n.internalFormat="RGBA32UI",n.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=n,this.material.uniforms.centersColorsTextureSize.value.copy(i);let o=256*4,l=new Float32Array(256*16);for(let c=0;c<this.meshMatrixWorlds.length;c++)l.set(this.meshMatrixWorlds[c].elements,c*16);let h=new is(l,o,1,Qr,ir);h.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=h,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:a,texture:r,size:t},centerColors:{data:s,texture:n,size:i},meshMatrixWorlds:{data:l,texture:h}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,i,r){this.splatCount>0&&(xm.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(xm),this.material.uniforms.basisViewport.value.set(2/xm.x,2/xm.y),this.material.uniforms.focal.value.set(t,i),this.material.uniforms.orthoZoom.value=r,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}},gR,Tte=new Promise(e=>{gR=e}),pC=!1,bm;function Pte(){if(pC)return;if(bm)return bm;async function e(){let t=await Promise.resolve().then(()=>(J_(),Z_));gR(t),pC=!0}return bm=e(),bm}var vR;Tte.then(e=>vR=e);var Dte=class{constructor(e={}){Nc(this,"updateView",function(){let t=new je,i=[],r=new O(0,0,-1),a=new O(0,0,-1),s=new O,n=new O;return function(o=!1,l){let h=this.updateMatrixWorldsInWorkerIfNeeded(),c=this.cropsChanged();if(!o){a.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,p=!1;if(a.dot(r)<=.95&&(d=!0),n.copy(l.position).sub(s).length()>=1&&(p=!0),!d&&!p&&!h&&!c&&!this.needsInitialRender)return}this.needsInitialRender=!1,s.copy(l.position),r.copy(a),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),i[0]=l.position.x,i[1]=l.position.y,i[2]=l.position.z;let u={sort:{view:t.elements,cameraPosition:i,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...h?{newMatrixWorlds:this.meshMatrixWorlds}:{},...c?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=u:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(u))}}()),this.scene=e.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new je().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(e,t){let i=new ae;this.splatMesh!==null&&this.splatMesh.getSplatCount()>0&&(e.getSize(i),this.cameraFocalLengthX=t.projectionMatrix.elements[0]*this.devicePixelRatio*i.x*.45,this.cameraFocalLengthY=t.projectionMatrix.elements[5]*this.devicePixelRatio*i.y*.45,this.splatMesh.updateUniforms(i,this.cameraFocalLengthX,this.cameraFocalLengthY,t.isPerspectiveCamera?-1:t.zoom*this.devicePixelRatio))}loadSplat(e={}){this.activePage=this.scene.activePage,e.position&&(e.position=new O().fromArray(e.position)),e.orientation&&(e.orientation=new zt().fromArray(e.orientation)),e.halfPrecisionCovariances=!!e.halfPrecisionCovariances;let t=[];if(this.splatEntries=t,this.activePage.traverseVisibleEntity(s=>{s.data.type==="Splat"&&t.push(s)}),this.splatMesh&&this.splatMesh.dispose(),t.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=t.map(s=>s.matrixWorld),this.meshMatrixWorldsOld=t.map(s=>s.matrixWorld.clone()),this.cropsArray=t.map(s=>s.data.crops.map(n=>n.data));let i=t.map(s=>new vR.GSplineBuffer(new Uint8Array(s.data.buffer).buffer)),r=0,a=[0];for(let s of i)r+=s.getSplatCount(),a.push(r);return this.setupSplatMesh(i,r,e.position,e.orientation,e.halfPrecisionCovariances,this.devicePixelRatio,a,this.meshMatrixWorlds),this.setupSortWorker(r),!0}updateMatrixWorldsInWorkerIfNeeded(){let e=this.splatDataTextures.meshMatrixWorlds.data;for(let t=0;t<this.meshMatrixWorlds.length;t++)e.set(this.meshMatrixWorlds[t].elements,t*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((t,i)=>t.equals(this.meshMatrixWorldsOld[i]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(t=>t.clone()),!0)}cropsChanged(){let e=!1;return this.splatEntries.forEach((t,i)=>{t.data.crops.forEach((r,a)=>{this.cropsArray[i][a]===void 0?(e=!0,this.cropsArray[i][a]=r.data):Object.entries(r.data).forEach(([s,n])=>{Array.isArray(n)&&n.some((o,l)=>o!==this.cropsArray[i][a][s][l])?(e=!0,this.cropsArray[i][a][s]=n):n!==this.cropsArray[i][a]?.[s]&&(e=!0,this.cropsArray[i][a][s]=n)})}),t.data.crops.length!==this.cropsArray[i]?.length&&(this.cropsArray[i].length=t.data.crops.length,e=!0)}),e}setupSplatMesh(e,t,i=new O,r=new zt,a=!1,s=1,n,o){this.splatMesh=Um.buildMesh(e,t,a,s,n,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=t,this.splatMesh.onBeforeRender=(l,h,c)=>this.update(l,c)}setupSortWorker(e){this.sortWorker=Mte(e),this.sortWorker.onmessage=t=>{t.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(t.data.indexesBuffer)),this.lastSortTime=t.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):t.data.sortCanceled?this.sortRunning=!1:t.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):t.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(e,t){this.splatMesh!==null&&(this.updateSplatMeshUniforms(e,t),this.updateView(!1,t))}getSplatMesh(){return this.splatMesh}},Ux=new Dh;Ux.wireframe=!0;var fC=new O,yw=class extends So{constructor(e,t){super(),this.data=e,this.sharedAssets=t,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.splatViewer=null,this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new Ste,this.invisibleObjects=new nu("jflkdsafjasdifjaslk",{...q1.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new Xr("fdasfa",{...xu.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=xte(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=yte(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Xr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let a=r;r=r.parent;let s=r.children.indexOf(a);i.splice(0,0,s)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>qP(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===Uu)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof Xr&&t.uiScene){let i=t.uiScene.find(e);if(i)return i}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof Xr&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(i=>{t===void 0&&i instanceof ya&&(t=i.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof Xr&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let r=this.createObject(e.id,e.data,e.children,i,e.localIndex,t);r.updateVisible(this),r.resetBBoxNeedsUpdate(),Hs(r)&&_o(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty(),r.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),_o(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Hs(i)&&(i.freeBooleanPointer(),r instanceof Ph&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof mw&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid),i.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(i),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(this),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Hs(i)&&(i.invalidateUpstreamBooleanData(),_o(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof Ph&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof Xr&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,i,r){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:s}=t.props;t={...t,props:s},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let a=this.find(e);if(a)try{vte(a,t,i,{scene:this,shared:r}),a instanceof ba&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,t,i,r,a,s=[]){e.updateEntityByOp(t,i,r,a),this.traverseEntity(n=>{(n instanceof ya||n instanceof Xr)&&(s.includes(n.frameId??"")||n.frameId===t)&&n.updateEntity2DByOp(t,i,r,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let i=Object.entries(t.data.lib.components).map((r,a)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(r=>{r instanceof _a&&r.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){ui.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{ui.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,a,s,n){if(e){let o=r.find(e);o&&o!==r&&a.forInstancesRec(l=>{l.data=op(l.data,h=>{let c=h.events.data(n.id),u=l.goUp(s);if(u){let d=[...WP(u.identity),e].join("-"),p=this.entityIdentityToEntity[d];if(p){let f=p.uuid,m=na.zoom(c,t);m[i]=f}else console.warn("cannot find instance")}}).data})}}rewriteActions(e,t,i,r,a,s){e.forEach(n=>{n.data.type==="Transition"?this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,a,s):n.data.type==="Animation"&&this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof ou&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{if(r.data.type==="GameControl"){let a=!1;if(t.forInstancesRec(s=>{s.data=op(s.data,n=>{s.isInstanceRoot||(n.events.delete(r.id),a=!0)}).data}),a===!1)for(let s of Cg.list)this.rewriteActions(r.data.gameActions[s],["gameActions",s],e,t,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),this.rewriteActions(r.data.inActions,["inActions"],e,t,i,r),this.rewriteActions(r.data.outActions,["outActions"],e,t,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],e,t,i,r)})}),!0})}expandInstances(e,t,i){let r=new Set;this.traverseEntity(a=>{if(a instanceof ou&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:r}),t||a.resetBBoxNeedsUpdate(),i&&a.traverseEntity(s=>{i.addClip(s)}),!0});for(let a of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),gw(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof ou&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i]),t.dispose()})}clearScene(){for(let e of this.children)ui.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let i=[],r=a=>{for(let s of a.children){let n=s.cloner;if(ui.is(s)&&!s.raycastLock&&(s.visible||n?.object.data.visible))if(t===!0&&s.isInstanceRoot){let o=[];if(e.intersectObject(s,!0,o),o.length){let l=o[0];l.object=s,l.point.applyMatrix4(l.object.matrixWorld);let h=s.matrixWorld.clone().invert();l.point.applyMatrix4(h),i.push(l)}}else(Hs(s)||Ax(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,i),Bx(s,e,i)),r(s)}};return r(this.activePage),i}raycastWithClones(e){let t=[],i=r=>{for(let a of r.children){let s=a.cloner;ui.is(a)&&(a.visible||s?.object.data.visible)&&((Hs(a)||Ax(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),Bx(a,e,t,!0)),i(a))}};return i(this),t}forEachEntity(e){for(let t of this.children)ui.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)ui.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)ui.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(i=>{if(i instanceof ba&&i.data.type==="Mesh"&&i.data.geometry.type==="TextGeometry"&&i.data.geometry.font===e){let r=i.geometry,a=i.data.geometry;r.updateFont(e,t).then(()=>{r.update(a);let s=i.invalidateDownstreamBooleanData();_o(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)mp.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)ui.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,i){let r=0;for(let a of e)this.createObject(a.id,a.data,a.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,a,s){let n={scene:this,shared:s},o=vw(e,t,n);return o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(a,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,s)),o.updateState(t,n),o instanceof ba&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(this),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&o.traverseEntity(l=>{let h=l.dataPatched;if(l instanceof ba&&h.bones&&h.boneInverses){let c=h.bones.map(p=>this.find(p)),u=h.boneInverses.map(p=>new je().fromArray(p)),d=new nb(c,u);l.bind(d,l.bindMatrix)}else l.matrixAutoUpdate=!0}),o}getCenter(e){let t=[];for(let r=0,a=e.length;r<a;++r){let{id:s,recursive:n}=e[r],o=this.find(s),l=n?o.recursiveBBox:o.singleBBox;t.push(...l.vertices)}let i=new sr;return i.setFromPoints(t),i.getCenter(fC),fC}copyMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e);i?t.copy(i.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e)?.parent;i?t.copy(i.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Fa)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof Tl&&e(t.material[i]);else t.material instanceof Tl&&e(t.material)})}updateViewPlaneSize(e,t,i=!1){this.traverseConcreteEntity(r=>{r instanceof _a&&r.setViewplaneSize(e,t,i)})}initializeSplatViewer(){this.splatViewer=new Dte({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}},Fm=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},Rte=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Lte(Math.atan2(r,i))},Ote=(e,t,i)=>{let r={x:0,y:0};return i=Fx(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},Fx=e=>e*(Math.PI/180),Lte=e=>e*(180/Math.PI),Ite=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,Ty=new Map,mC=e=>{Ty.has(e)&&clearTimeout(Ty.get(e)),Ty.set(e,setTimeout(e,100))},Vg=(e,t,i)=>{let r=t.split(/[ ,]+/g),a;for(let s=0;s<r.length;s+=1)a=r[s],e.addEventListener?e.addEventListener(a,i,!1):e.attachEvent&&e.attachEvent(a,i)},gC=(e,t,i)=>{let r=t.split(/[ ,]+/g),a;for(let s=0;s<r.length;s+=1)a=r[s],e.removeEventListener?e.removeEventListener(a,i):e.detachEvent&&e.detachEvent(a,i)},yR=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),vC=()=>{if(typeof window>"u")return;let e=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:e,y:t}},Nx=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},xw=(e,t,i)=>{let r=xR(e);for(let a in r)if(r.hasOwnProperty(a))if(typeof t=="string")r[a]=t+" "+i;else{let s="";for(let n=0,o=t.length;n<o;n+=1)s+=t[n]+" "+i+", ";r[a]=s.slice(0,-2)}return r},Bte=(e,t)=>{let i=xR(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},xR=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},Py=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},Ute=(e,t)=>{let i={};for(let r in e)e.hasOwnProperty(r)&&t.hasOwnProperty(r)?i[r]=t[r]:e.hasOwnProperty(r)&&(i[r]=e[r]);return i},zx=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},Fte=(e,t,i)=>({x:Math.min(Math.max(e.x,t.x-i),t.x+i),y:Math.min(Math.max(e.y,t.y-i),t.y+i)});typeof window<"u"&&(bR="ontouchstart"in window,wR=!!window.PointerEvent,_R=!!window.MSPointerEvent);var bR,wR,_R,Ad={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},qc,yp={};wR?qc=Ad.pointer:_R?qc=Ad.MSPointer:bR?(qc=Ad.touch,yp=Ad.mouse):qc=Ad.mouse;function Uh(){}Uh.prototype.on=function(e,t){var i=this,r=e.split(/[ ,]+/g),a;i._handlers_=i._handlers_||{};for(var s=0;s<r.length;s+=1)a=r[s],i._handlers_[a]=i._handlers_[a]||[],i._handlers_[a].push(t);return i};Uh.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i};Uh.prototype.trigger=function(e,t){var i=this,r=e.split(/[ ,]+/g),a;i._handlers_=i._handlers_||{};for(var s=0;s<r.length;s+=1)a=r[s],i._handlers_[a]&&i._handlers_[a].length&&i._handlers_[a].forEach(function(n){n.call(i,{type:a,target:i},t)})};Uh.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=Ute(t.options,e))};Uh.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},Vg(e,qc[t],i._domHandlers_[t]),yp[t]&&Vg(e,yp[t],i._domHandlers_[t]),i};Uh.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},gC(e,qc[t],i._domHandlers_[t]),yp[t]&&gC(e,yp[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var bw=Uh;function kr(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=kr.id,kr.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}kr.prototype=new bw;kr.constructor=kr;kr.id=0;kr.prototype.buildEl=function(e){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};kr.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=Bte("borderRadius","50%"),i=xw("transition","opacity",e),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},Py(r.el,i),this.options.shape==="circle"&&Py(r.back,t),Py(r.front,t),this.applyStyles(r),this};kr.prototype.applyStyles=function(e){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this};kr.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};kr.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};kr.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};kr.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t};kr.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t};kr.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",a={};a.front=xw("transition",["top","left"],r);var s={front:{}};s.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(a),i.applyStyles(s),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)};kr.prototype.restCallback=function(){var e=this,t={};t.front=xw("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};kr.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};kr.prototype.computeDirection=function(e){var t=e.angle.radian,i=Math.PI/4,r=Math.PI/2,a,s,n;if(t>i&&t<i*3&&!e.lockX?a="up":t>-i&&t<=i&&!e.lockY?a="left":t>-i*3&&t<=-i&&!e.lockX?a="down":e.lockY||(a="right"),e.lockY||(t>-r&&t<r?s="left":s="right"),e.lockX||(t>0?n="up":n="down"),e.force>this.options.threshold){var o={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(o[l]=this.direction[l]);var h={};this.direction={x:s,y:n,angle:a},e.direction=this.direction;for(l in o)o[l]===this.direction[l]&&(h[l]=!0);if(h.x&&h.y&&h.angle)return e;(!h.x||!h.y)&&this.trigger("plain",e),h.x||this.trigger("plain:"+s,e),h.y||this.trigger("plain:"+n,e),h.angle||this.trigger("dir dir:"+a,e)}else this.resetDirection();return e};var Nte=kr;function wr(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=wr.id,wr.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(t),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}wr.prototype=new bw;wr.constructor=wr;wr.id=0;wr.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,a=t.length;r<a;r+=1)if(t[r].identifier===i)return t[r];return!1}};wr.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};wr.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}};wr.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,a={},s=i.options,n={x:i.parentIsFlex?r.x:r.x+i.box.left,y:i.parentIsFlex?r.y:r.y+i.box.top};if(e.x&&e.y)a={x:e.x-n.x,y:e.y-n.y};else if(e.top||e.right||e.bottom||e.left){var o=document.createElement("DIV");o.style.display="hidden",o.style.top=e.top,o.style.right=e.right,o.style.bottom=e.bottom,o.style.left=e.left,o.style.position="absolute",s.zone.appendChild(o);var l=o.getBoundingClientRect();s.zone.removeChild(o),a=e,e={x:l.left+r.x,y:l.top+r.y}}var h=new Nte(i,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:e,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(Nx(h.ui.el,a),Nx(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h};wr.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};wr.prototype.bindNipple=function(e){var t=this,i,r=function(a,s){i=a.type+" "+s.id+":"+a.type,t.trigger(i,s)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};wr.prototype.pressureFn=function(e,t,i){var r=this,a=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var s=e.force||e.pressure||e.webkitForce||0;s!==a&&(t.trigger("pressure",s),r.trigger("pressure "+t.identifier+":pressure",s),a=s)}.bind(r),100)};wr.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=yR(e),t.updateBox();var a=function(s){t.actives.length<i.maxNumberOfNipples?t.processOnStart(s):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(l){return l.identifier===n})<0){var o=[e[0]];o.identifier=n,t.processOnEnd(o)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(s))};return zx(e,a),t.manager.bindDocument(),!1};wr.prototype.processOnStart=function(e){var t=this,i=t.options,r,a=t.manager.getIdentifier(e),s=e.force||e.pressure||e.webkitForce||0,n={x:e.pageX,y:e.pageY},o=t.getOrCreate(a,n);o.identifier!==a&&t.manager.removeIdentifier(o.identifier),o.identifier=a;var l=function(c){c.trigger("start",c),t.trigger("start "+c.id+":start",c),c.show(),s>0&&t.pressureFn(e,c,c.identifier),t.processOnMove(e)};if((r=t.idles.indexOf(o))>=0&&t.idles.splice(r,1),t.actives.push(o),t.ids.push(o.identifier),i.mode!=="semi")l(o);else{var h=Fm(n,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};wr.prototype.getOrCreate=function(e,t){var i=this,r=i.options,a;return/(semi|static)/.test(r.mode)?(a=i.idles[0],a?(i.idles.splice(0,1),a):r.mode==="semi"?i.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1)):(a=i.createNipple(t,e),a)};wr.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),a=t.nipples.get(r),s=t.manager.scroll;if(!Ite(e)){this.processOnEnd(e);return}if(!a){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(i.dynamicPage){var n=a.el.getBoundingClientRect();a.position={x:s.x+n.left,y:s.y+n.top}}a.identifier=r;var o=a.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=a.position.y),i.lockY&&(l.x=a.position.x);var h=Fm(l,a.position),c=Rte(l,a.position),u=Fx(c),d=h/o,p={distance:h,position:l},f,m;if(a.options.shape==="circle"?(f=Math.min(h,o),m=Ote(a.position,f,c)):(m=Fte(l,a.position,o),f=Fm(m,a.position)),i.follow){if(h>o){let b=l.x-m.x,_=l.y-m.y;a.position.x+=b,a.position.y+=_,a.el.style.top=a.position.y-(t.box.top+s.y)+"px",a.el.style.left=a.position.x-(t.box.left+s.x)+"px",h=Fm(l,a.position)}}else l=m,h=f;var g=l.x-a.position.x,v=l.y-a.position.y;a.frontPosition={x:g,y:v},i.dataOnly||Nx(a.ui.front,a.frontPosition);var x={identifier:a.identifier,position:l,force:d,pressure:e.force||e.pressure||e.webkitForce||0,distance:h,angle:{radian:u,degree:c},vector:{x:g/o,y:-v/o},raw:p,instance:a,lockX:i.lockX,lockY:i.lockY};x=a.computeDirection(x),x.angle={radian:Fx(180-c),degree:180-c},a.trigger("move",x),t.trigger("move "+a.id+":move",x)};wr.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),a=t.nipples.get(r),s=t.manager.removeIdentifier(a.identifier);!a||(i.dataOnly||a.hide(function(){i.mode==="dynamic"&&(a.trigger("removed",a),t.trigger("removed "+a.id+":removed",a),t.manager.trigger("removed "+a.id+":removed",a),a.destroy())}),clearInterval(t.pressureIntervals[a.identifier]),a.resetDirection(),a.trigger("end",a),t.trigger("end "+a.id+":end",a),t.ids.indexOf(a.identifier)>=0&&t.ids.splice(t.ids.indexOf(a.identifier),1),t.actives.indexOf(a)>=0&&t.actives.splice(t.actives.indexOf(a),1),/(semi|static)/.test(i.mode)?t.idles.push(a):t.nipples.indexOf(a)>=0&&t.nipples.splice(t.nipples.indexOf(a),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[s.id]=s.identifier))};wr.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()};wr.prototype.destroy=function(){var e=this;e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()});for(var t in e.pressureIntervals)e.pressureIntervals.hasOwnProperty(t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off()};var zte=wr;function ea(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=vC(),t.config(e),t.prepareCollections();var i=function(){var a;t.collections.forEach(function(s){s.forEach(function(n){a=n.el.getBoundingClientRect(),n.position={x:t.scroll.x+a.left,y:t.scroll.y+a.top}})})};if(typeof window>"u")return t.collections;Vg(window,"resize",function(){mC(i)});var r=function(){t.scroll=vC()};return Vg(window,"scroll",function(){mC(r)}),t.collections}ea.prototype=new bw;ea.constructor=ea;ea.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return i=r.get(t),!i}),i}};ea.prototype.create=function(e){return this.createCollection(e)};ea.prototype.createCollection=function(e){var t=this,i=new zte(t,e);return t.bindCollection(i),t.collections.push(i),i};ea.prototype.bindCollection=function(e){var t=this,i,r=function(a,s){i=a.type+" "+s.id+":"+a.type,t.trigger(i,s)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};ea.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};ea.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};ea.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};ea.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t};ea.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};ea.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};ea.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};ea.prototype.onAny=function(e,t){var i=this,r,a="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=yR(t);var s=function(o,l,h){h.ids.indexOf(l)>=0&&(h[a](o),o._found_=!0)},n=function(o){r=i.getIdentifier(o),zx(i.collections,s.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return zx(t,n),!1};ea.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.off()};ea.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1)};var kte=ea,yC=new kte,Vte={create:function(e){return yC.create(e)},factory:yC},SR=new Map,Xd=new Map,ph=class{constructor(e,t,i,r){this.data=t;let{audio:a,volume:s,delay:n,loop:o}=t;if(!a)throw new Error("Missing property");let l=typeof a=="string"?r.getAudio(a).src:a.data;this.audioPlayer=new Ud({src:l,volume:s,delay:n,loop:o}),Xd.has(i.uuid)?Xd.get(i.uuid).push(this):Xd.set(i.uuid,[this]),SR.set(e,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},kx=class{constructor(e){this.data=e}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(e){let t=SR.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):t.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(e){let t=Xd.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let e=[...Xd.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},AR=class{constructor(e,t,i,r,a){if(this.data=t,this.shared=r,this.condition=a,t.interaction==="play")this.interaction=new ph(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new kx(t);else throw new Error("Missing property")}dispatchBasic(){if(ar(this.shared,this.condition)===!1)return!1;this.interaction instanceof ph?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(ar(this.shared,this.condition)===!1)return!1;this.interaction instanceof ph?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){if(ar(this.shared,this.condition)===!1)return!1;this.interaction instanceof ph&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}},ER=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.delay=0,this.emission=e.emission,e.delay!==void 0&&(this.delay=e.delay),this.particleSystem=this.page.scene.find(this.data.emitterObjectId)}toggleEmitting(){this.particleSystem.started&&!this.particleSystem.stopped?this.stop():this.start(this.delay)}toggleFroze(){this.particleSystem.started&&!this.particleSystem.isFrozen?this.freeze():this.unFreeze()}start(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.start(0),this.clearDelay()},this.delay);return}this.particleSystem.start()}stop(){this.particleSystem.stop(),this.clearDelay()}freeze(){this.particleSystem.froze(),this.clearDelay()}unFreeze(){this.particleSystem.unFroze(),this.clearDelay()}reset(){this.particleSystem.reset(),this.clearDelay()}reverseFromCurrent(){switch(this.emission){case"emitToggle":this.toggleEmitting();break;case"pauseToggle":this.toggleFroze();break}}dispatchBasic(){if(ar(this.shared,this.condition)===!1||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"emitToggle":this.toggleEmitting();break;case"pause":this.freeze();break;case"pauseToggle":this.toggleFroze();break;case"stop":this.stop();break;case"reset":this.reset();break;default:break}}dispatchConditional(){if(ar(this.shared,this.condition)===!1||!this.particleSystem)return!1;switch(this.emission){case"start":this.particleSystem.start();break;case"stop":this.particleSystem.stop();break;case"reset":this.particleSystem.reset();break;default:break}}dispatchGameControl(e){if(ar(this.shared,this.condition)===!1||!this.particleSystem)return!1;e==="start"?this.particleSystem.start():this.particleSystem.stop()}dispose(){!this.particleSystem||(this.particleSystem.reset(),this.clearDelay())}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}},jte="text/plain",Gte="us-ascii",xC=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),Hte=(e,{stripHash:t})=>{let i=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);if(!i)throw new Error(`Invalid URL: ${e}`);let{type:r,data:a,hash:s}=i.groups,n=r.split(";");s=t?"":s;let o=!1;n[n.length-1]==="base64"&&(n.pop(),o=!0);let l=(n.shift()||"").toLowerCase(),h=[...n.map(c=>{let[u,d=""]=c.split("=").map(p=>p.trim());return u==="charset"&&(d=d.toLowerCase(),d===Gte)?"":`${u}${d?`=${d}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==jte)&&h.unshift(l),`data:${h.join(";")},${o?a.trim():a}${s?`#${s}`:""}`};function Wte(e,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},e=e.trim(),/^data:/i.test(e))return Hte(e,t);if(/^view-source:/i.test(e))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let i=e.startsWith("//");!i&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let r=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&r.protocol==="https:"&&(r.protocol="http:"),t.forceHttps&&r.protocol==="http:"&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){let s=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,n=0,o="";for(;;){let h=s.exec(r.pathname);if(!h)break;let c=h[0],u=h.index,d=r.pathname.slice(n,u);o+=d.replace(/\/{2,}/g,"/"),o+=c,n=u+c.length}let l=r.pathname.slice(n,r.pathname.length);o+=l.replace(/\/{2,}/g,"/"),r.pathname=o}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let s=r.pathname.split("/"),n=s[s.length-1];xC(n,t.removeDirectoryIndex)&&(s=s.slice(0,-1),r.pathname=s.slice(1).join("/")+"/")}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let s of[...r.searchParams.keys()])xC(s,t.removeQueryParameters)&&r.searchParams.delete(s);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let a=e;return e=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!a.endsWith("/")&&r.hash===""&&(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),i&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}var qte=class{constructor({url:e,context:t},i,r,a){if(this.controlsManager=i,this.shared=r,this.condition=a,!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:Wte(e,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=t??"tab"}dispatch(){if(ar(this.shared,this.condition)===!1)return!1;Ob?window.location.assign(this.url):(this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.controlsManager.orbitControls?.onPointerUp(Lt[0]),nq())}},MR=class{constructor(e,t,i,r,a){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=a,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=s=>{this.timeoutIdQueue.shift();let n=this.page.scene.find(s);if(n===void 0)return;let o=this.controlsManager.sharedGameControlGlobals.rapierWorld,l=o?n.dataPatched.physics?.fusedBody:!0;if(n.cloner){for(let h of n.cloner.children)l?(h.playModeVisible=!1,h.rigidBody&&n.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(h.rigidBody.collider(0).handle),o.removeRigidBody(h.rigidBody),h.rigidBody=void 0),h.bvhGeometry&&(h.bvhGeometry=void 0)):this.clone===void 0||this.clone===h?(h.playModeVisible=!1,h.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(h.rigidBody.collider(0).handle),o.removeRigidBody(h.rigidBody),h.rigidBody=void 0)):h.playModeVisible===void 0&&(h.playModeVisible=!0);(l||this.clone===void 0||this.clone===!1)&&(n.visible=!1,n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0))}else n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0),n.visible=!1;o===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.rigidBody!==void 0),n.destroyedInAction=!0,this.controlsManager.requestRender()},this.objects=[...e.objects]}dispatch(e){if(ar(this.shared,this.condition)===!1)return!1;this.clone=e,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(ar(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(e=>window.clearTimeout(e))}},CR=class{constructor(e,t,i,r,a){this.data=e,this.page=t,this.shared=i,this.eventManager=r,this.condition=a,this.shared=i}dispatch(){if(ar(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),Rw(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},TR={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,timelineChangeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},ww={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},Xte=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],jg={CSS:{},springs:{}};function Ys(e,t,i){return Math.min(Math.max(e,t),i)}function Yd(e,t){return e.indexOf(t)>-1}function Dy(e,t){return e.apply(null,t)}var Bt={arr:function(e){return Array.isArray(e)},obj:function(e){return Yd(Object.prototype.toString.call(e),"Object")},pth:function(e){return Bt.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return!("isNode"in e)&&(e.nodeType||Bt.svg(e))},str:function(e){return typeof e=="string"},fnc:function(e){return typeof e=="function"},und:function(e){return typeof e>"u"},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return Bt.hex(e)||Bt.rgb(e)||Bt.hsl(e)},key:function(e){return!TR.hasOwnProperty(e)&&!ww.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function PR(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function DR(e,t){var i=PR(e),r=Ys(Bt.und(i[0])?1:i[0],.1,100),a=Ys(Bt.und(i[1])?100:i[1],.1,100),s=Ys(Bt.und(i[2])?10:i[2],.1,100),n=Ys(Bt.und(i[3])?0:i[3],.1,100),o=Math.sqrt(a/r),l=s/(2*Math.sqrt(a*r)),h=l<1?o*Math.sqrt(1-l*l):0,c=1,u=l<1?(l*o+-n)/h:-n+o;function d(f){var m=t?t*f/1e3:f;return l<1?m=Math.exp(-m*l*o)*(c*Math.cos(h*m)+u*Math.sin(h*m)):m=(c+u*m)*Math.exp(-m*o),f===0||f===1?f:1-m}function p(){var f=jg.springs[e];if(f)return f;for(var m=1/6,g=0,v=0;;)if(g+=m,d(g)===1){if(v++,v>=16)break}else v=0;var x=g*m*1e3;return jg.springs[e]=x,x}return t?d:p}function Yte(e){return e===void 0&&(e=10),function(t){return Math.ceil(Ys(t,1e-6,1)*e)*(1/e)}}var Qte=function(){var e=11,t=1/(e-1);function i(c,u){return 1-3*u+3*c}function r(c,u){return 3*u-6*c}function a(c){return 3*c}function s(c,u,d){return((i(u,d)*c+r(u,d))*c+a(u))*c}function n(c,u,d){return 3*i(u,d)*c*c+2*r(u,d)*c+a(u)}function o(c,u,d,p,f){var m,g,v=0;do g=u+(d-u)/2,m=s(g,p,f)-c,m>0?d=g:u=g;while(Math.abs(m)>1e-7&&++v<10);return g}function l(c,u,d,p){for(var f=0;f<4;++f){var m=n(u,d,p);if(m===0)return u;var g=s(u,d,p)-c;u-=g/m}return u}function h(c,u,d,p){if(!(0<=c&&c<=1&&0<=d&&d<=1))return;var f=new Float32Array(e);if(c!==u||d!==p)for(var m=0;m<e;++m)f[m]=s(m*t,c,d);function g(v){for(var x=0,b=1,_=e-1;b!==_&&f[b]<=v;++b)x+=t;--b;var M=(v-f[b])/(f[b+1]-f[b]),A=x+M*t,S=n(A,c,d);return S>=.001?l(v,A,c,d):S===0?A:o(v,x,x+t,c,d)}return function(v){return c===u&&d===p||v===0||v===1?v:s(g(v),u,p)}}return h}(),RR=function(){var e={linear:function(){return function(r){return r}}},t={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var a,s=4;r<((a=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((a*3-2)/22-r,2)}},Elastic:function(r,a){r===void 0&&(r=1),a===void 0&&(a=.5);var s=Ys(r,1,10),n=Ys(a,.1,2);return function(o){return o===0||o===1?o:-s*Math.pow(2,10*(o-1))*Math.sin((o-1-n/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/n)}}},i=["Quad","Cubic","Quart","Quint","Expo"];return i.forEach(function(r,a){t[r]=function(){return function(s){return Math.pow(s,a+2)}}}),Object.keys(t).forEach(function(r){var a=t[r];e["easeIn"+r]=a,e["easeOut"+r]=function(s,n){return function(o){return 1-a(s,n)(1-o)}},e["easeInOut"+r]=function(s,n){return function(o){return o<.5?a(s,n)(o*2)/2:1-a(s,n)(o*-2+2)/2}}}),e}();function _w(e,t){if(Bt.fnc(e))return e;var i=e.split("(")[0],r=RR[i],a=PR(e);switch(i){case"spring":return DR(e,t);case"cubicBezier":return Dy(Qte,a);case"steps":return Dy(Yte,a);default:return Dy(r,a)}}function OR(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function vv(e,t){for(var i=e.length,r=arguments.length>=2?arguments[1]:void 0,a=[],s=0;s<i;s++)if(s in e){var n=e[s];t.call(r,n,s,e)&&a.push(n)}return a}function yv(e){return e.reduce(function(t,i){return t.concat(Bt.arr(i)?yv(i):i)},[])}function bC(e){return Bt.arr(e)?e:(Bt.str(e)&&(e=OR(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function Sw(e,t){return e.some(function(i){return i===t})}function Aw(e){var t={};for(var i in e)t[i]=e[i];return t}function Vx(e,t){var i=Aw(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function xv(e,t){var i=Aw(e);for(var r in t)i[r]=Bt.und(e[r])?t[r]:e[r];return i}function Kte(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function Zte(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,function(o,l,h,c){return l+l+h+h+c+c}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),a=parseInt(r[1],16),s=parseInt(r[2],16),n=parseInt(r[3],16);return"rgba("+a+","+s+","+n+",1)"}function Jte(e){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),i=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,a=parseInt(t[3],10)/100,s=t[4]||1;function n(d,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?d+(p-d)*6*f:f<1/2?p:f<2/3?d+(p-d)*(2/3-f)*6:d}var o,l,h;if(r==0)o=l=h=a;else{var c=a<.5?a*(1+r):a+r-a*r,u=2*a-c;o=n(u,c,i+1/3),l=n(u,c,i),h=n(u,c,i-1/3)}return"rgba("+o*255+","+l*255+","+h*255+","+s+")"}function $te(e){if(Bt.rgb(e))return Kte(e);if(Bt.hex(e))return Zte(e);if(Bt.hsl(e))return Jte(e)}function Mo(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function eie(e){if(Yd(e,"translate")||e==="perspective")return"px";if(Yd(e,"rotate")||Yd(e,"skew"))return"deg"}function jx(e,t){return Bt.fnc(e)?e(t.target,t.id,t.total):e}function Tn(e,t){return e.getAttribute(t)}function Ew(e,t,i){var r=Mo(t);if(Sw([i,"deg","rad","turn"],r))return t;var a=jg.CSS[t+i];if(!Bt.und(a))return a;var s=100,n=document.createElement(e.tagName),o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(n),n.style.position="absolute",n.style.width=s+i;var l=s/n.offsetWidth;o.removeChild(n);var h=l*parseFloat(t);return jg.CSS[t+i]=h,h}function LR(e,t,i){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return i?Ew(e,a,i):a}}function Mw(e,t){if(Bt.dom(e)&&!Bt.inp(e)&&(Tn(e,t)||Bt.svg(e)&&e[t]))return"attribute";if(Bt.dom(e)&&Sw(Xte,t))return"transform";if(Bt.dom(e)&&t!=="transform"&&LR(e,t))return"css";if(e[t]!=null)return"object"}function IR(e){if(Bt.dom(e)){for(var t=e.style.transform||"",i=/(\w+)\(([^)]*)\)/g,r=new Map,a;a=i.exec(t);)r.set(a[1],a[2]);return r}}function tie(e,t,i,r){var a=Yd(t,"scale")?1:0+eie(t),s=IR(e).get(t)||a;return i&&(i.transforms.list.set(t,s),i.transforms.last=t),r?Ew(e,s,r):s}function Cw(e,t,i,r){switch(Mw(e,t)){case"transform":return tie(e,t,r,i);case"css":return LR(e,t,i);case"attribute":return Tn(e,t);default:return e[t]||0}}function Tw(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=Mo(e)||0,a=parseFloat(t),s=parseFloat(e.replace(i[0],""));switch(i[0][0]){case"+":return a+s+r;case"-":return a-s+r;case"*":return a*s+r}}function BR(e,t){if(Bt.col(e))return $te(e);if(/\s/g.test(e))return e;var i=Mo(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function Pw(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function iie(e){return Math.PI*2*Tn(e,"r")}function rie(e){return Tn(e,"width")*2+Tn(e,"height")*2}function aie(e){return Pw({x:Tn(e,"x1"),y:Tn(e,"y1")},{x:Tn(e,"x2"),y:Tn(e,"y2")})}function UR(e){for(var t=e.points,i=0,r,a=0;a<t.numberOfItems;a++){var s=t.getItem(a);a>0&&(i+=Pw(r,s)),r=s}return i}function sie(e){var t=e.points;return UR(e)+Pw(t.getItem(t.numberOfItems-1),t.getItem(0))}function FR(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return iie(e);case"rect":return rie(e);case"line":return aie(e);case"polyline":return UR(e);case"polygon":return sie(e)}}function nie(e){var t=FR(e);return e.setAttribute("stroke-dasharray",t),t}function oie(e){for(var t=e.parentNode;Bt.svg(t)&&Bt.svg(t.parentNode);)t=t.parentNode;return t}function NR(e,t){var i=t||{},r=i.el||oie(e),a=r.getBoundingClientRect(),s=Tn(r,"viewBox"),n=a.width,o=a.height,l=i.viewBox||(s?s.split(" "):[0,0,n,o]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:n/l[2],h:o/l[3]}}function lie(e,t){var i=Bt.str(e)?OR(e)[0]:e,r=t||100;return function(a){return{property:a,el:i,svg:NR(i),totalLength:FR(i)*(r/100)}}}function hie(e,t){function i(o){o===void 0&&(o=0);var l=t+o>=1?t+o:0;return e.el.getPointAtLength(l)}var r=NR(e.el,e.svg),a=i(),s=i(-1),n=i(1);switch(e.property){case"x":return(a.x-r.x)*r.w;case"y":return(a.y-r.y)*r.h;case"angle":return Math.atan2(n.y-s.y,n.x-s.x)*180/Math.PI}}function wC(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=BR(Bt.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:Bt.str(e)||t?r.split(i):[]}}function zR(e){var t=e?yv(Bt.arr(e)?e.map(bC):bC(e)):[];return vv(t,function(i,r,a){return a.indexOf(i)===r})}function kR(e){var t=zR(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:IR(i)}}})}function cie(e,t){var i=Aw(t);if(/^spring/.test(i.easing)&&(i.duration=DR(i.easing)),Bt.arr(e)){var r=e.length,a=r===2&&!Bt.obj(e[0]);a?e={value:e}:Bt.fnc(t.duration)||(i.duration=t.duration/r)}var s=Bt.arr(e)?e:[e];return s.map(function(n,o){var l=Bt.obj(n)&&!Bt.pth(n)?n:{value:n};return Bt.und(l.delay)&&(l.delay=o?0:t.delay),Bt.und(l.endDelay)&&(l.endDelay=o===s.length-1?t.endDelay:0),l}).map(function(n){return xv(n,i)})}function uie(e){for(var t=vv(yv(e.map(function(s){return Object.keys(s)})),function(s){return Bt.key(s)}).reduce(function(s,n){return s.indexOf(n)<0&&s.push(n),s},[]),i={},r=function(s){var n=t[s];i[n]=e.map(function(o){var l={};for(var h in o)Bt.key(h)?h==n&&(l.value=o[h]):l[h]=o[h];return l})},a=0;a<t.length;a++)r(a);return i}function die(e,t){var i=[],r=t.keyframes;r&&(t=xv(uie(r),t));for(var a in t)Bt.key(a)&&i.push({name:a,tweens:cie(t[a],e)});return i}function pie(e,t){var i={};for(var r in e){var a=jx(e[r],t);Bt.arr(a)&&(a=a.map(function(s){return jx(s,t)}),a.length===1&&(a=a[0])),i[r]=a}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function fie(e,t){var i;return e.tweens.map(function(r){var a=pie(r,t),s=a.value,n=Bt.arr(s)?s[1]:s,o=Mo(n),l=Cw(t.target,e.name,o,t),h=i?i.to.original:l,c=Bt.arr(s)?s[0]:h,u=Mo(c)||Mo(l),d=o||u;return Bt.und(n)&&(n=h),a.from=wC(c,d),a.to=wC(Tw(n,c),d),a.start=i?i.end:0,a.end=a.start+a.delay+a.duration+a.endDelay,a.easing=_w(a.easing,a.duration),a.isPath=Bt.pth(s),a.isColor=Bt.col(a.from.original),a.isColor&&(a.round=1),i=a,a})}var VR={css:function(e,t,i){return e.style[t]=i},attribute:function(e,t,i){return e.setAttribute(t,i)},object:function(e,t,i){return e[t]=i},transform:function(e,t,i,r,a){if(r.list.set(t,i),t===r.last||a){var s="";r.list.forEach(function(n,o){s+=o+"("+n+") "}),e.style.transform=s}}};function jR(e,t){var i=kR(e);i.forEach(function(r){for(var a in t){var s=jx(t[a],r),n=r.target,o=Mo(s),l=Cw(n,a,o,r),h=o||Mo(l),c=Tw(BR(s,h),l),u=Mw(n,a);VR[u](n,a,c,r.transforms,!0)}})}function mie(e,t){var i=Mw(e.target,t.name);if(i){var r=fie(t,e),a=r[r.length-1];return{type:i,property:t.name,animatable:e,tweens:r,duration:a.end,delay:r[0].delay,endDelay:a.endDelay}}}function gie(e,t){return vv(yv(e.map(function(i){return t.map(function(r){return mie(i,r)})})),function(i){return!Bt.und(i)})}function GR(e,t){var i=e.length,r=function(s){return s.timelineOffset?s.timelineOffset:0},a={};return a.duration=i?Math.max.apply(Math,e.map(function(s){let n=s.startOnceDelay??0,o=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+n+o+l+s.duration*(s.loop??1)})):t.duration,a.delay=i?Math.min.apply(Math,e.map(function(s){let n=s.startOnceDelay??0,o=s.pingPongDelayCorrection??0;return r(s)+n+o+s.delay})):t.delay,a.endDelay=i?a.duration-Math.max.apply(Math,e.map(function(s){let n=s.startOnceDelay??0,o=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+n+o+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,a}var _C=0;function vie(e){var t=Vx(TR,e),i=Vx(ww,e),r=die(i,e),a=kR(e.targets),s=gie(a,r),n=GR(s,i),o=_C;return _C++,xv(t,{id:o,children:[],animatables:a,animations:s,duration:n.duration,delay:n.delay,endDelay:n.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection,pingPongEndDelayCorrection:i.pingPongEndDelayCorrection})}var Ms=[],SC=[],Nm,yie=function(){function e(){Nm=requestAnimationFrame(t)}function t(i){var r=Ms.length;if(r){for(var a=0;a<r;){var s=Ms[a];s.paused?(Ms.splice(a,1),r-=1):(s.tick(i),a++)}e()}else Nm=cancelAnimationFrame(Nm)}return e}();function xie(e){document.hidden?(Ms.forEach(function(t){return t.pause(e.timeStamp)}),SC=Ms.slice(0),br.running=Ms=[]):SC.forEach(function(t){return t.play(e.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",xie);function br(e){e===void 0&&(e={});var t=0,i=0,r=0,a,s,n=0,o=null;function l(S){var P=window.Promise&&new Promise(function(L){return o=L});return S.finished=P,P}var h=vie(e),c=l(h);function u(){var S=h.direction;S!=="alternate"&&(h.direction=S!=="normal"?"normal":"reverse"),h.reversed=!h.reversed,s.forEach(function(P){(P.loop===1||P.loop%2===0)&&(P.reversed=h.reversed)})}function d(){h.direction="normal",h.reversed=!1,s.forEach(function(S){return S.reversed=!1})}function p(S){return h.reversed?h.duration-S:S}function f(){t=0,i=p(h.currentTime)*(1/br.speed)}function m(S,P,L=!1){P&&(h.reversed?P.seek(P.duration*P.loop-(S-P.timelineOffset-P.pingPongDelayCorrection),L):P.seek(S-P.timelineOffset-P.startOnceDelay-P.pingPongDelayCorrection,L))}function g(S,P=!1){if(h.reversed)for(var L=n;L--;)m(S,s[L],P);else for(var E=0;E<n;E++)m(S,s[E],P)}function v(S){var P=0,L=h.animations,E=L.length;for(h.direction!=="alternate"&&h.parent?.direction==="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1&&(h.parent?.reversed&&h.direction==="alternate"?S=h.duration-h.delay+h.endDelay-S:S=h.duration+h.delay-h.endDelay-S):M(!1,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)&&(h.parent?.reversed&&h.direction==="alternate"?S=h.duration-h.delay+h.endDelay-S:S=h.duration+h.delay-h.endDelay-S);P<E;){var T=L[P],B=T.animatable,V=T.tweens,I=V.length-1,H=V[I];I&&(H=vv(V,function(Pe){return S<Pe.end})[0]||H);let Re;h.parent?.reversed&&h.direction==="alternate"?Re=Ys(S-H.start-H.endDelay,0,H.duration)/H.duration:Re=Ys(S-H.start-H.delay,0,H.duration)/H.duration;for(var q=isNaN(Re)?1:H.easing(Re),X=H.to.strings,Y=H.round,ie=[],ce=H.to.numbers.length,de=void 0,ue=0;ue<ce;ue++){var re=void 0;let Pe,te;h.direction!=="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1?(Pe=H.to.numbers[ue],te=H.from.numbers[ue]||0):(te=H.to.numbers[ue],Pe=H.from.numbers[ue]||0):M(!0,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)?(Pe=H.to.numbers[ue],te=H.from.numbers[ue]||0):(te=H.to.numbers[ue],Pe=H.from.numbers[ue]||0),H.isPath?re=hie(H.value,q*te):re=Pe+q*(te-Pe),Y&&(H.isColor&&ue>2||(re=Math.round(re*Y)/Y)),ie.push(re)}var se=X.length;if(!se)de=ie[0];else{de=X[0];for(var he=0;he<se;he++){var _e=X[he],Ee=X[he+1],fe=ie[he];isNaN(fe)||(Ee?de+=fe+Ee:de+=fe+" ")}}VR[T.type](B.target,T.property,de,B.transforms),T.currentValue=de,P++}}function x(S){h[S]&&!h.passThrough&&h[S](h)}function b(){h.remaining&&h.remaining!==!0&&h.remaining--}let _={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function M(S,P,L,E,T){return _[S<<4|P<<3|L<<2|E<<1|T]}function A(S,P=!1){var L=h.duration;let E=h.delay,T=L-h.endDelay;h.parent?.reversed&&h.direction==="alternate"&&(E=h.endDelay,T=L-h.delay);var B=p(S);if(h.progress=Ys(B/L*100,0,100),P||(h.reversePlayback=B<h.currentTime),n&&g(B,P),!h.began&&h.currentTime>=0&&(h.began=!0,x("begin")),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,x("loopBegin")),(h.reversed||B>=0)&&B<=E&&h.currentTime!==0&&(v(0),x("change")),(B>=T&&h.currentTime!==L+h.pingPongDelayCorrection||!L)&&(v(L),x("change")),B>E&&B<T?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,x("changeBegin")),v(B),x("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,x("change"),n&&x("timelineChangeComplete")):h.began&&B>T&&x("changeComplete"),h.currentTime=Ys(B,0,L+h.pingPongDelayCorrection),h.began&&x("update"),S>=L)if(b(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,x("loopComplete"),x("complete"),!h.passThrough&&"Promise"in window&&(o(),c=l(h)));else{n?t+=h.duration/br.speed:t+=h.duration;for(let V of s)V.setStartTime(0),V.remaining=V.loop;x("loopComplete"),h.loopBegan=!1,h.direction==="alternate"?u():n&&d()}}return h.reset=function(){var S=h.direction;h.passThrough=!1,h.currentTime=0,h.progress=0,h.paused=!0,h.began=!1,h.loopBegan=!1,h.changeBegan=!1,h.completed=!1,h.changeCompleted=!1,h.reversePlayback=!1,h.reversed=S==="reverse",h.remaining=h.loop,s=h.children,n=s.length;for(var P=n;P--;)h.children[P].reset();v(h.reversed?h.duration:0)},h.setStartTime=function(S){t=S},h.set=function(S,P){return jR(S,P),h},h.tick=function(S){r=S,t||(t=r),A((r+(i-t))*br.speed)},h.seek=function(S,P=!1){A(S-t,P)},h.pause=function(S){h.paused=!0,n&&(a=S??performance.now())},h.play=function(S){!h.paused||(h.completed&&h.reset(),h.paused=!1,Ms.push(h),n&&a!==void 0&&(t+=(S??performance.now())-a),Nm||yie())},h.reverse=function(){u(),h.completed=!h.reversed,f()},h.restart=function(){h.reset(),h.play()},h.reset(),h.autoplay&&h.play(),h}function AC(e,t){for(var i=t.length;i--;)Sw(e,t[i].animatable.target)&&t.splice(i,1)}function bie(e){for(var t=zR(e),i=Ms.length;i--;){var r=Ms[i],a=r.animations,s=r.children;AC(t,a);for(var n=s.length;n--;){var o=s[n],l=o.animations;AC(t,l),!l.length&&!o.children.length&&s.splice(n,1)}!a.length&&!s.length&&r.pause()}}function wie(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?_w(t.easing):null,a=t.grid,s=t.axis,n=t.from||0,o=n==="first",l=n==="center",h=n==="last",c=Bt.arr(e),u=parseFloat(c?e[0]:e),d=c?parseFloat(e[1]):0,p=Mo(c?e[1]:e)||0,f=t.start||0+(c?u:0),m=[],g=0;return function(v,x,b){if(o&&(n=0),l&&(n=(b-1)/2),h&&(n=b-1),!m.length){for(var _=0;_<b;_++){if(!a)m.push(Math.abs(n-_));else{var M=l?(a[0]-1)/2:n%a[0],A=l?(a[1]-1)/2:Math.floor(n/a[0]),S=_%a[0],P=Math.floor(_/a[0]),L=M-S,E=A-P,T=Math.sqrt(L*L+E*E);s==="x"&&(T=-L),s==="y"&&(T=-E),m.push(T)}g=Math.max.apply(Math,m)}r&&(m=m.map(function(V){return r(V/g)*g})),i==="reverse"&&(m=m.map(function(V){return s?V<0?V*-1:-V:Math.abs(g-V)}))}var B=c?(d-u)/g:u;return f+B*(Math.round(m[x]*100)/100)+p}}function _ie(e){e===void 0&&(e={});var t=br(e);return t.duration=0,t.add=function(i,r){var a=Ms.indexOf(t),s=t.children;a>-1&&Ms.splice(a,1);function n(d){d.passThrough=!0}for(var o=0;o<s.length;o++)n(s[o]);var l=xv(i,Vx(ww,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=Bt.und(r)?h:Tw(r,h),n(t);var c=br(l);n(c),s.push(c),c.parent=t;var u=GR(s,e);return t.delay=u.delay,t.endDelay=u.endDelay,t.duration=u.duration,c.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}br.version="3.2.0";br.speed=1;br.running=Ms;br.remove=bie;br.get=Cw;br.set=jR;br.convertPx=Ew;br.path=lie;br.setDashoffset=nie;br.stagger=wie;br.timeline=_ie;br.easing=_w;br.penner=RR;br.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};var HR=br,EC=new O,MC=new O,CC=new zt;function Sie(e,t,i,r){if(r===0)return i.copy(e);if(r===1)return i.copy(t);let a=e.w*t.w+e.x*t.x+e.y*t.y+e.z*t.z;if(a>=1)return i.copy(e);let s=1-a*a;if(s<=Number.EPSILON){let c=1-r;return i.w=c*e.w+r*t.w,i.x=c*e.x+r*t.x,i.y=c*e.y+r*t.y,i.z=c*e.z+r*t.z,i.normalize(),i}let n=Math.sqrt(s),o=Math.atan2(n,a),l=Math.sin((1-r)*o)/n,h=Math.sin(r*o)/n;return i.w=e.w*l+t.w*h,i.x=e.x*l+t.x*h,i.y=e.y*l+t.y*h,i.z=e.z*l+t.z*h,i}function sa(e,t,i,r,a,s){let n=i[e]?i[e]:void 0,o=r[e];if(o==null)return;let l=n!=null?typeof n=="string"?Number(a.getVariable(n)??0):n:t[e],h=typeof o=="string"?Number(a.getVariable(o)??0):o;if(l!==h)return{update:c=>{let u=dt.lerp(l,h,c);s?t[e]=Math.trunc(u):t[e]=u},start:()=>{t[e]=l},end:()=>{t[e]=h}}}function Dw(e,t,i,r,a,s){let n=i[e]?i[e]:void 0,o=r[e];if(!o)return;let l=t[e],h=[...n??l].map(u=>typeof u=="string"?Number(a.getVariable(u)??0):u),c=[...o].map(u=>typeof u=="string"?Number(a.getVariable(u)??0):u);if(!(h.length!==c.length||GP(h,c)))return{update:u=>{h.forEach((d,p)=>{let f=dt.lerp(d,c[p],u);t[e][p]=s?Math.trunc(f):f})},start:()=>{Object.assign(t[e],h)},end:()=>{Object.assign(t[e],c)}}}function Gg(e,t,i){return t.forEach((r,a)=>{e.setComponent(a,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function TC(e,t,i,r,a){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=s?Gg(new O,s,a):o.clone(),h=Gg(new O,n,a);if(!l.equals(h))return{update:c=>{o.lerpVectors(l,h,c)},start:()=>{o.copy(l)},end:()=>{o.copy(h)}}}function PC(e,t,i){return t.forEach((r,a)=>{e.setComponent(a,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function Hg(e,t,i,r,a){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=!(o instanceof ae),h=o instanceof ae?o:new ae().fromArray(o),c=s?PC(new ae,s,a):h.clone(),u=PC(new ae,n,a);if(!c.equals(u))return{update:d=>{h.lerpVectors(c,u,d),l&&(t[e]=h.toArray())},start:()=>{h.copy(c),l&&(t[e]=h.toArray())},end:()=>{h.copy(u),l&&(t[e]=h.toArray())}}}function Aie(e,t,i,r){let a=i[e]?i[e]:void 0,s=r[e];if(!s)return;let n=t[e],o=a?new je().fromArray(a):n.clone(),l=new O,h=new zt,c=new O;o.decompose(l,h,c);let u=new je().fromArray(s),d=new O,p=new zt,f=new O;if(u.decompose(d,p,f),!o.equals(u))return{update:m=>{CC.slerpQuaternions(h,p,m),EC.lerpVectors(l,d,m),MC.lerpVectors(c,f,m),n.compose(EC,CC,MC)},start:()=>{n.compose(l,h,c)},end:()=>{n.compose(d,p,f)}}}function Eie(e,t,i,r,a){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=s?typeof s=="string"?a.getColor(s).clone():new _t().setRGB(s.r,s.g,s.b):o.clone(),h=typeof n=="string"?a.getColor(n).clone():new _t().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let c=o.clone();return t[e]=c,{update:u=>{c.lerpColors(l,h,u)},start:()=>{c.copy(l)},end:()=>{c.copy(h)}}}function wm(e,t,i,r,a){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=new ca(o.r,o.g,o.b,o.a),h=s?typeof s=="string"?a.getColor(s).clone():new ca(s.r,s.g,s.b,s.a):l.clone(),c=typeof n=="string"?a.getColor(n).clone():new ca(n.r,n.g,n.b,n.a);if(!h.equals(c))return{update:u=>{l.lerpColors(h,c,u);let d=dt.lerp(h.a,c.a,u);l.a=d,t[e]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(h)},end:()=>{l.copy(c)}}}function Rl(e,t,i,r,a){if(typeof t[e]=="number")return sa(e,t,i??{},r,a);if(Array.isArray(t[e]))return Dw(e,t,i??{},r,a)}function Mie(e,t,i,r){let a=[],s=e.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,n=e.cameraType==="OrthographicCamera"?i.orthographic?.zoom:i.perspective?.zoom;if(n!==void 0){let o=s??e.zoom,l=n;o!==l&&a.push({update:h=>{e.zoom=dt.lerp(o,l,h),e.updateProjectionMatrix()},start:()=>{e.zoom=o,e.updateProjectionMatrix()},end:()=>{e.zoom=l,e.updateProjectionMatrix()}})}if(i.targetOffset!==void 0){let o=sa("targetOffset",e,t,i,r);o&&a.push(o)}return a}function Cie(e,t,i,r){if(i.scaleBaked===void 0)return;let a=(t.scaleBaked??e.data.geometry.scaleBaked).map(o=>typeof o=="string"?Number(r.getVariable(o)??0):o),s=i.scaleBaked.map(o=>typeof o=="string"?Number(r.getVariable(o)??0):o);if(vh.isEqual(a,s))return;let n=[];return n.push({update:o=>{e.updateGeometryInteractions({scaleBaked:[dt.lerp(a[0],s[0],o),dt.lerp(a[1],s[1],o),dt.lerp(a[2],s[2],o)]},r),e.invalidateDownstreamBooleanData()},start:()=>{e.updateGeometryInteractions({scaleBaked:a},r),e.invalidateDownstreamBooleanData()},end:()=>{e.updateGeometryInteractions({scaleBaked:s},r),e.invalidateDownstreamBooleanData()}}),n}function Tie(e,t,i,r){if(!i.extrusion)return;let a=e.extrusion,s=t.extrusion??{},n=i.extrusion,o=[];return T3.forEach(l=>{let h=Rl(l,a,s,n,r);h&&o.push(h)}),o}function Pie(e,t,i,r){let a=[];if(!("geometry"in i))return a;let s=e.geometry.userData.parameters,n="geometry"in t?t.geometry:{},o=i.geometry;if(e instanceof vp){let l=Cie(e,n,o,r);l&&a.push(...l)}else{let l={};if(Object.assign(l,Ao(s,aE)),aE.forEach(h=>{let c=Rl(h,l,n,o,r);c&&a.push(c)}),e instanceof mw){Object.assign(l,{extrusion:{...s.extrusion}});let h=Tie(l,n,o,r);h&&a.push(...h)}a.length&&a.push({update:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},start:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},end:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()}})}return a}function Die(e,t,i,r){let a=[];if(i.intensity!==void 0){let s=sa("intensity",e,t,i,r);s&&a.push(s)}if(i.color!==void 0){let s=Eie("color",e,t,i,r);s&&a.push(s)}return a}function Rie(e,t,i,r){let a=[];if(Array.isArray(e.material)){if(!("materials"in i&&i.materials))return a;let s="materials"in t&&t.materials?t.materials:[],n=i.materials;e.material.forEach((o,l)=>{if(!n[l])return;let h=s[l]??{},c=n[l];typeof h=="string"||typeof c=="string"||a.push(...DC(o,h,c,r))})}else{if(!("material"in i&&i.material))return a;let s="material"in t&&t.material?t.material:{},n=i.material;if(typeof s=="string"||typeof n=="string")return a;a.push(...DC(e.material,s,n,r))}return a}function DC(e,t,i,r){let a=[],s=Wc(i,r)||!!t.layers&&Wc(t,r);a.push(kie(e,s));for(let n of e.layers){let o=t.layers?.data(n.uuid),l=i.layers.data(n.uuid);if(!l||n.type!=="light"&&(!(n.visible??!0)||!(l.visible??!0)))continue;let h=n.getNames().filter(c=>!E3.some(u=>c.includes(u)));for(let c of h)try{let u=n.getValue(c),d;if(c==="colors")d=Nie(n,o,l,c);else if(Array.isArray(u))c==="steps"&&(d=Fie(n,o,l,c));else if(typeof u=="number")d=Oie(n,o,l,c,r);else{if(typeof u=="boolean")continue;u instanceof ae?d=Lie(n,o,l,c):u instanceof O?d=Iie(n,o,l,c,r):u instanceof ca?d=Uie(n,o,l,c,r):u instanceof _t?d=Bie(n,o,l,c,r):"isTexture"in u&&(d=zie(n,o,l,c))}d&&(Array.isArray(d)?a.push(...d):a.push(d))}catch(u){console.error(`lerpMaterial: unexpected material layer for ${c}`,u)}}return a}function Oie(e,t,i,r,a){if(!e.hasValue(r)||!(r in i))return;let s=t?t[r]:e.getValue(r),n=i[r],o=typeof s=="string"?Number(a.getVariable(s)??0):s,l=typeof n=="string"?Number(a.getVariable(n)??0):n;if(o!==l)return{update:h=>{e.setValue(r,dt.lerp(o,l,h))},start:()=>{e.setValue(r,o)},end:()=>{e.setValue(r,l)}}}function Lie(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let a=e.getValue(r),s=t?new ae().fromArray(t[r]):a.clone(),n=new ae().fromArray(i[r]);if(!s.equals(n))return{update:o=>{a.lerpVectors(s,n,o)},start:()=>{a.copy(s)},end:()=>{a.copy(n)}}}function Iie(e,t,i,r,a){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),n=t?t[r]:void 0,o=i[r],l=n?Gg(new O,n,a):s.clone(),h=Gg(new O,o,a);if(!l.equals(h))return{update:c=>{s.lerpVectors(l,h,c)},start:()=>{s.copy(l)},end:()=>{s.copy(h)}}}function Bie(e,t,i,r,a){if(!e.hasValue(r)||!(r in i))return;let s=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=s?typeof s=="string"?a.getColor(s).clone():new _t().setRGB(s.r,s.g,s.b):o.clone(),h=typeof n=="string"?a.getColor(n).clone():new _t().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let c=o.clone();return{update:u=>{e.getValue(r)!==c&&e.setValue(r,c),c.lerpColors(l,h,u)},start:()=>{c.copy(l)},end:()=>{c.copy(h)}}}function Uie(e,t,i,r,a){if(!e.hasValue(r)||!(r in i))return;let s=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=s?typeof s=="string"?a.getColor(s).clone():new _t().setRGB(s.r,s.g,s.b):o.clone(),h=typeof n=="string"?a.getColor(n).clone():new ca(n.r,n.g,n.b,n.a);if(l.equals(h))return;let c=o.clone();return{update:u=>{e.getValue(r)!==c&&e.setValue(r,c),c.lerpColors(l,h,u)},start:()=>{c.copy(l)},end:()=>{c.copy(h)}}}function Fie(e,t,i,r="steps"){if(!e.hasValue(r)||!(r in i))return;let a=[],s=e.getValue(r),n=t?t[r]:s,o=i[r];for(let l=0;l<s.length;++l){let h=n[l],c=o[l];h!==c&&a.push({update:u=>{s[l]=dt.lerp(h,c,u)},start:()=>{s[l]=h},end:()=>{s[l]=c}})}return a.length?a:void 0}function Nie(e,t,i,r="colors"){if(!e.hasValue(r)||!(r in i))return;let a=[],s=e.getValue(r),n=t?t[r]:s.map(l=>l.toArray()),o=i[r];for(let l=0;l<s.length;++l){let h=[...n[l]],c=[...o[l]];yg.isEqual(h,c)||a.push({update:u=>{s[l].fromArray(yg.lerp(h,c,u))},start:()=>{s[l].fromArray(h)},end:()=>{s[l].fromArray(c)}})}return a.length?a:void 0}function zie(e,t,i,r="texture"){if(!e.hasValue(r)||!(r in i))return;let a=e.getNode("rotation"),s=t?.[r]?.rotation??0,n=i[r]?.rotation??0;if(a&&s!==n)return{update:g=>{a.value=dt.lerp(s,n,g)*dt.DEG2RAD},start:()=>{a.value=s*dt.DEG2RAD},end:()=>{a.value=n*dt.DEG2RAD}};let o=e.getNode("mat");if(!o)return;let l=t?t[r]:o,h=i[r],c=[...l.repeat],u=[...l.offset],d=[...h.repeat],p=[...h.offset],f=l.rotation??0,m=h.rotation??0;if(!wo.isEqual(c,d)||!wo.isEqual(u,p)||f!==m)return{update:g=>{o.repeat=wo.lerp(c,d,g),o.offset=wo.lerp(u,p,g),o.rotation=dt.lerp(f,m,g),o.updateMatrix()},start:()=>{o.repeat=[...c],o.offset=[...u],o.rotation=f,o.updateMatrix()},end:()=>{o.repeat=[...d],o.offset=[...p],o.rotation=m,o.updateMatrix()}}}function kie(e,t){return{update:()=>{e.transparent=t}}}var Ry=new O,RC=new Qi;function Vie(e,t,i,r,a){let s=[],n,o,l,h,c,u,d,p;if(e instanceof $r?(n=Hg("position",e,t,i,a),n&&s.push(n),l=sa("rotation",e,t,i,a),l&&s.push(l),h=Hg("shear",e,t,i,a),h&&s.push(h)):(p={slide:t.pathSnapping?.slide??e.updatedPathSnapping?.slide??e.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??e.updatedPathSnapping?.offset??e.dataPatched.pathSnapping?.offset??0},u=sa("slide",p,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,a),u&&s.push(u),d=sa("offset",p,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,a),d&&s.push(d),!u&&!d&&(n=TC("position",e,t,i,a),n&&s.push(n),o=TC("scale",e,t,i,a),o&&s.push(o),l=jie(e,t,i,r,a),l&&s.push(l),c=Aie("hiddenMatrix",e,t,i),c&&s.push(c))),n||o||l||c||u||d){let f=e instanceof $r?()=>{e.updateWorldMatrix(!0)}:()=>{e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e.parent?.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),Hs(e)&&_o(e.parent)&&e.invalidateDownstreamBooleanData(!0),e.updatePathSnapping(Object.assign({},t.pathSnapping,p))};s.push({update:f,start:f,end:f})}return s}function jie(e,t,i,r,a){let s=t?.rotation?t.rotation.map(c=>(typeof c=="string"?Number(a.getVariable(c)??0):c)*dt.DEG2RAD):void 0,n=i.rotation?.map(c=>(typeof c=="string"?Number(a.getVariable(c)??0):c)*dt.DEG2RAD);if(!n)return;let o=s?new O().fromArray(s):new O().setFromEuler(e.rotation),l=new O().fromArray(n);if(o.equals(l))return;let h=Ry.subVectors(l,o);if(r&&h.toArray().every(c=>Math.abs(c)<2*Math.PI)){let c=new zt().setFromEuler(RC.setFromVector3(o)),u=new zt().setFromEuler(RC.setFromVector3(l));return{update:d=>{Sie(c,u,e.quaternion,d)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}else return{update:c=>{Ry.lerpVectors(o,l,c),e.rotation.setFromVector3(Ry)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}function Gie(e,t,i,r){let a=[];if(!("cloner"in i)||!e.cloner)return a;let s=e.cloner,n="cloner"in t?t.cloner:{},o=i.cloner;x3.forEach(p=>{let f;p==="count"?f=sa("count",s.parameters,n,o,r,!0):f=Rl(p,s.parameters,n??{},o,r),f&&a.push(f)});let l=Hie(s,n,o,r);l?.length&&a.push(...l);let h=Wie(s,n,o,r);h?.length&&a.push(...h);let c=qie(s,n,o,r);c?.length&&a.push(...c);let u=Xie(s,n,o,r);u?.length&&a.push(...u);let d=Yie(s,n,o,r);return d?.length&&a.push(...d),a.length&&a.push({update:()=>{s.update()}}),a}function Hie(e,t,i,r){if(e.parameters.type!=="radial")return;let a=t.radial,s=i.radial;if(!s)return;let n=e.parameters.radial,o=[];return b3.forEach(l=>{let h=Rl(l,n,a??{},s,r);h&&o.push(h)}),o}function Wie(e,t,i,r){if(e.parameters.type!=="linear")return;let a=t.linear,s=i.linear;if(!s)return;let n=[],o=e.parameters.linear;return w3.forEach(l=>{let h=Rl(l,o,a??{},s,r);h&&n.push(h)}),n}function qie(e,t,i,r){if(e.parameters.type!=="grid")return;let a=t.grid,s=i.grid;if(!s)return;let n=[],o=e.parameters.grid;return _3.forEach(l=>{let h;l==="count"?h=Dw(l,o,a??{},s,r,!0):h=Rl(l,o,a??{},s,r),h&&n.push(h)}),n}function Xie(e,t,i,r){if(e.parameters.type!=="toObject")return;let a=t.toObject,s=i.toObject;if(!s)return;let n=[],o=e.parameters.toObject;return S3.forEach(l=>{let h;l==="count"?h=sa(l,o,a??{},s,r,!0):h=Rl(l,o,a??{},s,r),h&&n.push(h)}),n}function Yie(e,t,i,r){if(!e.parameters.randomness)return;let a=t.randomnessObject,s=i.randomnessObject;if(!s)return;let n=[],o=e.parameters.randomnessObject;return A3.forEach(l=>{let h=Rl(l,o,a??{},s,r);h&&n.push(h)}),n}function Qie(e,t){return{update:()=>{e instanceof Yr&&(e.fill.enabled=t)}}}function Kie(e,t){return{update:()=>{e instanceof Yr&&(e.stroke.enabled=t)}}}function Zie(e,t){return{update:()=>{e instanceof Yr&&(e.dropShadow.enabled=t)}}}function Jie(e,t){return{update:()=>{e instanceof Yr&&(e.innerShadow.enabled=t)}}}function $ie(e,t){return{update:()=>{e instanceof Yr&&(e.backgroundBlur.enabled=t)}}}function ere(e,t){return{update:()=>{e instanceof Yr&&(e.layerBlur.enabled=t)}}}function tre(e,t,i,r,a){let s=[],n,o,l,h,c,u,d,p,f,m,g,v,x,b,_;if("width"in e&&(n=sa("width",e,t,i,a),n&&s.push(n)),"height"in e&&(o=sa("height",e,t,i,a),o&&s.push(o)),e instanceof Yr||e instanceof Rn){let M={...t.fill},A={...i.fill};M.enabled!==void 0&&M.enabled!==A.enabled&&(s.push(Qie(e,!0)),M.enabled||Object.assign(M,{enabled:!0,color:{...M.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),l=wm("color",e.fill,M,A,a),l&&s.push(l)}if(e instanceof Yr){let M={...t.stroke},A={...i.stroke};(M.enabled||A.enabled)&&(s.push(Kie(e,!0)),M.enabled||Object.assign(M,{enabled:!0,color:{...M.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),h=wm("color",e.stroke,M,A,a),h&&s.push(h),c=sa("thickness",e.stroke,M,A,a),c&&s.push(c)}if(e instanceof Yr){let M={...t.dropShadow},A={...i.dropShadow};(M.enabled||A.enabled)&&(s.push(Zie(e,!0)),M.enabled||Object.assign(M,{enabled:!0,color:{...M.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),u=wm("color",e.dropShadow,M,A,a),u&&s.push(u),d=sa("blurRadius",e.dropShadow,M,A,a),d&&s.push(d),f=sa("spread",e.dropShadow,M,A,a),f&&s.push(f),p=Hg("offset",e.dropShadow,M,A,a),p&&s.push(p)}if(e instanceof Yr){let M={...t.innerShadow},A={...i.innerShadow};(M.enabled||A.enabled)&&(s.push(Jie(e,!0)),M.enabled||Object.assign(M,{enabled:!0,color:{...M.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),m=wm("color",e.innerShadow,M,A,a),m&&s.push(m),g=sa("blurRadius",e.innerShadow,M,A,a),g&&s.push(g),x=sa("spread",e.innerShadow,M,A,a),x&&s.push(x),v=Hg("offset",e.innerShadow,M,A,a),v&&s.push(v)}if(e instanceof Yr||e instanceof Rn){let M={...t.backgroundBlur},A={...i.backgroundBlur};(M.enabled||A.enabled)&&(s.push($ie(e,!0)),M.enabled||Object.assign(M,{enabled:!0,radius:0}),A.enabled||Object.assign(A,{enabled:!0,radius:0})),b=sa("radius",e.backgroundBlur,M,A,a),b&&s.push(b)}if(e instanceof Yr){let M={...t.layerBlur},A={...i.layerBlur};(M.enabled||A.enabled)&&(s.push(ere(e,!0)),M.enabled||Object.assign(M,{enabled:!0,radius:0}),A.enabled||Object.assign(A,{enabled:!0,radius:0})),_=sa("radius",e.layerBlur,M,A,a),_&&s.push(_)}if(e instanceof Rn||e instanceof Rp){let M=Dw("cornerRadius",e,t,i,a);M&&s.push(M)}return s}function OC(e,t,i,r,a){let s=[];return e.data.visible&&s.push(...Vie(e,t,i,a,r)),e instanceof $r?s.push(...tre(e,t,i,a,r)):(e.data.visible&&s.push(...Gie(e,t,i,r)),Hs(e)?(e instanceof ba&&e.data.visible&&s.push(...Pie(e,t,i,r)),e.data.visible&&s.push(...Rie(e,t,i,r))):lJ(e)?e.data.visible&&s.push(...Die(e,t,i,r)):oJ(e)&&s.push(...Mie(e,t,i,r))),s.length?{update:n=>{s.forEach(o=>o.update(n))},start:n=>{s.forEach(o=>o.start?.(n))},end:n=>{s.forEach(o=>o.end?.(n))}}:void 0}var LC=new O;function Rw(e,t,i=!1){let r=[],a=s=>{let n=s.data;delete s.states,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let o of n.states){let l={...o.data};s.states||(s.states={}),s.states[o.id]=uh.patch(n,l)}BC(e.scene,s,null,t,n.events.find(o=>o.data.type==="Follow"||o.data.type==="LookAt")!==void 0),IC(e)};e.scene.traverse2D(a),e.traverseChildren(s=>{if(i&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(LC,!0),s.rigidBody?.setAngvel(LC,!0)),!ui.is(s))return;let n=s.uuid,o=s.data;if(delete s.states,s.uuid===Uu)return;let l=!1;r.some(h=>e.scene.find(n)?.isDescendantOf(h))?l=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&r.push(n),s.data=o,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let h of o.states){let c={...h.data};e.data.globalPhysics.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||l)&&(h.data.position!==void 0&&delete c.position,h.data.rotation!==void 0&&delete c.rotation,h.data.hiddenMatrix!==void 0&&delete c.hiddenMatrix),s.states||(s.states={}),s.states[h.id]=lh.patch(o,c)}BC(e.scene,s,null,t,o.events.find(h=>h.data.type==="Follow"||h.data.type==="LookAt")!==void 0),IC(e),s instanceof ya&&s.frame&&(s.frame.traverse(h=>a(h)),s.uiCanvas?.applySize())}),e.frame&&(e.frame.traverse(s=>a(s)),e.uiCanvas?.applySize())}function IC(e){e.traverseEntity(t=>{for(let i of t.data.events){let r=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...i.data.actions);break;case"GameControl":for(let a of Object.values(i.data.gameActions))r.push(...a);break;case"DragDrop":r.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":r.push(...i.data.inActions,...i.data.outActions);break}for(let a of r)if(a.data.type==="Create"&&a.data.hideBase==="Yes"){let s=e.scene.find(a.data.object);s&&(s.visible=!1)}}})}function BC(e,t,i,r,a=!1){if(t instanceof ba&&t.removeInteractionGeometry(r),t instanceof $r?t.changeSelectedState(i,{shared:r},a):t.changeSelectedState(i,{scene:e,shared:r},a),t instanceof ba&&t.updateGeometryGroupsIfNeeded(),t instanceof _a&&t.updateCameraState(t.dataPatched,{scene:e,shared:r}),!(t instanceof $r)){if(t.cloner)for(let s of t.cloner.children)s.playModeVisible=void 0;t.updateVisible()}}function WR(e){let t;if(e.easing===5){let{control1:i,control2:r}=e;t=`cubicBezier(
8024
8037
  ${i[0]}, ${i[1]}, ${r[0]}, ${r[1]}
8025
- )`}else if(e.easing===6){let{mass:i,stiffness:r,damping:a,velocity:s}=e;t=`spring( ${i}, ${r}, ${a}, ${s} )`}else{let i;switch(e.easing){case 0:i=rl.linear;break;case 1:i=rl.ease;break;case 2:i=rl.easeIn;break;case 3:i=rl.easeOut;break;case 4:i=rl.easeInOut;break;default:i=rl.linear}let[r,a,s,n]=i;t=`cubicBezier( ${r}, ${a}, ${s}, ${n} )`}return{duration:Math.max(e.duration,1e-4),easing:t}}function Gx(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var ire={type:"beginState"},rre={type:"completeState",isfromEntity:!1},UC=class{constructor(e,t,i,r,a,s){if(this.object=e,this.data=r,this.sharedAssets=a,this.allowSlerp=s,this.targets={t:0},this.firstLoop=!0,this._changeBegan=!1,this._changeCompleted=!0,this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.requestRender()),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))},this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let n=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=n,this.object.dispatchEvent({type:"beginState",state:n}),this.object instanceof $r||this.object.traverseEntity(o=>{o!==this.object&&o instanceof _a&&o.dispatchEvent(ire)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let n=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=n,this.object.dispatchEvent({type:"completeState",state:n}),this.object instanceof $r||this.object.traverseEntity(o=>{o!==this.object&&o instanceof _a&&o.dispatchEvent(rre)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=OC(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let n=zm(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!n)throw new Error("Missing property");this.from=n}else{let n=zm(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(i===void 0)throw new Error("Missing property");{let n=zm(this.object,i);if(!n)throw new Error("Missing property");this.to=n}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...Gx(r),...WR(r),change:this.onChange},this.callback=OC(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},qR=class extends ua{constructor(e,t,i,r){if(super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.useToggle=!1,this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!1,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let a=this.page.scene.find(e.object)??this.page.uiCanvas?.find(e.object)??this.page.scene.find2DInUIObjects(e.object);if(!a)throw new Error("Missing property");if(!a.states)throw new Error("Missing property");if(this.object=a,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.timeline?.paused===!1}get changeBegan(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=zm(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:t=!1,isRebuild:i=!1}={}){try{let r=Gx(this.data.tweens[0].data);i&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=HR.timeline({autoplay:!1,...r,...r.loop===!0||r.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let a=this.tweens.findIndex(s=>s?.changeBegan);if(t===!0&&(this.timelineNeedsRebuild=!0),e){let s=a===-1?0:a;for(let n=s;n<this.data.tweens.length-1;n++){let o=this.data.tweens[n],l=this.data.tweens[n+1],h;n===s&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof _a&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let c=new UC(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.shared,this.data.allowSlerp??!1);a!==-1&&n===s&&Object.assign(c.params,{startOnceDelay:0}),this.tweens[n]=c,this.timeline.add(c.params,this.timeline.duration+(n===s?r.delay:0))}this.timeline.duration+=r.endDelay}else{let s=a===-1?this.data.tweens.length-1:a+1;for(let n=s;n>0;n--){let o=this.data.tweens[n],l=this.data.tweens[n-1],h;n===s&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof _a&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let c=new UC(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.shared,this.data.allowSlerp??!1);a!==-1&&n===s&&Object.assign(c.params,{startOnceDelay:0}),this.tweens[n-1]=c,this.timeline.add(c.params,this.timeline.duration+(n===s?r.endDelay:0))}this.timeline.duration+=r.delay}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(ar(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=Gx(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}},this.startOnceDelay+e)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object instanceof $r?this.object.changeSelectedState(e,{shared:this.shared}):this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(ar(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function zm(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var are={type:"beginState"},FC={type:"completeState",isfromEntity:!1},NC={type:"requestRender"},XR=class extends ua{constructor(e,t,i,r){super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new O,this.posEnd=new O,this.qStart=new zt,this.qEnd=new zt,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t=this.page.scene.find(this.data.targetCamera);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=HR({targets:i,t:1,...WR(this.data),update:()=>{i.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(t.position),this.qEnd.copy(t.quaternion),this.zoomEnd=t.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(t.uuid)),this.page.activeCamera.dispatchEvent(are));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,i.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(NC),i.t===1&&r.dispatchEvent(FC)}})}switchCamera(e){let t=this.page.activeCamera,i=this.page.scene.find(e);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),t.dispatchEvent({type:"cameraChange",camera:i})}play(){if(ar(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(ar(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(FC),this.page.activeCamera.dispatchEvent(NC))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},YR=class extends ua{constructor(e,t,i,r,a){super(),this.page=t,this.animationControls=i,this.shared=r,this.condition=a,this.startOnceDelay=0,this.toggleIsForward=!1;let s=e.object,n=t.scene.find(e.object);n&&Array.isArray(n.identity)&&(s=n.identity[0]),this.data={...e,object:s};let o=this.animationControls.clipIdToAction[e.clipId+"/"+s];this.duration=o?.getClip()?.duration??1;let l=o?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(ar(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let a=i.split("/")[1];this.threeAnimAction!==r&&a===t&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=dt.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){if(ar(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,a])=>{let s=r.split("/")[1];this.threeAnimAction!==a&&s===i&&a.isRunning()&&(t?a.fadeOut(.2):a.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},QR=class{constructor(e,t,i,r,a){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.condition=a,this.timeOutId=-1,this.scene=t.scene}dispatch(){if(ar(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(t=>{t.type==="ParticleSystem"&&(t.sleep(),t.wakeUp(),t.data.autoPlay?t.start():t.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),Rw(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}},KR=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=ar(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let e=this.shared.getVariable(this.data.variableId),t=iD(this.data.expression,this.shared,as.typeOfVariable(e));t!==void 0&&this.shared.updateVariable(this.data.variableId,typeof t=="string"?{textValue:t}:t)}dispose(){}},ZR=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.timeoutId=null}dispatchInner(){if(ar(this.shared,this.condition)===!1)return!1;let e=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,e==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&e!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&e!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&e!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let t=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);e==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,t===void 0?!1:!t):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!t),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let e=this.data.delay,t=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&t==="Playing"&&(e=this.data.pauseDelay),e!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},e)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};function ar(e,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let i=iD(t.expression,e,"boolean");return t.negate?!i:!!i}function Na(e,t,i,r,a,s){let n={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[]},o=l=>({id:h,data:c})=>{try{c.type==="Audio"?ja[e.type].includes("Audio")&&n.Audio.push(new AR(h,c,s,r,l)):c.type==="Video"&&!(s instanceof $r)?ja[e.type].includes("Video")&&n.Video.push(new $R(h,c,s,r,l)):c.type==="Particles"?ja[e.type].includes("Particles")&&n.Particles.push(new ER(c,i,r,l)):c.type==="Link"?ja[e.type].includes("Link")&&n.Link.push(new qte(c,a.controlsManager,r,l)):c.type==="Create"?ja[e.type].includes("Create")&&n.Create.push(new eO(c,i,a.controlsManager,r,l)):c.type==="Destroy"?ja[e.type].includes("Destroy")&&n.Destroy.push(new MR(c,i,a.controlsManager,r,l)):c.type==="Reset"?ja[e.type].includes("Reset")&&n.Reset.push(new CR(c,i,r,a,l)):c.type==="Transition"?ja[e.type].includes("Transition")&&n.Transition.push(new qR(c,i,r,l)):c.type==="SwitchCamera"?ja[e.type].includes("SwitchCamera")&&n.SwitchCamera.push(new XR(c,i,r,l)):c.type==="SceneTransition"?ja[e.type].includes("SceneTransition")&&n.SceneTransition.push(new QR(c,i,a,r,l)):c.type==="Animation"?ja[e.type].includes("Animation")&&n.Animation.push(new YR(c,i,a.animationControls,r,l)):c.type==="SetVariable"?ja[e.type].includes("SetVariable")&&n.SetVariable.push(new KR(c,i,r,l)):c.type==="DynamicVariablePlay"?ja[e.type].includes("DynamicVariablePlay")&&n.DynamicVariablePlay.push(new ZR(c,i,r,l)):c.type==="Conditional"&&ja[e.type].includes("Conditional")&&(c.ifActions.forEach(o({expression:c.condition,negate:!1})),c.elseActions.forEach(o({expression:c.condition,negate:!0})))}catch{}};return t.forEach(o()),n}function Jr(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof AR||i instanceof $R||i instanceof ER||i instanceof YR||i instanceof qR||i instanceof eO||i instanceof MR||i instanceof XR||i instanceof QR||i instanceof CR||i instanceof KR||i instanceof ZR)&&i.dispose()})})}function sre(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(a=>a.uuid===t):i=e.material.layers.find(a=>a.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var JR=new Map,Qd=new Map,lu=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:a,volume:s,delay:n}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=sre(i,r);o&&(this.videoElement=o,this.videoElement.loop=a===1/0,Ob&&(this.videoElement.autoplay=!0),s!==void 0&&(this.videoElement.volume=s)),n!==void 0&&(this.delay=n),Qd.has(i.uuid)?Qd.get(i.uuid).push(this):Qd.set(i.uuid,[this]),JR.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Hx=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=JR.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=Qd.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...Qd.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},$R=class{constructor(e,t,i,r,a){if(this.data=t,this.shared=r,this.condition=a,t.interaction==="play")this.interaction=new lu(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Hx(t);else throw new Error("Missing property")}dispatchBasic(){if(ar(this.shared,this.condition)===!1)return!1;this.interaction instanceof lu?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(ar(this.shared,this.condition)===!1)return!1;this.interaction instanceof lu?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},zC=(()=>{let e,t,i,r;function a(o){!e&&!kC()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(e=requestAnimationFrame(s)),o&&(t=o,r=o.requestRender)}function s(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,u=h.length,d=0;for(;d<u;){let p=h[d];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&c[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),d++):(c[p.userData.actionId]>p.userData.quantity&&c[p.userData.actionId]--,h.splice(d,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(p.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody)):(p.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),u--,r())}e=d>0?requestAnimationFrame(s):void 0,i=d>0?o:void 0}function n(){kC()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):a()}return typeof document<"u"&&document.addEventListener("visibilitychange",n),a})();function kC(){return!!document&&document.hidden}var VC=new zt,nre=new O,ore=new O,eO=class{constructor(e,t,i,r,a){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=a,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=dt.generateUUID(),this.dispatch=()=>{if(ar(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{if(ar(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=Y7(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let n=new xa(this.object);if(n.playModeVisible=!0,n.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,h=this.page.scene.find(l);h&&(h.updateMatrixWorldSVD(),n.hiddenMatrix.copy(h.matrixWorldRigid))}n.position.fromArray(this.data.position),n.rotation.fromArray(this.data.rotation),n.updateMatrix(),this.page.add(n);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(n),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,n.updateWorldMatrix(!0,!0),n.traverseObject(this.traverseObjectCB),zC(),this.controlsManager.requestRender()},this.traverseObjectCB=n=>{n.hasNonUniformScale&&n.updateMatrixWorldSVD();let o;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(n instanceof Xs)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof xa)o=n.object;else if(o=n,o.dataPatched.cloner?.hideBase)return!0}else{if(n instanceof Xs)return;n instanceof xa?o=n.object:o=n}this.data.destroy==="Time"?n.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(n.userData.quantity=this.data.destroyAfterQuantity,n.userData.actionId=this.uniqueId);let l=new O().fromArray(this.data.velocity),h=o.dataPatched;if(!(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(n,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(n.rigidBody?.collider(0).setActiveEvents(1),n.userData.hasCollisionDestroy=!0),n.matrixWorld.decompose(nre,VC,ore),l.applyQuaternion(VC),this.data.velocity.some(c=>c!==0)&&this.data.dynamic&&n.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in n.object&&this.controlsManager.addBoundsTree(n),this.data.velocity.some(c=>c!==0)&&this.data.dynamic&&(n.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let s=this.page.scene.find(this.data.object);if(!s)throw new Error("Missing Property");if(this.object=s,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");zC(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},tO=200,Oy=.02,Ly=.3,lre=65,nne=new O,jC=new O,GC=new O,hre=new O,Pa=new O,Ga=new O,$o=new O,Iy=new je,HC=new je,cre=new je,one=new je,zs=new zt,io=new zt,fn=new Qi(0,0,0,"YXZ"),ure=new O(1,0,0),ks=new O(0,1,0),dre=new O(0,0,1),WC=new O(1,1,1),lne=new Sa,pre=1,fre=.025,mre=16e-6,qC=12,gre=20,Hr=new Es,gs=new sr,vre={type:"requestRender"},yre={type:"updateMatrix"},XC=Math.PI/6,Wx=class extends ua{constructor(e,t,i,r,a,s,n,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=a,this.cameraFollow=s,this.camera=n,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new je,this.target0=new O,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=tO,this.euler0=new Qi(0,0,0,"YXZ"),this.position0Cam=new O,this.quat0Cam=new zt,this.scale0Cam=new O,this.hiddenMatrix0Cam=new je,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new Es(new O(0,-40,0),new O(0,40,0)),matrix:new je,position:new O,rotation:new zt},this.euler=new Qi(0,0,0,"YXZ"),this.eulerDelta=new O,this.lastPosition=new O,this.lastCameraQuaternion=new zt,this.lastCameraPosition=new O,this.PI_2=Math.PI/2,this.prevMouse=new ae,this.velocityTarget=new O,this.velocity=new O,this.directionXZ=new O,this.rotVelocityStick=new O,this.rotVelocityTarget=new O,this.rotVelocity=new O,this.rotDirection=new O,this.nonColliderRotOffset=new je,this.nonColliderPosOffset=new je,this.firstPointerId=-1,this.rot=new O,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new je,this.objectToTarget=new O,this.objectToTarget0=new O,this.objectToCamXZ=new O,this.objectToCamXZ0=new O,this.targetToCamera=new O,this.targetToCamera0=new O,this.cameraPolarAxis0=new O,this.targetPos=new O,this.targetQuat=new zt,this.lerpFactorPos=new O().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new zt,this.objXZQuatInv=new zt,this.objXZRotMat=new je,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new O,this.pushedVelocity=new O,this.groundYRotation=0,this.objectRealQuat=new zt,this.colliderWorldQuat=new zt,this.groundNormal=new O,this.groundTilt=new zt,this.groundTiltInv=new zt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new O,this.quaternion=new zt,this.scale=new O,this.initialAction=!0,this.onPointerDown=f=>{f.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!rs&&(!TA||PA>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let m=f.clientX-this.prevMouse.x,g=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(TA&&PA<15.5&&!rs?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Wx.isLocked=!0:Wx.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let g=2;g<4;g++){let v=f.axes[g];m===0?g===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(v)>=.3&&(this.vrEulerYOffset+=v<0?1:-1),this.movementState.rotPosY=v):this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=a.sharedGameControlGlobals,e===n&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),c=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,c,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new O(0,0,-1).applyQuaternion(this.camera.quaternion),m=new O().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let g,v;Math.abs(f.y)<1e-6?(m.y=0,f.y=0,v=m.projectOnVector(f)):m.y/f.y>0?v=f.multiplyScalar(m.y/f.y):v=f.multiplyScalar(m.length()),this.targetToCamera0.copy(v).negate(),g=this.camera.position.clone().add(v),this.objectToTarget0.subVectors(g,this.position);let x=new Qi().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-x.x,x.x=0,x.z=0,x.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(x)}if(this.object instanceof _a&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*pre,this.speedOrbit=(i.speedRotate??100)*fre,this.mouseOrbitSensitivity=(i.speedRotate??100)*mre,this.keyAssignments=i.keyAssignments.map(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??vu.defaultData.gravity)*qC,this.usePhysics=this.gloabalPhysics.usePhysics??vu.defaultData.usePhysics,this.jumpPower=i.jumpPower*gre,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??Tg.defaultDataThirdPerson.orientWith,this.slopeThresh=lre*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*Oy/this.pixelsPerMeter,this.stepThresh=i.collider.height*Ly/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*Oy/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*Ly/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*Oy/this.pixelsPerMeter,this.stepThresh=i.collider.height*Ly/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let u=new O().fromArray(i.collider.position),d=new zt().setFromEuler(new Qi().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(u).multiply(this.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(u,d,WC),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new Tt;f.push({fi:0,data:{...qr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...qr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=new sw({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new xr(F3.create({parameters:{width:p,height:p/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new Qi().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof _a?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Cg.list.forEach(i=>{this.actions[i]=Na({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),Jr(this.actions.idle),Jr(this.actions.move),Jr(this.actions.run),Jr(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Pa.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let a=r*60,s=!1;if(this.usePhysics&&this.collisionEnabled){let o=Ga.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*qC),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(s=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(c.rigidBody===h&&c.userData.isFollowingObj!==this.object.uuid){(c.hasNonUniformScale?c.matrixWorldRigid:c.matrixWorld).decompose(Pa,io,Ga),this.groundVelocity.subVectors(Pa,c.prevT),this.object.getWorldPosition(Ga).add(this.collider.position).sub(Pa),this.groundYRotation=fn.setFromQuaternion(io).y-c.prevR.y,$o.copy(Ga).applyAxisAngle(ks,this.groundYRotation),this.groundVelocity.add($o.sub(Ga)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*a),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=Pa.subVectors(this.path[1],this.position),h=Ga.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**a),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**a),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**a)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let n=hre.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=Ga.copy(n);o.y=0,n.set(0,n.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let o=Pa;this.camera.getWorldDirection(o);let l=$o.copy(ks).multiplyScalar(o.dot(ks));o.sub(l);let h=Ga.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(fn.setFromVector3(this.rot),this.moveMode==="walk"&&(fn.x=0),n.applyEuler(fn),s&&(io.setFromUnitVectors(ks,this.groundNormal),n.applyQuaternion(io)),i){let o=fn.set(0,this.vrEulerYOffset*XC,0);i.applyEuler(o),n.x+=i.x,n.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let o=Ga;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=$o.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),c=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),Pa.copy(n).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let u=ui.is(l)?l:l.object;if(c!==null&&this.lastHitObj!==u){let d;l instanceof xa&&(d=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[u.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(d),u.dispatchEvent(Xx));this.lastHitObj=u}if(c!==null){this.pushedVelocity.copy(h),o.copy(c.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(n);l<0&&n.addScaledVector(o,-l),n.add(this.pushedVelocity)}else n.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**a):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**a),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(ks,this.euler.y-this.euler0.y);let o=Ga.copy(this.objectToCamXZ).normalize(),l=$o.copy(n).multiplyScalar(r);l.y=0;let h=l.sub(Pa.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=dt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=dt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=dt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(fn.copy(t),fn.y=0):(fn.copy(this.euler),fn.y=0),this.nonColliderRotOffset.makeRotationFromEuler(fn)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*XC),zs.setFromAxisAngle(ure,this.rot.x),io.setFromAxisAngle(ks,this.rot.y),io.multiply(zs),zs.setFromAxisAngle(dre,this.rot.z),io.multiply(zs),this.quaternion.copy(io),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=Ga.copy(n).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new O;for(let c=0;c<5;c++){let u=o.length(),d=$o.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,d,this.object.rigidBody?.collider(0).shape,u,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&c===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let x of v)if(x.data.target==="character"){let b=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,_;if(p.cloner){for(let M of p.cloner.children)if(M.rigidBody===b){_=M;break}}x.dispatch(_),p.dispatchEvent(Xx)}}}let f=jC.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),m=GC.copy(d).multiplyScalar(l.toi).dot(f),g=l.toi;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(g=l.toi*(m-this.offset)/m,h.addScaledVector(d,g)),o.copy(d).multiplyScalar(u-g),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),x=$o.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);x.y=0;let b=v.add(x);b.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(b,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);_!==null&&_.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{c===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(Pa.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(zs.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=n.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),this.collisionAdjustment(r/o)}else this.position.addScaledVector(n,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);Iy.lookAt(l,o,ks).setPosition(l),Iy.decompose(this.targetPos,this.targetQuat,Pa),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**a),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**a),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=dt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=dt.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(yre),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(vre),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=zs.setFromAxisAngle(ks,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?dt.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=dt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=dt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Pa.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=io.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){ks.angleTo(e)*180/Math.PI<15||ks.angleTo(e)*180/Math.PI>85?zs.identity():zs.setFromUnitVectors(ks,e),this.groundTilt.slerp(zs,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=GC.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=Iy.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Pa,zs,Ga).compose(Pa,zs,WC);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object))return;gs.makeEmpty(),a.updateMatrixWorldSVD();let s=a.matrixWorldRigid,n=HC.copy(s).invert(),o=cre.copy(HC).multiply(i);Hr.copy(this.collider.segment),Hr.start.applyMatrix4(o),Hr.end.applyMatrix4(o);let l=jC.copy(this.position).applyMatrix4(n);gs.expandByPoint(Hr.start),gs.expandByPoint(Hr.end),gs.min.addScalar(-this.collider.radius),gs.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(Hr.end)},intersectsBounds:h=>h.intersectsBox(gs),intersectsTriangle:h=>{let c=Pa,u=Ga,d=h.closestPointToSegment(Hr,c,u);if(d<this.collider.radius){let p=this.collider.radius-d,f=u.sub(c).normalize(),m=$o.copy(l);m.addScaledVector(f,p);let g=m.applyMatrix4(s).sub(this.position);t.add(g),Hr.start.addScaledVector(f,p),Hr.end.addScaledVector(f,p)}}})}),gs.makeEmpty(),Hr.copy(this.collider.segment),Hr.start.applyMatrix4(i),Hr.end.applyMatrix4(i),gs.expandByPoint(Hr.start),gs.expandByPoint(Hr.end),gs.min.addScalar(-this.collider.radius),gs.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(a){return a.distanceToPoint(Hr.end)},intersectsBounds:a=>a.intersectsBox(gs),intersectsTriangle:a=>{let s=Pa,n=Ga,o=a.closestPointToSegment(Hr,s,n);if(o<this.collider.radius){let l=this.collider.radius-o,h=n.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),Hr.start.addScaledVector(h,l),Hr.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}},iO=Wx;iO.isLocked=!1;var xre=Ro(cT());function mo(e,t){let i=new St;if(!e.getAttribute("position"))return i.setAttribute("position",new ut([],3)),i.setIndex([]),i;let{positions:r,triIndices:a}=pv(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new ut(r,3)),i.setIndex(a),t&&i.applyMatrix4(t),i}var bre=new je,wre=new je,mn=[[0,0,0],[0,0,0],[0,0,0]];function rO(e){let t=e.elements;mn[0][0]=t[0],mn[0][1]=t[4],mn[0][2]=t[8],mn[1][0]=t[1],mn[1][1]=t[5],mn[1][2]=t[9],mn[2][0]=t[2],mn[2][1]=t[6],mn[2][2]=t[10];let{u:i,v:r}=(0,xre.SVD)(mn),a=bre.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),s=wre.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1);return a.multiply(s.transpose())}var _re=class extends nP{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new Dl({color:65280,linewidth:10}),t=new O(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new O(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,a=new O().addVectors(t,i.multiplyScalar(r)),s=new St;return s.setFromPoints([t,a]),new Zm(s,e)}},aO=e=>e instanceof nu||e instanceof ou;function Sre(e,t){return e.distance-t.distance}function sO(e,t,i){if(!(!fo(t)||!t.visible)){Hs(t)&&t.raycast(e,i);for(let r of t.children)sO(e,r,i)}}function km(e,t,i,r=!1){if(!r&&!i.some(s=>Wg(e,s)!==void 0))return[];let a=[];return t.children.forEach(s=>sO(e,s,a)),a.sort(Sre),a}function qx(e){let t=[];if(e.length){let i=e[0].object;fo(i)&&t.push(i);let r=i.parent;for(;r;)aO(r)&&t.push(r),r=r.parent}return t}function go(e,t,i,r){let a=e.frame;if(a){let s=t[0]*a.width,n=(1-t[1])*a.height;for(let o of i){let l=o===a.uuid?a:a.find(o);if(l?.intersects(s,n))return r(l),!0}}return!1}function Wg(e,t){if(Hs(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(aO(t))return nO(e,t)}function nO(e,t){if(!(!fo(t)||!t.visible)){if(Hs(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=nO(e,i);if(r)return r}}}function Are(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}function Ere(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width,y:1-(t-(i.top+window.scrollY))/i.height}}var Mre=class{constructor(e,t,i,r,a,s,n,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=a,this.requestRender=s,this.isExport=n,this.frame=o,this.raycaster=new _re,this._useWindowEvents=!1,this.pointerWorld={x:0,y:0},this.pointerScreen={x:0,y:0},this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(e){this._domRect=e}get domRect(){return this._domRect}updateRaycaster(e){let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e;this.pointerWorld=Are(t,i,this._domRect),this.pointerScreen=Ere(t,i,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}},en=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},Ow=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],oO=e=>Ow.find(([t,i])=>i===e)?.[0],Op=e=>Ow.find(([t])=>t===e)?.[1],Cre=(e,t)=>{let i=oO(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},Tre=class extends en{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target||i.eventName==="Scroll")return;let r=this.splineEvents[oO(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:a}=this.eventContext;a.dispatchEvent(r)};let{page:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,a]of Ow)if(i.data.events.some(s=>s.data.type===a&&!s.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let s={id:i.uuid,name:i.name},n=Cre(a,s),o=this.splineEvents[r];o?o[i.uuid]=n:this.splineEvents[r]={[i.uuid]:n}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},Pre=class{constructor(e,t,i,r,a,s){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.alreadyPlayedNonTogglingActions=new Set,this.useToggle=t.runMode==="Toggle",(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Na(t,t.actions,r,a,s,i)}disconnect(){Jr(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()}),this.actions.SwitchCamera.forEach(t=>{t.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing)||this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.SwitchCamera.some(t=>t.playing)||this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},Dre=class extends en{constructor(e,t,i){super(e),this.useForRaycastProperty=i,this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.sceneInterects=null,this.onCanvasRaycast=n=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(n);let{raycaster:o,page:l}=this.eventContext,h=km(o,l,[],!0);this.sceneInterects=h,h.length&&(this.eventContext.sharedAssets.raycastProperty={x:h[0].point.x,y:h[0].point.y,z:h[0].point.z,objX:h[0].object.matrixWorld.elements[12],objY:h[0].object.matrixWorld.elements[13],objZ:h[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=n=>{(n.target===this.eventContext.domElement||n.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(o=>{(o.data.type==="MouseDown"||o.data.type==="MousePress")&&(this.onCanvasRaycast(n),o.dispatch())})},this.onCanvasMouseUp=n=>{(n.target===this.eventContext.domElement||n.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(o=>{o.data.type==="MouseUp"?(this.onCanvasRaycast(n),o.dispatch()):o.data.type==="MousePress"&&o.dispatchRelease()})},this.onMouseDown=n=>{Lt.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseDown"))},this.onMouseUp=n=>{Lt.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=n=>{Lt.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent())},this.onMousePressRelease=n=>{Lt.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent(!0))},this.onKeyDown=n=>{this.heldKeys[n.key]||(this.handleKeyEvent(n,"KeyDown"),this.handleKeyEventHeld(n,"KeyDown",!0)),this.heldKeys[n.key]=!0},this.onKeyUp=n=>{this.handleKeyEvent(n,"KeyUp"),this.handleKeyEventHeld(n,"KeyUp",!0)},this.onKeyPressDown=n=>{this.heldKeysPress[n.key]?this.handleKeyEventHeld(n,"KeyPress"):(this.handleKeyEvent(n,"KeyPress"),this.handleKeyEventHeld(n,"KeyPress",!0)),this.heldKeysPress[n.key]=!0},this.onKeyPressUp=n=>{this.handleKeyEvent(n,"KeyPress",!0)},this.releaseHeldKey=n=>{delete this.heldKeys[n.key]},this.releaseHeldKeyPress=n=>{delete this.heldKeysPress[n.key]},this._onUserEvent=({eventName:n,target:o,reverse:l})=>{if(!n||!o)return;let h=Op(n);h&&(h==="MouseDown"||h==="MouseUp"||h==="MousePress"?(o.dispatchEvent({type:"beginEvent",eventName:h}),this.eventsPerObjects[h]?.[o.uuid]?.forEach(c=>{c.dispatchUserEvent(l)})):(h==="KeyDown"||h==="KeyUp"||h==="KeyPress")&&(o.dispatchEvent({type:"beginEvent",eventName:h}),this.eventsPerObjects[h]?.[o.uuid]?.forEach(c=>{c.dispatchUserEvent()})))};let{page:r,sharedAssets:a}=this.eventContext,s=(n,o)=>{if(!n.data?.events.length)return;let l=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let h of l){let c=this.eventsPerObjects[h];n.data.events.filter(({data:u})=>u.type===h&&u.disabled!==!0).forEach(({id:u,data:d})=>{try{let p=new Pre(u,d,n,r,a,t);p.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(p):c[n.uuid]?c[n.uuid].some(f=>f.id===p.id)||c[n.uuid].push(p):c[n.uuid]=[p]}catch{}}),c[n.uuid]?.length&&this.objectsPerTypes[h].push(n instanceof $r&&(h==="MouseDown"||h==="MouseUp"||h==="MousePress")?o:n)}};r.traverseEntity(n=>{(n instanceof ya||n instanceof Xr)&&n.frame?.traverse(o=>{s(o,n)}),s(n)})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),e.addEventListener("pointerdown",this.onCanvasMouseDown),e.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r,pointerScreen:a}=this.eventContext,s=this.objectsPerTypes[e],n=s.filter(o=>!(o instanceof $r));if(!(!s.length&&!this.useForRaycastProperty)&&!(r.uiCanvas&&go(r,[a.x,a.y],Object.keys(this.eventsPerObjects[e]),o=>{this.handleObjectMouseEventDispatch(o,e)}))){if(t||this.useForRaycastProperty){let o;if(this.sceneInterects===null?o=km(i,r,n,this.useForRaycastProperty):(o=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&o.length&&(this.eventContext.sharedAssets.raycastProperty={x:o[0].point.x,y:o[0].point.y,z:o[0].point.z,objX:o[0].object.matrixWorld.elements[12],objY:o[0].object.matrixWorld.elements[13],objZ:o[0].object.matrixWorld.elements[14]}),t){let l=[o[0]?.uv?.x??0,o[0]?.uv?.y??0];qx(o).forEach(h=>{h instanceof ya&&go(h,l,Object.keys(this.eventsPerObjects[e]),c=>{this.handleObjectMouseEventDispatch(c,e)}),this.eventsPerObjects[e][h.uuid]&&this.handleObjectMouseEventDispatch(h,e)})}}t||n.forEach(o=>{let l=Wg(i,o);l&&(this.handleObjectMouseEventDispatch(o,e),o instanceof ya&&go(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),h=>{this.handleObjectMouseEventDispatch(h,e)}))})}}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=i.filter(s=>!(s instanceof $r)),a=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:n,page:o,pointerScreen:l}=this.eventContext,h=!1;if(o.uiCanvas&&(h=go(o,[l.x,l.y],Object.keys(this.eventsPerObjects[t]),c=>{a.push(c)})),s&&!h){let c=km(n,o,r);a=qx(c),c.forEach(u=>{u.object instanceof ya&&go(u.object,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),d=>{a.push(d)})})}else r.forEach(c=>{let u=Wg(n,c);u&&(a.push(c),c instanceof ya&&go(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),d=>{a.push(d)}))})}this._prevObjects.length&&this._prevObjects.forEach(s=>{a.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),a.length&&a.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=a}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let a=this.eventsPerObjects[t][r.uuid];a.some(({data:s})=>"key"in s&&s.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),a.forEach(s=>{"key"in s.data&&s.data.key===e.key&&(i?s.dispatchRelease():s.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(i)})})}},Rre=new O,Ore=new O,lO=class{constructor(e,t,i,r,a){this.actionsIn=Na(e,e.inActions,i,r,a,t),this.actionsOut=Na(e,e.outActions,i,r,a,t)}disconnect(){Jr(this.actionsIn),Jr(this.actionsOut)}},Lre=class extends lO{constructor(e,t,i,r,a,s){super(t,i,r,a,s),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrixWorld=()=>{for(let d of this.objects)if(!d.visible)return;let h=Rre.setFromMatrixPosition(this.objects[0].matrixWorld),c=Ore.setFromMatrixPosition(this.objects[1].matrixWorld),u=h.distanceTo(c)<=this.distance?"in":"out";if(this.stage!==u){this.stage=u;let d=u==="in"?this.actionsIn:this.actionsOut;d.Audio.forEach(p=>p.dispatchConditional()),d.Particles.forEach(p=>p.dispatchConditional()),d.Video.forEach(p=>p.dispatchConditional()),d.Link.forEach(p=>p.dispatch()),d.Create.forEach(p=>p.dispatch()),d.Destroy.forEach(p=>p.dispatch()),d.Reset.forEach(p=>p.dispatch()),d.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),d.Transition.forEach(p=>p.play()),d.Animation.forEach(p=>p.play()),d.SwitchCamera.forEach(p=>p.play()),d.SceneTransition.forEach(p=>p.dispatch()),d.SetVariable.forEach(p=>p.checkConditions()),d.SetVariable.forEach(p=>p.dispatch()),d.DynamicVariablePlay.forEach(p=>p.dispatch())}};let{distance:n,fromObject:o,toObject:l}=t.condition;this.distance=n;for(let h of[o,l]){if(!h)throw new Error("Missing property");let c=r.find(h);if(!c)throw new Error("Missing property");this.objects.push(c)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)})}},Ire=class extends lO{constructor(e,t,i,r,a,s){super(t,i,r,a,s),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(c=>c.dispatchConditional()),this.actionsOut.Particles.forEach(c=>c.dispatchConditional()),this.actionsOut.Video.forEach(c=>c.dispatchConditional()),this.actionsOut.Link.forEach(c=>c.dispatch()),this.actionsOut.Create.forEach(c=>c.dispatch()),this.actionsOut.Destroy.forEach(c=>c.dispatch()),this.actionsOut.Reset.forEach(c=>c.dispatch()),this.actionsIn.Transition.forEach(c=>c.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(c=>c.play()),this.actionsOut.Animation.forEach(c=>c.play()),this.actionsIn.SwitchCamera.forEach(c=>c.pause()),this.actionsOut.SwitchCamera.forEach(c=>c.play()),this.actionsOut.SceneTransition.forEach(c=>c.dispatch()),this.actionsOut.SetVariable.forEach(c=>c.checkConditions()),this.actionsOut.SetVariable.forEach(c=>c.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(c=>c.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(c=>c.dispatchConditional()),this.actionsIn.Particles.forEach(c=>c.dispatchConditional()),this.actionsIn.Video.forEach(c=>c.dispatchConditional()),this.actionsIn.Link.forEach(c=>c.dispatch()),this.actionsIn.Create.forEach(c=>c.dispatch()),this.actionsIn.Destroy.forEach(c=>c.dispatch()),this.actionsIn.Reset.forEach(c=>c.dispatch()),this.actionsOut.Transition.forEach(c=>c.pause()),this.actionsOut.Transition.forEach(c=>c.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(c=>c.play()),this.actionsIn.Animation.forEach(c=>c.play()),this.actionsOut.SwitchCamera.forEach(c=>c.pause()),this.actionsIn.SwitchCamera.forEach(c=>c.play()),this.actionsIn.SceneTransition.forEach(c=>c.dispatch()),this.actionsIn.SetVariable.forEach(c=>c.checkConditions()),this.actionsIn.SetVariable.forEach(c=>c.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(c=>c.dispatch()))};let{condition:n}=t;if(!n.object)throw new Error("Missing property");let o=r.find(n.object)??r.scene.find2D(n.object);if(!o)throw new Error("Missing property");if(this.toObject=o,n.state&&!this.toObject.states?.[n.state])throw new Error("Missing property");this.toState=n.state}connect(){oh(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),oh(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),oh(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),oh(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},Bre=class extends en{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(a=>{if(a.data?.events.length){for(let{id:s,data:n}of a.data.events)if(!n.disabled&&n.type==="Conditional")try{let o;n.condition.type==="Comparison"||(n.condition.type==="Distance"?o=new Lre(s,n,a,i,r,t):n.condition.type==="State"&&(o=new Ire(s,n,a,i,r,t))),o&&(this.eventsPerConditions[n.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Ed=new O,el=new O,Yl=new O,YC=new ts,Ure=.01,xi=new O,Br=new O,QC=new O,fh=new zt,By=new Qi,Fre=new je,Uy=new Ht,Mc=new O,gn=new O,Cc=.2;function Fy(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var Nre=function(){let e=new je;return(t,i,r)=>{let a=t.obj;e.copy(a.hiddenMatrix),a.parent!==null&&e.premultiply(a.parent.matrixWorld),e.invert(),a.position.copy(i),t.reference==="global"&&Fy(a.position,t.limits),a.position.applyMatrix4(e),t.reference==="parent"?Fy(a.position,t.limits):t.reference==="local"&&(fh.copy(t.quat0).invert(),a.position.sub(t.position0),a.position.applyQuaternion(fh),Fy(a.position,t.limits),fh.invert(),a.position.applyQuaternion(fh),a.position.add(t.position0)),e.multiply(r??a.matrixWorld).decompose(xi,a.quaternion,Br),a.updateMatrix(),a.hasNonUniformScale&&(a.updateMatrixWorld(),a.updateMatrixWorldSVD()),a instanceof Fa&&_o(a.parent)&&a.invalidateDownstreamBooleanData(!0)}}(),zre=class{constructor(e,t,i,r,a,s){this.object=e,this.data=t,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=Na(t,t.dragDropActions.drag,i,r,a,this.object),this.actionsDrop=Na(t,t.dragDropActions.drop,i,r,a,this.object);let n=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(n.push(l),s[l.uuid]&&s[l.uuid].forEach(h=>{let c=i.find(h);!c||c.data.visible!==!1&&n.push(c)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(this.dropDestIds.push(l.uuid),s[l.uuid]&&s[l.uuid].forEach(h=>{let c=i.find(h);!c||c.data.visible!==!1&&this.dropDestIds.push(c.uuid)}))}),this.dragItems=n.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new O().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new O().setFromMatrixPosition(o.matrixWorld),pointStart:new O,pointEnd:new O,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new O().copy(o.position),quat0:new zt().copy(o.quaternion),snapped:!1,orientationMatrix:new je,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Jr(this.actionsDrag),Jr(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},kre=class extends en{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(Lt.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:a,page:s}=this.eventContext,n=s.raycastWithClones(a);if(this.lastDropDestination=null,n.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:c,pointStart:u}of o.dragItems){if(h===n[0].object||h===n[0].object.object||ui.is(h)&&h.isAncestorOf(n[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(xi,fh,Br),By.setFromQuaternion(fh),d.prevR===void 0?(d.prevR=By.clone(),d.prevT=xi.clone()):(d.prevR.copy(By),d.prevT.copy(xi)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,u,o.data.plane,o.data.referenceFrame),c.copy(u),(this.eventManager.controlsManager.usePhysics&&h.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(Lt.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:a,page:s}=this.eventContext,n=s.raycastWithClones(a);if(Lt.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===n[0]?.object||h===n[0]?.object?.object||ui.is(h)&&h.isAncestorOf(n[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=n.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof nu)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(c=>c===h.object.uuid||s.scene.find(c).isAncestorOf(h.object.uuid))))[0]),l){let h=QC.copy(l.face.normal).applyMatrix3(Uy.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){xi.copy(h).applyMatrix3(Uy.setFromMatrix4(o.obj.matrixWorld).transpose());let c=o.obj;xi.x>Cc?Br.x=-c.recursiveBBox.min.x:xi.x<-Cc&&(Br.x=-c.recursiveBBox.max.x),xi.y>Cc?Br.y=-c.recursiveBBox.min.y:xi.y<-Cc&&(Br.y=-c.recursiveBBox.max.y),xi.z>Cc?Br.z=-c.recursiveBBox.min.z:xi.z<-Cc&&(Br.z=-c.recursiveBBox.max.z),Br.applyMatrix3(Uy.invert())}else Br.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(Br)}this.activeEvent.data.autoOrient&&(xi.set(0,1,0).cross(h),xi.length()<1e-4&&xi.set(-1,0,0).cross(h),Br.crossVectors(QC,xi),o.orientationMatrix.makeBasis(xi,Br,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Animation.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Audio.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(c=>{c.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.stop()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(h=>h.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let a=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!a)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&a&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(s=>{s.stop(),s.object.currentState!==null&&s.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(s=>{s.stop()}),this.activeEvent.actionsDrag.Audio.forEach(s=>{s.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(s=>{s.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(s=>s.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(s=>s.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(s=>s.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let i={};e.page.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.page.traverseEntity(r=>{r.data?.events.filter(a=>a.data.type==="DragDrop"&&!a.data.disabled).forEach(a=>{this.events.push(new zre(r,a.data,e.page,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:a,raycaster:s}=this.eventContext;a().getWorldDirection(el),el.negate();let n=fh.identity();switch(r==="parent"?Fre.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(xi,n,Br):r==="local"&&e.matrixWorld.decompose(xi,n,Br),i){case"x":xi.set(1,0,0).applyQuaternion(n),Mc.copy(el).cross(xi),gn.copy(xi).cross(Mc);break;case"y":xi.set(0,1,0).applyQuaternion(n),Mc.copy(el).cross(xi),gn.copy(xi).cross(Mc);break;case"z":xi.set(0,0,1).applyQuaternion(n),Mc.copy(el).cross(xi),gn.copy(xi).cross(Mc);break;case"xy":gn.set(0,0,1).applyQuaternion(n);break;case"yz":gn.set(1,0,0).applyQuaternion(n);break;case"xz":gn.set(0,1,0).applyQuaternion(n);break;case"adaptive":el.angleTo(Br.set(0,1,0))>Math.PI/6?(xi.crossVectors(Br.set(0,1,0),el),gn.crossVectors(xi,Br)):gn.set(0,1,0);break;default:gn.copy(el);break}Yl.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:Yl;if(YC.setFromNormalAndCoplanarPoint(gn,o),!!s.ray.intersectPlane(YC,t)&&(i==="x"||i==="y"||i==="z")){let l=Br.subVectors(t,o).dot(xi);t.copy(o).addScaledVector(xi,l)}}updateDragItem(e,t=!1){Yl.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Ed.subVectors(e.fromPosition,Yl).divideScalar(e.currentDampingFactor):e.reset==="original"?(Ed.subVectors(e.obj.userData.worldPosition0,Yl).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Ed.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Yl).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Ed.length()<Ure:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&Nre(e,Ed.add(Yl),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},Tc=new O,Ny=new O,ro=new O,ao=new O,KC=new ts,Vre=.01,jre={type:"requestRender"},Gre=function(){let e=new O,t=new O;return(i,r,a)=>a>0?(e.subVectors(i,r),e.length()<=a?i:t.copy(r).add(e.normalize().multiplyScalar(a))):r}(),ZC=function(){let e=new je;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Fa&&_o(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),Hre=class{constructor(e,t,i,r,a){this.data=e,this.object=t,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new O,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...M1.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Na(e,e.actions,i,r,a,t)}},Wre=class extends en{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(Lt.length>1)){this.eventContext.updateRaycaster(r);for(let a of this.events)a.target===void 0&&this.updateSingleEvent(a)}},this.onMouseEnter=r=>{for(let a of this.events)a.target===void 0&&(a.isReset=!1,a.currentDampingFactor=a.data.dampingFactor)},this.onMouseLeave=r=>{for(let a of this.events)a.target===void 0&&(a.data.resetOnPointerLeave&&(a.isReset=!0,a.currentDampingFactor=a.resetDampingFactor),this.updateSingleEvent(a))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{page:i}=this.eventContext;i.traverseEntity(r=>{let a=r.data?.events.find(s=>s.data.type==="Follow"&&!s.data.disabled);a&&(!i.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Hre(a.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),rs&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=i.target,a=this.onTargetChange(i);this.pairOfEventListeners.push([r,a]),r.addEventListener("requestRender",a)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),rs&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,Jr(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(n=>{n.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:a}=e.data;if(e.object.getWorldPosition(ro),e.isReset)ao.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(ao);else{let{getCamera:n,raycaster:o}=this.eventContext;if(i==="custom"?(n().getWorldDirection(Ny),Ny.negate(),Tc.copy(Ny)):i==="xy"?Tc.set(0,0,1):i==="xz"?Tc.set(0,1,0):i==="yz"&&Tc.set(1,0,0),KC.setFromNormalAndCoplanarPoint(Tc,ro),!o.ray.intersectPlane(KC,ao))return}if(!e.isReset){if(ao.distanceTo(e.worldPosition0)>r&&a&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)ao.copy(e.worldPosition0),e.currentDampingFactor=e.resetDampingFactor;else return;else if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return}e.data.enabledTranslation[0]===!1&&(ao.x=ro.x),e.data.enabledTranslation[1]===!1&&(ao.y=ro.y),e.data.enabledTranslation[2]===!1&&(ao.z=ro.z);let s=Gre(ro,ao,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let n=Tc.subVectors(s,ro).divideScalar(e.currentDampingFactor);ro.add(n),t&&ZC(e.object,ro),e.paused=n.length()<Vre}else ZC(e.object,s),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(jre)}},Md=new O,_m=new O,Cd=new je,Pc=new zt,tl=new zt,Td=new O,Pd=new O,Ql=new O,so=new O,zy=new ts,qre=1e-6,Xre={type:"requestRender"},Yre={type:"changeRotation"},JC=function(){let e=new je;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(rO(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof Fa&&_o(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),Qre=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new zt,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...C1.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},Kre=class extends en{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(Lt.length>1)){this._lastMouseEvent=i,this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:a})=>{if(!r||!a)return;let s=Op(r);s&&s==="LookAt"&&this.updateSingleEvent(i)};let{page:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(a=>a.data.type==="LookAt"&&!a.data.disabled);r&&(!t.data.globalPhysics.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Qre(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),rs&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?t.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let s=this.onTargetChange(i),n=i.target;this.pairOfEventListeners.push([n,s]),n.addEventListener("requestRender",s)}let r=this.createUserEventListener(i),a=i.object;this.pairOfUserEventListeners.push([a,r]),a.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),rs&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:a,limitDistance:s,enabledRotation:n,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:c,target:u}=e;if(c.getWorldPosition(Td),!e.isReset)if(e.target)e.target.getWorldPosition(Pd);else{if(a==="custom"?(l().getWorldDirection(_m),_m.negate(),zy.setFromNormalAndCoplanarPoint(_m,Td)):(a==="xy"?Md.set(0,0,1):a==="xz"?Md.set(0,1,0):a==="yz"&&Md.set(1,0,0),zy.setFromNormalAndCoplanarPoint(Md,Td)),!h.ray.intersectPlane(zy,Pd))return;r>0&&(a==="custom"||a===void 0)&&Pd.addScaledVector(_m,r)}if(e.isReset||(u?t==="target"?Ql.copy(u.up).applyMatrix4(Cd.extractRotation(u.matrixWorld)).normalize():n.some(d=>d===!1)?(i==="x"?(so.set(0,0,1),n[2]===!1&&so.set(0,1,0)):i==="y"?(so.set(1,0,0),n[0]===!1&&so.set(0,0,1)):(so.set(0,1,0),n[1]===!1&&so.set(1,0,0)),Ql.copy(so).applyQuaternion(e.worldQuaternion0).normalize()):Ql.set(0,1,0):a==="custom"?Ql.set(0,1,0):Ql.copy(Md)),e.isReset)tl.copy(e.worldQuaternion0);else if(Td.distanceTo(Pd)>s&&o&&u)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)tl.copy(e.worldQuaternion0),e.currentDampingFactor=e.resetDampingFactor;else return;else{if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return;Zre(Cd,Pd,Td,Ql,i,so),tl.setFromRotationMatrix(Cd),Pc.setFromUnitVectors(so.applyQuaternion(tl),Ql),n.some(d=>d===!1)&&t!=="target"&&tl.premultiply(Pc).normalize()}e.currentDampingFactor>1?(c.updateWorldMatrix(!0,!1),Pc.setFromRotationMatrix(rO(c.matrixWorld)),Pc.slerp(tl,1/e.currentDampingFactor),JC(c,Cd.makeRotationFromQuaternion(Pc)),e.paused=8*(1-Pc.dot(tl))<qre):(JC(c,Cd.makeRotationFromQuaternion(tl)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),c.dispatchEvent(Xre),c.dispatchEvent(Yre)}},vs=new O,Ir=new O,vr=new O;function Zre(e,t,i,r,a,s){let n=e.elements;vr.subVectors(t,i),vr.lengthSq()===0&&(vr.z=1),vr.normalize(),Ir.crossVectors(r,vr),Ir.lengthSq()===0&&(Math.abs(r.z)===1?vr.x+=1e-4:vr.z+=1e-4,vr.normalize(),Ir.crossVectors(r,vr)),Ir.normalize(),vs.crossVectors(vr,Ir),a==="x"?s.z===1?[Ir,vs,vr]=[vr,Ir,vs]:(Ir.negate(),[Ir,vr]=[vr,Ir]):a==="y"?s.x===1?[Ir,vs,vr]=[vs,vr,Ir]:(Ir.negate(),[vs,vr]=[vr,vs]):s.x===1&&(Ir.negate(),[Ir,vs]=[vs,Ir]),n[0]=Ir.x,n[4]=vs.x,n[8]=vr.x,n[1]=Ir.y,n[5]=vs.y,n[9]=vr.y,n[2]=Ir.z,n[6]=vs.z,n[10]=vr.z}var Jre=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=Na(t,t.actions,r,a,s,i)}disconnect(){Jr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Particles.forEach(e=>e.dispatchBasic()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},$re=class extends en{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this.objects2D=[],this._prevObjects=[],this.onMouseDown=s=>{Lt.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onMouseUp=s=>{Lt.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=s=>{Lt.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:s,target:n,reverse:o})=>{if(!s||!n)return;let l=Op(s);l&&l==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(h=>h.dispatchUserEvent(o)))};let{page:i,sharedAssets:r}=this.eventContext,a=(s,n)=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:o,data:l}of s.data.events)if(!l.disabled&&l.type==="MouseHover")try{let h=new Jre(o,l,s,i,r,t);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(h):this.eventsPerObjects[s.uuid]=[h]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s instanceof $r?n:s)}};i.traverseEntity(s=>{(s instanceof ya||s instanceof Xr)&&s.frame?.traverse(n=>{a(n,s)}),a(s)})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),rs&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),rs&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:a,pointerScreen:s}=this.eventContext,n=!1;if(a.uiCanvas&&(n=go(a,[s.x,s.y],Object.keys(this.eventsPerObjects),o=>{t.push(o)})),i&&!n){let o=km(r,a,this.objects);t=qx(o),o.forEach(l=>{l.object instanceof ya&&go(l.object,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{t.push(h)})})}else this.objects.forEach(o=>{let l=Wg(r,o);l&&(t.push(o),o instanceof ya&&go(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{t.push(h)}))})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},eae=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=Na(t,t.actions,r,a,s,i)}connect(){this.scrollCounter=0}disconnect(){Jr(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch()),this.actions.DynamicVariablePlay.forEach(r=>r.dispatch())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},tae=class{constructor(e,t,i,r,a,s,n){this.id=e,this.data=t,this.object=i,this.domElement=s,this.eventManager=n,this.scrollStart=0,this.scrollEnd=0,this.actions=Na(t,t.actions,r,a,n,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,a=i.clientTop||t.clientTop||0,s=Math.round(e.top+r-a);if(this.data.startFrom==="enter"){let n=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?n:l==="bottom"?n-o:n-o*.5;this.scrollStart=s-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=e,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){Jr(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:e,y:t}){this.actions.Transition.forEach(a=>{a.object.currentTransitionEvent!==this&&(a.object.currentTransitionEvent=this,a.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(a=>a.seek(r)),this.actions.Animation.forEach(a=>a.seek(r)),this.actions.Create.forEach(a=>a.dispatchThrottled()),this.actions.SetVariable.forEach(a=>a.checkConditions()),this.actions.SetVariable.forEach(a=>a.dispatch()),this.actions.DynamicVariablePlay.forEach(a=>a.dispatch())}dispatch(e){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(e)}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},iae=class extends en{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([o,l])=>{l.forEach(h=>h.handleResize())})},this.onScroll=o=>{if(!this.isInview)return;let l={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([h,c])=>{h.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:l}),c.forEach(u=>u.dispatch(l))})},this.onWheel=o=>{!this.isInview||o.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:o.deltaY}),h.forEach(c=>c.dispatch(o.deltaY))})},this.onUserEvent=({eventName:o,target:l,reverse:h})=>{if(!o||!l)return;let c=Op(o);c&&c==="Scroll"&&(l.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(l)?.forEach(u=>{u.dispatchUserEvent(h)}))};let{page:i,sharedAssets:r,domElement:a,isExport:s}=this.eventContext,n=o=>{if(o.data?.events.length){for(let{id:l,data:h}of o.data.events)if(!h.disabled&&h.type==="Scroll")if(h.trigger==="load"||!s){let c=new eae(l,h,o,i,r,t);this.wheelEventsPerObject.has(o)?this.wheelEventsPerObject.get(o)?.push(c):this.wheelEventsPerObject.set(o,[c])}else{let c=new tae(l,h,o,i,r,a,t);this.scrollEventsPerObject.has(o)?this.scrollEventsPerObject.get(o)?.push(c):this.scrollEventsPerObject.set(o,[c])}}};i.traverseEntity(o=>{(o instanceof ya||o instanceof Xr)&&o.frame?.traverse(l=>{n(l)}),n(o)}),this.intersectionObserver=new IntersectionObserver(o=>{let l=o[0];l&&(this.isInview=l.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},rae=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.actions=Na(t,t.actions,r,a,s,i)}disconnect(){Jr(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof ph?t.interaction.audioPlayer.play():t.interaction instanceof kx&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof lu?t.interaction.play(i==="autoplay"):t.interaction instanceof Hx&&t.interaction.dispatch())}),this.actions.Particles.forEach(t=>{(t.data.triggerAfter??"any")===e&&t.dispatchBasic()})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof ph?t.interaction.audioPlayer.play():t.interaction instanceof kx&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof lu?t.interaction.play():t.interaction instanceof Hx&&t.interaction.dispatch()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()})}},aae=class extends en{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext,a=r?document:i;a.removeEventListener("pointerdown",this.onAny),a.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(o=>{o.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.actions.Audio.forEach(s=>{s.interaction instanceof ph&&s.interaction.audioPlayer.play()}),a.actions.Video.forEach(s=>{let n=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof lu&&s.interaction.play(n==="autoplay")}),a.actions.Particles.forEach(s=>{s.dispatchBasic()})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:i,target:r,reverse:a})=>{if(!i||!r)return;let s=Op(i);s&&s==="Start"&&(r instanceof $r||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(a)}),this.eventsAfterPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(a)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext,i=r=>{if(r.data?.events.length)for(let{id:a,data:s}of r.data.events){if(s.disabled||s.type!=="Start")continue;let n=new rae(a,s,r,t,e,this.eventManager);(n.actions.Transition.length||n.actions.Animation.length||n.actions.SwitchCamera.length||n.actions.Create.length||n.actions.Destroy.length||n.actions.SceneTransition.length||n.actions.Reset.length||n.actions.SetVariable.length||n.actions.DynamicVariablePlay.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(n):this.eventsPerObject.set(r,[n])),n.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Particles.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n]))}};if(t.traverseEntity(r=>{(r instanceof ya||r instanceof Xr)&&r.frame?.traverse(a=>{i(a)}),i(r)}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:a}=this.eventContext,s=a?document:r;s.addEventListener("pointerdown",this.onMouseDown,{once:!0}),s.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),s.addEventListener("pointerdown",this.onAny),s.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,o])=>{n.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([r,a])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(s=>s.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,a])=>{r.removeEventListener("userEvent",this.onUserEvent),a.forEach(s=>s.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},sae=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.disabled=!1,this.alreadyPlayedNonTogglingActions=new Set,this.actions=Na(t,t.actions,r,a,s,i),this.target=t.target,this.useToggle=t.runMode==="Toggle"}disconnect(){Jr(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()})):(this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}))}},nae=class extends en{constructor(e,t,i,r,a){super(e),this.sharedVariables=t,this.eventManager=i,this.needsMouse=r,this.needsRaycast=a,this.dynamicVars=[],this.variablesToWatch=[],this.prevMouseProperty=null,this.prevRaycastProperty=null,this.pauseTime=0,this.events=[],this.onFrame=s=>{this.rafId=window.requestAnimationFrame(this.onFrame);let n=new Date,o=[],l=[];for(let u=0;u<this.propertiesToWatch.length;u++){let{objectId:d,property:p,prevValue:f}=this.propertiesToWatch[u],m=this.eventContext.scene.find(d),g=P1.propertyPaths[p];if(g[0]==="width"||g[0]==="height"||g[0]==="depth")m=m.geometry.userData.parameters[g[0]];else for(let v=0;v<g.length;v++)m=m[g[v]];f===null?this.propertiesToWatch[u].prevValue=m instanceof O?m.clone():m:(m instanceof O?!m.equals(f):f!==m)&&(l.push({objId:d,property:p}),m instanceof O?this.propertiesToWatch[u].prevValue.copy(m):this.propertiesToWatch[u].prevValue=m)}for(let u=0;u<this.variablesToWatch.length;u++){let{id:d,prevValue:p}=this.variablesToWatch[u],f=this.shared.getVariable(d);f!==p&&(o.push(d),this.variablesToWatch[u].prevValue=f)}for(let u=0;u<this.dynamicVars.length;u++){let{id:d,expectedTime:p,last:f,data:m,timerSeconds:g,startValue:v}=this.dynamicVars[u],x=1e3;if((m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&m.format==="number3decimal"?x=1:m.dynamicVariableType==="counter"?x=m.updateInterval:m.dynamicVariableType==="random"&&(x=m.isStatic?1/0:m.updateInterval),p===-1){this.dynamicVars[u].last=s,this.dynamicVars[u].expectedTime=s+x;continue}if(!((this.shared.getDynamicVariablePlayState(d)==="Stopped"||this.shared.getDynamicVariablePlayState(d)==="Restarted")&&(this.dynamicVars[u].last=s,this.dynamicVars[u].expectedTime=s+x,m.dynamicVariableType==="counter"&&this.shared.getVariable(d)!==v&&(this.shared.updateVariable(d,v),this.eventManager.requestRender()),(m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&this.dynamicVars[u].timerSeconds!==v&&(this.dynamicVars[u].timerSeconds=v,this.shared.updateVariable(d,ws.getFormattedTimerTime(v,m)),this.eventManager.requestRender()),this.shared.getDynamicVariablePlayState(d)==="Restarted"&&this.shared.setDynamicVariablePlayState(d,"Playing"),this.shared.getDynamicVariablePlayState(d)==="Stopped"))){if(this.shared.getDynamicVariablePlayState(d)==="Paused"){this.dynamicVars[u].deltaToExpectedTime===void 0&&(this.dynamicVars[u].deltaToExpectedTime=Math.max(this.dynamicVars[u].expectedTime-s,0)),this.dynamicVars[u].last=s-(x-this.dynamicVars[u].deltaToExpectedTime),this.dynamicVars[u].expectedTime=s+this.dynamicVars[u].deltaToExpectedTime;continue}else this.dynamicVars[u].deltaToExpectedTime=void 0;if(s>=p)if(this.dynamicVars[u].last=s,this.dynamicVars[u].expectedTime+=x,m.dynamicVariableType==="random"){let b=m.min+Math.random()*(m.max-m.min),_=m.decimals;b=Math.round(b*Math.pow(10,_))/Math.pow(10,_),this.shared.updateVariable(d,b),o.push(d),this.eventManager.requestRender()}else if(m.dynamicVariableType==="counter"){if(m.increment===0)continue;let b=this.shared.getVariable(d),_=this.shared.getDynamicVariableToggleIsForward(d)??!0,M=this.shared.getVariable(d)+m.increment*(_?1:-1);m.hasEnd&&(M=m.increment>0?dt.clamp(M,v,m.endValue):dt.clamp(M,m.endValue,v),M===v&&this.shared.setDynamicVariableToggleIsForward(d,void 0),m.repeat?M===m.endValue&&(M=v):(M===v||M===m.endValue)&&this.shared.setDynamicVariablePlayState(d,"Paused")),M!==b&&(o.push(d),this.shared.updateVariable(d,M),this.eventManager.requestRender())}else if(m.dynamicVariableType==="time")this.shared.updateVariable(d,gM(n,m)),o.push(d),this.eventManager.requestRender();else{let b=as.isTextValue(m.endValue)?$C(m.endValue.textValue):m.endValue,_=this.shared.getDynamicVariableToggleIsForward(d)??!0,M=g+(s-f)/1e3*(m.dynamicVariableType==="timer"?-1:1)*(_?1:-1);M=Math.max(M,0),m.hasEnd&&(M=m.dynamicVariableType==="stopwatch"?dt.clamp(M,v,b):dt.clamp(M,b,v),M===v&&this.shared.setDynamicVariableToggleIsForward(d,void 0),m.repeat?Math.abs(M-b)<(m.format==="number3decimal"?1e-4:.1)&&(M=v):(Math.abs(M-v)<(m.format==="number3decimal"?1e-4:.1)||Math.abs(M-b)<(m.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(d,"Paused")),M!==g&&(o.push(d),this.dynamicVars[u].timerSeconds=M,this.shared.updateVariable(d,ws.getFormattedTimerTime(M,m)),this.eventManager.requestRender())}}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(u=>{u.data.variableId==="mouseProperty"&&(u.dispatch(),this.eventManager.requestRender())}));let h=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,h=!0);let c=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,c=!0),this.events.forEach(u=>{(o.includes(u.data.variableId)||l.find(d=>d.objId===u.data.objectId&&d.property===u.data.property)||u.data.variableId==="mouseProperty"&&h||u.data.variableId==="raycastProperty"&&c)&&(u.dispatch(),this.eventManager.requestRender())})},this.onBlur=()=>{this.pause()},this.onFocus=()=>{this.resume()},e.page.traverseEntity(s=>{s.data?.events.filter(n=>n.data.type==="VariableChange"&&!n.data.disabled).forEach(n=>{this.events.push(new oae(s.uuid,n.data,s,e.page,e.sharedAssets,i))})}),this.propertiesToWatch=this.events.filter(s=>s.data.variableId==="objectProperty"&&s.data.objectId!==null).map(s=>({objectId:s.data.objectId,property:s.data.property,prevValue:null})),this.shared=e.sharedAssets,this.sharedVariables.forEach(({id:s,data:n})=>{if(!("dynamicVariableType"in n)){this.events.find(l=>l.data.variableId===s)&&this.variablesToWatch.push({id:s,prevValue:this.shared.getVariable(s)});return}let o;if(n.dynamicVariableType==="timer"||n.dynamicVariableType==="stopwatch"){let l;if(as.isTextValue(n.value)&&Array.isArray(n.value.textValue)){let h=n.value.textValue;h.length===3?l=h[2]+h[1]*60+h[0]*3600:l=h[1]+h[0]*60}else l=n.value;o=l,this.dynamicVars.push({id:s,last:-1,expectedTime:-1,data:n,timerSeconds:l,startValue:o})}else n.dynamicVariableType==="time"&&this.shared.updateVariable(s,gM(new Date,n)),n.dynamicVariableType==="counter"&&(o=as.isTextValue(n.value)?$C(n.value.textValue):n.value),this.dynamicVars.push({id:s,last:-1,expectedTime:-1,data:n,startValue:o})})}pause(){this.pauseTime=Date.now()}resume(){let e=Date.now()-this.pauseTime;for(let t=0;t<this.dynamicVars.length;t++)this.dynamicVars[t].last+=e,this.dynamicVars[t].expectedTime+=e}connect(){this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(e=>e.dispose())}},oae=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.actions=Na(t,t.actions,r,a,s,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch())}dispose(){Jr(this.actions)}};function $C(e){return e.length===3?e[2]+e[1]*60+e[0]*3600:e[1]+e[0]*60}var lae="https://unpkg.com/@splinetool/runtime@1.0.84/build/",hae="https://unpkg.com/@splinetool/navmesh-wasm@1.0.84/build/",cae=`
8038
+ )`}else if(e.easing===6){let{mass:i,stiffness:r,damping:a,velocity:s}=e;t=`spring( ${i}, ${r}, ${a}, ${s} )`}else{let i;switch(e.easing){case 0:i=rl.linear;break;case 1:i=rl.ease;break;case 2:i=rl.easeIn;break;case 3:i=rl.easeOut;break;case 4:i=rl.easeInOut;break;default:i=rl.linear}let[r,a,s,n]=i;t=`cubicBezier( ${r}, ${a}, ${s}, ${n} )`}return{duration:Math.max(e.duration,1e-4),easing:t}}function Gx(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var ire={type:"beginState"},rre={type:"completeState",isfromEntity:!1},UC=class{constructor(e,t,i,r,a,s){if(this.object=e,this.data=r,this.sharedAssets=a,this.allowSlerp=s,this.targets={t:0},this.firstLoop=!0,this._changeBegan=!1,this._changeCompleted=!0,this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.requestRender()),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))},this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let n=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=n,this.object.dispatchEvent({type:"beginState",state:n}),this.object instanceof $r||this.object.traverseEntity(o=>{o!==this.object&&o instanceof _a&&o.dispatchEvent(ire)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let n=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=n,this.object.dispatchEvent({type:"completeState",state:n}),this.object instanceof $r||this.object.traverseEntity(o=>{o!==this.object&&o instanceof _a&&o.dispatchEvent(rre)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=OC(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let n=zm(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!n)throw new Error("Missing property");this.from=n}else{let n=zm(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(i===void 0)throw new Error("Missing property");{let n=zm(this.object,i);if(!n)throw new Error("Missing property");this.to=n}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...Gx(r),...WR(r),change:this.onChange},this.callback=OC(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},qR=class extends ua{constructor(e,t,i,r){if(super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.useToggle=!1,this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!1,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let a=this.page.scene.find(e.object)??this.page.uiCanvas?.find(e.object)??this.page.scene.find2DInUIObjects(e.object);if(!a)throw new Error("Missing property");if(!a.states)throw new Error("Missing property");if(this.object=a,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.timeline?.paused===!1}get changeBegan(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=zm(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:t=!1,isRebuild:i=!1}={}){try{let r=Gx(this.data.tweens[0].data);i&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=HR.timeline({autoplay:!1,...r,...r.loop===!0||r.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let a=this.tweens.findIndex(s=>s?.changeBegan);if(t===!0&&(this.timelineNeedsRebuild=!0),e){let s=a===-1?0:a;for(let n=s;n<this.data.tweens.length-1;n++){let o=this.data.tweens[n],l=this.data.tweens[n+1],h;n===s&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof _a&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let c=new UC(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.shared,this.data.allowSlerp??!1);a!==-1&&n===s&&Object.assign(c.params,{startOnceDelay:0}),this.tweens[n]=c,this.timeline.add(c.params,this.timeline.duration+(n===s?r.delay:0))}this.timeline.duration+=r.endDelay}else{let s=a===-1?this.data.tweens.length-1:a+1;for(let n=s;n>0;n--){let o=this.data.tweens[n],l=this.data.tweens[n-1],h;n===s&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof _a&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let c=new UC(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.shared,this.data.allowSlerp??!1);a!==-1&&n===s&&Object.assign(c.params,{startOnceDelay:0}),this.tweens[n-1]=c,this.timeline.add(c.params,this.timeline.duration+(n===s?r.endDelay:0))}this.timeline.duration+=r.delay}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(ar(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=Gx(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}},this.startOnceDelay+e)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object instanceof $r?this.object.changeSelectedState(e,{shared:this.shared}):this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(ar(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function zm(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var are={type:"beginState"},FC={type:"completeState",isfromEntity:!1},NC={type:"requestRender"},XR=class extends ua{constructor(e,t,i,r){super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new O,this.posEnd=new O,this.qStart=new zt,this.qEnd=new zt,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t=this.page.scene.find(this.data.targetCamera);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=HR({targets:i,t:1,...WR(this.data),update:()=>{i.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(t.position),this.qEnd.copy(t.quaternion),this.zoomEnd=t.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(t.uuid)),this.page.activeCamera.dispatchEvent(are));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,i.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(NC),i.t===1&&r.dispatchEvent(FC)}})}switchCamera(e){let t=this.page.activeCamera,i=this.page.scene.find(e);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),t.dispatchEvent({type:"cameraChange",camera:i})}play(){if(ar(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(ar(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(FC),this.page.activeCamera.dispatchEvent(NC))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},YR=class extends ua{constructor(e,t,i,r,a){super(),this.page=t,this.animationControls=i,this.shared=r,this.condition=a,this.startOnceDelay=0,this.toggleIsForward=!1;let s=e.object,n=t.scene.find(e.object);n&&Array.isArray(n.identity)&&(s=n.identity[0]),this.data={...e,object:s};let o=this.animationControls.clipIdToAction[e.clipId+"/"+s];this.duration=o?.getClip()?.duration??1;let l=o?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(ar(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let a=i.split("/")[1];this.threeAnimAction!==r&&a===t&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=dt.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){if(ar(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,a])=>{let s=r.split("/")[1];this.threeAnimAction!==a&&s===i&&a.isRunning()&&(t?a.fadeOut(.2):a.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},QR=class{constructor(e,t,i,r,a){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.condition=a,this.timeOutId=-1,this.scene=t.scene}dispatch(){if(ar(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(t=>{t.type==="ParticleSystem"&&(t.sleep(),t.wakeUp(),t.data.autoPlay?t.start():t.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),Rw(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}},KR=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=ar(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let e=this.shared.getVariable(this.data.variableId),t=iD(this.data.expression,this.shared,as.typeOfVariable(e));t!==void 0&&this.shared.updateVariable(this.data.variableId,typeof t=="string"?{textValue:t}:t)}dispose(){}},ZR=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.timeoutId=null}dispatchInner(){if(ar(this.shared,this.condition)===!1)return!1;let e=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,e==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&e!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&e!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&e!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let t=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);e==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,t===void 0?!1:!t):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!t),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let e=this.data.delay,t=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&t==="Playing"&&(e=this.data.pauseDelay),e!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},e)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};function ar(e,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let i=iD(t.expression,e,"boolean");return t.negate?!i:!!i}function Na(e,t,i,r,a,s){let n={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[]},o=l=>({id:h,data:c})=>{try{c.type==="Audio"?ja[e.type].includes("Audio")&&n.Audio.push(new AR(h,c,s,r,l)):c.type==="Video"&&!(s instanceof $r)?ja[e.type].includes("Video")&&n.Video.push(new $R(h,c,s,r,l)):c.type==="Particles"?ja[e.type].includes("Particles")&&n.Particles.push(new ER(c,i,r,l)):c.type==="Link"?ja[e.type].includes("Link")&&n.Link.push(new qte(c,a.controlsManager,r,l)):c.type==="Create"?ja[e.type].includes("Create")&&n.Create.push(new eO(c,i,a.controlsManager,r,l)):c.type==="Destroy"?ja[e.type].includes("Destroy")&&n.Destroy.push(new MR(c,i,a.controlsManager,r,l)):c.type==="Reset"?ja[e.type].includes("Reset")&&n.Reset.push(new CR(c,i,r,a,l)):c.type==="Transition"?ja[e.type].includes("Transition")&&n.Transition.push(new qR(c,i,r,l)):c.type==="SwitchCamera"?ja[e.type].includes("SwitchCamera")&&n.SwitchCamera.push(new XR(c,i,r,l)):c.type==="SceneTransition"?ja[e.type].includes("SceneTransition")&&n.SceneTransition.push(new QR(c,i,a,r,l)):c.type==="Animation"?ja[e.type].includes("Animation")&&n.Animation.push(new YR(c,i,a.animationControls,r,l)):c.type==="SetVariable"?ja[e.type].includes("SetVariable")&&n.SetVariable.push(new KR(c,i,r,l)):c.type==="DynamicVariablePlay"?ja[e.type].includes("DynamicVariablePlay")&&n.DynamicVariablePlay.push(new ZR(c,i,r,l)):c.type==="Conditional"&&ja[e.type].includes("Conditional")&&(c.ifActions.forEach(o({expression:c.condition,negate:!1})),c.elseActions.forEach(o({expression:c.condition,negate:!0})))}catch{}};return t.forEach(o()),n}function Jr(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof AR||i instanceof $R||i instanceof ER||i instanceof YR||i instanceof qR||i instanceof eO||i instanceof MR||i instanceof XR||i instanceof QR||i instanceof CR||i instanceof KR||i instanceof ZR)&&i.dispose()})})}function sre(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(a=>a.uuid===t):i=e.material.layers.find(a=>a.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var JR=new Map,Qd=new Map,lu=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:a,volume:s,delay:n}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=sre(i,r);o&&(this.videoElement=o,this.videoElement.loop=a===1/0,Ob&&(this.videoElement.autoplay=!0),s!==void 0&&(this.videoElement.volume=s)),n!==void 0&&(this.delay=n),Qd.has(i.uuid)?Qd.get(i.uuid).push(this):Qd.set(i.uuid,[this]),JR.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Hx=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=JR.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=Qd.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...Qd.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},$R=class{constructor(e,t,i,r,a){if(this.data=t,this.shared=r,this.condition=a,t.interaction==="play")this.interaction=new lu(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Hx(t);else throw new Error("Missing property")}dispatchBasic(){if(ar(this.shared,this.condition)===!1)return!1;this.interaction instanceof lu?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(ar(this.shared,this.condition)===!1)return!1;this.interaction instanceof lu?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},zC=(()=>{let e,t,i,r;function a(o){!e&&!kC()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(e=requestAnimationFrame(s)),o&&(t=o,r=o.requestRender)}function s(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,u=h.length,d=0;for(;d<u;){let p=h[d];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&c[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),d++):(c[p.userData.actionId]>p.userData.quantity&&c[p.userData.actionId]--,h.splice(d,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(p.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody)):(p.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),u--,r())}e=d>0?requestAnimationFrame(s):void 0,i=d>0?o:void 0}function n(){kC()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):a()}return typeof document<"u"&&document.addEventListener("visibilitychange",n),a})();function kC(){return!!document&&document.hidden}var VC=new zt,nre=new O,ore=new O,eO=class{constructor(e,t,i,r,a){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=a,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=dt.generateUUID(),this.dispatch=()=>{if(ar(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{if(ar(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=Y7(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let n=new xa(this.object);if(n.playModeVisible=!0,n.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,h=this.page.scene.find(l);h&&(h.updateMatrixWorldSVD(),n.hiddenMatrix.copy(h.matrixWorldRigid))}n.position.fromArray(this.data.position),n.rotation.fromArray(this.data.rotation),n.updateMatrix(),this.page.add(n);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(n),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,n.updateWorldMatrix(!0,!0),n.traverseObject(this.traverseObjectCB),zC(),this.controlsManager.requestRender()},this.traverseObjectCB=n=>{n.hasNonUniformScale&&n.updateMatrixWorldSVD();let o;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(n instanceof Xs)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof xa)o=n.object;else if(o=n,o.dataPatched.cloner?.hideBase)return!0}else{if(n instanceof Xs)return;n instanceof xa?o=n.object:o=n}this.data.destroy==="Time"?n.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(n.userData.quantity=this.data.destroyAfterQuantity,n.userData.actionId=this.uniqueId);let l=new O().fromArray(this.data.velocity),h=o.dataPatched;if(!(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(n,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(n.rigidBody?.collider(0).setActiveEvents(1),n.userData.hasCollisionDestroy=!0),n.matrixWorld.decompose(nre,VC,ore),l.applyQuaternion(VC),this.data.velocity.some(c=>c!==0)&&this.data.dynamic&&n.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in n.object&&this.controlsManager.addBoundsTree(n),this.data.velocity.some(c=>c!==0)&&this.data.dynamic&&(n.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let s=this.page.scene.find(this.data.object);if(!s)throw new Error("Missing Property");if(this.object=s,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");zC(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},tO=200,Oy=.02,Ly=.3,lre=65,nne=new O,jC=new O,GC=new O,hre=new O,Pa=new O,Ga=new O,$o=new O,Iy=new je,HC=new je,cre=new je,one=new je,zs=new zt,io=new zt,fn=new Qi(0,0,0,"YXZ"),ure=new O(1,0,0),ks=new O(0,1,0),dre=new O(0,0,1),WC=new O(1,1,1),lne=new Sa,pre=1,fre=.025,mre=16e-6,qC=12,gre=20,Hr=new Es,gs=new sr,vre={type:"requestRender"},yre={type:"updateMatrix"},XC=Math.PI/6,Wx=class extends ua{constructor(e,t,i,r,a,s,n,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=a,this.cameraFollow=s,this.camera=n,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new je,this.target0=new O,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=tO,this.euler0=new Qi(0,0,0,"YXZ"),this.position0Cam=new O,this.quat0Cam=new zt,this.scale0Cam=new O,this.hiddenMatrix0Cam=new je,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new Es(new O(0,-40,0),new O(0,40,0)),matrix:new je,position:new O,rotation:new zt},this.euler=new Qi(0,0,0,"YXZ"),this.eulerDelta=new O,this.lastPosition=new O,this.lastCameraQuaternion=new zt,this.lastCameraPosition=new O,this.PI_2=Math.PI/2,this.prevMouse=new ae,this.velocityTarget=new O,this.velocity=new O,this.directionXZ=new O,this.rotVelocityStick=new O,this.rotVelocityTarget=new O,this.rotVelocity=new O,this.rotDirection=new O,this.nonColliderRotOffset=new je,this.nonColliderPosOffset=new je,this.firstPointerId=-1,this.rot=new O,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new je,this.objectToTarget=new O,this.objectToTarget0=new O,this.objectToCamXZ=new O,this.objectToCamXZ0=new O,this.targetToCamera=new O,this.targetToCamera0=new O,this.cameraPolarAxis0=new O,this.targetPos=new O,this.targetQuat=new zt,this.lerpFactorPos=new O().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new zt,this.objXZQuatInv=new zt,this.objXZRotMat=new je,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new O,this.pushedVelocity=new O,this.groundYRotation=0,this.objectRealQuat=new zt,this.colliderWorldQuat=new zt,this.groundNormal=new O,this.groundTilt=new zt,this.groundTiltInv=new zt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new O,this.quaternion=new zt,this.scale=new O,this.initialAction=!0,this.onPointerDown=f=>{f.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!rs&&(!TA||PA>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let m=f.clientX-this.prevMouse.x,g=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(TA&&PA<15.5&&!rs?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Wx.isLocked=!0:Wx.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let g=2;g<4;g++){let v=f.axes[g];m===0?g===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(v)>=.3&&(this.vrEulerYOffset+=v<0?1:-1),this.movementState.rotPosY=v):this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=a.sharedGameControlGlobals,e===n&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),c=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,c,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new O(0,0,-1).applyQuaternion(this.camera.quaternion),m=new O().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let g,v;Math.abs(f.y)<1e-6?(m.y=0,f.y=0,v=m.projectOnVector(f)):m.y/f.y>0?v=f.multiplyScalar(m.y/f.y):v=f.multiplyScalar(m.length()),this.targetToCamera0.copy(v).negate(),g=this.camera.position.clone().add(v),this.objectToTarget0.subVectors(g,this.position);let x=new Qi().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-x.x,x.x=0,x.z=0,x.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(x)}if(this.object instanceof _a&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*pre,this.speedOrbit=(i.speedRotate??100)*fre,this.mouseOrbitSensitivity=(i.speedRotate??100)*mre,this.keyAssignments=i.keyAssignments.map(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??vu.defaultData.gravity)*qC,this.usePhysics=this.gloabalPhysics.usePhysics??vu.defaultData.usePhysics,this.jumpPower=i.jumpPower*gre,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??Tg.defaultDataThirdPerson.orientWith,this.slopeThresh=lre*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*Oy/this.pixelsPerMeter,this.stepThresh=i.collider.height*Ly/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*Oy/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*Ly/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*Oy/this.pixelsPerMeter,this.stepThresh=i.collider.height*Ly/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let u=new O().fromArray(i.collider.position),d=new zt().setFromEuler(new Qi().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(u).multiply(this.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(u,d,WC),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new Tt;f.push({fi:0,data:{...qr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...qr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=new sw({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new xr(F3.create({parameters:{width:p,height:p/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new Qi().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof _a?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Cg.list.forEach(i=>{this.actions[i]=Na({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),Jr(this.actions.idle),Jr(this.actions.move),Jr(this.actions.run),Jr(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Pa.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let a=r*60,s=!1;if(this.usePhysics&&this.collisionEnabled){let o=Ga.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*qC),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(s=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(c.rigidBody===h&&c.userData.isFollowingObj!==this.object.uuid){(c.hasNonUniformScale?c.matrixWorldRigid:c.matrixWorld).decompose(Pa,io,Ga),this.groundVelocity.subVectors(Pa,c.prevT),this.object.getWorldPosition(Ga).add(this.collider.position).sub(Pa),this.groundYRotation=fn.setFromQuaternion(io).y-c.prevR.y,$o.copy(Ga).applyAxisAngle(ks,this.groundYRotation),this.groundVelocity.add($o.sub(Ga)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*a),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=Pa.subVectors(this.path[1],this.position),h=Ga.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**a),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**a),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**a)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let n=hre.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=Ga.copy(n);o.y=0,n.set(0,n.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let o=Pa;this.camera.getWorldDirection(o);let l=$o.copy(ks).multiplyScalar(o.dot(ks));o.sub(l);let h=Ga.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(fn.setFromVector3(this.rot),this.moveMode==="walk"&&(fn.x=0),n.applyEuler(fn),s&&(io.setFromUnitVectors(ks,this.groundNormal),n.applyQuaternion(io)),i){let o=fn.set(0,this.vrEulerYOffset*XC,0);i.applyEuler(o),n.x+=i.x,n.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let o=Ga;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=$o.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),c=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),Pa.copy(n).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let u=ui.is(l)?l:l.object;if(c!==null&&this.lastHitObj!==u){let d;l instanceof xa&&(d=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[u.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(d),u.dispatchEvent(Xx));this.lastHitObj=u}if(c!==null){this.pushedVelocity.copy(h),o.copy(c.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(n);l<0&&n.addScaledVector(o,-l),n.add(this.pushedVelocity)}else n.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**a):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**a),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(ks,this.euler.y-this.euler0.y);let o=Ga.copy(this.objectToCamXZ).normalize(),l=$o.copy(n).multiplyScalar(r);l.y=0;let h=l.sub(Pa.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=dt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=dt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=dt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(fn.copy(t),fn.y=0):(fn.copy(this.euler),fn.y=0),this.nonColliderRotOffset.makeRotationFromEuler(fn)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*XC),zs.setFromAxisAngle(ure,this.rot.x),io.setFromAxisAngle(ks,this.rot.y),io.multiply(zs),zs.setFromAxisAngle(dre,this.rot.z),io.multiply(zs),this.quaternion.copy(io),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=Ga.copy(n).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new O;for(let c=0;c<5;c++){let u=o.length(),d=$o.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,d,this.object.rigidBody?.collider(0).shape,u,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&c===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let x of v)if(x.data.target==="character"){let b=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,_;if(p.cloner){for(let M of p.cloner.children)if(M.rigidBody===b){_=M;break}}x.dispatch(_),p.dispatchEvent(Xx)}}}let f=jC.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),m=GC.copy(d).multiplyScalar(l.toi).dot(f),g=l.toi;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(g=l.toi*(m-this.offset)/m,h.addScaledVector(d,g)),o.copy(d).multiplyScalar(u-g),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),x=$o.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);x.y=0;let b=v.add(x);b.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(b,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);_!==null&&_.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{c===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(Pa.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(zs.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=n.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),this.collisionAdjustment(r/o)}else this.position.addScaledVector(n,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);Iy.lookAt(l,o,ks).setPosition(l),Iy.decompose(this.targetPos,this.targetQuat,Pa),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**a),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**a),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=dt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=dt.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(yre),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(vre),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=zs.setFromAxisAngle(ks,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?dt.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=dt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=dt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Pa.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=io.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){ks.angleTo(e)*180/Math.PI<15||ks.angleTo(e)*180/Math.PI>85?zs.identity():zs.setFromUnitVectors(ks,e),this.groundTilt.slerp(zs,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=GC.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=Iy.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Pa,zs,Ga).compose(Pa,zs,WC);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object))return;gs.makeEmpty(),a.updateMatrixWorldSVD();let s=a.matrixWorldRigid,n=HC.copy(s).invert(),o=cre.copy(HC).multiply(i);Hr.copy(this.collider.segment),Hr.start.applyMatrix4(o),Hr.end.applyMatrix4(o);let l=jC.copy(this.position).applyMatrix4(n);gs.expandByPoint(Hr.start),gs.expandByPoint(Hr.end),gs.min.addScalar(-this.collider.radius),gs.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(Hr.end)},intersectsBounds:h=>h.intersectsBox(gs),intersectsTriangle:h=>{let c=Pa,u=Ga,d=h.closestPointToSegment(Hr,c,u);if(d<this.collider.radius){let p=this.collider.radius-d,f=u.sub(c).normalize(),m=$o.copy(l);m.addScaledVector(f,p);let g=m.applyMatrix4(s).sub(this.position);t.add(g),Hr.start.addScaledVector(f,p),Hr.end.addScaledVector(f,p)}}})}),gs.makeEmpty(),Hr.copy(this.collider.segment),Hr.start.applyMatrix4(i),Hr.end.applyMatrix4(i),gs.expandByPoint(Hr.start),gs.expandByPoint(Hr.end),gs.min.addScalar(-this.collider.radius),gs.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(a){return a.distanceToPoint(Hr.end)},intersectsBounds:a=>a.intersectsBox(gs),intersectsTriangle:a=>{let s=Pa,n=Ga,o=a.closestPointToSegment(Hr,s,n);if(o<this.collider.radius){let l=this.collider.radius-o,h=n.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),Hr.start.addScaledVector(h,l),Hr.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}},iO=Wx;iO.isLocked=!1;var xre=Ro(cT());function mo(e,t){let i=new St;if(!e.getAttribute("position"))return i.setAttribute("position",new ut([],3)),i.setIndex([]),i;let{positions:r,triIndices:a}=pv(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new ut(r,3)),i.setIndex(a),t&&i.applyMatrix4(t),i}var bre=new je,wre=new je,mn=[[0,0,0],[0,0,0],[0,0,0]];function rO(e){let t=e.elements;mn[0][0]=t[0],mn[0][1]=t[4],mn[0][2]=t[8],mn[1][0]=t[1],mn[1][1]=t[5],mn[1][2]=t[9],mn[2][0]=t[2],mn[2][1]=t[6],mn[2][2]=t[10];let{u:i,v:r}=(0,xre.SVD)(mn),a=bre.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),s=wre.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1);return a.multiply(s.transpose())}var _re=class extends nP{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new Dl({color:65280,linewidth:10}),t=new O(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new O(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,a=new O().addVectors(t,i.multiplyScalar(r)),s=new St;return s.setFromPoints([t,a]),new Zm(s,e)}},aO=e=>e instanceof nu||e instanceof ou;function Sre(e,t){return e.distance-t.distance}function sO(e,t,i){if(!(!fo(t)||!t.visible)){Hs(t)&&t.raycast(e,i);for(let r of t.children)sO(e,r,i)}}function km(e,t,i,r=!1){if(!r&&!i.some(s=>Wg(e,s)!==void 0))return[];let a=[];return t.children.forEach(s=>sO(e,s,a)),a.sort(Sre),a}function qx(e){let t=[];if(e.length){let i=e[0].object;fo(i)&&t.push(i);let r=i.parent;for(;r;)aO(r)&&t.push(r),r=r.parent}return t}function go(e,t,i,r){let a=e.frame;if(a){let s=t[0]*a.width,n=(1-t[1])*a.height;for(let o of i){let l=o===a.uuid?a:a.find(o);if(l?.intersects(s,n))return r(l),!0}}return!1}function Wg(e,t){if(Hs(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(aO(t))return nO(e,t)}function nO(e,t){if(!(!fo(t)||!t.visible)){if(Hs(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=nO(e,i);if(r)return r}}}function Are(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}function Ere(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width,y:1-(t-(i.top+window.scrollY))/i.height}}var Mre=class{constructor(e,t,i,r,a,s,n,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=a,this.requestRender=s,this.isExport=n,this.frame=o,this.raycaster=new _re,this._useWindowEvents=!1,this.pointerWorld={x:0,y:0},this.pointerScreen={x:0,y:0},this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(e){this._domRect=e}get domRect(){return this._domRect}updateRaycaster(e){let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e;this.pointerWorld=Are(t,i,this._domRect),this.pointerScreen=Ere(t,i,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}},en=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},Ow=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],oO=e=>Ow.find(([t,i])=>i===e)?.[0],Op=e=>Ow.find(([t])=>t===e)?.[1],Cre=(e,t)=>{let i=oO(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},Tre=class extends en{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target||i.eventName==="Scroll")return;let r=this.splineEvents[oO(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:a}=this.eventContext;a.dispatchEvent(r)};let{page:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,a]of Ow)if(i.data.events.some(s=>s.data.type===a&&!s.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let s={id:i.uuid,name:i.name},n=Cre(a,s),o=this.splineEvents[r];o?o[i.uuid]=n:this.splineEvents[r]={[i.uuid]:n}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},Pre=class{constructor(e,t,i,r,a,s){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.alreadyPlayedNonTogglingActions=new Set,this.useToggle=t.runMode==="Toggle",(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Na(t,t.actions,r,a,s,i)}disconnect(){Jr(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()}),this.actions.SwitchCamera.forEach(t=>{t.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing)||this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.SwitchCamera.some(t=>t.playing)||this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},Dre=class extends en{constructor(e,t,i){super(e),this.useForRaycastProperty=i,this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.sceneInterects=null,this.onCanvasRaycast=n=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(n);let{raycaster:o,page:l}=this.eventContext,h=km(o,l,[],!0);this.sceneInterects=h,h.length&&(this.eventContext.sharedAssets.raycastProperty={x:h[0].point.x,y:h[0].point.y,z:h[0].point.z,objX:h[0].object.matrixWorld.elements[12],objY:h[0].object.matrixWorld.elements[13],objZ:h[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=n=>{(n.target===this.eventContext.domElement||n.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(o=>{(o.data.type==="MouseDown"||o.data.type==="MousePress")&&(this.onCanvasRaycast(n),o.dispatch())})},this.onCanvasMouseUp=n=>{(n.target===this.eventContext.domElement||n.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(o=>{o.data.type==="MouseUp"?(this.onCanvasRaycast(n),o.dispatch()):o.data.type==="MousePress"&&o.dispatchRelease()})},this.onMouseDown=n=>{Lt.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseDown"))},this.onMouseUp=n=>{Lt.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=n=>{Lt.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent())},this.onMousePressRelease=n=>{Lt.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent(!0))},this.onKeyDown=n=>{this.heldKeys[n.key]||(this.handleKeyEvent(n,"KeyDown"),this.handleKeyEventHeld(n,"KeyDown",!0)),this.heldKeys[n.key]=!0},this.onKeyUp=n=>{this.handleKeyEvent(n,"KeyUp"),this.handleKeyEventHeld(n,"KeyUp",!0)},this.onKeyPressDown=n=>{this.heldKeysPress[n.key]?this.handleKeyEventHeld(n,"KeyPress"):(this.handleKeyEvent(n,"KeyPress"),this.handleKeyEventHeld(n,"KeyPress",!0)),this.heldKeysPress[n.key]=!0},this.onKeyPressUp=n=>{this.handleKeyEvent(n,"KeyPress",!0)},this.releaseHeldKey=n=>{delete this.heldKeys[n.key]},this.releaseHeldKeyPress=n=>{delete this.heldKeysPress[n.key]},this._onUserEvent=({eventName:n,target:o,reverse:l})=>{if(!n||!o)return;let h=Op(n);h&&(h==="MouseDown"||h==="MouseUp"||h==="MousePress"?(o.dispatchEvent({type:"beginEvent",eventName:h}),this.eventsPerObjects[h]?.[o.uuid]?.forEach(c=>{c.dispatchUserEvent(l)})):(h==="KeyDown"||h==="KeyUp"||h==="KeyPress")&&(o.dispatchEvent({type:"beginEvent",eventName:h}),this.eventsPerObjects[h]?.[o.uuid]?.forEach(c=>{c.dispatchUserEvent()})))};let{page:r,sharedAssets:a}=this.eventContext,s=(n,o)=>{if(!n.data?.events.length)return;let l=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let h of l){let c=this.eventsPerObjects[h];n.data.events.filter(({data:u})=>u.type===h&&u.disabled!==!0).forEach(({id:u,data:d})=>{try{let p=new Pre(u,d,n,r,a,t);p.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(p):c[n.uuid]?c[n.uuid].some(f=>f.id===p.id)||c[n.uuid].push(p):c[n.uuid]=[p]}catch{}}),c[n.uuid]?.length&&this.objectsPerTypes[h].push(n instanceof $r&&(h==="MouseDown"||h==="MouseUp"||h==="MousePress")?o:n)}};r.traverseEntity(n=>{(n instanceof ya||n instanceof Xr)&&n.frame?.traverse(o=>{s(o,n)}),s(n)})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),e.addEventListener("pointerdown",this.onCanvasMouseDown),e.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r,pointerScreen:a}=this.eventContext,s=this.objectsPerTypes[e],n=s.filter(o=>!(o instanceof $r));if(!(!s.length&&!this.useForRaycastProperty)&&!(r.uiCanvas&&go(r,[a.x,a.y],Object.keys(this.eventsPerObjects[e]),o=>{this.handleObjectMouseEventDispatch(o,e)}))){if(t||this.useForRaycastProperty){let o;if(this.sceneInterects===null?o=km(i,r,n,this.useForRaycastProperty):(o=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&o.length&&(this.eventContext.sharedAssets.raycastProperty={x:o[0].point.x,y:o[0].point.y,z:o[0].point.z,objX:o[0].object.matrixWorld.elements[12],objY:o[0].object.matrixWorld.elements[13],objZ:o[0].object.matrixWorld.elements[14]}),t){let l=[o[0]?.uv?.x??0,o[0]?.uv?.y??0];qx(o).forEach(h=>{h instanceof ya&&go(h,l,Object.keys(this.eventsPerObjects[e]),c=>{this.handleObjectMouseEventDispatch(c,e)}),this.eventsPerObjects[e][h.uuid]&&this.handleObjectMouseEventDispatch(h,e)})}}t||n.forEach(o=>{let l=Wg(i,o);l&&(this.handleObjectMouseEventDispatch(o,e),o instanceof ya&&go(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),h=>{this.handleObjectMouseEventDispatch(h,e)}))})}}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=i.filter(s=>!(s instanceof $r)),a=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:n,page:o,pointerScreen:l}=this.eventContext,h=!1;if(o.uiCanvas&&(h=go(o,[l.x,l.y],Object.keys(this.eventsPerObjects[t]),c=>{a.push(c)})),s&&!h){let c=km(n,o,r);a=qx(c),c.forEach(u=>{u.object instanceof ya&&go(u.object,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),d=>{a.push(d)})})}else r.forEach(c=>{let u=Wg(n,c);u&&(a.push(c),c instanceof ya&&go(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),d=>{a.push(d)}))})}this._prevObjects.length&&this._prevObjects.forEach(s=>{a.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),a.length&&a.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=a}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let a=this.eventsPerObjects[t][r.uuid];a.some(({data:s})=>"key"in s&&s.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),a.forEach(s=>{"key"in s.data&&s.data.key===e.key&&(i?s.dispatchRelease():s.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(i)})})}},Rre=new O,Ore=new O,lO=class{constructor(e,t,i,r,a){this.actionsIn=Na(e,e.inActions,i,r,a,t),this.actionsOut=Na(e,e.outActions,i,r,a,t)}disconnect(){Jr(this.actionsIn),Jr(this.actionsOut)}},Lre=class extends lO{constructor(e,t,i,r,a,s){super(t,i,r,a,s),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrixWorld=()=>{for(let d of this.objects)if(!d.visible)return;let h=Rre.setFromMatrixPosition(this.objects[0].matrixWorld),c=Ore.setFromMatrixPosition(this.objects[1].matrixWorld),u=h.distanceTo(c)<=this.distance?"in":"out";if(this.stage!==u){this.stage=u;let d=u==="in"?this.actionsIn:this.actionsOut;d.Audio.forEach(p=>p.dispatchConditional()),d.Particles.forEach(p=>p.dispatchConditional()),d.Video.forEach(p=>p.dispatchConditional()),d.Link.forEach(p=>p.dispatch()),d.Create.forEach(p=>p.dispatch()),d.Destroy.forEach(p=>p.dispatch()),d.Reset.forEach(p=>p.dispatch()),d.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),d.Transition.forEach(p=>p.play()),d.Animation.forEach(p=>p.play()),d.SwitchCamera.forEach(p=>p.play()),d.SceneTransition.forEach(p=>p.dispatch()),d.SetVariable.forEach(p=>p.checkConditions()),d.SetVariable.forEach(p=>p.dispatch()),d.DynamicVariablePlay.forEach(p=>p.dispatch())}};let{distance:n,fromObject:o,toObject:l}=t.condition;this.distance=n;for(let h of[o,l]){if(!h)throw new Error("Missing property");let c=r.find(h);if(!c)throw new Error("Missing property");this.objects.push(c)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)})}},Ire=class extends lO{constructor(e,t,i,r,a,s){super(t,i,r,a,s),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(c=>c.dispatchConditional()),this.actionsOut.Particles.forEach(c=>c.dispatchConditional()),this.actionsOut.Video.forEach(c=>c.dispatchConditional()),this.actionsOut.Link.forEach(c=>c.dispatch()),this.actionsOut.Create.forEach(c=>c.dispatch()),this.actionsOut.Destroy.forEach(c=>c.dispatch()),this.actionsOut.Reset.forEach(c=>c.dispatch()),this.actionsIn.Transition.forEach(c=>c.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(c=>c.play()),this.actionsOut.Animation.forEach(c=>c.play()),this.actionsIn.SwitchCamera.forEach(c=>c.pause()),this.actionsOut.SwitchCamera.forEach(c=>c.play()),this.actionsOut.SceneTransition.forEach(c=>c.dispatch()),this.actionsOut.SetVariable.forEach(c=>c.checkConditions()),this.actionsOut.SetVariable.forEach(c=>c.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(c=>c.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(c=>c.dispatchConditional()),this.actionsIn.Particles.forEach(c=>c.dispatchConditional()),this.actionsIn.Video.forEach(c=>c.dispatchConditional()),this.actionsIn.Link.forEach(c=>c.dispatch()),this.actionsIn.Create.forEach(c=>c.dispatch()),this.actionsIn.Destroy.forEach(c=>c.dispatch()),this.actionsIn.Reset.forEach(c=>c.dispatch()),this.actionsOut.Transition.forEach(c=>c.pause()),this.actionsOut.Transition.forEach(c=>c.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(c=>c.play()),this.actionsIn.Animation.forEach(c=>c.play()),this.actionsOut.SwitchCamera.forEach(c=>c.pause()),this.actionsIn.SwitchCamera.forEach(c=>c.play()),this.actionsIn.SceneTransition.forEach(c=>c.dispatch()),this.actionsIn.SetVariable.forEach(c=>c.checkConditions()),this.actionsIn.SetVariable.forEach(c=>c.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(c=>c.dispatch()))};let{condition:n}=t;if(!n.object)throw new Error("Missing property");let o=r.find(n.object)??r.scene.find2D(n.object);if(!o)throw new Error("Missing property");if(this.toObject=o,n.state&&!this.toObject.states?.[n.state])throw new Error("Missing property");this.toState=n.state}connect(){oh(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),oh(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),oh(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),oh(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},Bre=class extends en{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(a=>{if(a.data?.events.length){for(let{id:s,data:n}of a.data.events)if(!n.disabled&&n.type==="Conditional")try{let o;n.condition.type==="Comparison"||(n.condition.type==="Distance"?o=new Lre(s,n,a,i,r,t):n.condition.type==="State"&&(o=new Ire(s,n,a,i,r,t))),o&&(this.eventsPerConditions[n.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Ed=new O,el=new O,Yl=new O,YC=new ts,Ure=.01,xi=new O,Br=new O,QC=new O,fh=new zt,By=new Qi,Fre=new je,Uy=new Ht,Mc=new O,gn=new O,Cc=.2;function Fy(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var Nre=function(){let e=new je;return(t,i,r)=>{let a=t.obj;e.copy(a.hiddenMatrix),a.parent!==null&&e.premultiply(a.parent.matrixWorld),e.invert(),a.position.copy(i),t.reference==="global"&&Fy(a.position,t.limits),a.position.applyMatrix4(e),t.reference==="parent"?Fy(a.position,t.limits):t.reference==="local"&&(fh.copy(t.quat0).invert(),a.position.sub(t.position0),a.position.applyQuaternion(fh),Fy(a.position,t.limits),fh.invert(),a.position.applyQuaternion(fh),a.position.add(t.position0)),e.multiply(r??a.matrixWorld).decompose(xi,a.quaternion,Br),a.updateMatrix(),a.hasNonUniformScale&&(a.updateMatrixWorld(),a.updateMatrixWorldSVD()),a instanceof Fa&&_o(a.parent)&&a.invalidateDownstreamBooleanData(!0)}}(),zre=class{constructor(e,t,i,r,a,s){this.object=e,this.data=t,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=Na(t,t.dragDropActions.drag,i,r,a,this.object),this.actionsDrop=Na(t,t.dragDropActions.drop,i,r,a,this.object);let n=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(n.push(l),s[l.uuid]&&s[l.uuid].forEach(h=>{let c=i.find(h);!c||c.data.visible!==!1&&n.push(c)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(this.dropDestIds.push(l.uuid),s[l.uuid]&&s[l.uuid].forEach(h=>{let c=i.find(h);!c||c.data.visible!==!1&&this.dropDestIds.push(c.uuid)}))}),this.dragItems=n.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new O().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new O().setFromMatrixPosition(o.matrixWorld),pointStart:new O,pointEnd:new O,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new O().copy(o.position),quat0:new zt().copy(o.quaternion),snapped:!1,orientationMatrix:new je,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Jr(this.actionsDrag),Jr(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},kre=class extends en{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(Lt.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:a,page:s}=this.eventContext,n=s.raycastWithClones(a);if(this.lastDropDestination=null,n.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:c,pointStart:u}of o.dragItems){if(h===n[0].object||h===n[0].object.object||ui.is(h)&&h.isAncestorOf(n[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(xi,fh,Br),By.setFromQuaternion(fh),d.prevR===void 0?(d.prevR=By.clone(),d.prevT=xi.clone()):(d.prevR.copy(By),d.prevT.copy(xi)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,u,o.data.plane,o.data.referenceFrame),c.copy(u),(this.eventManager.controlsManager.usePhysics&&h.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(Lt.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:a,page:s}=this.eventContext,n=s.raycastWithClones(a);if(Lt.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===n[0]?.object||h===n[0]?.object?.object||ui.is(h)&&h.isAncestorOf(n[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=n.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof nu)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(c=>c===h.object.uuid||s.scene.find(c).isAncestorOf(h.object.uuid))))[0]),l){let h=QC.copy(l.face.normal).applyMatrix3(Uy.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){xi.copy(h).applyMatrix3(Uy.setFromMatrix4(o.obj.matrixWorld).transpose());let c=o.obj;xi.x>Cc?Br.x=-c.recursiveBBox.min.x:xi.x<-Cc&&(Br.x=-c.recursiveBBox.max.x),xi.y>Cc?Br.y=-c.recursiveBBox.min.y:xi.y<-Cc&&(Br.y=-c.recursiveBBox.max.y),xi.z>Cc?Br.z=-c.recursiveBBox.min.z:xi.z<-Cc&&(Br.z=-c.recursiveBBox.max.z),Br.applyMatrix3(Uy.invert())}else Br.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(Br)}this.activeEvent.data.autoOrient&&(xi.set(0,1,0).cross(h),xi.length()<1e-4&&xi.set(-1,0,0).cross(h),Br.crossVectors(QC,xi),o.orientationMatrix.makeBasis(xi,Br,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Animation.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Audio.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(c=>{c.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.stop()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(h=>h.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let a=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!a)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&a&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(s=>{s.stop(),s.object.currentState!==null&&s.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(s=>{s.stop()}),this.activeEvent.actionsDrag.Audio.forEach(s=>{s.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(s=>{s.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(s=>s.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(s=>s.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(s=>s.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let i={};e.page.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.page.traverseEntity(r=>{r.data?.events.filter(a=>a.data.type==="DragDrop"&&!a.data.disabled).forEach(a=>{this.events.push(new zre(r,a.data,e.page,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:a,raycaster:s}=this.eventContext;a().getWorldDirection(el),el.negate();let n=fh.identity();switch(r==="parent"?Fre.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(xi,n,Br):r==="local"&&e.matrixWorld.decompose(xi,n,Br),i){case"x":xi.set(1,0,0).applyQuaternion(n),Mc.copy(el).cross(xi),gn.copy(xi).cross(Mc);break;case"y":xi.set(0,1,0).applyQuaternion(n),Mc.copy(el).cross(xi),gn.copy(xi).cross(Mc);break;case"z":xi.set(0,0,1).applyQuaternion(n),Mc.copy(el).cross(xi),gn.copy(xi).cross(Mc);break;case"xy":gn.set(0,0,1).applyQuaternion(n);break;case"yz":gn.set(1,0,0).applyQuaternion(n);break;case"xz":gn.set(0,1,0).applyQuaternion(n);break;case"adaptive":el.angleTo(Br.set(0,1,0))>Math.PI/6?(xi.crossVectors(Br.set(0,1,0),el),gn.crossVectors(xi,Br)):gn.set(0,1,0);break;default:gn.copy(el);break}Yl.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:Yl;if(YC.setFromNormalAndCoplanarPoint(gn,o),!!s.ray.intersectPlane(YC,t)&&(i==="x"||i==="y"||i==="z")){let l=Br.subVectors(t,o).dot(xi);t.copy(o).addScaledVector(xi,l)}}updateDragItem(e,t=!1){Yl.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Ed.subVectors(e.fromPosition,Yl).divideScalar(e.currentDampingFactor):e.reset==="original"?(Ed.subVectors(e.obj.userData.worldPosition0,Yl).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Ed.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Yl).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Ed.length()<Ure:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&Nre(e,Ed.add(Yl),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},Tc=new O,Ny=new O,ro=new O,ao=new O,KC=new ts,Vre=.01,jre={type:"requestRender"},Gre=function(){let e=new O,t=new O;return(i,r,a)=>a>0?(e.subVectors(i,r),e.length()<=a?i:t.copy(r).add(e.normalize().multiplyScalar(a))):r}(),ZC=function(){let e=new je;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Fa&&_o(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),Hre=class{constructor(e,t,i,r,a){this.data=e,this.object=t,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new O,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...M1.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Na(e,e.actions,i,r,a,t)}},Wre=class extends en{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(Lt.length>1)){this.eventContext.updateRaycaster(r);for(let a of this.events)a.target===void 0&&this.updateSingleEvent(a)}},this.onMouseEnter=r=>{for(let a of this.events)a.target===void 0&&(a.isReset=!1,a.currentDampingFactor=a.data.dampingFactor)},this.onMouseLeave=r=>{for(let a of this.events)a.target===void 0&&(a.data.resetOnPointerLeave&&(a.isReset=!0,a.currentDampingFactor=a.resetDampingFactor),this.updateSingleEvent(a))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{page:i}=this.eventContext;i.traverseEntity(r=>{let a=r.data?.events.find(s=>s.data.type==="Follow"&&!s.data.disabled);a&&(!i.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Hre(a.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),rs&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=i.target,a=this.onTargetChange(i);this.pairOfEventListeners.push([r,a]),r.addEventListener("requestRender",a)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),rs&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,Jr(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(n=>{n.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:a}=e.data;if(e.object.getWorldPosition(ro),e.isReset)ao.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(ao);else{let{getCamera:n,raycaster:o}=this.eventContext;if(i==="custom"?(n().getWorldDirection(Ny),Ny.negate(),Tc.copy(Ny)):i==="xy"?Tc.set(0,0,1):i==="xz"?Tc.set(0,1,0):i==="yz"&&Tc.set(1,0,0),KC.setFromNormalAndCoplanarPoint(Tc,ro),!o.ray.intersectPlane(KC,ao))return}if(!e.isReset){if(ao.distanceTo(e.worldPosition0)>r&&a&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)ao.copy(e.worldPosition0),e.currentDampingFactor=e.resetDampingFactor;else return;else if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return}e.data.enabledTranslation[0]===!1&&(ao.x=ro.x),e.data.enabledTranslation[1]===!1&&(ao.y=ro.y),e.data.enabledTranslation[2]===!1&&(ao.z=ro.z);let s=Gre(ro,ao,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let n=Tc.subVectors(s,ro).divideScalar(e.currentDampingFactor);ro.add(n),t&&ZC(e.object,ro),e.paused=n.length()<Vre}else ZC(e.object,s),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(jre)}},Md=new O,_m=new O,Cd=new je,Pc=new zt,tl=new zt,Td=new O,Pd=new O,Ql=new O,so=new O,zy=new ts,qre=1e-6,Xre={type:"requestRender"},Yre={type:"changeRotation"},JC=function(){let e=new je;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(rO(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof Fa&&_o(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),Qre=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new zt,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...C1.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},Kre=class extends en{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(Lt.length>1)){this._lastMouseEvent=i,this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:a})=>{if(!r||!a)return;let s=Op(r);s&&s==="LookAt"&&this.updateSingleEvent(i)};let{page:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(a=>a.data.type==="LookAt"&&!a.data.disabled);r&&(!t.data.globalPhysics.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new Qre(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),rs&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?t.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let s=this.onTargetChange(i),n=i.target;this.pairOfEventListeners.push([n,s]),n.addEventListener("requestRender",s)}let r=this.createUserEventListener(i),a=i.object;this.pairOfUserEventListeners.push([a,r]),a.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),rs&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:a,limitDistance:s,enabledRotation:n,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:c,target:u}=e;if(c.getWorldPosition(Td),!e.isReset)if(e.target)e.target.getWorldPosition(Pd);else{if(a==="custom"?(l().getWorldDirection(_m),_m.negate(),zy.setFromNormalAndCoplanarPoint(_m,Td)):(a==="xy"?Md.set(0,0,1):a==="xz"?Md.set(0,1,0):a==="yz"&&Md.set(1,0,0),zy.setFromNormalAndCoplanarPoint(Md,Td)),!h.ray.intersectPlane(zy,Pd))return;r>0&&(a==="custom"||a===void 0)&&Pd.addScaledVector(_m,r)}if(e.isReset||(u?t==="target"?Ql.copy(u.up).applyMatrix4(Cd.extractRotation(u.matrixWorld)).normalize():n.some(d=>d===!1)?(i==="x"?(so.set(0,0,1),n[2]===!1&&so.set(0,1,0)):i==="y"?(so.set(1,0,0),n[0]===!1&&so.set(0,0,1)):(so.set(0,1,0),n[1]===!1&&so.set(1,0,0)),Ql.copy(so).applyQuaternion(e.worldQuaternion0).normalize()):Ql.set(0,1,0):a==="custom"?Ql.set(0,1,0):Ql.copy(Md)),e.isReset)tl.copy(e.worldQuaternion0);else if(Td.distanceTo(Pd)>s&&o&&u)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)tl.copy(e.worldQuaternion0),e.currentDampingFactor=e.resetDampingFactor;else return;else{if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return;Zre(Cd,Pd,Td,Ql,i,so),tl.setFromRotationMatrix(Cd),Pc.setFromUnitVectors(so.applyQuaternion(tl),Ql),n.some(d=>d===!1)&&t!=="target"&&tl.premultiply(Pc).normalize()}e.currentDampingFactor>1?(c.updateWorldMatrix(!0,!1),Pc.setFromRotationMatrix(rO(c.matrixWorld)),Pc.slerp(tl,1/e.currentDampingFactor),JC(c,Cd.makeRotationFromQuaternion(Pc)),e.paused=8*(1-Pc.dot(tl))<qre):(JC(c,Cd.makeRotationFromQuaternion(tl)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),c.dispatchEvent(Xre),c.dispatchEvent(Yre)}},vs=new O,Ir=new O,vr=new O;function Zre(e,t,i,r,a,s){let n=e.elements;vr.subVectors(t,i),vr.lengthSq()===0&&(vr.z=1),vr.normalize(),Ir.crossVectors(r,vr),Ir.lengthSq()===0&&(Math.abs(r.z)===1?vr.x+=1e-4:vr.z+=1e-4,vr.normalize(),Ir.crossVectors(r,vr)),Ir.normalize(),vs.crossVectors(vr,Ir),a==="x"?s.z===1?[Ir,vs,vr]=[vr,Ir,vs]:(Ir.negate(),[Ir,vr]=[vr,Ir]):a==="y"?s.x===1?[Ir,vs,vr]=[vs,vr,Ir]:(Ir.negate(),[vs,vr]=[vr,vs]):s.x===1&&(Ir.negate(),[Ir,vs]=[vs,Ir]),n[0]=Ir.x,n[4]=vs.x,n[8]=vr.x,n[1]=Ir.y,n[5]=vs.y,n[9]=vr.y,n[2]=Ir.z,n[6]=vs.z,n[10]=vr.z}var Jre=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=Na(t,t.actions,r,a,s,i)}disconnect(){Jr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Particles.forEach(e=>e.dispatchBasic()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},$re=class extends en{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this.objects2D=[],this._prevObjects=[],this.onMouseDown=s=>{Lt.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onMouseUp=s=>{Lt.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=s=>{Lt.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:s,target:n,reverse:o})=>{if(!s||!n)return;let l=Op(s);l&&l==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(h=>h.dispatchUserEvent(o)))};let{page:i,sharedAssets:r}=this.eventContext,a=(s,n)=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:o,data:l}of s.data.events)if(!l.disabled&&l.type==="MouseHover")try{let h=new Jre(o,l,s,i,r,t);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(h):this.eventsPerObjects[s.uuid]=[h]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s instanceof $r?n:s)}};i.traverseEntity(s=>{(s instanceof ya||s instanceof Xr)&&s.frame?.traverse(n=>{a(n,s)}),a(s)})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),rs&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),rs&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:a,pointerScreen:s}=this.eventContext,n=!1;if(a.uiCanvas&&(n=go(a,[s.x,s.y],Object.keys(this.eventsPerObjects),o=>{t.push(o)})),i&&!n){let o=km(r,a,this.objects);t=qx(o),o.forEach(l=>{l.object instanceof ya&&go(l.object,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{t.push(h)})})}else this.objects.forEach(o=>{let l=Wg(r,o);l&&(t.push(o),o instanceof ya&&go(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{t.push(h)}))})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},eae=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=Na(t,t.actions,r,a,s,i)}connect(){this.scrollCounter=0}disconnect(){Jr(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch()),this.actions.DynamicVariablePlay.forEach(r=>r.dispatch())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},tae=class{constructor(e,t,i,r,a,s,n){this.id=e,this.data=t,this.object=i,this.domElement=s,this.eventManager=n,this.scrollStart=0,this.scrollEnd=0,this.actions=Na(t,t.actions,r,a,n,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,a=i.clientTop||t.clientTop||0,s=Math.round(e.top+r-a);if(this.data.startFrom==="enter"){let n=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?n:l==="bottom"?n-o:n-o*.5;this.scrollStart=s-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=e,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){Jr(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:e,y:t}){this.actions.Transition.forEach(a=>{a.object.currentTransitionEvent!==this&&(a.object.currentTransitionEvent=this,a.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(a=>a.seek(r)),this.actions.Animation.forEach(a=>a.seek(r)),this.actions.Create.forEach(a=>a.dispatchThrottled()),this.actions.SetVariable.forEach(a=>a.checkConditions()),this.actions.SetVariable.forEach(a=>a.dispatch()),this.actions.DynamicVariablePlay.forEach(a=>a.dispatch())}dispatch(e){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(e)}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},iae=class extends en{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([o,l])=>{l.forEach(h=>h.handleResize())})},this.onScroll=o=>{if(!this.isInview)return;let l={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([h,c])=>{h.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:l}),c.forEach(u=>u.dispatch(l))})},this.onWheel=o=>{!this.isInview||o.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:o.deltaY}),h.forEach(c=>c.dispatch(o.deltaY))})},this.onUserEvent=({eventName:o,target:l,reverse:h})=>{if(!o||!l)return;let c=Op(o);c&&c==="Scroll"&&(l.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(l)?.forEach(u=>{u.dispatchUserEvent(h)}))};let{page:i,sharedAssets:r,domElement:a,isExport:s}=this.eventContext,n=o=>{if(o.data?.events.length){for(let{id:l,data:h}of o.data.events)if(!h.disabled&&h.type==="Scroll")if(h.trigger==="load"||!s){let c=new eae(l,h,o,i,r,t);this.wheelEventsPerObject.has(o)?this.wheelEventsPerObject.get(o)?.push(c):this.wheelEventsPerObject.set(o,[c])}else{let c=new tae(l,h,o,i,r,a,t);this.scrollEventsPerObject.has(o)?this.scrollEventsPerObject.get(o)?.push(c):this.scrollEventsPerObject.set(o,[c])}}};i.traverseEntity(o=>{(o instanceof ya||o instanceof Xr)&&o.frame?.traverse(l=>{n(l)}),n(o)}),this.intersectionObserver=new IntersectionObserver(o=>{let l=o[0];l&&(this.isInview=l.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},rae=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.actions=Na(t,t.actions,r,a,s,i)}disconnect(){Jr(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof ph?t.interaction.audioPlayer.play():t.interaction instanceof kx&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof lu?t.interaction.play(i==="autoplay"):t.interaction instanceof Hx&&t.interaction.dispatch())}),this.actions.Particles.forEach(t=>{(t.data.triggerAfter??"any")===e&&t.dispatchBasic()})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof ph?t.interaction.audioPlayer.play():t.interaction instanceof kx&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof lu?t.interaction.play():t.interaction instanceof Hx&&t.interaction.dispatch()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()})}},aae=class extends en{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext,a=r?document:i;a.removeEventListener("pointerdown",this.onAny),a.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(o=>{o.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.actions.Audio.forEach(s=>{s.interaction instanceof ph&&s.interaction.audioPlayer.play()}),a.actions.Video.forEach(s=>{let n=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof lu&&s.interaction.play(n==="autoplay")}),a.actions.Particles.forEach(s=>{s.dispatchBasic()})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(a=>{a.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:i,target:r,reverse:a})=>{if(!i||!r)return;let s=Op(i);s&&s==="Start"&&(r instanceof $r||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(a)}),this.eventsAfterPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(a)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext,i=r=>{if(r.data?.events.length)for(let{id:a,data:s}of r.data.events){if(s.disabled||s.type!=="Start")continue;let n=new rae(a,s,r,t,e,this.eventManager);(n.actions.Transition.length||n.actions.Animation.length||n.actions.SwitchCamera.length||n.actions.Create.length||n.actions.Destroy.length||n.actions.SceneTransition.length||n.actions.Reset.length||n.actions.SetVariable.length||n.actions.DynamicVariablePlay.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(n):this.eventsPerObject.set(r,[n])),n.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Particles.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n]))}};if(t.traverseEntity(r=>{(r instanceof ya||r instanceof Xr)&&r.frame?.traverse(a=>{i(a)}),i(r)}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:a}=this.eventContext,s=a?document:r;s.addEventListener("pointerdown",this.onMouseDown,{once:!0}),s.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),s.addEventListener("pointerdown",this.onAny),s.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,o])=>{n.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([r,a])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(s=>s.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,a])=>{r.removeEventListener("userEvent",this.onUserEvent),a.forEach(s=>s.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},sae=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.disabled=!1,this.alreadyPlayedNonTogglingActions=new Set,this.actions=Na(t,t.actions,r,a,s,i),this.target=t.target,this.useToggle=t.runMode==="Toggle"}disconnect(){Jr(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()})):(this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}))}},nae=class extends en{constructor(e,t,i,r,a){super(e),this.sharedVariables=t,this.eventManager=i,this.needsMouse=r,this.needsRaycast=a,this.dynamicVars=[],this.variablesToWatch=[],this.prevMouseProperty=null,this.prevRaycastProperty=null,this.pauseTime=0,this.events=[],this.onFrame=s=>{this.rafId=window.requestAnimationFrame(this.onFrame);let n=new Date,o=[],l=[];for(let u=0;u<this.propertiesToWatch.length;u++){let{objectId:d,property:p,prevValue:f}=this.propertiesToWatch[u],m=this.eventContext.scene.find(d),g=P1.propertyPaths[p];if(g[0]==="width"||g[0]==="height"||g[0]==="depth")m=m.geometry.userData.parameters[g[0]];else for(let v=0;v<g.length;v++)m=m[g[v]];f===null?this.propertiesToWatch[u].prevValue=m instanceof O?m.clone():m:(m instanceof O?!m.equals(f):f!==m)&&(l.push({objId:d,property:p}),m instanceof O?this.propertiesToWatch[u].prevValue.copy(m):this.propertiesToWatch[u].prevValue=m)}for(let u=0;u<this.variablesToWatch.length;u++){let{id:d,prevValue:p}=this.variablesToWatch[u],f=this.shared.getVariable(d);f!==p&&(o.push(d),this.variablesToWatch[u].prevValue=f)}for(let u=0;u<this.dynamicVars.length;u++){let{id:d,expectedTime:p,last:f,data:m,timerSeconds:g,startValue:v}=this.dynamicVars[u],x=1e3;if((m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&m.format==="number3decimal"?x=1:m.dynamicVariableType==="counter"?x=m.updateInterval:m.dynamicVariableType==="random"&&(x=m.isStatic?1/0:m.updateInterval),p===-1){this.dynamicVars[u].last=s,this.dynamicVars[u].expectedTime=s+x;continue}if(!((this.shared.getDynamicVariablePlayState(d)==="Stopped"||this.shared.getDynamicVariablePlayState(d)==="Restarted")&&(this.dynamicVars[u].last=s,this.dynamicVars[u].expectedTime=s+x,m.dynamicVariableType==="counter"&&this.shared.getVariable(d)!==v&&(this.shared.updateVariable(d,v),this.eventManager.requestRender()),(m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&this.dynamicVars[u].timerSeconds!==v&&(this.dynamicVars[u].timerSeconds=v,this.shared.updateVariable(d,ws.getFormattedTimerTime(v,m)),this.eventManager.requestRender()),this.shared.getDynamicVariablePlayState(d)==="Restarted"&&this.shared.setDynamicVariablePlayState(d,"Playing"),this.shared.getDynamicVariablePlayState(d)==="Stopped"))){if(this.shared.getDynamicVariablePlayState(d)==="Paused"){this.dynamicVars[u].deltaToExpectedTime===void 0&&(this.dynamicVars[u].deltaToExpectedTime=Math.max(this.dynamicVars[u].expectedTime-s,0)),this.dynamicVars[u].last=s-(x-this.dynamicVars[u].deltaToExpectedTime),this.dynamicVars[u].expectedTime=s+this.dynamicVars[u].deltaToExpectedTime;continue}else this.dynamicVars[u].deltaToExpectedTime=void 0;if(s>=p)if(this.dynamicVars[u].last=s,this.dynamicVars[u].expectedTime+=x,m.dynamicVariableType==="random"){let b=m.min+Math.random()*(m.max-m.min),_=m.decimals;b=Math.round(b*Math.pow(10,_))/Math.pow(10,_),this.shared.updateVariable(d,b),o.push(d),this.eventManager.requestRender()}else if(m.dynamicVariableType==="counter"){if(m.increment===0)continue;let b=this.shared.getVariable(d),_=this.shared.getDynamicVariableToggleIsForward(d)??!0,M=this.shared.getVariable(d)+m.increment*(_?1:-1);m.hasEnd&&(M=m.increment>0?dt.clamp(M,v,m.endValue):dt.clamp(M,m.endValue,v),M===v&&this.shared.setDynamicVariableToggleIsForward(d,void 0),m.repeat?M===m.endValue&&(M=v):(M===v||M===m.endValue)&&this.shared.setDynamicVariablePlayState(d,"Paused")),M!==b&&(o.push(d),this.shared.updateVariable(d,M),this.eventManager.requestRender())}else if(m.dynamicVariableType==="time")this.shared.updateVariable(d,gM(n,m)),o.push(d),this.eventManager.requestRender();else{let b=as.isTextValue(m.endValue)?$C(m.endValue.textValue):m.endValue,_=this.shared.getDynamicVariableToggleIsForward(d)??!0,M=g+(s-f)/1e3*(m.dynamicVariableType==="timer"?-1:1)*(_?1:-1);M=Math.max(M,0),m.hasEnd&&(M=m.dynamicVariableType==="stopwatch"?dt.clamp(M,v,b):dt.clamp(M,b,v),M===v&&this.shared.setDynamicVariableToggleIsForward(d,void 0),m.repeat?Math.abs(M-b)<(m.format==="number3decimal"?1e-4:.1)&&(M=v):(Math.abs(M-v)<(m.format==="number3decimal"?1e-4:.1)||Math.abs(M-b)<(m.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(d,"Paused")),M!==g&&(o.push(d),this.dynamicVars[u].timerSeconds=M,this.shared.updateVariable(d,ws.getFormattedTimerTime(M,m)),this.eventManager.requestRender())}}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(u=>{u.data.variableId==="mouseProperty"&&(u.dispatch(),this.eventManager.requestRender())}));let h=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,h=!0);let c=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,c=!0),this.events.forEach(u=>{(o.includes(u.data.variableId)||l.find(d=>d.objId===u.data.objectId&&d.property===u.data.property)||u.data.variableId==="mouseProperty"&&h||u.data.variableId==="raycastProperty"&&c)&&(u.dispatch(),this.eventManager.requestRender())})},this.onBlur=()=>{this.pause()},this.onFocus=()=>{this.resume()},e.page.traverseEntity(s=>{s.data?.events.filter(n=>n.data.type==="VariableChange"&&!n.data.disabled).forEach(n=>{this.events.push(new oae(s.uuid,n.data,s,e.page,e.sharedAssets,i))})}),this.propertiesToWatch=this.events.filter(s=>s.data.variableId==="objectProperty"&&s.data.objectId!==null).map(s=>({objectId:s.data.objectId,property:s.data.property,prevValue:null})),this.shared=e.sharedAssets,this.sharedVariables.forEach(({id:s,data:n})=>{if(!("dynamicVariableType"in n)){this.events.find(l=>l.data.variableId===s)&&this.variablesToWatch.push({id:s,prevValue:this.shared.getVariable(s)});return}let o;if(n.dynamicVariableType==="timer"||n.dynamicVariableType==="stopwatch"){let l;if(as.isTextValue(n.value)&&Array.isArray(n.value.textValue)){let h=n.value.textValue;h.length===3?l=h[2]+h[1]*60+h[0]*3600:l=h[1]+h[0]*60}else l=n.value;o=l,this.dynamicVars.push({id:s,last:-1,expectedTime:-1,data:n,timerSeconds:l,startValue:o})}else n.dynamicVariableType==="time"&&this.shared.updateVariable(s,gM(new Date,n)),n.dynamicVariableType==="counter"&&(o=as.isTextValue(n.value)?$C(n.value.textValue):n.value),this.dynamicVars.push({id:s,last:-1,expectedTime:-1,data:n,startValue:o})})}pause(){this.pauseTime=Date.now()}resume(){let e=Date.now()-this.pauseTime;for(let t=0;t<this.dynamicVars.length;t++)this.dynamicVars[t].last+=e,this.dynamicVars[t].expectedTime+=e}connect(){this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(e=>e.dispose())}},oae=class{constructor(e,t,i,r,a,s){this.id=e,this.data=t,this.object=i,this.actions=Na(t,t.actions,r,a,s,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch())}dispose(){Jr(this.actions)}};function $C(e){return e.length===3?e[2]+e[1]*60+e[0]*3600:e[1]+e[0]*60}var lae="https://unpkg.com/@splinetool/runtime@1.0.85/build/",hae="https://unpkg.com/@splinetool/navmesh-wasm@1.0.85/build/",cae=`
8026
8039
  (async function() {
8027
8040
  const [wasmImport, wasmBinary] = await Promise.all([
8028
8041
  import('${lae}' + 'navmesh.js'),
@@ -8088,7 +8101,7 @@ onmessage = function(messageEvent) {
8088
8101
  <path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
8089
8102
  </svg>
8090
8103
  `),P.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),P.addEventListener("touchend",E=>E.preventDefault()),this.joysticks[p]=[void 0,f];return}let A={zone:f,mode:"static",position:b,size:m};v==="hide"&&(A.restOpacity=0);let S=Vte.create(A);S.on("move",(P,L)=>{let E=this.gameControl;d==="pos"?L.force<.2?E.moveForce=0:(E.movementState.movePosZ=Math.sin(-L.angle.radian),E.movementState.movePosX=Math.cos(-L.angle.radian),L.force>1.2?E.movementState.run=1:E.movementState.run=0,L.force<.3?E.moveForce=(L.force-.2)/.1:E.moveForce=1):d==="rot"&&(L.force<.2?E.rotForce=0:(E.movementState.rotPosX=L.vector.y,E.movementState.rotPosY=-L.vector.x,L.force<.3?E.rotForce=(L.force-.2)/.1:E.rotForce=1)),this.requestRender()}),S.on("end",(P,L)=>{let E=this.gameControl;d==="pos"?(E.movementState.movePosZ=0,E.movementState.movePosX=0,E.moveForce=1):d==="rot"&&(E.movementState.rotPosX=0,E.movementState.rotPosY=0,E.rotForce=1)}),this.joysticks[p]=[S,f]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(d=>d.disabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new pi.World(new pi.Vector3(0,this.gravity,0)),this.events=new pi.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(n=>{let o;if(n instanceof Xs)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof xa)o=n.object;else{if(n instanceof Bm||n instanceof Lm)return;if(o=n,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0}let l=o.dataPatched,h;for(let g of l.events)g.data.disabled!==!0&&g.data.type==="GameControl"&&(h=g.data);if(!l.physics||(l.physics.enabled==="visibility"?!l.visible:!l.physics.enabled))return!0;n.updateMatrixWorldSVD();let c=qg(l),u=!1,d=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let g of l.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){u=!0;let v=new sae(g.id,g.data,o,this.page,this.sharedAssets,this.eventManager);v.disabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(x=>x.id!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[v]}else if(g.data.type==="Follow"){f=!0;let v=g.data.target;n.traverseVisible(x=>{x.userData.isFollowingObj=v})}}l.physics.rigidBody==="dynamic"&&l.physics.fusedBody===!1&&(n.matrixWorldFusedFalse=n.matrixWorld.clone());let m=n.geometry;if(h!==void 0){let g=pi.RigidBodyDesc.kinematicPositionBased();(n.hasNonUniformScale?n.matrixWorldRigid:n.matrixWorld).decompose(Er,Vs,il),n.position0=Er.clone().divideScalar(this.pixelsPerMeter),n.rotation0=Vs.clone(),Er.divideScalar(this.pixelsPerMeter),g.setTranslation(Er.x,Er.y,Er.z).setRotation(Vs);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);n.rigidBody=v;let x;h.collider.type==="sphere"?x=pi.ColliderDesc.ball(h.collider.radius/this.pixelsPerMeter):h.collider.type==="capsule"?x=pi.ColliderDesc.capsule((h.collider.height/2-h.collider.radius)/this.pixelsPerMeter,h.collider.radius/this.pixelsPerMeter):x=pi.ColliderDesc.cuboid(h.collider.width/this.pixelsPerMeter/2,h.collider.height/this.pixelsPerMeter/2,h.collider.depth/this.pixelsPerMeter/2),x.setFrictionCombineRule(pi.CoefficientCombineRule.Average).setRestitutionCombineRule(pi.CoefficientCombineRule.Average).setDensity(l.physics.density).setFriction(l.physics.friction).setRestitution(l.physics.restitution);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(x,v);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,o),Er.fromArray(h.collider.position).multiply(il.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(Er);let _=new zt().setFromEuler(new Qi().setFromVector3(new O().fromArray(h.collider.rotation)));b.setRotationWrtParent(_),b.setActiveEvents(pi.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else l.physics.rigidBody==="dynamic"||c||f||d||p||u?(this.addRigidBody(n,o,{hasFollow:f,hasTransformAnim:c,hasDrag:p}),this.generateSensorColliderDescs(o,l.physics.fusedBody)):(m&&e.push(mo(m,n.matrixWorld)),l.physics.fusedBody&&n.traverseObject((g,v)=>{if(v===0)return;let x;if(g instanceof Xs)if(g.objectForSample){if(g.objectForSample.dataPatched.physics.fusedBody)return;x=g.object}else return g.object.dataPatched.physics.fusedBody===!0&&g.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else{if(g instanceof Bm||g instanceof Lm)return;if(g instanceof xa)x=g.object;else if(x=g,x.dataPatched.cloner?.hideBase)return!0}let b=x.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let _=g.geometry;_?.getAttribute("position")!==void 0&&e.push(mo(_,g.matrixWorld))}),this.generateSensorColliderDescs(o,l.physics.fusedBody,t));if(l.physics?.fusedBody===!0||h)return!0}),e.length===0)return;let i=dh(e);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=pi.RigidBodyDesc.fixed(),a=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),s=pi.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(pi.CoefficientCombineRule.Multiply).setRestitutionCombineRule(pi.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(s,a);for(let[n,o]of t){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(n,a);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(e=>{for(let t of e.dataPatched.events)if(t.data.type==="Trigger"&&t.data.disabled!==!0){let i=new sT(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=new je().compose(js.fromArray(t.data.position),Oc.setFromEuler(nT.fromArray(t.data.rotation)),Wy);if(t.data.triggerZone==="box"){let a=new sr;a.min.fromArray(t.data.size).multiplyScalar(-.5),a.max.fromArray(t.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([a,r,e,i])}else this.sharedGameControlGlobals.triggers.push([t.data.radius,r,e,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(e=>e.disconnect()),this.sharedGameControlGlobals.triggers.forEach(e=>e[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(e=>{let t=e;t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0),t.position0&&(t.position0=void 0),t.rotation0&&(t.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let e of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(e,t,i){if(!this.isEnabled)return!0;let r=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(r=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,r=!1):this.initializationCounter===2&&this.gameControl&&(r=!this.gameControl.update(e,t,i)&&r),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let a=.016666666666666666;if(e===0)r=this.stepPhysics()&&r;else{let s=e/1e3;s<a&&s>a*.55&&(s=a),this.accumulator+=s;let n=performance.now(),o=0,l=6;for(;this.accumulator>=a&&o<l&&(r=this.stepPhysics()&&r,this.accumulator-=a,o++,!(performance.now()-n>a*1e3)););this.accumulator=this.accumulator%a}}return r}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(Er,Vs,il),Gy.setFromQuaternion(Vs);let t=e;t.prevR===void 0?(t.prevR=Gy.clone(),t.prevT=Er.clone()):(t.prevR.copy(Gy),t.prevT.copy(Er)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation(Er.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(Vs))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(e,t,i){let r=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent,a;if(t.cloner){for(let s of t.cloner.children)if(s.rigidBody===r){a=s;break}}e.dispatch(a),t.dispatchEvent(Xx)}updateUseWindowEvents(e){this.orbitControls?.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=oT.copy(e.matrixWorld).invert();e.traverseEntity((a,s)=>{if(t===!1&&s===1)return!0;for(let n of a.dataPatched.events)if(n.data.type==="Trigger"&&n.data.disabled!==!0){let o=new sT(n.id,n.data,a,this.page,this.sharedAssets,this.eventManager),l;if(n.data.triggerZone==="box"?l=pi.ColliderDesc.cuboid(...n.data.size.map(h=>h/(2*this.pixelsPerMeter))):l=pi.ColliderDesc.ball(n.data.radius/this.pixelsPerMeter),l.setDensity(0).setSensor(!0).setActiveEvents(pi.ActiveEvents.COLLISION_EVENTS),js.fromArray(n.data.position),Oc.setFromEuler(nT.fromArray(n.data.rotation)),Em.compose(js,Oc,Wy).premultiply(a.matrixWorld),i?(Em.decompose(js,Oc,Hy),l.setActiveCollisionTypes(pi.ActiveCollisionTypes.KINEMATIC_FIXED|pi.ActiveCollisionTypes.DYNAMIC_FIXED)):(Em.premultiply(r).decompose(js,Oc,Hy),e.rigidBody.bodyType()===pi.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===pi.RigidBodyType.Fixed?l.setActiveCollisionTypes(pi.ActiveCollisionTypes.KINEMATIC_FIXED|pi.ActiveCollisionTypes.DYNAMIC_FIXED):l.setActiveCollisionTypes(pi.ActiveCollisionTypes.KINEMATIC_KINEMATIC|pi.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),js.divideScalar(this.pixelsPerMeter),l.setTranslation(js.x,js.y,js.z),l.setRotation(Oc),i)i.push([l,o]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(l,e.rigidBody);this.sensorToTriggerEvent[h.handle]=o}}})}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,a,s]=this.sharedGameControlGlobals.triggers[t];for(let n=0;n<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;n++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[n];if(a===o||s.isValidTriggeringObject(ui.is(o)?o:o.object)===!1)continue;let l=oT.copy(a.matrixWorld).decompose(js,lT,Hy).compose(js,lT,Wy).multiply(r),h=Em.copy(o.matrixWorld).invert().multiply(l);i instanceof sr?e=o.bvhGeometry.boundsTree.intersectsBox(i,h):(qy.radius=i,qy.center.setFromMatrixPosition(h),e=o.bvhGeometry.boundsTree.intersectsSphere(qy)),e?s.currentIntersectedObjects.indexOf(o)===-1&&(s.currentIntersectedObjects.push(o),s.dispatch(),a.dispatchEvent(Mae)):s.currentIntersectedObjects=s.currentIntersectedObjects.filter(c=>c!==o)}}}};function Pae(e){let t=this._clip.duration,i=this._clip.start??0,r=this.loop,a=this.time+e,s=this._loopCount,n=r===Zx;if(e===0)return s===-1?a:n&&(s&1)===1?t-(a-i):a;if(r===wT){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(a>=t)a=t;else if(a<0)a=0;else{this.time=a;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=a,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,n)):this._setEndings(this.repetitions===0,!0,n)),a>=t||a<i){let o=Math.floor((a-i)/(t-i));a-=(t-i)*o,s+=Math.abs(o);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n||(a=e>0?t:i,this.repetitions===1&&(a=t)),this.time=a,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let h=e<0;this._setEndings(h,!h,n)}else this._setEndings(!1,!1,n);this._loopCount=s,this.time=a,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=a;if(n&&(s&1)===1)return t-(a-i)}return a}var hT=!1,Dae=class{constructor(e,t,i,r){this.scene=e,this.requestRender=t,this.updateDisplayProgress=i,this.animationInspectorState=r,this.clipIdToAction={},this.activeClip=null,this.needsUpdate=!1,this.addClip=a=>{a.data.type==="Empty"&&a.data.animations&&a.data.animations.forEach((s,n)=>{let o=s[0]+"/";if(Array.isArray(a.identity)?o+=a.identity[0]:o+=a.uuid,this.clipIdToAction[o])return;let l=n1.parse(JSON.parse(s[2]));a.animations[n]=l;let h=this.mixer.clipAction(l,a);hT===!1&&(Object.getPrototypeOf(h)._updateTime=Pae,hT=!0),h.clampWhenFinished=!0,this.clipIdToAction[o]=h})},this.mixer=new R6(e),this.scene.traverseEntity(this.addClip)}deleteClip(e,t){let i=this.scene.find(t);if(!i)return;let r=i.animations.find(s=>s.uuid===e);if(!r)return;let a=this.clipIdToAction[e];!a||(a.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[e],i.animations=i.animations.filter(s=>s.uuid!==e))}get isPlaying(){return Object.values(this.clipIdToAction).some(e=>e.isRunning())}playFromInspector(e){this.mixer.stopAllAction();let t=this.clipIdToAction[e];!t||(t.play(),this.activeClip=t.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(e=>{e.repetitions=1/0,e.loop=_T}),this.mixer.stopAllAction(),this.requestRender()}play(e){let t=e.clipId+"/"+e.object,i=this.clipIdToAction[t];if(i)return e&&(e.repeat>=0&&(i.repetitions=e.repeat+1),e.direction==="pingpong"&&e.repeat!==0&&(i.loop=Zx)),i.play(),i.paused=!1,this.requestRender(),i}resumeFromInspector(e){let t=this.clipIdToAction[e];!t||(t.play(),t.paused=!1,this.requestRender())}pauseFromInspector(e){let t=this.clipIdToAction[e];!t||(t.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(e){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(e/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*this.maxFrames%this.maxFrames)),this.requestRender()}get maxFrames(){return this.activeClip?.tracks[0]?.times.length??0}setProgressFromInspector(e,t){if(!this.clipIdToAction[t])return;this.activeClip!==this.clipIdToAction[t].getClip()&&this.playFromInspector(t);let i=this.clipIdToAction[t].paused;this.clipIdToAction[t].paused=!1,this.mixer.setTime(Math.min(this.maxFrames?e/this.maxFrames:0,.9999)*this.activeClip.duration),this.requestRender(),i&&(this.clipIdToAction[t].paused=!0)}},Xy=new WeakMap,Rae=class extends Pu{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){let a=new o1(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,s=>{this.parse(s,t,r)},i,r)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,wi).catch(i)}decodeDracoFile(e,t,i,r,a=Cs,s=()=>{}){let n={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:a};return this.decodeGeometry(e,n).then(t).catch(s)}decodeGeometry(e,t){let i=JSON.stringify(t);if(Xy.has(e)){let o=Xy.get(e);if(o.key===i)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,a=this.workerNextTaskID++,s=e.byteLength,n=this._getWorker(a,s).then(o=>(r=o,new Promise((l,h)=>{r._callbacks[a]={resolve:l,reject:h},r.postMessage({type:"decode",id:a,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return n.catch(()=>!0).then(()=>{r&&a&&this._releaseTask(r,a)}),Xy.set(e,{key:i,promise:n}),n}_createGeometry(e){let t=new St;e.index&&t.setIndex(new Ut(e.index.array,1));for(let i=0;i<e.attributes.length;i++){let r=e.attributes[i],a=r.name,s=r.array,n=r.itemSize,o=new Ut(s,n);a==="color"&&(this._assignVertexColorSpace(o,r.vertexColorSpace),o.normalized=!(s instanceof Float32Array)),t.setAttribute(a,o)}return t}_assignVertexColorSpace(e,t){if(t!==wi)return;let i=new _t;for(let r=0,a=e.count;r<a;r++)i.fromBufferAttribute(e,r).convertSRGBToLinear(),e.setXYZ(r,i.r,i.g,i.b)}_loadLibrary(e,t){let i=new o1(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,a)=>{i.load(e,r,void 0,a)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{let r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);let a=Oae.toString(),s=["/* draco decoder */",r,"","/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
8091
- `);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(a){let s=a.data;switch(s.type){case"decode":r._callbacks[s.id].resolve(s);break;case"error":r._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,a){return r._taskLoad>a._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function Oae(){let e,t;onmessage=function(n){let o=n.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(c){e.onModuleLoaded=function(u){c({draco:u})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(c=>{let u=c.draco,d=new u.Decoder;try{let p=i(u,d,new Int8Array(l),h),f=p.attributes.map(m=>m.array.buffer);p.index&&f.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},f)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{u.destroy(d)}});break}};function i(n,o,l,h){let c=h.attributeIDs,u=h.attributeTypes,d,p,f=o.GetEncodedGeometryType(l);if(f===n.TRIANGULAR_MESH)d=new n.Mesh,p=o.DecodeArrayToMesh(l,l.byteLength,d);else if(f===n.POINT_CLOUD)d=new n.PointCloud,p=o.DecodeArrayToPointCloud(l,l.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let m={index:null,attributes:[]};for(let g in c){let v=self[u[g]],x,b;if(h.useUniqueIDs)b=c[g],x=o.GetAttributeByUniqueId(d,b);else{if(b=o.GetAttributeId(d,n[c[g]]),b===-1)continue;x=o.GetAttribute(d,b)}let _=a(n,o,d,g,v,x);g==="color"&&(_.vertexColorSpace=h.vertexColorSpace),m.attributes.push(_)}return f===n.TRIANGULAR_MESH&&(m.index=r(n,o,d)),n.destroy(d),m}function r(n,o,l){let h=l.num_faces()*3,c=h*4,u=n._malloc(c);o.GetTrianglesUInt32Array(l,c,u);let d=new Uint32Array(n.HEAPF32.buffer,u,h).slice();return n._free(u),{array:d,itemSize:1}}function a(n,o,l,h,c,u){let d=u.num_components(),p=l.num_points()*d,f=p*c.BYTES_PER_ELEMENT,m=s(n,c),g=n._malloc(f);o.GetAttributeDataArrayForAllPoints(l,u,m,f,g);let v=new c(n.HEAPF32.buffer,g,p).slice();return n._free(g),{name:h,array:v,itemSize:d}}function s(n,o){switch(o){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}var xl;function Lae(){return xl||(xl=new Rae,xl.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),xl.decoderPending}async function Iae(e){if(xl){let t={attributeIDs:xl.defaultAttributeIDs,attributeTypes:xl.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await xl.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,a])=>({name:r,itemSize:a.itemSize,array:a.array}))}}return null}async function Bae(e,t){let[i,r]=s3(A1.deserialize(new Uint8Array(e)));return R3(i),t&&t(i),r.result().data}function Uae(e){let t=[];return e.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function Fae(e){for(let t of e){let i=await Iae(t.geometry.data.draco);if(i){let r=t.geometry.data;i.index&&(r.index={array:i.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};i.attributes.forEach(({name:s,array:n,itemSize:o})=>{a[s]={array:n,itemSize:o,type:"Float32Array",normalized:!1}}),r.attributes=a,r.draco=void 0}}}var Nae=class{constructor(e,t,i,r,a,s,n){this.id=e,this.data=t,this.dataEvent=i,this.object=r,this.stage=!1,this.actions=Na(i,t.actions,a,s,n,r)}disconnect(){Jr(this.actions)}dispatchIn(){this.actions.Audio.forEach(e=>e.dispatchBasic()),this.actions.Particles.forEach(e=>e.dispatchBasic()),this.actions.Video.forEach(e=>e.dispatchBasic()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.Link.forEach(e=>e.dispatch()),this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.actions.Transition.forEach(e=>e.toggle()),this.actions.Animation.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>e.play()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}dispatchOut(){this.actions.Transition.forEach(e=>{e.toggle()})}},zae=class extends en{constructor(e,t){super(e),this.eventManager=t,this.breakpoints=[],this.resize=(i,r)=>{this.breakpoints.forEach(a=>{let s=T1.deviceToSize(a.data.size),n=a.dataEvent.orientation==="horizontal"?i:r,o;switch(a.data.operator){case"<":o=n<s[0];break;case">":o=n>s[0];break;case"<>":o=n>s[0]&&n<s[1];break}a.stage!==o&&(a.stage=o,a.stage?a.dispatchIn():a.dispatchOut())})},this.onResizeObserver=new ResizeObserver(i=>{for(let r of i){let{width:a,height:s}=r.contentRect;this.resize(a,s)}})}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext;this.onResizeObserver.observe(i);let r=a=>{if(!(!a.visible||!a.data?.events.length))for(let{data:s}of a.data.events)s.disabled||s.type==="Resize"&&s.breakpoints.forEach(({data:n,id:o})=>{try{let l=new Nae(o,n,s,a,e,t,this.eventManager);this.breakpoints.push(l)}catch{}})};e.traverseEntity(a=>{(a instanceof ya||a instanceof Xr)&&a.frame?.traverse(s=>{r(s)}),r(a)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}},kae=class{constructor(e,t,i,r,a){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.sharedVariables=a,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onTouchMovePreventScroll=s=>{let n=window.parent!==window,o=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(s.touches.length>1||this.preventTouchScroll||n===!1&&o===!1)&&s.preventDefault()},this.onMouseWheelPreventScroll=s=>{this.preventScroll&&s.preventDefault()},this.onMouseMove=s=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(s),pressed:s.buttons>0}},this.onMouseDown=s=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(s),pressed:!0}},this.onMouseUp=s=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(s),pressed:!1}},this.getMousePosition=s=>{let{domRect:n}=this.eventContext,{pageX:o,pageY:l}=s.touches?.length>0?s.touches[0]:s;return{x:o-(n.left+window.scrollX),y:l-(n.top+window.scrollY)}},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new Tre(this.eventContext),DynamicVariable:new nae(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),Conditional:new Bre(this.eventContext,this),Start:new aae(this.eventContext,this),Basic:new Dre(this.eventContext,this,this.needsRaycast),MouseHover:new $re(this.eventContext,this),Scroll:new iae(this.eventContext,this),Follow:new Wre(this.eventContext,this),DragDrop:new kre(this.eventContext,this),LookAt:new Kre(this.eventContext),Resize:new zae(this.eventContext,this)};let{page:e,domElement:t}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),e.traverseEntity(i=>{i.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(i=>i.connect()),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:e,domElement:t}=this.eventContext;t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(i=>{i.removeEventListener("requestRender",this.requestRender),i.destroyedInAction=!1}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}initializeActionsDependentStates(){let e=this.eventContext.sharedAssets;e.resetDynamicVariablePlayState();let t=i=>{if(i.data.type==="Conditional"&&(i.data.ifActions.forEach(t),i.data.elseActions.forEach(t)),i.data.type==="Conditional"||i.data.type==="SetVariable")for(let r of i.data.type==="Conditional"?i.data.condition:i.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));i.data.type==="DynamicVariablePlay"&&i.data.variableId!==""&&(i.data.mode==="Play"||i.data.mode==="PlayPause"||i.data.mode==="Toggle")&&e.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(i=>{if(i.data?.events.length){for(let r of i.data.events)if(!r.data.disabled)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let a of["inActions","outActions"])r.data[a].forEach(t);else if(r.data.type==="DragDrop")for(let a of["drag","drop"])r.data.dragDropActions[a].forEach(t);else if(r.data.type==="GameControl")for(let a of["idle","move","jump","run"])r.data.gameActions[a].forEach(t);else if(r.data.type==="Resize")for(let a of r.data.breakpoints)a.data.actions.forEach(t);else r.data.type==="LookAt"||r.data.actions.forEach(t)}})}},Vae=class{constructor(e,t,i,r,a){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new ae().copy(i),this._editorSize=new ae().copy(r),this._aspect=t.aspect,this._fov=a??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let a=jae(t,1080,2160,1,15)/100;r*=t/i,r*=1-a}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function jae(e,t,i,r,a){return(e-t)/(i-t)*(a-r)+r}var Gae=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new nw(e.shared,t),this.scene=new yw(e.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof Xr&&!e.uiScene&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof ba&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},Hae=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function Wae(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function Kd(e){return e instanceof vp?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function qae(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Fa)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let a=r.parent;for(;a;){if(a instanceof Fa&&r.states&&Object.keys(r.states).length)return;a=a.parent}let s=r.material.uuid,n=t.shared.materials[s];if(n){if(!wa.isMergable(n))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!wa.isMergable(l.material))return;s=wa.getHash(l.material)}}i[s]||(i[s]={});let o=i[s][Kd(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[s][Kd(r)]=[r],r.cloner)for(let l of r.cloner.children)i[s][Kd(r)].push(l)}),i}function Xae(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let a=r.length;a>t&&(t=a)})}),t}function Yae(e,t){let i=qae(t,e),r=Xae(i),a=new Array(r),s=0,n=new Array(r),o=0,l=new Array(r),h=0,c=new Array(r),u=0;for(let[d,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(g=>{g instanceof Fa&&(n[o++]=g.geometry.clone(),l[h++]=g)}),h<2)continue;for(let g=0;g<h;g++)l[g].updateWorldMatrix(!0,!1),n[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&Wae(n[g]);let m=dh(n.slice(0,o),!1);if(m){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new xr(m,l[0].material);break}default:{g=new xr(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let v=x=>{u=0;for(let b of x)b.children&&v(b.children),b instanceof Fa&&(Array.isArray(b.material)||i[b.material.uuid]&&i[b.material.uuid][Kd(b)]&&i[b.material.uuid][Kd(b)].length>1||(c[u++]=b));for(let b=0;b<u;b++)t.attach(c[b])};for(let x=0;x<h;x++){let b=l[x];v(b.children),a[s++]=b}}}for(let d=0;d<s;d++)a[d].removeFromParent()}var Qae=Ro(XB(),1),Kae=new ae;function Zae(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var Lw=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=r=>{if(this.time=r,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(a=>{a.type==="ParticleSystem"&&(a.update(this.dt),this._skipRender=!1)}),this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&((this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let a=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=a,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=()=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=Kae.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let r=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(r!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}},this._debouncedResize=Rb(this._resize,10),this._onScroll=r=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Hae({x:10,y:10})),oq(e)}async load(e,t,i){Zae(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){if(this.disposed)return;let r=await Bae(e);this._data=r;let a=Uae(r);r.version&&(0,Qae.default)(r.version,"1.0.84")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([a.length&&Lae(),BM(r)&&qQ(),kZ(r)&&jQ(),hp.physicsEnabled(r.scene.objects)&&dq(),RM(r)&&CZ(),dC(r)&&Pte(),EZ(r)&&AZ(),$M(r)&&Oee(),vae(r)&&cq()].filter(Boolean)),a.length&&await Fae(a),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new Gae(r);if(s.resetPersonalCameraFromDocumentData(),this._scene=s.scene,this._sharedAssetsManager=s.sharedAssets,this._camera=this._scene.activeCamera,this._renderer||(this._renderer=new wee({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),await this._renderer.compileAsync(this._scene,this._camera),window.location.search.includes("merge-geometries")){let l=performance.now();Yae(r,s.scene);let h=performance.now();console.log("Merged geometries in ",h-l," ms")}BM(r)&&this._scene.traverse(l=>{_o(l)&&l.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(l=>{l instanceof Xs&&l.pendingMediaLoad&&l.update()})}),this._scene?.traverse(l=>{l.type==="ParticleSystem"&&(l.wakeUp(),l.data.autoPlay?l.start():l.stop())});let n=Object.keys(r.shared.fonts).map(l=>this._sharedAssetsManager.getFont(l).loadingPromise);if(Promise.all(n).then(()=>{s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),RM(r)&&Cae(r)&&await Promise.all(n),$M(r)){let l=[];this._scene.traverseEntity(h=>{(h instanceof ya||h instanceof Xr)&&h.uiCanvas&&l.push(h.uiCanvas)}),await Promise.all(l.map(h=>h.promise))}this._scene.rewriteEventsBeforeGoToPlayMode(),Rw(this._scene.activePage,this._sharedAssetsManager),dC(r)&&this._scene.initializeSplatViewer(),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let o=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(o.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=o.size[0],this._viewportHeight=o.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new Vae(this._renderer,this._camera,new ae(this._viewportWidth,this._viewportHeight),new ae(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(o.allowResponsive??!1)&&o.preset==="fullscreen"),t){let l=new Mre(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,o);this._scene.updateMatrixWorld(!0),this._controls=new Tae(l),this._animationControls=new Dae(this._scene,this._requestRenderAutoMode),this._eventManager=new kae(r.scene.publish,this._controls,this._animationControls,l,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300),document.addEventListener("scroll",this._onScroll)}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){let r=t;typeof i.data.value=="number"?r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t):typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()==="false"?!1:!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let a=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,a),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&as.isTextValue(e)?as.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==Uu&&!this._scene.isInvisibleObjects(t)&&!(t instanceof Xr)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof cO&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a}={r:0,g:0,b:0,a:1},s=new ca(t,i,r,a);try{s.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.activePage.setBackgroundColor(s),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{K2.unsubscribe(e)}),this._variablesCache.clear(),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),this.dt=0,lq(this.canvas),document.removeEventListener("scroll",this._onScroll)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t;e.traverseAncestors(a=>{a instanceof Xr&&(t=a.name)});let i={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,parentUuid:e.parent instanceof Xr||e instanceof yw?void 0:e.parent?.uuid,emitEvent(a){e.dispatchEvent({type:"userEvent",eventName:a})},emitEventReverse(a){e.dispatchEvent({type:"userEvent",eventName:a,reverse:!0})}},r=K2(i,(a,s)=>{typeof e[a]!="object"&&Object.getOwnPropertyDescriptor(e,a)?.writable&&(e[a]=s),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}setUIWasmUrl(e){FD.skiaWasmUrl=e}};var bv=window,wv=bv.ShadowRoot&&(bv.ShadyCSS===void 0||bv.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Iw=Symbol(),uO=new WeakMap,Lp=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Iw)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(wv&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=uO.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&uO.set(i,t))}return t}toString(){return this.cssText}},dO=e=>new Lp(typeof e=="string"?e:e+"",void 0,Iw),Bw=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,a,s)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(a)+e[s+1],e[0]);return new Lp(i,e,Iw)},Uw=(e,t)=>{wv?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),a=bv.litNonce;a!==void 0&&r.setAttribute("nonce",a),r.textContent=i.cssText,e.appendChild(r)})},_v=wv?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return dO(i)})(e):e;var Fw,Sv=window,pO=Sv.trustedTypes,Jae=pO?pO.emptyScript:"",fO=Sv.reactiveElementPolyfillSupport,zw={toAttribute(e,t){switch(t){case Boolean:e=e?Jae:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},mO=(e,t)=>t!==e&&(t==t||e==e),Nw={attribute:!0,type:String,converter:zw,reflect:!1,hasChanged:mO},Io=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let a=this._$Ep(r,i);a!==void 0&&(this._$Ev.set(a,r),t.push(a))}),t}static createProperty(t,i=Nw){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,a=this.getPropertyDescriptor(t,r,i);a!==void 0&&Object.defineProperty(this.prototype,t,a)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(a){let s=this[t];this[i]=a,this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Nw}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let a of r)this.createProperty(a,i[a])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let a of r)i.unshift(_v(a))}else t!==void 0&&i.push(_v(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return Uw(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=Nw){var a;let s=this.constructor._$Ep(t,r);if(s!==void 0&&r.reflect===!0){let n=(((a=r.converter)===null||a===void 0?void 0:a.toAttribute)!==void 0?r.converter:zw).toAttribute(i,r.type);this._$El=t,n==null?this.removeAttribute(s):this.setAttribute(s,n),this._$El=null}}_$AK(t,i){var r;let a=this.constructor,s=a._$Ev.get(t);if(s!==void 0&&this._$El!==s){let n=a.getPropertyOptions(s),o=typeof n.converter=="function"?{fromAttribute:n.converter}:((r=n.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?n.converter:zw;this._$El=s,this[s]=o.fromAttribute(i,n.type),this._$El=null}}requestUpdate(t,i,r){let a=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||mO)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):a=!1),!this.isUpdatePending&&a&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((a,s)=>this[s]=a),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(a=>{var s;return(s=a.hostUpdate)===null||s===void 0?void 0:s.call(a)}),this.update(r)):this._$Ek()}catch(a){throw i=!1,this._$Ek(),a}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var a;return(a=r.hostUpdated)===null||a===void 0?void 0:a.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};Io.finalized=!0,Io.elementProperties=new Map,Io.elementStyles=[],Io.shadowRootOptions={mode:"open"},fO?.({ReactiveElement:Io}),((Fw=Sv.reactiveElementVersions)!==null&&Fw!==void 0?Fw:Sv.reactiveElementVersions=[]).push("1.6.0");var kw,Av=window,ju=Av.trustedTypes,gO=ju?ju.createPolicy("lit-html",{createHTML:e=>e}):void 0,Ol=`lit$${(Math.random()+"").slice(9)}$`,SO="?"+Ol,$ae=`<${SO}>`,Gu=document,Bp=(e="")=>Gu.createComment(e),Up=e=>e===null||typeof e!="object"&&typeof e!="function",AO=Array.isArray,ese=e=>AO(e)||typeof e?.[Symbol.iterator]=="function",Ip=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,vO=/-->/g,yO=/>/g,Fh=RegExp(`>|[
8104
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(a){let s=a.data;switch(s.type){case"decode":r._callbacks[s.id].resolve(s);break;case"error":r._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,a){return r._taskLoad>a._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function Oae(){let e,t;onmessage=function(n){let o=n.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(c){e.onModuleLoaded=function(u){c({draco:u})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(c=>{let u=c.draco,d=new u.Decoder;try{let p=i(u,d,new Int8Array(l),h),f=p.attributes.map(m=>m.array.buffer);p.index&&f.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},f)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{u.destroy(d)}});break}};function i(n,o,l,h){let c=h.attributeIDs,u=h.attributeTypes,d,p,f=o.GetEncodedGeometryType(l);if(f===n.TRIANGULAR_MESH)d=new n.Mesh,p=o.DecodeArrayToMesh(l,l.byteLength,d);else if(f===n.POINT_CLOUD)d=new n.PointCloud,p=o.DecodeArrayToPointCloud(l,l.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let m={index:null,attributes:[]};for(let g in c){let v=self[u[g]],x,b;if(h.useUniqueIDs)b=c[g],x=o.GetAttributeByUniqueId(d,b);else{if(b=o.GetAttributeId(d,n[c[g]]),b===-1)continue;x=o.GetAttribute(d,b)}let _=a(n,o,d,g,v,x);g==="color"&&(_.vertexColorSpace=h.vertexColorSpace),m.attributes.push(_)}return f===n.TRIANGULAR_MESH&&(m.index=r(n,o,d)),n.destroy(d),m}function r(n,o,l){let h=l.num_faces()*3,c=h*4,u=n._malloc(c);o.GetTrianglesUInt32Array(l,c,u);let d=new Uint32Array(n.HEAPF32.buffer,u,h).slice();return n._free(u),{array:d,itemSize:1}}function a(n,o,l,h,c,u){let d=u.num_components(),p=l.num_points()*d,f=p*c.BYTES_PER_ELEMENT,m=s(n,c),g=n._malloc(f);o.GetAttributeDataArrayForAllPoints(l,u,m,f,g);let v=new c(n.HEAPF32.buffer,g,p).slice();return n._free(g),{name:h,array:v,itemSize:d}}function s(n,o){switch(o){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}var xl;function Lae(){return xl||(xl=new Rae,xl.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),xl.decoderPending}async function Iae(e){if(xl){let t={attributeIDs:xl.defaultAttributeIDs,attributeTypes:xl.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await xl.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,a])=>({name:r,itemSize:a.itemSize,array:a.array}))}}return null}async function Bae(e,t){let[i,r]=s3(A1.deserialize(new Uint8Array(e)));return R3(i),t&&t(i),r.result().data}function Uae(e){let t=[];return e.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function Fae(e){for(let t of e){let i=await Iae(t.geometry.data.draco);if(i){let r=t.geometry.data;i.index&&(r.index={array:i.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};i.attributes.forEach(({name:s,array:n,itemSize:o})=>{a[s]={array:n,itemSize:o,type:"Float32Array",normalized:!1}}),r.attributes=a,r.draco=void 0}}}var Nae=class{constructor(e,t,i,r,a,s,n){this.id=e,this.data=t,this.dataEvent=i,this.object=r,this.stage=!1,this.actions=Na(i,t.actions,a,s,n,r)}disconnect(){Jr(this.actions)}dispatchIn(){this.actions.Audio.forEach(e=>e.dispatchBasic()),this.actions.Particles.forEach(e=>e.dispatchBasic()),this.actions.Video.forEach(e=>e.dispatchBasic()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.Link.forEach(e=>e.dispatch()),this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.actions.Transition.forEach(e=>e.toggle()),this.actions.Animation.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>e.play()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}dispatchOut(){this.actions.Transition.forEach(e=>{e.toggle()})}},zae=class extends en{constructor(e,t){super(e),this.eventManager=t,this.breakpoints=[],this.resize=(i,r)=>{this.breakpoints.forEach(a=>{let s=T1.deviceToSize(a.data.size),n=a.dataEvent.orientation==="horizontal"?i:r,o;switch(a.data.operator){case"<":o=n<s[0];break;case">":o=n>s[0];break;case"<>":o=n>s[0]&&n<s[1];break}a.stage!==o&&(a.stage=o,a.stage?a.dispatchIn():a.dispatchOut())})},this.onResizeObserver=new ResizeObserver(i=>{for(let r of i){let{width:a,height:s}=r.contentRect;this.resize(a,s)}})}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext;this.onResizeObserver.observe(i);let r=a=>{if(!(!a.visible||!a.data?.events.length))for(let{data:s}of a.data.events)s.disabled||s.type==="Resize"&&s.breakpoints.forEach(({data:n,id:o})=>{try{let l=new Nae(o,n,s,a,e,t,this.eventManager);this.breakpoints.push(l)}catch{}})};e.traverseEntity(a=>{(a instanceof ya||a instanceof Xr)&&a.frame?.traverse(s=>{r(s)}),r(a)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}},kae=class{constructor(e,t,i,r,a){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.sharedVariables=a,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onTouchMovePreventScroll=s=>{let n=window.parent!==window,o=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(s.touches.length>1||this.preventTouchScroll||n===!1&&o===!1)&&s.preventDefault()},this.onMouseWheelPreventScroll=s=>{this.preventScroll&&s.preventDefault()},this.onMouseMove=s=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(s),pressed:s.buttons>0}},this.onMouseDown=s=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(s),pressed:!0}},this.onMouseUp=s=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(s),pressed:!1}},this.getMousePosition=s=>{let{domRect:n}=this.eventContext,{pageX:o,pageY:l}=s.touches?.length>0?s.touches[0]:s;return{x:o-(n.left+window.scrollX),y:l-(n.top+window.scrollY)}},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new Tre(this.eventContext),DynamicVariable:new nae(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),Conditional:new Bre(this.eventContext,this),Start:new aae(this.eventContext,this),Basic:new Dre(this.eventContext,this,this.needsRaycast),MouseHover:new $re(this.eventContext,this),Scroll:new iae(this.eventContext,this),Follow:new Wre(this.eventContext,this),DragDrop:new kre(this.eventContext,this),LookAt:new Kre(this.eventContext),Resize:new zae(this.eventContext,this)};let{page:e,domElement:t}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),e.traverseEntity(i=>{i.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(i=>i.connect()),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:e,domElement:t}=this.eventContext;t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(i=>{i.removeEventListener("requestRender",this.requestRender),i.destroyedInAction=!1}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}initializeActionsDependentStates(){let e=this.eventContext.sharedAssets;e.resetDynamicVariablePlayState();let t=i=>{if(i.data.type==="Conditional"&&(i.data.ifActions.forEach(t),i.data.elseActions.forEach(t)),i.data.type==="Conditional"||i.data.type==="SetVariable")for(let r of i.data.type==="Conditional"?i.data.condition:i.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));i.data.type==="DynamicVariablePlay"&&i.data.variableId!==""&&(i.data.mode==="Play"||i.data.mode==="PlayPause"||i.data.mode==="Toggle")&&e.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(i=>{if(i.data?.events.length){for(let r of i.data.events)if(!r.data.disabled)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let a of["inActions","outActions"])r.data[a].forEach(t);else if(r.data.type==="DragDrop")for(let a of["drag","drop"])r.data.dragDropActions[a].forEach(t);else if(r.data.type==="GameControl")for(let a of["idle","move","jump","run"])r.data.gameActions[a].forEach(t);else if(r.data.type==="Resize")for(let a of r.data.breakpoints)a.data.actions.forEach(t);else r.data.type==="LookAt"||r.data.actions.forEach(t)}})}},Vae=class{constructor(e,t,i,r,a){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new ae().copy(i),this._editorSize=new ae().copy(r),this._aspect=t.aspect,this._fov=a??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let a=jae(t,1080,2160,1,15)/100;r*=t/i,r*=1-a}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function jae(e,t,i,r,a){return(e-t)/(i-t)*(a-r)+r}var Gae=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new nw(e.shared,t),this.scene=new yw(e.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof Xr&&!e.uiScene&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof ba&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},Hae=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function Wae(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function Kd(e){return e instanceof vp?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function qae(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Fa)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let a=r.parent;for(;a;){if(a instanceof Fa&&r.states&&Object.keys(r.states).length)return;a=a.parent}let s=r.material.uuid,n=t.shared.materials[s];if(n){if(!wa.isMergable(n))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!wa.isMergable(l.material))return;s=wa.getHash(l.material)}}i[s]||(i[s]={});let o=i[s][Kd(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[s][Kd(r)]=[r],r.cloner)for(let l of r.cloner.children)i[s][Kd(r)].push(l)}),i}function Xae(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let a=r.length;a>t&&(t=a)})}),t}function Yae(e,t){let i=qae(t,e),r=Xae(i),a=new Array(r),s=0,n=new Array(r),o=0,l=new Array(r),h=0,c=new Array(r),u=0;for(let[d,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(g=>{g instanceof Fa&&(n[o++]=g.geometry.clone(),l[h++]=g)}),h<2)continue;for(let g=0;g<h;g++)l[g].updateWorldMatrix(!0,!1),n[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&Wae(n[g]);let m=dh(n.slice(0,o),!1);if(m){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new xr(m,l[0].material);break}default:{g=new xr(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let v=x=>{u=0;for(let b of x)b.children&&v(b.children),b instanceof Fa&&(Array.isArray(b.material)||i[b.material.uuid]&&i[b.material.uuid][Kd(b)]&&i[b.material.uuid][Kd(b)].length>1||(c[u++]=b));for(let b=0;b<u;b++)t.attach(c[b])};for(let x=0;x<h;x++){let b=l[x];v(b.children),a[s++]=b}}}for(let d=0;d<s;d++)a[d].removeFromParent()}var Qae=Ro(XB(),1),Kae=new ae;function Zae(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var Lw=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=r=>{if(this.time=r,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(a=>{a.type==="ParticleSystem"&&(a.update(this.dt),this._skipRender=!1)}),this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&((this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let a=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=a,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=()=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=Kae.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let r=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(r!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}},this._debouncedResize=Rb(this._resize,10),this._onScroll=r=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Hae({x:10,y:10})),oq(e)}async load(e,t,i){Zae(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){if(this.disposed)return;let r=await Bae(e);this._data=r;let a=Uae(r);r.version&&(0,Qae.default)(r.version,"1.0.85")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([a.length&&Lae(),BM(r)&&qQ(),kZ(r)&&jQ(),hp.physicsEnabled(r.scene.objects)&&dq(),RM(r)&&CZ(),dC(r)&&Pte(),EZ(r)&&AZ(),$M(r)&&Oee(),vae(r)&&cq()].filter(Boolean)),a.length&&await Fae(a),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new Gae(r);if(s.resetPersonalCameraFromDocumentData(),this._scene=s.scene,this._sharedAssetsManager=s.sharedAssets,this._camera=this._scene.activeCamera,this._renderer||(this._renderer=new wee({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),await this._renderer.compileAsync(this._scene,this._camera),window.location.search.includes("merge-geometries")){let l=performance.now();Yae(r,s.scene);let h=performance.now();console.log("Merged geometries in ",h-l," ms")}BM(r)&&this._scene.traverse(l=>{_o(l)&&l.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(l=>{l instanceof Xs&&l.pendingMediaLoad&&l.update()})}),this._scene?.traverse(l=>{l.type==="ParticleSystem"&&(l.wakeUp(),l.data.autoPlay?l.start():l.stop())});let n=Object.keys(r.shared.fonts).map(l=>this._sharedAssetsManager.getFont(l).loadingPromise);if(Promise.all(n).then(()=>{s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),RM(r)&&Cae(r)&&await Promise.all(n),$M(r)){let l=[];this._scene.traverseEntity(h=>{(h instanceof ya||h instanceof Xr)&&h.uiCanvas&&l.push(h.uiCanvas)}),await Promise.all(l.map(h=>h.promise))}this._scene.rewriteEventsBeforeGoToPlayMode(),Rw(this._scene.activePage,this._sharedAssetsManager),dC(r)&&this._scene.initializeSplatViewer(),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let o=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(o.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=o.size[0],this._viewportHeight=o.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new Vae(this._renderer,this._camera,new ae(this._viewportWidth,this._viewportHeight),new ae(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(o.allowResponsive??!1)&&o.preset==="fullscreen"),t){let l=new Mre(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,o);this._scene.updateMatrixWorld(!0),this._controls=new Tae(l),this._animationControls=new Dae(this._scene,this._requestRenderAutoMode),this._eventManager=new kae(r.scene.publish,this._controls,this._animationControls,l,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300),document.addEventListener("scroll",this._onScroll)}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){let r=t;typeof i.data.value=="number"?r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t):typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()==="false"?!1:!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let a=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,a),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&as.isTextValue(e)?as.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==Uu&&!this._scene.isInvisibleObjects(t)&&!(t instanceof Xr)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof cO&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a}={r:0,g:0,b:0,a:1},s=new ca(t,i,r,a);try{s.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.activePage.setBackgroundColor(s),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{K2.unsubscribe(e)}),this._variablesCache.clear(),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),this.dt=0,lq(this.canvas),document.removeEventListener("scroll",this._onScroll)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t;e.traverseAncestors(a=>{a instanceof Xr&&(t=a.name)});let i={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,parentUuid:e.parent instanceof Xr||e instanceof yw?void 0:e.parent?.uuid,emitEvent(a){e.dispatchEvent({type:"userEvent",eventName:a})},emitEventReverse(a){e.dispatchEvent({type:"userEvent",eventName:a,reverse:!0})}},r=K2(i,(a,s)=>{typeof e[a]!="object"&&Object.getOwnPropertyDescriptor(e,a)?.writable&&(e[a]=s),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}setUIWasmUrl(e){FD.skiaWasmUrl=e}};var bv=window,wv=bv.ShadowRoot&&(bv.ShadyCSS===void 0||bv.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Iw=Symbol(),uO=new WeakMap,Lp=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Iw)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(wv&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=uO.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&uO.set(i,t))}return t}toString(){return this.cssText}},dO=e=>new Lp(typeof e=="string"?e:e+"",void 0,Iw),Bw=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,a,s)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(a)+e[s+1],e[0]);return new Lp(i,e,Iw)},Uw=(e,t)=>{wv?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),a=bv.litNonce;a!==void 0&&r.setAttribute("nonce",a),r.textContent=i.cssText,e.appendChild(r)})},_v=wv?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return dO(i)})(e):e;var Fw,Sv=window,pO=Sv.trustedTypes,Jae=pO?pO.emptyScript:"",fO=Sv.reactiveElementPolyfillSupport,zw={toAttribute(e,t){switch(t){case Boolean:e=e?Jae:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},mO=(e,t)=>t!==e&&(t==t||e==e),Nw={attribute:!0,type:String,converter:zw,reflect:!1,hasChanged:mO},Io=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let a=this._$Ep(r,i);a!==void 0&&(this._$Ev.set(a,r),t.push(a))}),t}static createProperty(t,i=Nw){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,a=this.getPropertyDescriptor(t,r,i);a!==void 0&&Object.defineProperty(this.prototype,t,a)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(a){let s=this[t];this[i]=a,this.requestUpdate(t,s,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Nw}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let a of r)this.createProperty(a,i[a])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let a of r)i.unshift(_v(a))}else t!==void 0&&i.push(_v(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return Uw(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=Nw){var a;let s=this.constructor._$Ep(t,r);if(s!==void 0&&r.reflect===!0){let n=(((a=r.converter)===null||a===void 0?void 0:a.toAttribute)!==void 0?r.converter:zw).toAttribute(i,r.type);this._$El=t,n==null?this.removeAttribute(s):this.setAttribute(s,n),this._$El=null}}_$AK(t,i){var r;let a=this.constructor,s=a._$Ev.get(t);if(s!==void 0&&this._$El!==s){let n=a.getPropertyOptions(s),o=typeof n.converter=="function"?{fromAttribute:n.converter}:((r=n.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?n.converter:zw;this._$El=s,this[s]=o.fromAttribute(i,n.type),this._$El=null}}requestUpdate(t,i,r){let a=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||mO)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):a=!1),!this.isUpdatePending&&a&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((a,s)=>this[s]=a),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(a=>{var s;return(s=a.hostUpdate)===null||s===void 0?void 0:s.call(a)}),this.update(r)):this._$Ek()}catch(a){throw i=!1,this._$Ek(),a}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var a;return(a=r.hostUpdated)===null||a===void 0?void 0:a.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};Io.finalized=!0,Io.elementProperties=new Map,Io.elementStyles=[],Io.shadowRootOptions={mode:"open"},fO?.({ReactiveElement:Io}),((Fw=Sv.reactiveElementVersions)!==null&&Fw!==void 0?Fw:Sv.reactiveElementVersions=[]).push("1.6.0");var kw,Av=window,ju=Av.trustedTypes,gO=ju?ju.createPolicy("lit-html",{createHTML:e=>e}):void 0,Ol=`lit$${(Math.random()+"").slice(9)}$`,SO="?"+Ol,$ae=`<${SO}>`,Gu=document,Bp=(e="")=>Gu.createComment(e),Up=e=>e===null||typeof e!="object"&&typeof e!="function",AO=Array.isArray,ese=e=>AO(e)||typeof e?.[Symbol.iterator]=="function",Ip=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,vO=/-->/g,yO=/>/g,Fh=RegExp(`>|[
8092
8105
  \f\r](?:([^\\s"'>=/]+)([
8093
8106
  \f\r]*=[
8094
8107
  \f\r]*(?:[^